| [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 |  | 
|---|
|  | 33 | INCLUDES = generic/include | 
|---|
|  | 34 | OPTIMIZATION = 3 | 
|---|
|  | 35 |  | 
|---|
| [d9faae91] | 36 | DEFS = -DRELEASE=$(RELEASE) "-DCOPYRIGHT=$(COPYRIGHT)" "-DNAME=$(NAME)" -D__$(BITS)_BITS__ -D__$(ENDIANESS)__ | 
|---|
| [4872160] | 37 |  | 
|---|
|  | 38 | GCC_CFLAGS = -I$(INCLUDES) -O$(OPTIMIZATION) -imacros $(CONFIG_HEADER) \ | 
|---|
|  | 39 | -fexec-charset=UTF-8 -fwide-exec-charset=UTF-32$(ENDIANESS) \ | 
|---|
|  | 40 | -finput-charset=UTF-8 -ffreestanding -fno-builtin -nostdlib -nostdinc \ | 
|---|
|  | 41 | -Wall -Wextra -Wno-unused-parameter -Wmissing-prototypes \ | 
|---|
| [e8c5c11] | 42 | -std=gnu99 -Werror-implicit-function-declaration -Wwrite-strings \ | 
|---|
| [e805e2f] | 43 | -pipe | 
|---|
| [4872160] | 44 |  | 
|---|
|  | 45 | ICC_CFLAGS = -I$(INCLUDES) -O$(OPTIMIZATION) -imacros $(CONFIG_HEADER) \ | 
|---|
|  | 46 | -ffreestanding -fno-builtin -nostdlib -nostdinc -Wall -Wmissing-prototypes \ | 
|---|
| [e805e2f] | 47 | -Werror-implicit-function-declaration -wd170 | 
|---|
| [4872160] | 48 |  | 
|---|
|  | 49 | CLANG_CFLAGS = -I$(INCLUDES) -O$(OPTIMIZATION) -imacros $(CONFIG_HEADER) \ | 
|---|
|  | 50 | -fexec-charset=UTF-8 -fwide-exec-charset=UTF-32$(ENDIANESS) \ | 
|---|
|  | 51 | -finput-charset=UTF-8 -ffreestanding -fno-builtin -nostdlib -nostdinc \ | 
|---|
|  | 52 | -Wall -Wextra -Wno-unused-parameter -Wmissing-prototypes \ | 
|---|
|  | 53 | -Werror-implicit-function-declaration -Wwrite-strings \ | 
|---|
| [bf85e56] | 54 | -pipe | 
|---|
| [4872160] | 55 |  | 
|---|
| [e805e2f] | 56 | ifeq ($(CONFIG_DEBUG),y) | 
|---|
|  | 57 | GCC_CFLAGS += -Werror | 
|---|
|  | 58 | ICC_CFLAGS += -Werror | 
|---|
|  | 59 | endif | 
|---|
|  | 60 |  | 
|---|
| [9ded977] | 61 | ifeq ($(CONFIG_LINE_DEBUG),y) | 
|---|
|  | 62 | GCC_CFLAGS += -g | 
|---|
|  | 63 | ICC_CFLAGS += -g | 
|---|
|  | 64 | CLANG_CFLAGS += -g | 
|---|
|  | 65 | endif | 
|---|
|  | 66 |  | 
|---|
| [4872160] | 67 | ifeq ($(COMPILER),gcc_native) | 
|---|
|  | 68 | CFLAGS = $(GCC_CFLAGS) $(EXTRA_CFLAGS) | 
|---|
|  | 69 | DEPEND_DEFS = $(DEFS) $(CONFIG_DEFS) | 
|---|
|  | 70 | endif | 
|---|
|  | 71 |  | 
|---|
|  | 72 | ifeq ($(COMPILER),gcc_cross) | 
|---|
|  | 73 | CFLAGS = $(GCC_CFLAGS) $(EXTRA_CFLAGS) | 
|---|
|  | 74 | DEPEND_DEFS = $(DEFS) $(CONFIG_DEFS) | 
|---|
|  | 75 | endif | 
|---|
|  | 76 |  | 
|---|
|  | 77 | ifeq ($(COMPILER),icc) | 
|---|
|  | 78 | CFLAGS = $(ICC_CFLAGS) $(EXTRA_CFLAGS) | 
|---|
|  | 79 | DEPEND_DEFS = $(DEFS) $(CONFIG_DEFS) | 
|---|
|  | 80 | endif | 
|---|
|  | 81 |  | 
|---|
|  | 82 | ifeq ($(COMPILER),clang) | 
|---|
|  | 83 | CFLAGS = $(CLANG_CFLAGS) $(EXTRA_CFLAGS) | 
|---|
|  | 84 | DEPEND_DEFS = $(DEFS) $(CONFIG_DEFS) | 
|---|
|  | 85 | endif | 
|---|
|  | 86 |  | 
|---|
|  | 87 | OBJECTS := $(addsuffix .o,$(basename $(SOURCES))) | 
|---|
|  | 88 | COMPONENT_OBJECTS := $(addsuffix .co,$(basename $(MODULES))) | 
|---|
|  | 89 |  | 
|---|
|  | 90 | all: $(VERSION_DEF) $(COMMON_MAKEFILE) $(COMMON_HEADER) $(CONFIG_MAKEFILE) $(CONFIG_HEADER) $(BOOT_OUTPUT) | 
|---|
|  | 91 | -[ -f $(DEPEND) ] && cp -a $(DEPEND) $(DEPEND_PREV) | 
|---|
|  | 92 |  | 
|---|
|  | 93 | clean: | 
|---|
|  | 94 | rm -f $(RAW) $(MAP) $(ARCH_INCLUDE) $(GENARCH_INCLUDE) | 
|---|
|  | 95 |  | 
|---|
|  | 96 | -include $(DEPEND) | 
|---|
|  | 97 |  | 
|---|
|  | 98 | $(BOOT_OUTPUT): $(RAW) | 
|---|
|  | 99 | $(OBJCOPY) -O $(BFD_OUTPUT) $< $@ | 
|---|
|  | 100 |  | 
|---|
|  | 101 | $(RAW): $(OBJECTS) $(COMPONENT_OBJECTS) $(LINK) | 
|---|
| [afdcc60e] | 102 | $(LD) -n $(LFLAGS) -T $(LINK) -M -Map $(MAP) -o $@ $(COMPONENT_OBJECTS) $(OBJECTS) | 
|---|
| [4872160] | 103 |  | 
|---|
| [adf6607] | 104 | $(LINK): $(LINK).comp $(DEPEND) | 
|---|
| [f4660690] | 105 | $(GCC) $(DEFS) $(GCC_CFLAGS) -D__ASM__ -D__LINKER__ -E -x c $(LINK).comp | grep -v "^\#" > $(LINK) | 
|---|
|  | 106 |  | 
|---|
| [4872160] | 107 | %.o: %.S $(DEPEND) | 
|---|
|  | 108 | $(CC) $(DEFS) $(CFLAGS) -D__ASM__ -c $< -o $@ | 
|---|
|  | 109 | ifeq ($(PRECHECK),y) | 
|---|
|  | 110 | $(JOBFILE) $(JOB) $< $@ as asm/preproc $(DEFS) $(CFLAGS) -D__ASM__ | 
|---|
|  | 111 | endif | 
|---|
|  | 112 |  | 
|---|
|  | 113 | %.o: %.c $(DEPEND) | 
|---|
|  | 114 | $(CC) $(DEFS) $(CFLAGS) -c $< -o $@ | 
|---|
|  | 115 | ifeq ($(PRECHECK),y) | 
|---|
|  | 116 | $(JOBFILE) $(JOB) $< $@ cc core $(DEFS) $(CFLAGS) | 
|---|
|  | 117 | endif | 
|---|
|  | 118 |  | 
|---|
|  | 119 | $(DEPEND): $(ARCH_INCLUDE) $(GENARCH_INCLUDE) $(COMMON_HEADER_ARCH) | 
|---|
|  | 120 | makedepend -f - -- $(DEPEND_DEFS) $(CFLAGS) -- $(SOURCES) > $@ 2> /dev/null | 
|---|
|  | 121 | -[ -f $(DEPEND_PREV) ] && diff -q $(DEPEND_PREV) $@ && mv -f $(DEPEND_PREV) $@ | 
|---|
|  | 122 |  | 
|---|
|  | 123 | $(ARCH_INCLUDE): arch/$(KARCH)/include/ | 
|---|
|  | 124 | ln -sfn ../../$< $@ | 
|---|
|  | 125 |  | 
|---|
|  | 126 | $(GENARCH_INCLUDE): genarch/include/ | 
|---|
|  | 127 | ln -sfn ../../$< $@ | 
|---|
|  | 128 |  | 
|---|
|  | 129 | $(COMMON_HEADER_ARCH): $(COMMON_HEADER) | 
|---|
|  | 130 | ln -sfn ../../../$< $@ | 
|---|