forked from linuxboot/linuxboot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
153 lines (125 loc) · 3.48 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
#
# Builds the LinuxBoot firmware image.
#
# This requires the vendor firmware image, a Linux kernel and an initrd.cpio.xz file.
#
#
all: linuxboot
-include .config
include Makefile.rules
include Makefile.uefi
# The config file should set the BOARD variable
# as well as point to the bzImage and initrd.cpio files
BOARD ?= qemu
KERNEL ?= bzImage
INITRD ?= initrd.cpio.xz
BUILD := build/$(BOARD)
# 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) ; \
)
# Bring in the board specific things
include boards/$(BOARD)/Makefile.board
# If they don't define a vendor ROM file
ROM ?= boards/$(BOARD)/$(BOARD).rom
ifdef USE_UTK
include Makefile.utk
endif
linuxboot: $(BUILD)/linuxboot.rom
# 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
echo 'ROM ?= $(ROM)' >> .config
# edk2 outputs will be in this deeply nested directory
EDK2_OUTPUT_DIR := edk2/Build/MdeModule/DEBUG_GCC5/X64
vendor:
$(EDK2_OUTPUT_DIR)/DxeCore.efi: edk2/.git
$(MAKE) -C edk2
edk2.force: edk2/.git
$(MAKE) -C edk2 build
# 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
$(BUILD)/Linux.ffs: $(KERNEL)
$(BUILD)/Initrd.ffs: $(INITRD)
$(BUILD)/%.ffs: $(BUILD)/%.vol
./bin/create-ffs \
-o $@ \
--type FIRMWARE_VOLUME_IMAGE \
$^
$(BUILD)/%.ffs: $(EDK2_OUTPUT_DIR)/%.efi
$(create-ffs)
$(BUILD)/%.ffs:
$(create-ffs)
$(BUILD)/%.rom:
cat > [email protected] $^
@if [ `stat -c"%s" [email protected]` -ne `stat -c"%s" $(ROM)` ]; then \
printf >&2 "%s: Wrong output size 0x%x != expected 0x%x\n" \
$@ `stat -c'%s' [email protected]` `stat -c'%s' $(ROM)` ; \
exit 1; \
fi
mv [email protected] $@
$(BUILD)/%.vol:
./bin/create-fv \
-v \
-o $@ \
--size $(or $($(basename $(notdir $@))-size),0x400000) \
--compress $(or $($(basename $(notdir $@))-compress),0) \
$(filter-out $(BUILD)/$(BOARD).txt,$^)
create-ffs = \
./bin/create-ffs \
-o $@ \
--name $(basename $(notdir $@)) \
--version 1.0 \
--type $(or $($(basename $(notdir $@))-type),DRIVER) \
--depex "$($(basename $(notdir $@))-depex)" \
--guid "$($(basename $(notdir $@))-guid)" \
$^
#
# Extract all of the firmware files from the vendor provided ROM
# --repack \
#
$(BUILD)/$(BOARD).txt: $(ROM)
( \
cd $(BUILD) ; \
$(pwd)/bin/extract-firmware \
-o rom \
) < $^ \
mv [email protected] $@
# All of the output volumes depend on extracting the firmware
$(patsubst %.vol,,$(FVS)): $(BUILD)/$(BOARD).txt
$(patsubst %.fv,,$(FVS)): $(BUILD)/$(BOARD).txt
# Most of the boards define a $(dxe-files) that are extracted
# from the vendor ROM. Make sure they depend on the board target
$(dxe-files): $(BUILD)/$(BOARD).txt
@true
# Any of the DXE modules are produced by running make in the dxe subdir
dxe/%.ffs:
$(MAKE) -C dxe $(notdir $@)
ifndef USE_UTK
$(BUILD)/linuxboot.rom: $(FVS)
else
$(BUILD)/linuxboot.rom: bin/utk $(DXE_FFS)
$< \
$(ROM) \
remove_dxes_except boards/$(BOARD)/image-files.txt \
$(foreach ffs,$(DXE_FFS), insert_dxe $(ffs)) \
$(UTK_EXTRA_OPS) \
save $@
endif
clean:
$(RM) $(BUILD)/{*.ffs,*.rom,*.vol,*.tmp}
$(RM) ./bin/utk