source: mainline/boot/Makefile.build@ 94e46c9

lfn serial ticket/834-toolchain-update topic/msim-upgrade topic/simplify-dev-export
Last change on this file since 94e46c9 was 2a5d1751, checked in by Jakub Jermar <jakub@…>, 11 years ago

Build boot with macro BOOT defined.

  • Property mode set to 100644
File size: 4.5 KB
Line 
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
31include Makefile.common
32
33INCLUDES = generic/include
34OPTIMIZATION = 3
35
36DEFS = -DBOOT -DRELEASE=$(RELEASE) "-DCOPYRIGHT=$(COPYRIGHT)" "-DNAME=$(NAME)" -D__$(BITS)_BITS__ -D__$(ENDIANESS)__
37
38GCC_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 \
42 -std=gnu99 -Werror-implicit-function-declaration -Wwrite-strings \
43 -pipe
44
45ICC_CFLAGS = -I$(INCLUDES) -O$(OPTIMIZATION) -imacros $(CONFIG_HEADER) \
46 -ffreestanding -fno-builtin -nostdlib -nostdinc -Wall -Wmissing-prototypes \
47 -Werror-implicit-function-declaration -wd170
48
49CLANG_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 \
54 -pipe
55
56ifeq ($(CONFIG_DEBUG),y)
57 GCC_CFLAGS += -Werror
58 ICC_CFLAGS += -Werror
59endif
60
61ifeq ($(CONFIG_LINE_DEBUG),y)
62 GCC_CFLAGS += -g
63 ICC_CFLAGS += -g
64 CLANG_CFLAGS += -g
65endif
66
67ifeq ($(COMPILER),gcc_native)
68 CFLAGS = $(GCC_CFLAGS) $(EXTRA_CFLAGS)
69 DEPEND_DEFS = $(DEFS) $(CONFIG_DEFS)
70endif
71
72ifeq ($(COMPILER),gcc_cross)
73 CFLAGS = $(GCC_CFLAGS) $(EXTRA_CFLAGS)
74 DEPEND_DEFS = $(DEFS) $(CONFIG_DEFS)
75endif
76
77ifeq ($(COMPILER),gcc_helenos)
78 CFLAGS = $(GCC_CFLAGS) $(EXTRA_CFLAGS)
79 DEPEND_DEFS = $(DEFS) $(CONFIG_DEFS)
80endif
81
82
83ifeq ($(COMPILER),icc)
84 CFLAGS = $(ICC_CFLAGS) $(EXTRA_CFLAGS)
85 DEPEND_DEFS = $(DEFS) $(CONFIG_DEFS)
86endif
87
88ifeq ($(COMPILER),clang)
89 CFLAGS = $(CLANG_CFLAGS) $(EXTRA_CFLAGS)
90 DEPEND_DEFS = $(DEFS) $(CONFIG_DEFS)
91endif
92
93OBJECTS := $(addsuffix .o,$(basename $(SOURCES)))
94COMPONENT_OBJECTS := $(addsuffix .co,$(basename $(MODULES)))
95
96all: $(VERSION_DEF) $(COMMON_MAKEFILE) $(COMMON_HEADER) $(CONFIG_MAKEFILE) $(CONFIG_HEADER) $(BOOT_OUTPUT)
97 -[ -f $(DEPEND) ] && cp -a $(DEPEND) $(DEPEND_PREV)
98
99clean:
100 rm -f $(RAW) $(MAP) $(ARCH_INCLUDE) $(GENARCH_INCLUDE)
101
102-include $(DEPEND)
103
104$(BOOT_OUTPUT): $(RAW)
105 $(OBJCOPY) -O $(BFD_OUTPUT) $< $@
106
107$(RAW): $(OBJECTS) $(COMPONENT_OBJECTS) $(LINK)
108 $(LD) -n $(LFLAGS) -T $(LINK) -M -Map $(MAP) -o $@ $(COMPONENT_OBJECTS) $(OBJECTS)
109
110$(LINK): $(LINK).comp $(DEPEND)
111 $(GCC) $(DEFS) $(GCC_CFLAGS) -D__ASM__ -D__LINKER__ -E -x c $(LINK).comp | grep -v "^\#" > $(LINK)
112
113%.o: %.S $(DEPEND)
114 $(CC) $(DEFS) $(CFLAGS) -D__ASM__ -c $< -o $@
115ifeq ($(PRECHECK),y)
116 $(JOBFILE) $(JOB) $< $@ as asm/preproc $(DEFS) $(CFLAGS) -D__ASM__
117endif
118
119%.o: %.c $(DEPEND)
120 $(CC) $(DEFS) $(CFLAGS) -c $< -o $@
121ifeq ($(PRECHECK),y)
122 $(JOBFILE) $(JOB) $< $@ cc core $(DEFS) $(CFLAGS)
123endif
124
125$(DEPEND): $(ARCH_INCLUDE) $(GENARCH_INCLUDE) $(COMMON_HEADER_ARCH)
126 makedepend -f - -- $(DEPEND_DEFS) $(CFLAGS) -- $(SOURCES) > $@ 2> /dev/null
127 -[ -f $(DEPEND_PREV) ] && diff -q $(DEPEND_PREV) $@ && mv -f $(DEPEND_PREV) $@
128
129$(ARCH_INCLUDE): arch/$(KARCH)/include/
130 ln -sfn ../../$< $@
131
132$(GENARCH_INCLUDE): genarch/include/
133 ln -sfn ../../$< $@
134
135$(COMMON_HEADER_ARCH): $(COMMON_HEADER)
136 ln -sfn ../../../$< $@
Note: See TracBrowser for help on using the repository browser.