1 ## SPDX-License-Identifier: GPL-2.0-only
3 # force the shell to bash - the edksetup.sh script doesn't work with dash
4 export SHELL
:= env bash
7 export WORKSPACE
:= $(CURDIR
)/workspace
8 export EDK2_PATH
:= $(WORKSPACE
)/$(word 3,$(subst /, ,$(CONFIG_EDK2_REPOSITORY
)))
10 ifeq ($(CONFIG_EDK2_USE_EDK2_PLATFORMS
),y
)
11 export EDK2_PLATFORMS_PATH
:= $(WORKSPACE
)/edk2-platforms
12 export PACKAGES_PATH
:= $(EDK2_PATH
):\
13 $(EDK2_PLATFORMS_PATH
)/Platform
/Intel
:\
14 $(EDK2_PLATFORMS_PATH
)/Silicon
/Intel
:\
15 $(EDK2_PLATFORMS_PATH
)/Features
/Intel
:\
16 $(EDK2_PLATFORMS_PATH
)/Features
/Intel
/Debugging
:\
17 $(EDK2_PLATFORMS_PATH
)/Features
/Intel
/Network
:\
18 $(EDK2_PLATFORMS_PATH
)/Features
/Intel
/OutOfBandManagement
:\
19 $(EDK2_PLATFORMS_PATH
)/Features
/Intel
/PowerManagement
:\
20 $(EDK2_PLATFORMS_PATH
)/Features
/Intel
/SystemInformation
:\
21 $(EDK2_PLATFORMS_PATH
)/Features
/Intel
/UserInterface
23 export PACKAGES_PATH
:= $(EDK2_PATH
)
26 OBJCOPY
= $(GCC_PREFIX
)objcopy
28 ifeq ($(CONFIG_EDK2_UEFIPAYLOAD
),y
)
29 BUILD_STR
= -p UefiPayloadPkg
/UefiPayloadPkg.dsc
31 BUILD_STR
+= -t COREBOOT
32 BUILD_STR
+= -D BOOTLOADER
=COREBOOT
35 ifeq ($(CONFIG_EDK2_UEFIPAYLOAD
),y
)
40 BUILD_STR
+= -D BUILD_ARCH
=X64
43 # EDK II (edk2/master) has the following build options relevant to coreboot:
46 # OPTION = DEFAULT_VALUE
48 # BOOTSPLASH_IMAGE = FALSE
49 ifneq ($(CONFIG_EDK2_BOOTSPLASH_FILE
),)
50 BUILD_STR
+= -D BOOTSPLASH_IMAGE
=TRUE
52 # BOOT_MANAGER_ESCAPE = FALSE
53 ifeq ($(CONFIG_EDK2_BOOT_MANAGER_ESCAPE
),y
)
54 BUILD_STR
+= -D BOOT_MANAGER_ESCAPE
=TRUE
56 # BUILD_TARGETS = DEBUG
57 ifeq ($(CONFIG_EDK2_DEBUG
),y
)
62 # CPU_TIMER_LIB_ENABLE = TRUE
63 ifneq ($(CONFIG_EDK2_CPU_TIMER_LIB
),y
)
64 BUILD_STR
+= -D CPU_TIMER_LIB_ENABLE
=FALSE
66 BUILD_STR
+= --pcd gUefiCpuPkgTokenSpaceGuid.PcdCpuCoreCrystalClockFrequency
=$(CONFIG_CPU_XTAL_HZ
)
68 # DISABLE_SERIAL_TERMINAL = FALSE
69 ifneq ($(CONFIG_EDK2_SERIAL_SUPPORT
),y
)
70 BUILD_STR
+= -D DISABLE_SERIAL_TERMINAL
=TRUE
72 # VARIABLE_SUPPORT = EMU
73 # MAX_VARIABLE_SIZE = 0x10000
74 ifeq ($(CONFIG_SMMSTORE_V2
),y
)
75 BUILD_STR
+= -D VARIABLE_SUPPORT
=SMMSTORE
76 BUILD_STR
+= --pcd gEfiMdeModulePkgTokenSpaceGuid.PcdMaxVariableSize
=0x8000
78 # PCIE_BASE_ADDRESS = 0
79 ifneq ($(CONFIG_ECAM_MMCONF_LENGTH
),)
80 BUILD_STR
+= --pcd gEfiMdePkgTokenSpaceGuid.PcdPciExpressBaseAddress
=$(CONFIG_ECAM_MMCONF_BASE_ADDRESS
)
82 # PCIE_BASE_LENGTH = 0
83 ifneq ($(CONFIG_ECAM_MMCONF_LENGTH
),)
84 BUILD_STR
+= --pcd gEfiMdePkgTokenSpaceGuid.PcdPciExpressBaseSize
=$(CONFIG_ECAM_MMCONF_LENGTH
)
86 # PS2_KEYBOARD_ENABLE = FALSE
87 ifeq ($(CONFIG_EDK2_PS2_SUPPORT
),y
)
88 BUILD_STR
+= -D PS2_KEYBOARD_ENABLE
=TRUE
90 # PLATFORM_BOOT_TIMEOUT = 3
91 ifneq ($(CONFIG_EDK2_BOOT_TIMEOUT
),)
92 BUILD_STR
+= -D PLATFORM_BOOT_TIMEOUT
=$(CONFIG_EDK2_BOOT_TIMEOUT
)
94 # SIO_BUS_ENABLE = FALSE
95 ifeq ($(CONFIG_EDK2_PS2_SUPPORT
),y
)
96 BUILD_STR
+= -D SIO_BUS_ENABLE
=TRUE
98 # SHELL_TYPE = BUILD_SHELL
99 ifneq ($(CONFIG_EDK2_HAVE_EFI_SHELL
),y
)
100 BUILD_STR
+= -D SHELL_TYPE
=NONE
102 # USE_CBMEM_FOR_CONSOLE = FALSE
103 ifeq ($(CONFIG_EDK2_CBMEM_LOGGING
),y
)
104 BUILD_STR
+= -D USE_CBMEM_FOR_CONSOLE
=TRUE
106 # SD_MMC_TIMEOUT = 1000000
107 ifneq ($(CONFIG_EDK2_SD_MMC_TIMEOUT
),)
108 BUILD_STR
+= -D SD_MMC_TIMEOUT
=$(shell echo
$$(( $(CONFIG_EDK2_SD_MMC_TIMEOUT
) * 1000)) )
110 # EDK2_SECURE_BOOT_SUPPORT = FALSE
111 ifeq ($(CONFIG_EDK2_SECURE_BOOT_SUPPORT
), y
)
112 BUILD_STR
+= -D SECURE_BOOT_ENABLE
=TRUE
114 # PCIEXP_SUPPORT_RESIZABLE_BARS = FALSE
115 ifeq ($(CONFIG_PCIEXP_SUPPORT_RESIZABLE_BARS
), y
)
116 BUILD_STR
+= --pcd gEfiMdeModulePkgTokenSpaceGuid.PcdPcieResizableBarSupport
=TRUE
120 # The MrChromebox repository has the following addition options:
122 ifeq ($(CONFIG_EDK2_REPO_MRCHROMEBOX
),y
)
124 # FOLLOW_BGRT_SPEC = FALSE
125 ifeq ($(CONFIG_EDK2_FOLLOW_BGRT_SPEC
),y
)
126 BUILD_STR
+= -D FOLLOW_BGRT_SPEC
=TRUE
129 ifeq ($(CONFIG_EDK2_GOP_DRIVER
), y
)
130 BUILD_STR
+= -D USE_PLATFORM_GOP
=TRUE
132 # PRIORITIZE_INTERNAL = FALSE
133 ifeq ($(CONFIG_EDK2_PRIORITIZE_INTERNAL
),y
)
134 BUILD_STR
+= -D PRIORITIZE_INTERNAL
=TRUE
137 ifeq ($(CONFIG_EDK2_DISABLE_TPM
),y
)
138 BUILD_STR
+= -D TPM_ENABLE
=FALSE
141 ifeq ($(CONFIG_EDK2_UFS_ENABLE
),y
)
142 BUILD_STR
+= -D UFS_ENABLE
=TRUE
144 # USE_PCO_MMIO_EMMC = FALSE
145 ifeq ($(CONFIG_EDK2_PCO_MMIO_EMMC
),y
)
146 BUILD_STR
+= -D USE_PCO_MMIO_EMMC
=TRUE
148 # TIMER_SUPPORT = HPET
149 ifeq ($(CONFIG_EDK2_USE_LAPIC_TIMER
),y
)
150 BUILD_STR
+= -D TIMER_SUPPORT
=LAPIC
156 # EDKII has the below PCDs that are relevant to coreboot:
158 # Allows EDKII to use the full framebuffer
159 ifeq ($(CONFIG_EDK2_FULL_SCREEN_SETUP
),y
)
160 BUILD_STR
+= --pcd gEfiMdeModulePkgTokenSpaceGuid.PcdConOutRow
=0
161 BUILD_STR
+= --pcd gEfiMdeModulePkgTokenSpaceGuid.PcdConOutColumn
=0
162 BUILD_STR
+= --pcd gEfiMdeModulePkgTokenSpaceGuid.PcdSetupConOutRow
=0
163 BUILD_STR
+= --pcd gEfiMdeModulePkgTokenSpaceGuid.PcdSetupConOutColumn
=0
166 bootloader
= $(word 8,$(subst /, ,$(BUILD_STR
)))
168 ifneq ($(CONFIG_EDK2_CUSTOM_BUILD_PARAMS
),)
169 BUILD_STR
+= $(CONFIG_EDK2_CUSTOM_BUILD_PARAMS
)
177 $(EDK2_PLATFORMS_PATH
): $(WORKSPACE
)
178 if
[ ! -d
"$(EDK2_PLATFORMS_PATH)" ]; then \
179 git clone
--recurse-submodules
$(CONFIG_EDK2_PLATFORMS_REPOSITORY
) $(EDK2_PLATFORMS_PATH
) -j5
; \
181 cd
$(EDK2_PLATFORMS_PATH
); \
182 if
! git rev-parse
--verify
-q
$(CONFIG_EDK2_PLATFORMS_TAG_OR_REV
)^
{object
} >/dev
/null
; then \
183 echo
" $(CONFIG_EDK2_PLATFORMS_TAG_OR_REV) is not a valid git reference"; \
186 if git status
--ignore-submodules
=dirty | grep
-q
"nothing to commit, working tree clean"; then \
187 echo
" Checking out edk2-platforms revision $(CONFIG_EDK2_PLATFORMS_TAG_OR_REV)"; \
188 git checkout
--detach
$(CONFIG_EDK2_PLATFORMS_TAG_OR_REV
) -f
; \
190 echo
" Working directory not clean; will not overwrite"; \
192 git submodule update
--init
--checkout
194 $(EDK2_PATH
): $(WORKSPACE
)
195 if
[ ! -d
"$(EDK2_PATH)" ]; then \
196 git clone
--recurse-submodules
$(CONFIG_EDK2_REPOSITORY
) $(EDK2_PATH
) -j5
; \
199 git checkout MdeModulePkg
/Logo
/Logo.bmp
> /dev
/null
2>&1 || true
; \
200 if
[ -e UefiPayloadPkg
/ShimLayer
/UniversalPayload.o
]; then \
201 rm UefiPayloadPkg
/ShimLayer
/UniversalPayload.o
; \
203 echo
" Fetching new commits from $(CONFIG_EDK2_REPOSITORY)"; \
204 git fetch
origin 2>/dev
/null
; \
205 if
! git rev-parse
--verify
-q
$(CONFIG_EDK2_TAG_OR_REV
)^
{object
} >/dev
/null
; then \
206 echo
" $(CONFIG_EDK2_TAG_OR_REV) is not a valid git reference"; \
209 if git status
--ignore-submodules
=dirty | grep
-q
-e
clean -e
"nothing added"; then \
210 echo
" Checking out $(project_name) revision $(CONFIG_EDK2_TAG_OR_REV)"; \
211 git checkout
--detach
$(CONFIG_EDK2_TAG_OR_REV
) -f
; \
212 git submodule update
--checkout
--recursive
; \
214 echo
" Working directory not clean; will not overwrite"; \
216 git submodule update
--init
--checkout
219 case
"$(CONFIG_EDK2_BOOTSPLASH_FILE)" in \
221 /*) convert
-background None
$(CONFIG_EDK2_BOOTSPLASH_FILE
) \
222 BMP3
:$(EDK2_PATH
)/MdeModulePkg
/Logo
/Logo.bmp
;; \
223 *) convert
-background None
$(top
)/$(CONFIG_EDK2_BOOTSPLASH_FILE
) \
224 BMP3
:$(EDK2_PATH
)/MdeModulePkg
/Logo
/Logo.bmp
;; \
227 gop_driver
: $(EDK2_PATH
)
228 if
[ -n
"$(CONFIG_EDK2_GOP_DRIVER)" ]; then \
229 echo
"Using GOP driver $(CONFIG_EDK2_GOP_FILE)"; \
230 cp
$(top
)/$(CONFIG_EDK2_GOP_FILE
) $(EDK2_PATH
)/UefiPayloadPkg
/IntelGopDriver.efi
; \
231 cp
$(top
)/$(CONFIG_INTEL_GMA_VBT_FILE
) $(EDK2_PATH
)/UefiPayloadPkg
/vbt.bin
; \
235 echo
-n
"EDK2: Checking uuid-dev:"
236 echo
"#include <uuid/uuid.h>" > libtest.c
237 echo
"int main(int argc, char **argv) { (void) argc; (void) argv; return 0; }" >> libtest.c
238 $(HOSTCC
) $(HOSTCCFLAGS
) libtest.c
-o libtest
>/dev
/null
2>&1 && echo
" Found!" || \
239 ( echo
" Not found!"; \
240 echo
"ERROR: please_install uuid-dev (libuuid-devel)"; exit
1 )
241 rm -rf libtest.c libtest
242 echo
-n
"EDK2: Checking nasm:"
243 type nasm
> /dev
/null
2>&1 && echo
" Found!" || \
244 ( echo
" Not found!"; echo
"ERROR: Please install nasm."; exit
1 )
245 echo
-n
"EDK2: Checking imagemagick:"
246 -convert
-size
1x1 xc
: test.png
&> /dev
/null
;
247 if
[ -f
test.png
]; then \
248 rm test.png
&& echo
" Found!"; \
250 echo
" Not found!"; \
251 echo
"ERROR: Please install imagemagick"; \
256 echo
" ##### $(project_name) Build Summary #####"
257 echo
" Repository: $(CONFIG_EDK2_REPOSITORY)"
258 echo
" Branch: $(CONFIG_EDK2_TAG_OR_REV)"
259 echo
" Packages path: $(PACKAGES_PATH)"
260 echo
" $(BUILD_STR)" | \
261 sed
-e
's/--/-/g' -e
's/-/\n /g' |
sort | sed \
262 -e
's/a /Architecture: /g' \
263 -e
's/b /Release: /g' \
264 -e
's/D /Option: /g' \
265 -e
's/pcd /Pcd: /g' \
266 -e
's/p /Payload: /g' \
267 -e
's/q /Build: Quiet/' \
268 -e
's/s /Build: Silent/' \
269 -e
's/t /Toolchain: /'
271 prep
: $(EDK2_PATH
) $(EDK2_PLATFORMS_PATH
) clean checktools logo gop_driver
273 source
$(EDK2_PATH
)/edksetup.sh
; \
274 unset CC
; $(MAKE
) -C
$(EDK2_PATH
)/BaseTools
2>&1; \
275 grep
-q
"COREBOOT" $(EDK2_PATH
)/Conf
/tools_def.txt
; \
276 if
[ $$?
-ne
0 ]; then \
277 cat ..
/tools_def.txt
>> $(EDK2_PATH
)/Conf
/tools_def.txt
; \
280 $(WORKSPACE
)/Build
/UefiPayloadPkgX64
/$(RELEASE_STR
)_COREBOOT
/FV
/UEFIPAYLOAD.fd
: \
283 source
$(EDK2_PATH
)/edksetup.sh
; \
284 echo
-n
"EDK2: Building... "; \
285 build
-a IA32
-a X64
-b
$(RELEASE_STR
) $(BUILD_STR
) \
286 -y
$(WORKSPACE
)/Build
/UefiPayloadPkgX64
/UEFIPAYLOAD.txt
; \
287 if
[ ! -f
$@
]; then \
293 $(WORKSPACE
)/Build
/UefiPayloadPkgX64
/UniversalPayload.elf
: \
296 source
$(EDK2_PATH
)/edksetup.sh
; \
297 echo
-n
"EDK2: Building... "; \
298 $(EDK2_PATH
)/UefiPayloadPkg
/UniversalPayloadBuild.sh
-a IA32
-b
$(RELEASE_STR
) $(BUILD_STR
)
299 if
[ ! -f
$@
]; then \
305 $(WORKSPACE
)/Build
/UefiPayloadPkgX64
/$(RELEASE_STR
)_COREBOOT
/IA32
/UefiPayloadPkg
/ShimLayer
/ShimLayer
/DEBUG
/ShimLayer.dll
: \
306 $(WORKSPACE
)/Build
/UefiPayloadPkgX64
/UniversalPayload.elf prep
307 cd
$(WORKSPACE
)/Build
/UefiPayloadPkgX64
&& \
308 $(OBJCOPY
) -I binary UniversalPayload.elf
-O elf32-i386
-B i386 \
309 $(EDK2_PATH
)/UefiPayloadPkg
/ShimLayer
/UniversalPayload.o
; \
311 source
$(EDK2_PATH
)/edksetup.sh
; \
312 build
-p UefiPayloadPkg
/UefiPayloadPkg.dsc
-b
$(RELEASE_STR
) -a IA32
-a X64 \
313 -m UefiPayloadPkg
/ShimLayer
/ShimLayer.inf \
314 -t COREBOOT
-D BOOTLOADER
=COREBOOT
-D SHIMLAYER
=TRUE \
315 -y
$(WORKSPACE
)/Build
/UefiPayloadPkgX64
/ShimLayer.txt
317 UefiPayloadPkg
: $(WORKSPACE
)/Build
/UefiPayloadPkgX64
/$(RELEASE_STR
)_COREBOOT
/FV
/UEFIPAYLOAD.fd
318 mv
$(WORKSPACE
)/Build
/UefiPayloadPkgX64
/$(RELEASE_STR
)_COREBOOT
/FV
/UEFIPAYLOAD.fd \
319 ..
/..
/..
/build
/UEFIPAYLOAD.fd
321 UniversalPayload
: $(WORKSPACE
)/Build
/UefiPayloadPkgX64
/$(RELEASE_STR
)_COREBOOT
/IA32
/UefiPayloadPkg
/ShimLayer
/ShimLayer
/DEBUG
/ShimLayer.dll
322 mv
$(WORKSPACE
)/Build
/UefiPayloadPkgX64
/$(RELEASE_STR
)_COREBOOT
/IA32
/UefiPayloadPkg
/ShimLayer
/ShimLayer
/DEBUG
/ShimLayer.dll \
323 ..
/..
/..
/build
/ShimmedUniversalPayload.elf
326 test -d
$(WORKSPACE
) && (cd
$(WORKSPACE
); rm -rf Build
; rm -f Conf
/tools_def.txt
) || exit
0
331 .PHONY
: $(EDK2_PATH
) checktools logo UefiPayloadPkg UniversalPayload
clean distclean