2016-08-02 23:25:47 +00:00
|
|
|
#
|
2018-01-25 23:23:51 +00:00
|
|
|
# Builds the LinuxBoot firmware image.
|
2016-08-02 23:25:47 +00:00
|
|
|
#
|
2018-01-25 23:23:51 +00:00
|
|
|
# This requires the vendor firmware image, a Linux kernel and an initrd.cpio.xz file.
|
2016-08-02 23:25:47 +00:00
|
|
|
#
|
2018-01-25 23:23:51 +00:00
|
|
|
#
|
2018-01-26 22:08:20 +00:00
|
|
|
all: linuxboot
|
2016-08-02 23:25:47 +00:00
|
|
|
|
2018-01-25 23:23:51 +00:00
|
|
|
-include .config
|
|
|
|
include Makefile.rules
|
2018-01-27 20:59:56 +00:00
|
|
|
include Makefile.uefi
|
2016-08-03 01:23:18 +00:00
|
|
|
|
2018-01-25 23:23:51 +00:00
|
|
|
# The config file should set the BOARD variable
|
2018-01-26 16:08:04 +00:00
|
|
|
# as well as point to the bzImage and initrd.cpio files
|
2018-01-25 23:23:51 +00:00
|
|
|
BOARD ?= qemu
|
2018-01-26 16:08:04 +00:00
|
|
|
KERNEL ?= bzImage
|
|
|
|
INITRD ?= initrd.cpio.xz
|
2018-01-26 22:08:20 +00:00
|
|
|
BUILD := build/$(BOARD)
|
2018-01-27 03:05:46 +00:00
|
|
|
|
|
|
|
# Make sure that we have a board file for the user
|
|
|
|
$(shell \
|
|
|
|
if [ ! -r boards/$(BOARD)/Makefile.board ]; then \
|
|
|
|
echo >&2 "BOARD=$(BOARD) is not valid."; \
|
|
|
|
echo >&2 ; \
|
|
|
|
echo >&2 "Supported mainboards:"; \
|
|
|
|
ls boards/*/Makefile.board | cut -d/ -f2 >&2 ; \
|
|
|
|
echo >&2 ; \
|
|
|
|
exit 1 ; \
|
|
|
|
fi; \
|
|
|
|
mkdir -p $(BUILD) ; \
|
|
|
|
)
|
2016-08-03 01:23:18 +00:00
|
|
|
|
2018-01-25 23:23:51 +00:00
|
|
|
# Bring in the board specific things
|
|
|
|
include boards/$(BOARD)/Makefile.board
|
2016-08-03 01:23:18 +00:00
|
|
|
|
2018-01-26 22:08:20 +00:00
|
|
|
linuxboot: $(BUILD)/linuxboot.rom
|
|
|
|
|
2018-01-26 16:08:04 +00:00
|
|
|
# Create a .config file based on the current parameters
|
|
|
|
config:
|
|
|
|
echo '# Generated $(DATE)' > .config
|
|
|
|
echo 'BOARD ?= $(BOARD)' >> .config
|
|
|
|
echo 'KERNEL ?= $(KERNEL)' >> .config
|
|
|
|
echo 'INITRD ?= $(INITRD)' >> .config
|
|
|
|
|
2016-08-03 01:23:18 +00:00
|
|
|
|
2018-01-25 23:23:51 +00:00
|
|
|
# edk2 outputs will be in this deeply nested directory
|
|
|
|
EDK2_OUTPUT_DIR := edk2/Build/MdeModule/DEBUG_GCC5/X64
|
2016-08-03 01:23:18 +00:00
|
|
|
|
2018-01-25 23:23:51 +00:00
|
|
|
vendor:
|
2016-11-29 16:19:48 +00:00
|
|
|
|
2018-01-25 23:23:51 +00:00
|
|
|
$(EDK2_OUTPUT_DIR)/DxeCore.efi: edk2/.git
|
|
|
|
$(MAKE) -C edk2
|
2016-12-13 18:10:21 +00:00
|
|
|
|
2016-08-03 01:23:18 +00:00
|
|
|
|
2018-01-25 23:23:51 +00:00
|
|
|
edk2.force: edk2/.git
|
|
|
|
$(MAKE) -C edk2 build
|
2017-09-22 19:09:57 +00:00
|
|
|
|
2018-01-25 23:23:51 +00:00
|
|
|
# If the edk2 directory doesn't exist, checkout a shallow branch of it
|
|
|
|
# and build the various Dxe/Smm files
|
|
|
|
edk2/.git:
|
|
|
|
git clone --depth 1 --branch UDK2018 https://github.com/linuxboot/edk2
|
2016-08-03 01:59:14 +00:00
|
|
|
|
2017-03-29 19:15:03 +00:00
|
|
|
|
2018-01-26 22:08:20 +00:00
|
|
|
$(BUILD)/Linux.ffs: $(KERNEL)
|
|
|
|
$(BUILD)/Initrd.ffs: $(INITRD)
|
2017-04-08 21:46:54 +00:00
|
|
|
|
2017-01-27 21:17:03 +00:00
|
|
|
|
2018-01-26 22:08:20 +00:00
|
|
|
$(BUILD)/%.ffs: $(EDK2_OUTPUT_DIR)/%.efi
|
2018-01-25 23:23:51 +00:00
|
|
|
$(create-ffs)
|
2018-01-26 22:08:20 +00:00
|
|
|
$(BUILD)/%.ffs:
|
2018-01-25 23:23:51 +00:00
|
|
|
$(create-ffs)
|
2017-02-28 23:02:10 +00:00
|
|
|
|
2018-01-26 22:08:20 +00:00
|
|
|
$(BUILD)/%.rom:
|
|
|
|
cat > $@.tmp $^
|
|
|
|
@if [ `stat -c'%s' $@.tmp` -ne $$[$($(basename $(notdir $@))-size)] ]; then \
|
|
|
|
echo >&2 "$@: Wrong output size"; \
|
|
|
|
exit 1; \
|
|
|
|
fi
|
|
|
|
@mv $@.tmp $@
|
2017-02-28 23:02:10 +00:00
|
|
|
|
2018-01-26 22:08:20 +00:00
|
|
|
$(BUILD)/%.vol:
|
2018-01-25 23:23:51 +00:00
|
|
|
./bin/create-fv \
|
|
|
|
-o $@ \
|
2018-01-26 22:08:20 +00:00
|
|
|
--size $(or $($(basename $(notdir $@))-size),0x400000) \
|
|
|
|
--compress $(or $($(basename $(notdir $@))-compress),0) \
|
2018-01-25 23:23:51 +00:00
|
|
|
$^
|
2017-01-27 21:17:03 +00:00
|
|
|
|
2018-01-25 23:23:51 +00:00
|
|
|
create-ffs = \
|
|
|
|
./bin/create-ffs \
|
|
|
|
-o $@ \
|
2018-01-26 22:08:20 +00:00
|
|
|
--name $(basename $(notdir $@)) \
|
2018-01-25 23:23:51 +00:00
|
|
|
--version 1.0 \
|
2018-01-26 22:08:20 +00:00
|
|
|
--type $(or $($(basename $(notdir $@))-type),DRIVER) \
|
|
|
|
--depex "$($(basename $(notdir $@))-depex)" \
|
|
|
|
--guid "$($(basename $(notdir $@))-guid)" \
|
2018-01-25 23:23:51 +00:00
|
|
|
$^
|
2018-01-26 22:08:20 +00:00
|
|
|
|
2018-01-27 03:05:46 +00:00
|
|
|
#
|
|
|
|
# Extract all of the firmware files from the vendor provided ROM
|
|
|
|
#
|
|
|
|
extract.intermediate: boards/$(BOARD)/$(BOARD).rom
|
|
|
|
( \
|
|
|
|
cd $(BUILD) ; \
|
|
|
|
$(pwd)/bin/extract-firmware \
|
|
|
|
-o rom \
|
|
|
|
) < $^ \
|
|
|
|
| tee $(BUILD)/$(BOARD).txt ; \
|
|
|
|
|
|
|
|
.INTERMEDIATE: extract.intermediate
|
|
|
|
|
|
|
|
# All of the output volumes depend on extracting the firmware
|
|
|
|
$(patsubst %.vol,,$(FVS)): extract.intermediate
|
|
|
|
|
|
|
|
$(BUILD)/linuxboot.rom: $(FVS)
|
|
|
|
|
2018-01-26 22:08:20 +00:00
|
|
|
|
|
|
|
clean:
|
|
|
|
$(RM) $(BUILD)/{*.ffs,*.rom,*.vol,*.tmp}
|