Add -pipe .. notably speeds up windows builds.
[coreboot.git] / src / config / Config.lb
1 ## This is Architecture independant part of the makefile
2
3 uses CONFIG_HAVE_OPTION_TABLE
4 uses CONFIG_AP_CODE_IN_CAR
5 uses CONFIG_ASSEMBLER_DEBUG
6
7 makedefine CPP:= $(CC) -x assembler-with-cpp -DASSEMBLY -E
8 makedefine LIBGCC_FILE_NAME := $(shell $(CC) -print-libgcc-file-name)
9 makedefine GCC ?= $(CC)
10 makedefine GCC_INC_DIR := $(shell LC_ALL=C $(GCC) -print-search-dirs | sed -ne "s/install: \(.*\)/\1include/gp")
11
12 makedefine CPPFLAGS := -I$(TOP)/src/include -I$(TOP)/src/arch/$(CONFIG_ARCH)/include -I$(GCC_INC_DIR) $(CPUFLAGS)
13 makedefine CFLAGS = $(CONFIG_CPU_OPT) $(DISTRO_CFLAGS) $(CPPFLAGS) -Os -nostdinc -nostdlib -Wall -Wundef -Wstrict-prototypes -Wmissing-prototypes -Wwrite-strings -Wredundant-decls -Wno-trigraphs -Werror-implicit-function-declaration -Wstrict-aliasing -Wshadow -fno-common -ffreestanding -fno-builtin -fomit-frame-pointer -pipe
14
15 if CONFIG_ASSEMBLER_DEBUG
16 makedefine DEBUG_CFLAGS := -g -dA -fverbose-asm
17 end
18
19 makedefine HOSTCFLAGS:= -Os -Wall -Wstrict-prototypes -Wmissing-prototypes -Wredundant-decls -Wno-trigraphs -Werror-implicit-function-declaration -Wstrict-aliasing -Wshadow
20
21 makerule ldscript.ld   
22         depends "ldoptions $(LDSUBSCRIPTS-1)" 
23         action  "echo 'INCLUDE ldoptions' > $@; for file in $(LDSUBSCRIPTS-1) ; do echo /\* $$file \*/ >> $@; cat $$file >> $@ ; done"
24 end
25
26 #makerule cpuflags   
27 #       depends "Makefile.settings" 
28 #       action  "perl -e 'print \"CPUFLAGS :=\n\"; foreach $$var (split(\" \", $$ENV{VARIABLES})) { if (exists($$ENV{$$var})) { print \"CPUFLAGS += -D$$var\" . (length($$ENV{$$var})?\"=\x27$$ENV{$$var}\x27\":\"\") .\"\n\"} else { print \"CPUFLAGS += -U$$var\n\"} }' > $@"
29 #end
30
31 #makerule ldoptions   
32 #       depends "Makefile.settings" 
33 #       action  "perl -e 'foreach $$var (split(\" \", $$ENV{VARIABLES})) { if ($$ENV{$$var} =~ m/^(0x[0-9a-fA-F]+|0[0-7]+|[0-9]+)$$/) { print \"$$var = $$ENV{$$var};\n\"; }}' > $@"
34 #end
35
36 makerule coreboot.rom
37         depends "coreboot" 
38         action  "$(CONFIG_OBJCOPY) -O binary coreboot coreboot.rom"
39 end
40
41 makerule coreboot.a
42         depends "$(OBJECTS)"
43         action  "rm -f coreboot.a"
44         action  "$(CONFIG_CROSS_COMPILE)ar cr coreboot.a $(OBJECTS)"
45 end
46
47
48 makerule coreboot_ram.o
49         depends "src/arch/$(CONFIG_ARCH)/lib/c_start.o $(DRIVER) coreboot.a $(LIBGCC_FILE_NAME)" 
50         action  "$(CC) $(DISTRO_LFLAGS) -nostdlib -r -o $@ src/arch/$(CONFIG_ARCH)/lib/c_start.o $(DRIVER) -Wl,--wrap,__divdi3 -Wl,--wrap,__udivdi3 -Wl,--wrap,__moddi3 -Wl,--wrap,__umoddi3 -Wl,-\( coreboot.a $(LIBGCC_FILE_NAME) -Wl,-\)"
51 end
52
53 makerule coreboot_ram
54         depends "coreboot_ram.o $(TOP)/src/config/coreboot_ram.ld ldoptions" 
55         action  "$(CC) $(DISTRO_LFLAGS) -nostdlib -nostartfiles -static -o $@ -T $(TOP)/src/config/coreboot_ram.ld coreboot_ram.o"
56         action  "$(CONFIG_CROSS_COMPILE)nm -n coreboot_ram | sort > coreboot_ram.map"
57 end
58
59 ##
60 ## By default compress the part of coreboot that runs from RAM
61 ##
62 makedefine COREBOOT_RAM-$(CONFIG_COMPRESS):=coreboot_ram.nrv2b
63 makedefine COREBOOT_RAM-$(CONFIG_UNCOMPRESSED):=coreboot_ram.bin
64
65 makerule coreboot_ram.bin 
66         depends "coreboot_ram" 
67         action  "$(CONFIG_OBJCOPY) -O binary $< $@"
68 end
69
70 makerule coreboot_ram.nrv2b 
71         depends "coreboot_ram.bin nrv2b" 
72         action  "./nrv2b e $< $@"
73 end
74
75 makerule coreboot_ram.rom
76         depends "$(COREBOOT_RAM-1)" 
77         action  "cp $(COREBOOT_RAM-1) coreboot_ram.rom"
78 end
79
80 makedefine COREBOOT_APC:=
81
82 if CONFIG_AP_CODE_IN_CAR
83         #for ap code in cache
84
85         makerule coreboot_apc.a
86                 depends "apc_auto.o"
87                 action  "rm -f coreboot_apc.a"
88                 action  "$(CONFIG_CROSS_COMPILE)ar cr coreboot_apc.a apc_auto.o"
89         end
90
91         makerule coreboot_apc.o
92                 depends "src/arch/$(CONFIG_ARCH)/lib/c_start.o coreboot_apc.a"
93                 action  "$(CC) $(DISTRO_LFLAGS) -nostdlib -r -o $@ $^"
94         end
95
96         makerule coreboot_apc
97                 depends "coreboot_apc.o $(TOP)/src/config/coreboot_apc.ld ldoptions"
98                 action  "$(CC) $(DISTRO_LFLAGS) -nostdlib -nostartfiles -static -o $@ -T $(TOP)/src/config/coreboot_apc.ld coreboot_apc.o"
99                 action  "$(CONFIG_CROSS_COMPILE)nm -n coreboot_apc | sort > coreboot_apc.map"
100         end
101
102         ##
103         ## By default compress the part of coreboot that runs from cache as ram
104         ##
105         makedefine COREBOOT_APC-$(CONFIG_COMPRESS):=coreboot_apc.nrv2b
106         makedefine COREBOOT_APC-$(CONFIG_UNCOMPRESSED):=coreboot_apc.bin
107
108         makerule coreboot_apc.bin
109                 depends "coreboot_apc"
110                 action  "$(CONFIG_OBJCOPY) -O binary $< $@"
111         end
112
113         makerule coreboot_apc.nrv2b
114         depends "coreboot_apc.bin nrv2b"
115         action  "./nrv2b e $< $@"
116         end
117
118         makerule coreboot_apc.rom
119                 depends "$(COREBOOT_APC-1)"
120                 action  "cp $(COREBOOT_APC-1) coreboot_apc.rom"
121         end
122
123         makedefine COREBOOT_APC:=coreboot_apc.rom
124
125 end
126
127 makedefine COREBOOT_RAM_ROM:=coreboot_ram.rom
128
129 makerule coreboot   
130         depends "crt0.o $(INIT-OBJECTS) $(COREBOOT_APC) $(COREBOOT_RAM_ROM) ldscript.ld"
131         action  "$(CC) $(DISTRO_LFLAGS) -nostdlib -nostartfiles -static -o $@ -T ldscript.ld crt0.o $(INIT-OBJECTS)"
132         action  "$(CONFIG_CROSS_COMPILE)nm -n coreboot | sort > coreboot.map"
133         action  "$(CONFIG_CROSS_COMPILE)objdump -dS coreboot > coreboot.disasm" 
134 end
135
136 # Force crt0.s (which has build time version code in it to rebuild every time)
137 makedefine .PHONY : crt0.s
138 makerule crt0.s   
139         depends "crt0.S $(CRT0_INCLUDES)" 
140         action  "$(CPP) $(CPPFLAGS) -I. -I$(TOP)/src  $< > $@.new && mv $@.new $@"
141 end
142
143 # generate an assembly listing via -a switch.
144 makerule crt0.o  
145         depends "crt0.s" 
146         action  "$(CC) -Wa,-acdlns -c $(CONFIG_CPU_OPT) -o $@ $< >crt0.disasm"
147 end
148
149 makerule etags   
150         depends "$(SOURCES)" 
151         action  "etags $(SOURCES)"
152 end
153 makerule tags   
154         depends "$(SOURCES)" 
155         action  "ctags $(SOURCES)"
156 end
157 makerule corebootDoc.config
158         depends "$(TOP)/src/config/corebootDoc.config" 
159         action "cat $(TOP)/src/config/corebootDoc.config > corebootDoc.config"
160         action "echo 'INPUT=$(SOURCES)' >> corebootDoc.config"
161 end
162 makerule documentation   
163         depends "corebootDoc.config"
164         action  "doxygen corebootDoc.config"
165 end
166
167 # Yes, the rule doesn't seem to make sense, but multiple images could try to
168 # create a romcc binary at the same time, clobbering each other.
169 # Our makefile architecture won't allow us to easily have the romcc target
170 # in the main makefile, so keep it here and move the race condition winner
171 # in place. That way, romcc may get compiled twice, but the binary will always
172 # be in a correct and valid state if it exists because the move is atomic.
173 makerule ../romcc   
174         depends "$(TOP)/util/romcc/romcc.c" 
175         action  "$(HOSTCC) -g $(HOSTCFLAGS) $< -o romcc.tmpfile"
176         action  "mv romcc.tmpfile $@"
177 end
178
179 makerule build_opt_tbl   
180         depends "$(TOP)/util/options/build_opt_tbl.c $(TOP)/src/include/pc80/mc146818rtc.h $(TOP)/src/include/boot/coreboot_tables.h Makefile.settings Makefile"
181         action  "$(HOSTCC) $(HOSTCFLAGS) $(CPUFLAGS) $< -o $@" 
182 end
183
184 makerule option_table.h option_table.c
185         depends "build_opt_tbl $(CONFIG_MAINBOARD)/cmos.layout" 
186         action  "./build_opt_tbl --config $(CONFIG_MAINBOARD)/cmos.layout --header option_table.h --option option_table.c"
187 end
188
189 if CONFIG_HAVE_OPTION_TABLE
190 object ./option_table.o 
191 end
192
193 makerule clean 
194         action  "rm -f $(OBJECTS)"
195         action  "rm -f $(DRIVER)"
196         action  "rm -f coreboot.* *~"
197         action  "rm -f coreboot"
198         action  "rm -f ldscript.ld"
199         action  "rm -f a.out *.s *.l *.o *.E *.inc"
200         action  "rm -f TAGS tags romcc*"
201         action  "rm -f docipl chips.c *chip.c coreboot_apc* coreboot_ram* coreboot_pay*"
202         action  "rm -f build_opt_tbl* nrv2b* option_table.c option_table.h crt0.S crt0.disasm"
203         action  "rm -f smm smm.elf smm.map smm_bin.c"
204         action  "rm -f dsdt.aml dsdt.c"
205         action  "rm -f payload"
206 end
207
208 # do standard config files that the user need not specify
209 # for now, this is just 'lib', but it may be more later. 
210 dir /lib
211 dir /console
212 dir /devices
213 dir /pc80
214 dir /boot