[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 |
|
---|
[4761f54] | 29 | .PHONY: all clean depend
|
---|
[4872160] | 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),clang)
|
---|
[a0a273e] | 67 | CFLAGS = $(COMMON_CFLAGS) $(CLANG_CFLAGS) $(EXTRA_CFLAGS)
|
---|
[4761f54] | 68 | else
|
---|
| 69 | CFLAGS = $(COMMON_CFLAGS) $(GCC_CFLAGS) $(EXTRA_CFLAGS)
|
---|
[4872160] | 70 | endif
|
---|
| 71 |
|
---|
| 72 | OBJECTS := $(addsuffix .o,$(basename $(SOURCES)))
|
---|
[4761f54] | 73 | DEPENDS := $(addsuffix .d,$(basename $(SOURCES)))
|
---|
[4872160] | 74 |
|
---|
| 75 | all: $(VERSION_DEF) $(COMMON_MAKEFILE) $(COMMON_HEADER) $(CONFIG_MAKEFILE) $(CONFIG_HEADER) $(BOOT_OUTPUT)
|
---|
| 76 |
|
---|
| 77 | clean:
|
---|
| 78 | rm -f $(RAW) $(MAP) $(ARCH_INCLUDE) $(GENARCH_INCLUDE)
|
---|
| 79 |
|
---|
[4761f54] | 80 | -include $(DEPENDS)
|
---|
[4872160] | 81 |
|
---|
[a0a273e] | 82 | AS_CFLAGS := $(addprefix -Xassembler ,$(AFLAGS))
|
---|
| 83 |
|
---|
[4872160] | 84 | $(BOOT_OUTPUT): $(RAW)
|
---|
| 85 | $(OBJCOPY) -O $(BFD_OUTPUT) $< $@
|
---|
| 86 |
|
---|
[4646710] | 87 | $(RAW): $(OBJECTS) $(LINK)
|
---|
| 88 | $(LD) -n $(LFLAGS) -T $(LINK) -M -Map $(MAP) -o $@ $(OBJECTS)
|
---|
[4872160] | 89 |
|
---|
[4761f54] | 90 | $(LINK): | depend
|
---|
[a0a273e] | 91 | $(CC) $(DEFS) $(CFLAGS) -D__ASM__ -D__LINKER__ -E -x c $(LINK).in | grep -v "^\#" > $(LINK)
|
---|
[f4660690] | 92 |
|
---|
[4761f54] | 93 | %.o: %.S | depend
|
---|
| 94 | $(CC) -MD $(DEFS) $(CFLAGS) $(AS_CFLAGS) -D__ASM__ -c $< -o $@
|
---|
[4872160] | 95 | ifeq ($(PRECHECK),y)
|
---|
| 96 | $(JOBFILE) $(JOB) $< $@ as asm/preproc $(DEFS) $(CFLAGS) -D__ASM__
|
---|
| 97 | endif
|
---|
| 98 |
|
---|
[4761f54] | 99 | %.o: %.c | depend
|
---|
| 100 | $(CC) -MD $(DEFS) $(CFLAGS) -c $< -o $@
|
---|
[4872160] | 101 | ifeq ($(PRECHECK),y)
|
---|
| 102 | $(JOBFILE) $(JOB) $< $@ cc core $(DEFS) $(CFLAGS)
|
---|
| 103 | endif
|
---|
| 104 |
|
---|
[4761f54] | 105 | %.o: %.s | depend
|
---|
| 106 | $(CC) -MD $(DEFS) $(CFLAGS) $(AS_CFLAGS) -D__ASM__ -c $< -o $@
|
---|
[4646710] | 107 | ifeq ($(PRECHECK),y)
|
---|
| 108 | $(JOBFILE) $(JOB) $< $@ as asm
|
---|
| 109 | endif
|
---|
| 110 |
|
---|
[b639d56] | 111 | depend: $(ARCH_INCLUDE) $(GENARCH_INCLUDE) $(PRE_DEPEND)
|
---|
[4872160] | 112 |
|
---|
[4646710] | 113 | $(COMPS).s: $(COMPS).zip
|
---|
| 114 | unzip -p $< $@ > $@
|
---|
| 115 |
|
---|
| 116 | $(COMPS).h: $(COMPS).zip
|
---|
| 117 | unzip -p $< $@ > $@
|
---|
| 118 |
|
---|
| 119 | $(COMPS)_desc.c: $(COMPS).zip
|
---|
| 120 | unzip -p $< $@ > $@
|
---|
| 121 |
|
---|
[94c05b89] | 122 | $(COMPONENTS_DEFLATE): $(COMPS).zip
|
---|
| 123 | unzip -p $< $@ > $@
|
---|
| 124 |
|
---|
[4646710] | 125 | $(COMPS).zip: $(COMPONENTS)
|
---|
| 126 | $(MKARRAY) --deflate $(COMPS) $(COMP) "$(AS_PROLOG)" ".section .components, \"a\"" $^
|
---|
| 127 |
|
---|
[239e32b8] | 128 | include Makefile.initrd
|
---|
[4646710] | 129 |
|
---|
[c8fbbe7] | 130 | $(ARCH_INCLUDE) $(ARCH_INCLUDE)/%.h: arch/$(KARCH)/include/
|
---|
[4872160] | 131 | ln -sfn ../../$< $@
|
---|
| 132 |
|
---|
[c8fbbe7] | 133 | $(GENARCH_INCLUDE) $(GENARCH_INCLUDE)/%.h: genarch/include/
|
---|
[4872160] | 134 | ln -sfn ../../$< $@
|
---|