2018-02-05 11:27:45 -05:00
|
|
|
modules-$(CONFIG_LINUXBOOT) += linuxboot
|
|
|
|
|
|
|
|
linuxboot_version := git
|
2018-08-13 06:31:07 -04:00
|
|
|
linuxboot_repo := https://github.com/osresearch/linuxboot
|
2018-05-02 14:53:54 -04:00
|
|
|
linuxboot_base_dir := linuxboot-$(linuxboot_version)
|
2018-02-05 11:27:45 -05:00
|
|
|
|
|
|
|
# linuxboot builds are specialized on a per-target basis.
|
2018-02-05 15:59:26 -05:00
|
|
|
# They can be specialized by defining $(CONFIG_LINUXBOOT_BOARD)
|
2018-02-05 11:27:45 -05:00
|
|
|
# otherwise it is assumed that it will have the same name
|
|
|
|
# as the Heads BOARD.
|
2018-02-05 15:59:26 -05:00
|
|
|
linuxboot_board := $(or $(CONFIG_LINUXBOOT_BOARD),$(BOARD))
|
2018-05-02 14:53:54 -04:00
|
|
|
linuxboot_dir := linuxboot-$(linuxboot_version)/build/$(linuxboot_board)
|
2018-03-14 20:31:47 -04:00
|
|
|
|
|
|
|
linuxboot_configure := \
|
2018-03-15 11:49:02 -04:00
|
|
|
echo >&2 "Pre-building edk2" ; \
|
|
|
|
$(MAKE) \
|
2018-05-02 14:53:54 -04:00
|
|
|
-C $(build)/$(linuxboot_base_dir) \
|
2018-03-15 11:49:02 -04:00
|
|
|
BOARD=$(linuxboot_board) \
|
|
|
|
edk2.force \
|
|
|
|
|| exit 1 ; \
|
2018-03-14 20:31:47 -04:00
|
|
|
if [ "$(linuxboot_board)" = "qemu" ]; then \
|
|
|
|
echo >&2 "Pre-building edk2 OVMF" ; \
|
2018-05-02 15:46:30 -04:00
|
|
|
( cd $(build)/$(linuxboot_base_dir)/edk2/OvmfPkg ; \
|
|
|
|
./build.sh -n `nproc` \
|
|
|
|
) || exit 1 ; \
|
2018-03-15 11:49:02 -04:00
|
|
|
fi ; \
|
|
|
|
touch .config ; \
|
2018-03-14 20:31:47 -04:00
|
|
|
|
2018-04-29 19:58:44 -07:00
|
|
|
ifdef CUSTOM
|
|
|
|
CUSTOMPWD=$(pwd)/$(CUSTOM)
|
|
|
|
endif
|
|
|
|
|
2018-02-05 11:27:45 -05:00
|
|
|
linuxboot_target := \
|
2018-05-02 14:53:54 -04:00
|
|
|
-C $(build)/$(linuxboot_base_dir) \
|
2018-02-08 16:02:29 -05:00
|
|
|
BOARD=$(linuxboot_board) \
|
2018-02-05 11:27:45 -05:00
|
|
|
KERNEL=$(build)/$(BOARD)/bzImage \
|
|
|
|
INITRD=$(build)/$(BOARD)/initrd.cpio.xz \
|
2018-04-29 19:58:44 -07:00
|
|
|
CUSTOM=$(CUSTOMPWD) \
|
2018-08-09 12:20:03 -04:00
|
|
|
CROSS=$(CROSS) \
|
2018-02-08 16:02:29 -05:00
|
|
|
$(if $(CONFIG_LINUXBOOT_ROM), ROM=$(pwd)/$(CONFIG_LINUXBOOT_ROM)) \
|
2018-02-05 11:27:45 -05:00
|
|
|
all
|
|
|
|
|
|
|
|
#
|
|
|
|
# Most mainboards will define a ROM file that contains the vendor ROM
|
2018-02-08 15:21:38 -05:00
|
|
|
# for the image. Provide a reasonable error if the ROM file doesn't exist.
|
2018-02-05 11:27:45 -05:00
|
|
|
#
|
|
|
|
ifneq "$(CONFIG_LINUXBOOT_ROM)" ""
|
|
|
|
ifneq "y" "$(shell [ -r '$(CONFIG_LINUXBOOT_ROM)' ] && echo y)"
|
|
|
|
$(error $(CONFIG_LINUXBOOT_ROM): you must provide a ROM file)
|
|
|
|
endif
|
|
|
|
|
|
|
|
endif
|
|
|
|
|
2018-05-02 11:38:39 -04:00
|
|
|
|
2018-02-05 11:27:45 -05:00
|
|
|
# The output file from the LinuxBoot build is a full ROM
|
|
|
|
# ready to flash onto the mainboard. There might be partial
|
|
|
|
# firmware volumes as well, but that depends on the board
|
|
|
|
# so this only retrieves the final one
|
2018-05-02 11:38:39 -04:00
|
|
|
linuxboot_output := build/$(linuxboot_board)/linuxboot.rom
|
|
|
|
linuxboot_rom := $(build)/$(linuxboot_dir)/$(linuxboot_output)
|
2018-02-05 11:27:45 -05:00
|
|
|
|
2018-05-02 14:53:54 -04:00
|
|
|
$(build)/$(BOARD)/linuxboot.rom: $(build)/$(linuxboot_dir)/.build
|
|
|
|
$(call do-copy,$(dir $<)linuxboot.rom,$@)
|
|
|
|
@touch $@
|
2018-02-05 11:27:45 -05:00
|
|
|
|
2018-05-02 11:38:39 -04:00
|
|
|
# Also force a rebuild if any of the input files are updated
|
|
|
|
$(build)/$(linuxboot_dir)/.build: \
|
|
|
|
$(CONFIG_LINUXBOOT_ROM) \
|
|
|
|
$(build)/$(BOARD)/bzImage \
|
|
|
|
$(build)/$(BOARD)/initrd.cpio.xz \
|
2018-02-05 17:27:12 -05:00
|
|
|
|
|
|
|
|
|
|
|
linuxboot.run: $(build)/$(BOARD)/linuxboot.rom
|
2018-05-02 14:53:54 -04:00
|
|
|
$(MAKE) -C $(build)/$(linuxboot_base_dir) \
|
2018-02-05 17:27:12 -05:00
|
|
|
BOARD:=$(linuxboot_board) \
|
|
|
|
KERNEL=$(build)/$(BOARD)/bzImage \
|
|
|
|
INITRD=$(build)/$(BOARD)/initrd.cpio.xz \
|
2018-04-29 19:58:44 -07:00
|
|
|
CUSTOM=$(CUSTOMPWD) \
|
2018-02-05 17:27:12 -05:00
|
|
|
run
|