[4872160] | 1 | #
|
---|
| 2 | # Copyright (c) 2006 Martin Decky
|
---|
| 3 | # All rights reserved.
|
---|
| 4 | #
|
---|
| 5 | # Redistribution and use in source and binary forms, with or without
|
---|
| 6 | # modification, are permitted provided that the following conditions
|
---|
| 7 | # are met:
|
---|
| 8 | #
|
---|
| 9 | # - Redistributions of source code must retain the above copyright
|
---|
| 10 | # notice, this list of conditions and the following disclaimer.
|
---|
| 11 | # - Redistributions in binary form must reproduce the above copyright
|
---|
| 12 | # notice, this list of conditions and the following disclaimer in the
|
---|
| 13 | # documentation and/or other materials provided with the distribution.
|
---|
| 14 | # - The name of the author may not be used to endorse or promote products
|
---|
| 15 | # derived from this software without specific prior written permission.
|
---|
| 16 | #
|
---|
| 17 | # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
---|
| 18 | # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
---|
| 19 | # OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
---|
| 20 | # IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
---|
| 21 | # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
---|
| 22 | # NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
---|
| 23 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
---|
| 24 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
---|
| 25 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
---|
| 26 | # THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
---|
| 27 | #
|
---|
| 28 |
|
---|
| 29 | .PHONY: all clean
|
---|
| 30 |
|
---|
| 31 | include Makefile.common
|
---|
| 32 |
|
---|
[96521f2f] | 33 | INCLUDES = -Igeneric/include -I$(ROOT_PATH)/abi/include
|
---|
[4872160] | 34 | OPTIMIZATION = 3
|
---|
| 35 |
|
---|
[2a5d1751] | 36 | DEFS = -DBOOT -DRELEASE=$(RELEASE) "-DCOPYRIGHT=$(COPYRIGHT)" "-DNAME=$(NAME)" -D__$(BITS)_BITS__ -D__$(ENDIANESS)__
|
---|
[4872160] | 37 |
|
---|
[a0a273e] | 38 | AFLAGS =
|
---|
[ae7bbfd0] | 39 | LFLAGS = --fatal-warnings
|
---|
| 40 |
|
---|
[a0a273e] | 41 | # FIXME: This condition is a workaround for issue #693.
|
---|
| 42 | ifneq ($(BARCH),mips32)
|
---|
| 43 | AFLAGS += --fatal-warnings
|
---|
| 44 | endif
|
---|
| 45 |
|
---|
| 46 | COMMON_CFLAGS = $(INCLUDES) -O$(OPTIMIZATION) -imacros $(CONFIG_HEADER) \
|
---|
| 47 | -ffreestanding -fno-builtin -nostdlib -nostdinc \
|
---|
| 48 | -fexec-charset=UTF-8 -finput-charset=UTF-8
|
---|
| 49 |
|
---|
| 50 | GCC_CFLAGS = -Wall -Wextra -Wno-unused-parameter -Wmissing-prototypes \
|
---|
[e8c5c11] | 51 | -std=gnu99 -Werror-implicit-function-declaration -Wwrite-strings \
|
---|
[e805e2f] | 52 | -pipe
|
---|
[4872160] | 53 |
|
---|
[a0a273e] | 54 | CLANG_CFLAGS = -Wall -Wextra -Wno-unused-parameter -Wmissing-prototypes \
|
---|
[4872160] | 55 | -Werror-implicit-function-declaration -Wwrite-strings \
|
---|
[a0a273e] | 56 | -pipe -fno-stack-protector -fno-PIC
|
---|
[4872160] | 57 |
|
---|
[e805e2f] | 58 | ifeq ($(CONFIG_DEBUG),y)
|
---|
[a0a273e] | 59 | COMMON_CFLAGS += -Werror
|
---|
[e805e2f] | 60 | endif
|
---|
| 61 |
|
---|
[9ded977] | 62 | ifeq ($(CONFIG_LINE_DEBUG),y)
|
---|
[a0a273e] | 63 | COMMON_CFLAGS += -g
|
---|
[9ded977] | 64 | endif
|
---|
| 65 |
|
---|
[4872160] | 66 | ifeq ($(COMPILER),gcc_native)
|
---|
[a0a273e] | 67 | CFLAGS = $(COMMON_CFLAGS) $(GCC_CFLAGS) $(EXTRA_CFLAGS)
|
---|
[4872160] | 68 | DEPEND_DEFS = $(DEFS) $(CONFIG_DEFS)
|
---|
| 69 | endif
|
---|
| 70 |
|
---|
| 71 | ifeq ($(COMPILER),gcc_cross)
|
---|
[a0a273e] | 72 | CFLAGS = $(COMMON_CFLAGS) $(GCC_CFLAGS) $(EXTRA_CFLAGS)
|
---|
[4872160] | 73 | DEPEND_DEFS = $(DEFS) $(CONFIG_DEFS)
|
---|
| 74 | endif
|
---|
| 75 |
|
---|
[8f2eca0] | 76 | ifeq ($(COMPILER),gcc_helenos)
|
---|
[a0a273e] | 77 | CFLAGS = $(COMMON_CFLAGS) $(GCC_CFLAGS) $(EXTRA_CFLAGS)
|
---|
[4872160] | 78 | DEPEND_DEFS = $(DEFS) $(CONFIG_DEFS)
|
---|
| 79 | endif
|
---|
| 80 |
|
---|
| 81 | ifeq ($(COMPILER),clang)
|
---|
[a0a273e] | 82 | CFLAGS = $(COMMON_CFLAGS) $(CLANG_CFLAGS) $(EXTRA_CFLAGS)
|
---|
[4872160] | 83 | DEPEND_DEFS = $(DEFS) $(CONFIG_DEFS)
|
---|
| 84 | endif
|
---|
| 85 |
|
---|
| 86 | OBJECTS := $(addsuffix .o,$(basename $(SOURCES)))
|
---|
| 87 |
|
---|
| 88 | all: $(VERSION_DEF) $(COMMON_MAKEFILE) $(COMMON_HEADER) $(CONFIG_MAKEFILE) $(CONFIG_HEADER) $(BOOT_OUTPUT)
|
---|
| 89 | -[ -f $(DEPEND) ] && cp -a $(DEPEND) $(DEPEND_PREV)
|
---|
| 90 |
|
---|
| 91 | clean:
|
---|
| 92 | rm -f $(RAW) $(MAP) $(ARCH_INCLUDE) $(GENARCH_INCLUDE)
|
---|
| 93 |
|
---|
[4646710] | 94 | ifneq ($(MAKECMDGOALS),clean)
|
---|
[4872160] | 95 | -include $(DEPEND)
|
---|
[4646710] | 96 | endif
|
---|
[4872160] | 97 |
|
---|
[a0a273e] | 98 | AS_CFLAGS := $(addprefix -Xassembler ,$(AFLAGS))
|
---|
| 99 |
|
---|
[4872160] | 100 | $(BOOT_OUTPUT): $(RAW)
|
---|
| 101 | $(OBJCOPY) -O $(BFD_OUTPUT) $< $@
|
---|
| 102 |
|
---|
[4646710] | 103 | $(RAW): $(OBJECTS) $(LINK)
|
---|
| 104 | $(LD) -n $(LFLAGS) -T $(LINK) -M -Map $(MAP) -o $@ $(OBJECTS)
|
---|
[4872160] | 105 |
|
---|
[4646710] | 106 | $(LINK): $(DEPEND)
|
---|
[a0a273e] | 107 | $(CC) $(DEFS) $(CFLAGS) -D__ASM__ -D__LINKER__ -E -x c $(LINK).in | grep -v "^\#" > $(LINK)
|
---|
[f4660690] | 108 |
|
---|
[4872160] | 109 | %.o: %.S $(DEPEND)
|
---|
[a0a273e] | 110 | $(CC) $(DEFS) $(CFLAGS) $(AS_CFLAGS) -D__ASM__ -c $< -o $@
|
---|
[4872160] | 111 | ifeq ($(PRECHECK),y)
|
---|
| 112 | $(JOBFILE) $(JOB) $< $@ as asm/preproc $(DEFS) $(CFLAGS) -D__ASM__
|
---|
| 113 | endif
|
---|
| 114 |
|
---|
| 115 | %.o: %.c $(DEPEND)
|
---|
| 116 | $(CC) $(DEFS) $(CFLAGS) -c $< -o $@
|
---|
| 117 | ifeq ($(PRECHECK),y)
|
---|
| 118 | $(JOBFILE) $(JOB) $< $@ cc core $(DEFS) $(CFLAGS)
|
---|
| 119 | endif
|
---|
| 120 |
|
---|
[4646710] | 121 | %.o: %.s $(DEPEND)
|
---|
[a0a273e] | 122 | $(CC) $(DEFS) $(CFLAGS) $(AS_CFLAGS) -D__ASM__ -c $< -o $@
|
---|
[4646710] | 123 | ifeq ($(PRECHECK),y)
|
---|
| 124 | $(JOBFILE) $(JOB) $< $@ as asm
|
---|
| 125 | endif
|
---|
| 126 |
|
---|
| 127 | $(DEPEND): $(ARCH_INCLUDE) $(GENARCH_INCLUDE) $(COMMON_HEADER_ARCH) $(PRE_DEPEND)
|
---|
[4872160] | 128 | makedepend -f - -- $(DEPEND_DEFS) $(CFLAGS) -- $(SOURCES) > $@ 2> /dev/null
|
---|
| 129 | -[ -f $(DEPEND_PREV) ] && diff -q $(DEPEND_PREV) $@ && mv -f $(DEPEND_PREV) $@
|
---|
| 130 |
|
---|
[4646710] | 131 | $(COMPS).s: $(COMPS).zip
|
---|
| 132 | unzip -p $< $@ > $@
|
---|
| 133 |
|
---|
| 134 | $(COMPS).h: $(COMPS).zip
|
---|
| 135 | unzip -p $< $@ > $@
|
---|
| 136 |
|
---|
| 137 | $(COMPS)_desc.c: $(COMPS).zip
|
---|
| 138 | unzip -p $< $@ > $@
|
---|
| 139 |
|
---|
[94c05b89] | 140 | $(COMPONENTS_DEFLATE): $(COMPS).zip
|
---|
| 141 | unzip -p $< $@ > $@
|
---|
| 142 |
|
---|
[4646710] | 143 | $(COMPS).zip: $(COMPONENTS)
|
---|
| 144 | $(MKARRAY) --deflate $(COMPS) $(COMP) "$(AS_PROLOG)" ".section .components, \"a\"" $^
|
---|
| 145 |
|
---|
[239e32b8] | 146 | include Makefile.initrd
|
---|
[4646710] | 147 |
|
---|
[4872160] | 148 | $(ARCH_INCLUDE): arch/$(KARCH)/include/
|
---|
| 149 | ln -sfn ../../$< $@
|
---|
| 150 |
|
---|
| 151 | $(GENARCH_INCLUDE): genarch/include/
|
---|
| 152 | ln -sfn ../../$< $@
|
---|
| 153 |
|
---|
| 154 | $(COMMON_HEADER_ARCH): $(COMMON_HEADER)
|
---|
| 155 | ln -sfn ../../../$< $@
|
---|