[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 |
|
---|
[0798689] | 33 | INCLUDES = -Igeneric/include -Iarch/$(KARCH)/include -Igenarch/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 |
|
---|
[fe171357] | 38 | AFLAGS = --fatal-warnings
|
---|
[37e8c4a] | 39 | LFLAGS = --fatal-warnings --warn-common
|
---|
[ae7bbfd0] | 40 |
|
---|
[a0a273e] | 41 | COMMON_CFLAGS = $(INCLUDES) -O$(OPTIMIZATION) -imacros $(CONFIG_HEADER) \
|
---|
| 42 | -ffreestanding -fno-builtin -nostdlib -nostdinc \
|
---|
[dd162f6] | 43 | -fexec-charset=UTF-8 -finput-charset=UTF-8 -fno-common \
|
---|
| 44 | -fdebug-prefix-map=$(realpath $(ROOT_PATH))=.
|
---|
[a0a273e] | 45 |
|
---|
| 46 | GCC_CFLAGS = -Wall -Wextra -Wno-unused-parameter -Wmissing-prototypes \
|
---|
[e8c5c11] | 47 | -std=gnu99 -Werror-implicit-function-declaration -Wwrite-strings \
|
---|
[e805e2f] | 48 | -pipe
|
---|
[4872160] | 49 |
|
---|
[a0a273e] | 50 | CLANG_CFLAGS = -Wall -Wextra -Wno-unused-parameter -Wmissing-prototypes \
|
---|
[4872160] | 51 | -Werror-implicit-function-declaration -Wwrite-strings \
|
---|
[a0a273e] | 52 | -pipe -fno-stack-protector -fno-PIC
|
---|
[4872160] | 53 |
|
---|
[e805e2f] | 54 | ifeq ($(CONFIG_DEBUG),y)
|
---|
[a0a273e] | 55 | COMMON_CFLAGS += -Werror
|
---|
[e805e2f] | 56 | endif
|
---|
| 57 |
|
---|
[9ded977] | 58 | ifeq ($(CONFIG_LINE_DEBUG),y)
|
---|
[a0a273e] | 59 | COMMON_CFLAGS += -g
|
---|
[9ded977] | 60 | endif
|
---|
| 61 |
|
---|
[4872160] | 62 | ifeq ($(COMPILER),clang)
|
---|
[a0a273e] | 63 | CFLAGS = $(COMMON_CFLAGS) $(CLANG_CFLAGS) $(EXTRA_CFLAGS)
|
---|
[4761f54] | 64 | else
|
---|
| 65 | CFLAGS = $(COMMON_CFLAGS) $(GCC_CFLAGS) $(EXTRA_CFLAGS)
|
---|
[4872160] | 66 | endif
|
---|
| 67 |
|
---|
| 68 | OBJECTS := $(addsuffix .o,$(basename $(SOURCES)))
|
---|
[4761f54] | 69 | DEPENDS := $(addsuffix .d,$(basename $(SOURCES)))
|
---|
[4872160] | 70 |
|
---|
| 71 | all: $(VERSION_DEF) $(COMMON_MAKEFILE) $(COMMON_HEADER) $(CONFIG_MAKEFILE) $(CONFIG_HEADER) $(BOOT_OUTPUT)
|
---|
| 72 |
|
---|
| 73 | clean:
|
---|
[0798689] | 74 | rm -f $(RAW) $(MAP)
|
---|
[4872160] | 75 |
|
---|
[4761f54] | 76 | -include $(DEPENDS)
|
---|
[4872160] | 77 |
|
---|
[a0a273e] | 78 | AS_CFLAGS := $(addprefix -Xassembler ,$(AFLAGS))
|
---|
| 79 |
|
---|
[4872160] | 80 | $(BOOT_OUTPUT): $(RAW)
|
---|
| 81 | $(OBJCOPY) -O $(BFD_OUTPUT) $< $@
|
---|
| 82 |
|
---|
[4646710] | 83 | $(RAW): $(OBJECTS) $(LINK)
|
---|
| 84 | $(LD) -n $(LFLAGS) -T $(LINK) -M -Map $(MAP) -o $@ $(OBJECTS)
|
---|
[4872160] | 85 |
|
---|
[4761f54] | 86 | $(LINK): | depend
|
---|
[53ad43c] | 87 | $(CC) $(DEFS) $(CFLAGS) -D__ASSEMBLER__ -D__LINKER__ -E -x c $(LINK).in | grep -v "^\#" > $(LINK)
|
---|
[f4660690] | 88 |
|
---|
[7f881cd8] | 89 | %.o: %.s | depend
|
---|
[53ad43c] | 90 | $(CC_JOB) -c -MD -MP $(DEFS) $(CFLAGS) $(AS_CFLAGS)
|
---|
[7f881cd8] | 91 |
|
---|
[4761f54] | 92 | %.o: %.S | depend
|
---|
[53ad43c] | 93 | $(CC_JOB) -c -MD -MP $(DEFS) $(CFLAGS) $(AS_CFLAGS)
|
---|
[4872160] | 94 |
|
---|
[4761f54] | 95 | %.o: %.c | depend
|
---|
[c631734] | 96 | $(CC_JOB) -c -MD -MP $(DEFS) $(CFLAGS)
|
---|
[4646710] | 97 |
|
---|
[0798689] | 98 | depend: $(PRE_DEPEND)
|
---|
[4872160] | 99 |
|
---|
[4646710] | 100 | $(COMPS).s: $(COMPS).zip
|
---|
| 101 | unzip -p $< $@ > $@
|
---|
| 102 |
|
---|
| 103 | $(COMPS).h: $(COMPS).zip
|
---|
| 104 | unzip -p $< $@ > $@
|
---|
| 105 |
|
---|
| 106 | $(COMPS)_desc.c: $(COMPS).zip
|
---|
| 107 | unzip -p $< $@ > $@
|
---|
| 108 |
|
---|
[94c05b89] | 109 | $(COMPONENTS_DEFLATE): $(COMPS).zip
|
---|
| 110 | unzip -p $< $@ > $@
|
---|
| 111 |
|
---|
[4646710] | 112 | $(COMPS).zip: $(COMPONENTS)
|
---|
| 113 | $(MKARRAY) --deflate $(COMPS) $(COMP) "$(AS_PROLOG)" ".section .components, \"a\"" $^
|
---|
| 114 |
|
---|
[239e32b8] | 115 | include Makefile.initrd
|
---|
[4646710] | 116 |
|
---|