2 ## This file is part of the coreboot project.
4 ## Copyright (C) 2011 secunet Security Networks AG
6 ## This program is free software; you can redistribute it and/or modify
7 ## it under the terms of the GNU General Public License as published by
8 ## the Free Software Foundation; version 2 of the License.
10 ## This program is distributed in the hope that it will be useful,
11 ## but WITHOUT ANY WARRANTY; without even the implied warranty of
12 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 ## GNU General Public License for more details.
15 ## You should have received a copy of the GNU General Public License
16 ## along with this program; if not, write to the Free Software
17 ## Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20 #######################################################################
21 # misleadingly named, this is the coreboot version
22 export KERNELVERSION := $(shell if [ -d "$(top)/.git" -a -f "`which git`" ]; \
23 then git describe --dirty --always || git describe; \
24 else echo 4.0$(KERNELREVISION); fi)
26 #######################################################################
27 # Test for coreboot toolchain (except when explicitely not requested)
28 ifneq ($(NOCOMPILE),1)
29 # only run if we're doing a build (not for tests, kconfig, ...)
30 ifneq ($(CONFIG_ANY_TOOLCHAIN),y)
31 _toolchain=$(shell $(CC_x86_32) -v 2>&1 |grep -q "gcc version .*coreboot toolchain" && echo coreboot)
32 ifeq ($(CONFIG_COMPILER_LLVM_CLANG),y)
33 _toolchain=$(shell $(CC_x86_32) -v 2>&1 |grep -q "clang version" && echo coreboot)
35 ifneq ($(_toolchain),coreboot)
36 $(error Please use the coreboot toolchain (or prove that your toolchain works))
41 #######################################################################
42 # Basic component discovery
43 MAINBOARDDIR=$(call strip_quotes,$(CONFIG_MAINBOARD_DIR))
46 ## Final build results, which CBFSTOOL uses to create the final
47 ## rom image file, are placed under $(objcbfs).
48 ## These typically have suffixes .debug .elf .bin and .map
49 export objcbfs := $(obj)/cbfs/$(call strip_quotes,$(CONFIG_CBFS_PREFIX))
51 ## Based on the active configuration, Makefile conditionally collects
52 ## the required assembly includes and saves them in a file.
53 ## Such files that do not have a clear one-to-one relation to a source
54 ## file under src/ are placed and built under $(objgenerated)
55 export objgenerated := $(obj)/generated
57 #######################################################################
58 # root rule to resolve if in build mode (ie. configuration exists)
59 real-target: $(obj)/config.h coreboot
60 coreboot: build-dirs $(obj)/coreboot.rom $(obj)/cbfstool $(obj)/rmodtool
62 #######################################################################
64 PHONY+= clean-abuild coreboot lint lint-stable build-dirs
66 #######################################################################
67 # root source directories of coreboot
68 subdirs-y := src/lib src/console src/device src/ec src/southbridge src/soc
69 subdirs-y += src/northbridge src/superio src/drivers src/cpu src/vendorcode
70 subdirs-y += util/cbfstool util/sconfig util/nvramtool
71 subdirs-y += src/arch/arm src/arch/arm64 src/arch/x86
72 subdirs-y += src/mainboard/$(MAINBOARDDIR)
74 subdirs-y += site-local
76 #######################################################################
77 # Add source classes and their build options
78 classes-y := ramstage romstage bootblock smm smmstub cpu_microcode
80 # Add dynamic classes for rmodules
81 $(foreach supported_arch,$(ARCH_SUPPORTED), \
82 $(eval $(call define_class,rmodules_$(supported_arch),$(supported_arch))))
84 #######################################################################
85 # Helper functions for ramstage postprocess
91 # files-in-dir-recursive,dir,files
92 files-in-dir-recursive=$(filter $(1)%,$(2))
95 parent-dir=$(dir $(if $(patsubst /%,,$(1)),,/)$(subst $( ),/,$(strip $(subst /, ,$(1)))))
97 # filters out exactly the directory specified
98 # filter-out-dir,dir_to_keep,dirs
99 filter-out-dir=$(filter-out $(1),$(2))
101 # filters out dir_to_keep and all its parents
102 # filter-out-dirs,dir_to_keep,dirs
103 filter-out-dirs=$(if $(filter-out ./ /,$(1)),$(call filter-out-dirs,$(call parent-dir,$(1)),$(call filter-out-dir,$(1),$(2))),$(call filter-out-dir,$(1),$(2)))
106 dir-wildcards=$(addsuffix %,$(1))
108 # files-in-dir,dir,files
109 files-in-dir=$(filter-out $(call dir-wildcards,$(call filter-out-dirs,$(1),$(sort $(dir $(2))))),$(call files-in-dir-recursive,$(1),$(2)))
111 #######################################################################
112 # reduce command line length by linking the objects of each
113 # directory into an intermediate file
114 ramstage-postprocess=$(foreach d,$(sort $(dir $(1))), \
115 $(eval $(d)ramstage.o: $(call files-in-dir,$(d),$(1)); $$(LD_ramstage) -o $$@ -r $$^ ) \
116 $(eval ramstage-objs:=$(d)ramstage.o $(filter-out $(call files-in-dir,$(d),$(1)),$(ramstage-objs))))
118 CPPFLAGS_romstage += -D__PRE_RAM__
119 ifeq ($(CONFIG_TRACE),y)
120 CFLAGS_ramstage += -finstrument-functions
122 ifeq ($(CONFIG_COVERAGE),y)
123 CFLAGS_ramstage += -fprofile-arcs -ftest-coverage
126 ifeq ($(CONFIG_USE_BLOBS),y)
127 forgetthis:=$(shell git submodule update --init --checkout 3rdparty)
130 CPPFLAGS_bootblock += -D__BOOT_BLOCK__ -D__PRE_RAM__
132 CPPFLAGS_smmstub += -D__SMM__
133 CPPFLAGS_smm += -D__SMM__
135 # SMM TSEG base is dynamic
136 ifneq ($(CONFIG_SMM_MODULES),y)
137 ifeq ($(CONFIG_SMM_TSEG),y)
142 ramstage-c-deps:=$$(OPTION_TABLE_H)
143 romstage-c-deps:=$$(OPTION_TABLE_H)
144 bootblock-c-deps:=$$(OPTION_TABLE_H)
145 smm-c-deps:=$$(OPTION_TABLE_H)
147 #######################################################################
148 # Add handler to compile ACPI's ASL
149 define ramstage-objs_asl_template
150 $(obj)/$(1).ramstage.o: src/$(1).asl $(obj)/config.h
151 @printf " IASL $$(subst $(top)/,,$$(@))\n"
152 $(CC_ramstage) -x assembler-with-cpp -E -MMD -MT $$(@) -D__ACPI__ -P -include $(src)/include/kconfig.h -I$(obj) -I$(src) -I$(src)/include -I$(src)/arch/$(ARCHDIR-$(ARCH-ramstage-y))/include -I$(src)/mainboard/$(MAINBOARDDIR) $$< -o $$(basename $$@).asl
153 cd $$(dir $$@); $(IASL) -p $$(notdir $$@) -tc $$(notdir $$(basename $$@)).asl
154 mv $$(basename $$@).hex $$(basename $$@).c
155 $(CC_ramstage) $$(CFLAGS_ramstage) $$(CPPFLAGS_ramstage) $$(if $$(subst dsdt,,$$(basename $$(notdir $(1)))), -DAmlCode=AmlCode_$$(basename $$(notdir $(1)))) -c -o $$@ $$(basename $$@).c
156 # keep %.o: %.c rule from catching the temporary .c file after a make clean
157 mv $$(basename $$@).c $$(basename $$@).hex
160 #######################################################################
161 # Parse plaintext cmos defaults into binary format
163 # arg2: binary file name
164 cbfs-files-processor-nvramtool= \
165 $(eval $(2): $(1) $(src)/mainboard/$(MAINBOARDDIR)/cmos.layout | $(objutil)/nvramtool/nvramtool ; \
166 printf " CREATE $(2) (from $(1))\n"; $(objutil)/nvramtool/nvramtool -y $(src)/mainboard/$(MAINBOARDDIR)/cmos.layout -D $(2).tmp -p $(1) && mv $(2).tmp $(2))
168 #######################################################################
169 # Link VSA binary to ELF-ish stage
171 # arg2: binary file name
172 cbfs-files-processor-vsa= \
173 $(eval $(2): $(1) ; \
174 printf " CREATE $(2) (from $(1))\n"; $(OBJCOPY_ramstage) --set-start 0x20 --adjust-vma 0x60000 -I binary -O elf32-i386 -B i386 $(1) $(2).tmp && $(LD_ramstage) -m elf_i386 -e 0x60020 --section-start .data=0x60000 $(2).tmp -o $(2))
176 #######################################################################
177 # Add handler for arbitrary files in CBFS
178 $(call add-special-class,cbfs-files)
179 cbfs-files-handler= \
180 $(eval tmp-cbfs-method:=$(word 2, $(subst :, ,$($(2)-file)))) \
181 $(eval $(2)-file:=$(call strip_quotes,$(word 1, $(subst :, ,$($(2)-file))))) \
182 $(if $(wildcard $(1)$($(2)-file)), \
183 $(eval tmp-cbfs-file:= $(wildcard $(1)$($(2)-file))), \
184 $(eval tmp-cbfs-file:= $($(2)-file))) \
185 $(if $(strip $($(2)-required)), \
186 $(if $(wildcard $(tmp-cbfs-file)),, \
187 $(info This build configuration requires $($(2)-required)) \
188 $(eval FAILBUILD:=1) \
190 $(if $(tmp-cbfs-method), \
191 $(eval tmp-old-cbfs-file:=$(tmp-cbfs-file)) \
192 $(eval tmp-cbfs-file:=$(shell mkdir -p $(obj)/mainboard/$(MAINBOARDDIR); mktemp $(obj)/mainboard/$(MAINBOARDDIR)/cbfs-file.XXXXXX).out) \
193 $(call cbfs-files-processor-$(tmp-cbfs-method),$(tmp-old-cbfs-file),$(tmp-cbfs-file))) \
194 $(eval cbfs-files += $(tmp-cbfs-file)|$(2)|$($(2)-type)|$($(2)-compression)|$($(2)-position)) \
195 $(eval $(2)-name:=) \
196 $(eval $(2)-type:=) \
197 $(eval $(2)-compression:=) \
198 $(eval $(2)-position:=) \
199 $(eval $(2)-required:=)
201 #######################################################################
202 # a variety of flags for our build
203 CBFS_COMPRESS_FLAG:=none
204 ifeq ($(CONFIG_COMPRESS_RAMSTAGE),y)
205 CBFS_COMPRESS_FLAG:=LZMA
208 CBFS_PAYLOAD_COMPRESS_FLAG:=none
209 ifeq ($(CONFIG_COMPRESSED_PAYLOAD_LZMA),y)
210 CBFS_PAYLOAD_COMPRESS_FLAG:=LZMA
213 ifneq ($(CONFIG_LOCALVERSION),"")
214 COREBOOT_EXTRA_VERSION := -$(call strip_quotes,$(CONFIG_LOCALVERSION))
217 CPPFLAGS_common := -Isrc -Isrc/include -I$(obj)
218 CPPFLAGS_common += -Isrc/device/oprom/include
219 CPPFLAGS_common += -include $(src)/include/kconfig.h
221 CFLAGS_common += -pipe -g -nostdinc
222 CFLAGS_common += -nostdlib -Wall -Wundef -Wstrict-prototypes -Wmissing-prototypes
223 CFLAGS_common += -Wwrite-strings -Wredundant-decls -Wno-trigraphs
224 CFLAGS_common += -Wstrict-aliasing -Wshadow
225 ifeq ($(CONFIG_WARNINGS_ARE_ERRORS),y)
226 CFLAGS_common += -Werror
228 CFLAGS_common += -fno-common -ffreestanding -fno-builtin -fomit-frame-pointer
229 ifneq ($(GDB_DEBUG),)
236 additional-dirs := $(objutil)/cbfstool $(objutil)/romcc $(objutil)/ifdtool \
237 $(objutil)/ifdfake $(objutil)/options $(objutil)/fletcher \
238 $(objutil)/cbootimage
240 #######################################################################
241 # generate build support files
242 $(obj)/build.h: .xcompile
243 @printf " GEN build.h\n"
245 printf "/* build system definitions (autogenerated) */\n" > $(obj)/build.ht
246 printf "#ifndef __BUILD_H\n" >> $(obj)/build.ht
247 printf "#define __BUILD_H\n\n" >> $(obj)/build.ht
248 printf "#define COREBOOT_VERSION \"$(KERNELVERSION)\"\n" >> $(obj)/build.ht
249 printf "#define COREBOOT_EXTRA_VERSION \"$(COREBOOT_EXTRA_VERSION)\"\n" >> $(obj)/build.ht
250 printf "#define COREBOOT_BUILD \"`LANG= date`\"\n" >> $(obj)/build.ht
251 printf "#define COREBOOT_BUILD_YEAR_BCD 0x`LANG= date +"%y"`\n" >> $(obj)/build.ht
252 printf "#define COREBOOT_BUILD_MONTH_BCD 0x`LANG= date +"%m"`\n" >> $(obj)/build.ht
253 printf "#define COREBOOT_BUILD_DAY_BCD 0x`LANG= date +"%d"`\n" >> $(obj)/build.ht
254 printf "#define COREBOOT_BUILD_WEEKDAY_BCD 0x`LANG= date +"%w"`\n" >> $(obj)/build.ht
255 printf "#define COREBOOT_DMI_DATE \"`LANG= date +"%m/%d/%Y"`\"\n" >> $(obj)/build.ht
256 printf "\n" >> $(obj)/build.ht
257 printf "#define COREBOOT_COMPILE_TIME \"`LANG= date +%T`\"\n" >> $(obj)/build.ht
258 printf "#define COREBOOT_COMPILE_BY \"$(subst \,@,$(shell PATH=$$PATH:/usr/ucb whoami))\"\n" >> $(obj)/build.ht
259 printf "#define COREBOOT_COMPILE_HOST \"$(shell hostname -s 2>/dev/null || hostname 2>/dev/null)\"\n" >> $(obj)/build.ht
260 printf "#define COREBOOT_COMPILE_DOMAIN \"$(shell test `uname -s` = "Linux" && dnsdomainname || domainname 2>/dev/null)\"\n" >> $(obj)/build.ht
261 printf "#endif\n" >> $(obj)/build.ht
262 mv $(obj)/build.ht $(obj)/build.h
264 $(obj)/ldoptions: $(obj)/config.h
265 awk '/^#define ([^"])* ([^"])*$$/ {gsub("\\r","",$$3); print $$2 " = " $$3 ";";}' $< > $@
268 mkdir -p $(objcbfs) $(objgenerated)
270 #######################################################################
272 CBFSTOOL:=$(objutil)/cbfstool/cbfstool
273 RMODTOOL:=$(objutil)/cbfstool/rmodtool
275 $(obj)/cbfstool: $(CBFSTOOL)
278 $(obj)/rmodtool: $(RMODTOOL)
281 _WINCHECK=$(shell uname -o 2> /dev/null)
283 ifeq ($(_WINCHECK),Msys)
284 STACK=-Wl,--stack,16384000
286 ifeq ($(_WINCHECK),Cygwin)
287 STACK=-Wl,--stack,16384000
290 # this allows ccache to prepend itself
291 # (ccache handling happens first)
292 ROMCC_BIN= $(objutil)/romcc/romcc
294 $(ROMCC_BIN): $(top)/util/romcc/romcc.c
295 @printf " HOSTCC $(subst $(obj)/,,$(@)) (this may take a while)\n"
296 @# Note: Adding -O2 here might cause problems. For details see:
297 @# http://www.coreboot.org/pipermail/coreboot/2010-February/055825.html
298 $(HOSTCC) -g $(STACK) -Wall -o $@ $<
300 IFDTOOL:=$(objutil)/ifdtool/ifdtool
301 $(IFDTOOL): $(top)/util/ifdtool/ifdtool.c
302 @printf " HOSTCC $(subst $(obj)/,,$(@))\n"
303 $(HOSTCC) $(HOSTCFLAGS) -o $@ $<
305 IFDFAKE:=$(objutil)/ifdfake/ifdfake
306 $(IFDFAKE): $(top)/util/ifdfake/ifdfake.c
307 @printf " HOSTCC $(subst $(obj)/,,$(@))\n"
308 $(HOSTCC) $(HOSTCFLAGS) -o $@ $<
310 FLETCHER:=$(objutil)/fletcher/fletcher
311 $(FLETCHER): $(top)/util/fletcher/fletcher.c
312 @printf " HOSTCC $(subst $(obj)/,,$(@))\n"
313 $(HOSTCC) $(HOSTCFLAGS) -o $@ $<
315 CBOOTIMAGE:=$(objutil)/cbootimage/cbootimage
317 subdirs-y += util/nvidia
319 #######################################################################
320 # needed objects that every mainboard uses
321 # Creation of these is architecture and mainboard independent
322 $(obj)/mainboard/$(MAINBOARDDIR)/static.c: $(src)/mainboard/$(MAINBOARDDIR)/devicetree.cb $(objutil)/sconfig/sconfig
323 @printf " SCONFIG $(subst $(src)/,,$(<))\n"
324 mkdir -p $(obj)/mainboard/$(MAINBOARDDIR)
325 $(objutil)/sconfig/sconfig $(MAINBOARDDIR) $(obj)/mainboard/$(MAINBOARDDIR)
327 ramstage-y+=$(obj)/mainboard/$(MAINBOARDDIR)/static.c
328 romstage-y+=$(obj)/mainboard/$(MAINBOARDDIR)/static.c
330 $(objutil)/%.o: $(objutil)/%.c
331 @printf " HOSTCC $(subst $(objutil)/,,$(@))\n"
332 $(HOSTCC) -MMD -I$(subst $(objutil)/,util/,$(dir $<)) -I$(dir $<) $(HOSTCFLAGS) -c -o $@ $<
334 $(obj)/%.ramstage.o $(abspath $(obj))/%.ramstage.o: $(obj)/%.c $(obj)/config.h $(OPTION_TABLE_H)
335 @printf " CC $(subst $(obj)/,,$(@))\n"
336 $(CC_ramstage) -MMD $(CFLAGS_ramstage) $(CPPFLAGS_ramstage) -c -o $@ $<
338 $(obj)/%.romstage.o $(abspath $(obj))/%.romstage.o: $(obj)/%.c $(obj)/config.h $(OPTION_TABLE_H)
339 @printf " CC $(subst $(obj)/,,$(@))\n"
340 $(CC_romstage) -MMD -D__PRE_RAM__ $(CFLAGS_romstage) $(CPPFLAGS_romstage) -c -o $@ $<
342 $(obj)/%.bootblock.o $(abspath $(obj))/%.bootblock.o: $(obj)/%.c $(obj)/config.h $(OPTION_TABLE_H)
343 @printf " CC $(subst $(obj)/,,$(@))\n"
344 $(CC_bootblock) -MMD $(CFLAGS_bootblock) $(CPPFLAGS_bootblock) -c -o $@ $<
346 #######################################################################
349 rm -rf coreboot-builds
351 clean-for-update-target:
352 rm -f $(obj)/ramstage* $(obj)/coreboot.romstage $(obj)/coreboot.pre* $(obj)/coreboot.bootblock $(obj)/coreboot.a
353 rm -rf $(obj)/bootblock* $(obj)/romstage* $(obj)/location.*
354 rm -f $(obj)/option_table.* $(obj)/crt0.S $(obj)/ldscript
355 rm -f $(obj)/mainboard/$(MAINBOARDDIR)/static.c $(obj)/mainboard/$(MAINBOARDDIR)/config.py $(obj)/mainboard/$(MAINBOARDDIR)/static.dot
356 rm -f $(obj)/mainboard/$(MAINBOARDDIR)/crt0.s $(obj)/mainboard/$(MAINBOARDDIR)/crt0.disasm
357 rm -f $(obj)/mainboard/$(MAINBOARDDIR)/romstage.inc
358 rm -f $(obj)/mainboard/$(MAINBOARDDIR)/bootblock.* $(obj)/mainboard/$(MAINBOARDDIR)/dsdt.*
359 rm -f $(obj)/cpu/x86/smm/smm_bin.c $(obj)/cpu/x86/smm/smm.* $(obj)/cpu/x86/smm/smm
360 $(MAKE) -C payloads/external/SeaBIOS -f Makefile.inc clean OUT=$(abspath $(obj)) HOSTCC="$(HOSTCC)" CC="$(CC_x86_32)" LD="$(LD_x86_32)"
363 rm -f $(obj)/coreboot*
365 #######################################################################
366 # Development utilities
369 @echo ldscripts=$(ldscripts)
372 dongle.py -c /dev/term/1 $(obj)/coreboot.rom EOF
375 FAILED=0; LINTLOG=`mktemp .tmpconfig.lintXXXXX`; \
376 for script in util/lint/$@-*; do \
377 echo; echo `basename $$script`; \
378 grep "^# DESCR:" $$script | sed "s,.*DESCR: *,," ; \
380 $$script > $$LINTLOG; \
381 if [ `cat $$LINTLOG | wc -l` -eq 0 ]; then \
382 printf "success\n\n"; \
384 echo test failed: ; \
387 FAILED=$$(( $$FAILED + 1 )); \
391 test $$FAILED -eq 0 || { echo "ERROR: $$FAILED test(s) failed."; rm -f $$LINTLOG && exit 1; }; \
396 for hook in commit-msg pre-commit ; do \
397 if [ util/gitconfig/$$hook -nt .git/hooks/$$hook -o \
398 ! -x .git/hooks/$$hook ]; then \
399 cp util/gitconfig/$$hook .git/hooks/$$hook; \
400 chmod +x .git/hooks/$$hook; \
403 git config remote.origin.push HEAD:refs/for/master
404 (git config --global user.name >/dev/null && git config --global user.email >/dev/null) || (printf 'Please configure your name and email in git:\n\n git config --global user.name "Your Name Comes Here"\n git config --global user.email your.email@example.com\n'; exit 1)
406 crossgcc: crossgcc-i386 crossgcc-arm
408 .PHONY: crossgcc-i386 crossgcc-arm
409 crossgcc-i386: clean-for-update
410 $(MAKE) -C util/crossgcc build-i386-without-gdb
412 crossgcc-arm: clean-for-update
413 $(MAKE) -C util/crossgcc build-armv7a-without-gdb
415 crosstools: crosstools-i386
417 .PHONY: crosstools-i386 crosstools-arm
418 crosstools-i386: clean-for-update
419 $(MAKE) -C util/crossgcc build-i386
421 crosstools-arm: clean-for-update
422 $(MAKE) -C util/crossgcc build-armv7a
424 crossgcc-clean: clean-for-update
425 $(MAKE) -C util/crossgcc clean
427 tools: $(objutil)/kconfig/conf $(objutil)/cbfstool/cbfstool $(objutil)/cbfstool/rmodtool $(objutil)/nvramtool/nvramtool $(ROMCC_BIN) $(objutil)/sconfig/sconfig $(IFDTOOL) $(IFDFAKE) $(CBOOTIMAGE)
429 ###########################################################################
430 # Common recipes for all stages
431 ###########################################################################
433 # find-substr is required for stages like romstage_null and romstage_xip to
434 # eliminate the _* part of the string
435 find-substr = $(word 1,$(subst _, ,$(1)))
437 # find-class is used to identify the class from the name of the stage
438 # The input to this macro can be something like romstage.x or romstage.x.y
439 # find-class recursively strips off the suffixes to extract the exact class name
440 # e.g.: if romstage.x is provided to find-class, it will remove .x and return romstage
441 # if romstage.x.y is provided, it will first remove .y, call find-class with romstage.x
442 # and remove .x the next time and finally return romstage
443 find-class = $(if $(filter $(1),$(basename $(1))),$(if $(CC_$(1)), $(1), $(call find-substr,$(1))),$(call find-class,$(basename $(1))))
445 $(objcbfs)/%.bin: $(objcbfs)/%.elf
446 $(eval class := $(call find-class,$(@F)))
447 @printf " OBJCOPY $(subst $(obj)/,,$(@))\n"
448 $(OBJCOPY_$(class)) -O binary $< $@
450 $(objcbfs)/%.elf: $(objcbfs)/%.debug
451 $(eval class := $(call find-class,$(@F)))
452 @printf " OBJCOPY $(subst $(obj)/,,$(@))\n"
454 $(NM_$(class)) -n $@.tmp | sort > $(basename $@).map
455 $(OBJCOPY_$(class)) --strip-debug $@.tmp
456 $(OBJCOPY_$(class)) --add-gnu-debuglink=$< $@.tmp
459 ###########################################################################
460 # Build the final rom image
461 ###########################################################################
463 COREBOOT_ROM_DEPENDENCIES:=
464 ifeq ($(CONFIG_PAYLOAD_ELF),y)
465 COREBOOT_ROM_DEPENDENCIES+=$(CONFIG_PAYLOAD_FILE)
467 ifeq ($(CONFIG_PAYLOAD_SEABIOS),y)
468 COREBOOT_ROM_DEPENDENCIES+=seabios
470 ifeq ($(CONFIG_PAYLOAD_FILO),y)
471 COREBOOT_ROM_DEPENDENCIES+=filo
473 ifeq ($(CONFIG_PAYLOAD_GRUB2),y)
474 COREBOOT_ROM_DEPENDENCIES+=grub2
477 extract_nth=$(word $(1), $(subst |, ,$(2)))
479 ifneq ($(CONFIG_UPDATE_IMAGE),y)
481 $(foreach file,$(cbfs-files), \
483 add$(if $(filter stage,$(call extract_nth,3,$(file))),-stage)$(if $(filter payload,$(call extract_nth,3,$(file))),-payload) \
484 -f $(call extract_nth,1,$(file)) \
485 -n $(call extract_nth,2,$(file)) $(if $(filter-out stage,$(call extract_nth,3,$(file))),-t $(call extract_nth,3,$(file))) \
486 $(if $(call extract_nth,4,$(file)),-b $(call extract_nth,4,$(file))) &&)
487 prebuilt-files = $(foreach file,$(cbfs-files), $(call extract_nth,1,$(file)))
489 $(obj)/coreboot.pre1: $(objcbfs)/bootblock.bin $$(prebuilt-files) $(CBFSTOOL) $$(cpu_ucode_cbfs_file)
490 $(CBFSTOOL) $@.tmp create -s $(CONFIG_COREBOOT_ROMSIZE_KB)K \
491 -B $(objcbfs)/bootblock.bin -a 64 \
492 $(CBFSTOOL_PRE1_OPTS)
493 $(prebuild-files) true
494 $(call add-cpu-microcode-to-cbfs,$@.tmp)
497 .PHONY: $(obj)/coreboot.pre1
498 $(obj)/coreboot.pre1: $(CBFSTOOL)
499 mv $(obj)/coreboot.rom $@
502 ifeq ($(CONFIG_PAYLOAD_LINUX),y)
503 ifneq ($(strip $(call strip_quotes,$(CONFIG_LINUX_COMMAND_LINE))),)
504 ADDITIONAL_PAYLOAD_CONFIG+=-C $(CONFIG_LINUX_COMMAND_LINE)
506 ifneq ($(strip $(call strip_quotes,$(CONFIG_LINUX_INITRD))),)
507 ADDITIONAL_PAYLOAD_CONFIG+=-I $(CONFIG_LINUX_INITRD)
511 ifeq ($(CONFIG_HAVE_REFCODE_BLOB),y)
512 REFCODE_BLOB=$(obj)/refcode.rmod
513 $(REFCODE_BLOB): $(RMODTOOL)
514 $(RMODTOOL) -i $(CONFIG_REFCODE_BLOB_FILE) -o $@
517 $(obj)/coreboot.rom: $(obj)/coreboot.pre $(objcbfs)/ramstage.elf $(CBFSTOOL) $(call strip_quotes,$(COREBOOT_ROM_DEPENDENCIES)) $$(INTERMEDIATE) $$(VBOOT_STUB) $(REFCODE_BLOB)
518 @printf " CBFS $(subst $(obj)/,,$(@))\n"
519 cp $(obj)/coreboot.pre $@.tmp
520 $(CBFSTOOL) $@.tmp add-stage -f $(objcbfs)/ramstage.elf -n $(CONFIG_CBFS_PREFIX)/ramstage -c $(CBFS_COMPRESS_FLAG)
521 ifeq ($(CONFIG_PAYLOAD_NONE),y)
522 @printf " PAYLOAD none (as specified by user)\n"
524 ifneq ($(CONFIG_PAYLOAD_FILE),)
525 @printf " PAYLOAD $(CONFIG_PAYLOAD_FILE) (compression: $(CBFS_PAYLOAD_COMPRESS_FLAG))\n"
526 $(CBFSTOOL) $@.tmp add-payload -f $(CONFIG_PAYLOAD_FILE) -n $(CONFIG_CBFS_PREFIX)/payload -c $(CBFS_PAYLOAD_COMPRESS_FLAG) $(ADDITIONAL_PAYLOAD_CONFIG)
528 ifneq ($(CONFIG_SEABIOS_PS2_TIMEOUT),)
529 ifneq ($(CONFIG_SEABIOS_PS2_TIMEOUT),0)
530 @printf " SeaBIOS Wait up to $(CONFIG_SEABIOS_PS2_TIMEOUT) ms for PS/2 keyboard controller initialization\n"
531 $(CBFSTOOL) $@.tmp add-int -i $(CONFIG_SEABIOS_PS2_TIMEOUT) -n etc/ps2-keyboard-spinup
534 ifeq ($(CONFIG_SEABIOS_VGA_COREBOOT),y)
535 @printf " SeaBIOS Adding generated legacy VGA option rom.\n"
536 $(CBFSTOOL) $@.tmp add -f $(CONFIG_PAYLOAD_VGABIOS_FILE) -n vgaroms/seavgabios.bin -t raw
538 ifeq ($(CONFIG_INCLUDE_CONFIG_FILE),y)
539 @printf " CONFIG $(DOTCONFIG)\n"
540 if [ -f $(DOTCONFIG) ]; then \
541 echo "# This image was built using git revision" `git rev-parse HEAD` > $(obj)/config.tmp ; \
542 sed -e '/^#/d' -e '/^ *$$/d' $(DOTCONFIG) >> $(obj)/config.tmp ; \
543 $(CBFSTOOL) $@.tmp add -f $(obj)/config.tmp -n config -t raw; rm -f $(obj)/config.tmp ; fi
545 ifeq ($(CONFIG_VBOOT_VERIFY_FIRMWARE),y)
546 $(CBFSTOOL) $@.tmp add-stage -f $(VBOOT_STUB) -n $(CONFIG_CBFS_PREFIX)/vboot -c $(CBFS_COMPRESS_FLAG)
548 ifeq ($(CONFIG_HAVE_REFCODE_BLOB),y)
549 $(CBFSTOOL) $@.tmp add-stage -f $(REFCODE_BLOB) -n $(CONFIG_CBFS_PREFIX)/refcode -c $(CBFS_COMPRESS_FLAG)
551 ifeq ($(CONFIG_PXE_ROM),y)
552 $(CBFSTOOL) $@.tmp add -f $(CONFIG_PXE_ROM_FILE) -n pci$(CONFIG_PXE_ROM_ID).rom -t raw
554 ifeq ($(CONFIG_CPU_INTEL_FIRMWARE_INTERFACE_TABLE),y)
555 ifeq ($(CONFIG_CPU_MICROCODE_IN_CBFS),y)
556 @printf " UPDATE-FIT \n"
557 $(CBFSTOOL) $@.tmp update-fit -n cpu_microcode_blob.bin -x $(CONFIG_CPU_INTEL_NUM_FIT_ENTRIES)
561 @printf " CBFSPRINT $(subst $(obj)/,,$(@))\n\n"
564 cbfs-files-$(CONFIG_BOOTSPLASH) += bootsplash.jpg
565 bootsplash.jpg-file := $(call strip_quotes,$(CONFIG_BOOTSPLASH_FILE))
566 bootsplash.jpg-type := bootsplash
568 ifeq ($(CONFIG_ARCH_ROMSTAGE_ARM),y)
569 ROMSTAGE_ELF := romstage.elf
571 ifeq ($(CONFIG_ARCH_ROMSTAGE_ARM64),y)
572 ROMSTAGE_ELF := romstage.elf
574 ifeq ($(CONFIG_ARCH_ROMSTAGE_X86_32),y)
575 ROMSTAGE_ELF := romstage_xip.elf
578 $(obj)/coreboot.pre: $(objcbfs)/$(ROMSTAGE_ELF) $(obj)/coreboot.pre1 $(CBFSTOOL)
579 @printf " CBFS $(subst $(obj)/,,$(@))\n"
580 cp $(obj)/coreboot.pre1 $@.tmp
581 $(CBFSTOOL) $@.tmp add-stage \
582 -f $(objcbfs)/$(ROMSTAGE_ELF) \
583 -n $(CONFIG_CBFS_PREFIX)/romstage -c none \
589 util/abuild/abuild -B -J -y -c 4 -z -p $(JENKINS_PAYLOAD)
590 (cd payloads/libpayload; $(MAKE) CONFIG_CCACHE=y V=$(V) Q=$(Q) junit.xml)
591 $(MAKE) V=$(V) Q=$(Q) -C util/cbmem junit.xml