Generate and extract debug sysmbols for coreboot. *.debug files can be
[coreboot.git] / src / arch / i386 / Makefile.inc
1 ##
2 ## This file is part of the coreboot project.
3 ##
4 ## Copyright (C) 2009-2010 coresystems GmbH
5 ## Copyright (C) 2009 Ronald G. Minnich
6 ##
7 ## This program is free software; you can redistribute it and/or modify
8 ## it under the terms of the GNU General Public License as published by
9 ## the Free Software Foundation; version 2 of the License.
10 ##
11 ## This program is distributed in the hope that it will be useful,
12 ## but WITHOUT ANY WARRANTY; without even the implied warranty of
13 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 ## GNU General Public License for more details.
15 ##
16 ## You should have received a copy of the GNU General Public License
17 ## along with this program; if not, write to the Free Software
18 ## Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
19 ##
20
21 #######################################################################
22 # Take care of subdirectories
23 subdirs-y += boot
24 # subdirs-y += init
25 subdirs-y += lib
26 subdirs-y += smp
27
28 obj-$(CONFIG_HAVE_OPTION_TABLE) += ../../option_table.o
29
30 #######################################################################
31 # Build the final rom image
32 COREBOOT_ROM_DEPENDENCIES:=
33 ifneq ($(CONFIG_PAYLOAD_NONE),y)
34 COREBOOT_ROM_DEPENDENCIES+=$(CONFIG_FALLBACK_PAYLOAD_FILE)
35 endif
36 ifeq ($(CONFIG_VGA_BIOS),y)
37 COREBOOT_ROM_DEPENDENCIES+=$(CONFIG_FALLBACK_VGA_BIOS_FILE)
38 endif
39 ifeq ($(CONFIG_INTEL_MBI),y)
40 COREBOOT_ROM_DEPENDENCIES+=$(CONFIG_FALLBACK_MBI_FILE)
41 endif
42 ifeq ($(CONFIG_BOOTSPLASH),y)
43 COREBOOT_ROM_DEPENDENCIES+=$(CONFIG_FALLBACK_BOOTSPLASH_FILE)
44 endif
45 ifeq ($(CONFIG_AP_CODE_IN_CAR),y)
46 COREBOOT_ROM_DEPENDENCIES+=$(obj)/coreboot_ap
47 endif
48 ifeq ($(CONFIG_GEODE_VSA_FILE),y)
49 COREBOOT_ROM_DEPENDENCIES+=$(CONFIG_VSA_FILENAME)
50 endif
51
52 $(obj)/coreboot.rom: $(obj)/coreboot.pre $(obj)/coreboot_ram $(CBFSTOOL) $(call strip_quotes,$(COREBOOT_ROM_DEPENDENCIES))
53         @printf "    CBFS       $(subst $(obj)/,,$(@))\n"
54         cp $(obj)/coreboot.pre $@.tmp
55         if [ -f $(obj)/coreboot_ap ]; \
56         then \
57                 $(CBFSTOOL) $@.tmp add-stage $(obj)/coreboot_ap $(CONFIG_CBFS_PREFIX)/coreboot_ap $(CBFS_COMPRESS_FLAG); \
58         fi
59         $(CBFSTOOL) $@.tmp add-stage $(obj)/coreboot_ram $(CONFIG_CBFS_PREFIX)/coreboot_ram $(CBFS_COMPRESS_FLAG)
60 ifeq ($(CONFIG_PAYLOAD_NONE),y)
61         @printf "    PAYLOAD    \e[1;31mnone (as specified by user)\e[0m\n"
62 else
63         @printf "    PAYLOAD    $(CONFIG_FALLBACK_PAYLOAD_FILE) (compression: $(CBFS_PAYLOAD_COMPRESS_NAME))\n"
64         $(CBFSTOOL) $@.tmp add-payload $(CONFIG_FALLBACK_PAYLOAD_FILE) $(CONFIG_CBFS_PREFIX)/payload $(CBFS_PAYLOAD_COMPRESS_FLAG)
65 endif
66 ifeq ($(CONFIG_VGA_BIOS),y)
67         @printf "    VGABIOS    $(CONFIG_FALLBACK_VGA_BIOS_FILE) $(CONFIG_FALLBACK_VGA_BIOS_ID)\n"
68         $(CBFSTOOL) $@.tmp add $(CONFIG_FALLBACK_VGA_BIOS_FILE) "pci$(CONFIG_FALLBACK_VGA_BIOS_ID).rom" optionrom
69 endif
70 ifeq ($(CONFIG_INTEL_MBI),y)
71         @printf "    MBI        $(CONFIG_FALLBACK_MBI_FILE)\n"
72         $(CBFSTOOL) $@.tmp add $(CONFIG_FALLBACK_MBI_FILE) mbi.bin mbi
73 endif
74 ifeq ($(CONFIG_BOOTSPLASH),y)
75         @printf "    BOOTSPLASH $(CONFIG_FALLBACK_BOOTSPLASH_FILE)\n"
76         $(CBFSTOOL) $@.tmp add $(CONFIG_FALLBACK_BOOTSPLASH_FILE) bootsplash.jpg bootsplash
77 endif
78 ifeq ($(CONFIG_GEODE_VSA_FILE),y)
79         @printf "    VSA        $(CONFIG_VSA_FILENAME)\n"
80         $(OBJCOPY) --set-start 0x20 --adjust-vma 0x60000 -I binary -O elf32-i386 -B i386 $(CONFIG_VSA_FILENAME) $(obj)/vsa.o
81         $(LD) -m elf_i386 -e 0x60020 --section-start .data=0x60000 $(obj)/vsa.o -o $(obj)/vsa.elf
82         $(CBFSTOOL) $@.tmp add-stage $(obj)/vsa.elf vsa
83 endif
84         mv $@.tmp $@
85         @printf "    CBFSPRINT  $(subst $(obj)/,,$(@))\n\n"
86         $(CBFSTOOL) $@ print
87
88 #######################################################################
89 # i386 specific tools
90
91 $(obj)/option_table.h: $(objutil)/options/build_opt_tbl $(top)/src/mainboard/$(MAINBOARDDIR)/cmos.layout
92         @printf "    OPTION     $(subst $(obj)/,,$(@))\n"
93         $(objutil)/options/build_opt_tbl --config $(top)/src/mainboard/$(MAINBOARDDIR)/cmos.layout --header $(obj)/option_table.h
94
95 $(obj)/option_table.c: $(objutil)/options/build_opt_tbl $(top)/src/mainboard/$(MAINBOARDDIR)/cmos.layout
96         @printf "    OPTION     $(subst $(obj)/,,$(@))\n"
97         $(objutil)/options/build_opt_tbl --config $(top)/src/mainboard/$(MAINBOARDDIR)/cmos.layout --option $(obj)/option_table.c
98
99 $(objutil)/options/build_opt_tbl: $(top)/util/options/build_opt_tbl.c $(top)/src/include/pc80/mc146818rtc.h $(top)/src/include/boot/coreboot_tables.h
100         @printf "    HOSTCC     $(subst $(obj)/,,$(@))\n"
101         $(HOSTCC) $(HOSTCFLAGS) $< -o $@
102
103 #######################################################################
104 # Build the coreboot_ram (stage 2)
105
106 $(obj)/coreboot_ram: $(obj)/coreboot_ram.o $(src)/arch/i386/coreboot_ram.ld #ldoptions
107         @printf "    CC         $(subst $(obj)/,,$(@))\n"
108         $(CC) -nostdlib -nostartfiles -static -o $@ -L$(obj) -T $(src)/arch/i386/coreboot_ram.ld $(obj)/coreboot_ram.o
109         $(NM) -n $(obj)/coreboot_ram | sort > $(obj)/coreboot_ram.map
110         $(OBJCOPY) --only-keep-debug $@ $(obj)/coreboot_ram.debug
111         $(OBJCOPY) --strip-debug $@
112         $(OBJCOPY) --add-gnu-debuglink=$(obj)/coreboot_ram.debug $@
113
114 $(obj)/coreboot_ram.o: $(obj)/arch/i386/lib/c_start.o $$(drivers) $(obj)/coreboot.a $(LIBGCC_FILE_NAME)
115         @printf "    CC         $(subst $(obj)/,,$(@))\n"
116         $(CC) -nostdlib -r -o $@ $(obj)/arch/i386/lib/c_start.o $(drivers) -Wl,--wrap,__divdi3 -Wl,--wrap,__udivdi3 -Wl,--wrap,__moddi3 -Wl,--wrap,__umoddi3 -Wl,--start-group $(obj)/coreboot.a $(LIBGCC_FILE_NAME) -Wl,--end-group
117
118 $(obj)/coreboot.a: $$(objs)
119         @printf "    AR         $(subst $(obj)/,,$(@))\n"
120         rm -f $(obj)/coreboot.a
121         $(AR) cr $(obj)/coreboot.a $^
122
123 #######################################################################
124 # coreboot_ap.rom
125
126 ifeq ($(CONFIG_AP_CODE_IN_CAR),y)
127
128 $(obj)/coreboot_ap: $(obj)/mainboard/$(MAINBOARDDIR)/ap_romstage.o
129         @printf "    CC         $(subst $(obj)/,,$(@))\n"
130         $(CC) -nostdlib -nostartfiles -static -o $@ -L$(obj) -T $(src)/arch/i386/init/ldscript_apc.lb $^
131         $(OBJCOPY) --only-keep-debug $@ $(obj)/coreboot_ap.debug
132         $(OBJCOPY) --strip-debug $@
133         $(OBJCOPY) --add-gnu-debuglink=$(obj)/coreboot_ap.debug $@
134         $(NM) -n $(obj)/coreboot_ap | sort > $(obj)/coreboot_ap.map
135
136
137 endif
138
139 #######################################################################
140 # done
141
142 crt0s = $(src)/arch/i386/init/prologue.inc
143 ldscripts =
144 ldscripts += $(src)/arch/i386/init/ldscript_fallback_cbfs.lb
145 ifeq ($(CONFIG_BIG_BOOTBLOCK),y)
146 crt0s += $(src)/cpu/x86/16bit/entry16.inc
147 ldscripts += $(src)/cpu/x86/16bit/entry16.lds
148 endif
149 crt0s += $(src)/cpu/x86/32bit/entry32.inc
150 ldscripts += $(src)/cpu/x86/32bit/entry32.lds
151 ifeq ($(CONFIG_BIG_BOOTBLOCK),y)
152 crt0s += $(src)/cpu/x86/16bit/reset16.inc
153 ldscripts += $(src)/cpu/x86/16bit/reset16.lds
154 crt0s += $(src)/arch/i386/lib/id.inc
155 ldscripts += $(src)/arch/i386/lib/id.lds
156 endif
157
158 crt0s += $(src)/cpu/x86/fpu_enable.inc
159 ifeq ($(CONFIG_SSE),y)
160 crt0s += $(src)/cpu/x86/sse_enable.inc
161 endif
162
163 crt0s += $(cpu_incs)
164
165 #
166 # FIXME move to CPU_INTEL_SOCKET_MPGA604
167 #
168 ifeq ($(CONFIG_BOARD_TYAN_S2735),y)
169 crt0s += $(src)/cpu/intel/car/cache_as_ram.inc
170 endif
171
172 ifeq ($(CONFIG_LLSHELL),y)
173 crt0s += $(src)/arch/i386/llshell/llshell.inc
174 endif
175
176 crt0s += $(obj)/mainboard/$(MAINBOARDDIR)/romstage.inc
177
178 ifeq ($(CONFIG_SSE),y)
179 crt0s += $(src)/cpu/x86/sse_disable.inc
180 endif
181 ifeq ($(CONFIG_MMX),y)
182 crt0s += $(src)/cpu/x86/mmx_disable.inc
183 endif
184
185 ifeq ($(CONFIG_BIG_BOOTBLOCK),y)
186 crt0s += $(chipset_bootblock_inc)
187 ldscripts += $(chipset_bootblock_lds)
188 endif
189
190 ifeq ($(CONFIG_ROMCC),y)
191 crt0s += $(src)/arch/i386/init/crt0_romcc_epilogue.inc
192 endif
193
194 OPTION_TABLE_H:=
195 ifeq ($(CONFIG_HAVE_OPTION_TABLE),y)
196 OPTION_TABLE_H:=$(obj)/option_table.h
197 endif
198
199 ifeq ($(CONFIG_ROMCC),y)
200 ROMCCFLAGS ?= -mcpu=p2 -O2
201
202 $(obj)/mainboard/$(MAINBOARDDIR)/romstage.inc: $(src)/mainboard/$(MAINBOARDDIR)/romstage.c $(objutil)/romcc/romcc $(OPTION_TABLE_H) $(obj)/build.h $(obj)/config.h
203         printf "    ROMCC      romstage.inc\n"
204         $(ROMCC) -c -S $(ROMCCFLAGS) -D__PRE_RAM__ -I. $(INCLUDES) $< -o $@
205 else
206
207 $(obj)/mainboard/$(MAINBOARDDIR)/ap_romstage.o: $(src)/mainboard/$(MAINBOARDDIR)/ap_romstage.c $(OPTION_TABLE_H)
208         @printf "    CC         $(subst $(obj)/,,$(@))\n"
209         $(CC) -MMD $(CFLAGS) -I$(src) -I. -c $(src)/mainboard/$(MAINBOARDDIR)/ap_romstage.c -o $@
210
211 $(obj)/mainboard/$(MAINBOARDDIR)/romstage.pre.inc: $(src)/mainboard/$(MAINBOARDDIR)/romstage.c $(OPTION_TABLE_H) $(obj)/build.h
212         @printf "    CC         romstage.inc\n"
213         $(CC) -MMD $(CFLAGS) -D__PRE_RAM__ -I$(src) -I. -c -S $< -o $@
214
215 $(obj)/mainboard/$(MAINBOARDDIR)/romstage.inc: $(obj)/mainboard/$(MAINBOARDDIR)/romstage.pre.inc
216         @printf "    POST       romstage.inc\n"
217         sed -e 's/\.rodata/.rom.data/g' -e 's/\.text/.section .rom.text/g' $^ > $@.tmp
218         mv $@.tmp $@
219 endif
220
221 # Things that appear in every board
222 initobjs += $(obj)/mainboard/$(MAINBOARDDIR)/crt0.o
223 objs += $(obj)/mainboard/$(MAINBOARDDIR)/mainboard.o
224 ifeq ($(CONFIG_GENERATE_MP_TABLE),y)
225 objs += $(obj)/mainboard/$(MAINBOARDDIR)/mptable.o
226 endif
227 ifeq ($(CONFIG_GENERATE_PIRQ_TABLE),y)
228 objs += $(obj)/mainboard/$(MAINBOARDDIR)/irq_tables.o
229 endif
230 ifeq ($(CONFIG_BOARD_HAS_HARD_RESET),y)
231 objs += $(obj)/mainboard/$(MAINBOARDDIR)/reset.o
232 endif
233 ifeq ($(CONFIG_GENERATE_ACPI_TABLES),y)
234 objs += $(obj)/mainboard/$(MAINBOARDDIR)/acpi_tables.o
235 objs += $(obj)/mainboard/$(MAINBOARDDIR)/dsdt.o
236 # make doesn't have arithmetic operators or greater-than comparisons
237 ifeq ($(subst 5,4,$(CONFIG_ACPI_SSDTX_NUM)),4)
238 objs += $(obj)/mainboard/$(MAINBOARDDIR)/ssdt2.o
239 objs += $(obj)/mainboard/$(MAINBOARDDIR)/ssdt3.o
240 objs += $(obj)/mainboard/$(MAINBOARDDIR)/ssdt4.o
241 endif
242 ifeq ($(CONFIG_ACPI_SSDTX_NUM),5)
243 objs += $(obj)/mainboard/$(MAINBOARDDIR)/ssdt5.o
244 endif
245 ifeq ($(CONFIG_BOARD_HAS_FADT),y)
246 objs += $(obj)/mainboard/$(MAINBOARDDIR)/fadt.o
247 endif
248 endif
249
250 ifeq ($(CONFIG_HAVE_BUS_CONFIG),y)
251 objs += $(obj)/mainboard/$(MAINBOARDDIR)/get_bus_conf.o
252 endif
253
254 ifeq ($(CONFIG_TINY_BOOTBLOCK),y)
255 include $(src)/arch/i386/Makefile.bootblock.inc
256 else
257 include $(src)/arch/i386/Makefile.bigbootblock.inc
258 endif