drivers/wifi: Remove unnecessary data structure copy
[coreboot2.git] / payloads / external / edk2 / Makefile
blob6464e9f8514fc0d6fcf452c7285cc359f6e9327e
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
6 project_name = edk2
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
22 else
23 export PACKAGES_PATH := $(EDK2_PATH)
24 endif
26 OBJCOPY = $(GCC_PREFIX)objcopy
28 ifeq ($(CONFIG_EDK2_UEFIPAYLOAD),y)
29 BUILD_STR = -p UefiPayloadPkg/UefiPayloadPkg.dsc
30 endif
31 BUILD_STR += -t COREBOOT
32 BUILD_STR += -D BOOTLOADER=COREBOOT
33 ifneq ($(V),1)
34 BUILD_STR += -q
35 ifeq ($(CONFIG_EDK2_UEFIPAYLOAD),y)
36 BUILD_STR += -s
37 endif
38 endif
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
51 endif
52 # BOOT_MANAGER_ESCAPE = FALSE
53 ifeq ($(CONFIG_EDK2_BOOT_MANAGER_ESCAPE),y)
54 BUILD_STR += -D BOOT_MANAGER_ESCAPE=TRUE
55 endif
56 # BUILD_TARGETS = DEBUG
57 ifeq ($(CONFIG_EDK2_DEBUG),y)
58 RELEASE_STR = DEBUG
59 else
60 RELEASE_STR = RELEASE
61 endif
62 # CPU_TIMER_LIB_ENABLE = TRUE
63 ifneq ($(CONFIG_EDK2_CPU_TIMER_LIB),y)
64 BUILD_STR += -D CPU_TIMER_LIB_ENABLE=FALSE
65 else
66 BUILD_STR += --pcd gUefiCpuPkgTokenSpaceGuid.PcdCpuCoreCrystalClockFrequency=$(CONFIG_CPU_XTAL_HZ)
67 endif
68 # DISABLE_SERIAL_TERMINAL = FALSE
69 ifneq ($(CONFIG_EDK2_SERIAL_SUPPORT),y)
70 BUILD_STR += -D DISABLE_SERIAL_TERMINAL=TRUE
71 endif
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
77 endif
78 # PCIE_BASE_ADDRESS = 0
79 ifneq ($(CONFIG_ECAM_MMCONF_LENGTH),)
80 BUILD_STR += --pcd gEfiMdePkgTokenSpaceGuid.PcdPciExpressBaseAddress=$(CONFIG_ECAM_MMCONF_BASE_ADDRESS)
81 endif
82 # PCIE_BASE_LENGTH = 0
83 ifneq ($(CONFIG_ECAM_MMCONF_LENGTH),)
84 BUILD_STR += --pcd gEfiMdePkgTokenSpaceGuid.PcdPciExpressBaseSize=$(CONFIG_ECAM_MMCONF_LENGTH)
85 endif
86 # PS2_KEYBOARD_ENABLE = FALSE
87 ifeq ($(CONFIG_EDK2_PS2_SUPPORT),y)
88 BUILD_STR += -D PS2_KEYBOARD_ENABLE=TRUE
89 endif
90 # PLATFORM_BOOT_TIMEOUT = 3
91 ifneq ($(CONFIG_EDK2_BOOT_TIMEOUT),)
92 BUILD_STR += -D PLATFORM_BOOT_TIMEOUT=$(CONFIG_EDK2_BOOT_TIMEOUT)
93 endif
94 # SIO_BUS_ENABLE = FALSE
95 ifeq ($(CONFIG_EDK2_PS2_SUPPORT),y)
96 BUILD_STR += -D SIO_BUS_ENABLE=TRUE
97 endif
98 # SHELL_TYPE = BUILD_SHELL
99 ifneq ($(CONFIG_EDK2_HAVE_EFI_SHELL),y)
100 BUILD_STR += -D SHELL_TYPE=NONE
101 endif
102 # USE_CBMEM_FOR_CONSOLE = FALSE
103 ifeq ($(CONFIG_EDK2_CBMEM_LOGGING),y)
104 BUILD_STR += -D USE_CBMEM_FOR_CONSOLE=TRUE
105 endif
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)) )
109 endif
110 # EDK2_SECURE_BOOT_SUPPORT = FALSE
111 ifeq ($(CONFIG_EDK2_SECURE_BOOT_SUPPORT), y)
112 BUILD_STR += -D SECURE_BOOT_ENABLE=TRUE
113 endif
114 # PCIEXP_SUPPORT_RESIZABLE_BARS = FALSE
115 ifeq ($(CONFIG_PCIEXP_SUPPORT_RESIZABLE_BARS), y)
116 BUILD_STR += --pcd gEfiMdeModulePkgTokenSpaceGuid.PcdPcieResizableBarSupport=TRUE
117 endif
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
127 endif
128 # GOP_DRIVER = FALSE
129 ifeq ($(CONFIG_EDK2_GOP_DRIVER), y)
130 BUILD_STR += -D USE_PLATFORM_GOP=TRUE
131 endif
132 # PRIORITIZE_INTERNAL = FALSE
133 ifeq ($(CONFIG_EDK2_PRIORITIZE_INTERNAL),y)
134 BUILD_STR += -D PRIORITIZE_INTERNAL=TRUE
135 endif
136 # TPM_ENABLE = TRUE
137 ifeq ($(CONFIG_EDK2_DISABLE_TPM),y)
138 BUILD_STR += -D TPM_ENABLE=FALSE
139 endif
140 # UFS_ENABLE = FALSE
141 ifeq ($(CONFIG_EDK2_UFS_ENABLE),y)
142 BUILD_STR += -D UFS_ENABLE=TRUE
143 endif
144 # USE_PCO_MMIO_EMMC = FALSE
145 ifeq ($(CONFIG_EDK2_PCO_MMIO_EMMC),y)
146 BUILD_STR += -D USE_PCO_MMIO_EMMC=TRUE
147 endif
148 # TIMER_SUPPORT = HPET
149 ifeq ($(CONFIG_EDK2_USE_LAPIC_TIMER),y)
150 BUILD_STR += -D TIMER_SUPPORT=LAPIC
151 endif
153 endif
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
164 endif
166 bootloader = $(word 8,$(subst /, ,$(BUILD_STR)))
168 ifneq ($(CONFIG_EDK2_CUSTOM_BUILD_PARAMS),)
169 BUILD_STR += $(CONFIG_EDK2_CUSTOM_BUILD_PARAMS)
170 endif
172 all: UefiPayloadPkg
174 $(WORKSPACE):
175 mkdir $(WORKSPACE)
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"; \
184 exit 1; \
185 fi; \
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; \
189 else \
190 echo " Working directory not clean; will not overwrite"; \
191 fi; \
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; \
198 cd $(EDK2_PATH); \
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; \
202 fi; \
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"; \
207 exit 1; \
208 fi; \
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; \
213 else \
214 echo " Working directory not clean; will not overwrite"; \
215 fi; \
216 git submodule update --init --checkout
218 logo: $(EDK2_PATH)
219 case "$(CONFIG_EDK2_BOOTSPLASH_FILE)" in \
220 "") ;; \
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;; \
225 esac \
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; \
232 fi; \
234 checktools:
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!"; \
249 else \
250 echo " Not found!"; \
251 echo "ERROR: Please install imagemagick"; \
252 exit 1; \
255 print:
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
272 cd $(WORKSPACE); \
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; \
278 fi; \
280 $(WORKSPACE)/Build/UefiPayloadPkgX64/$(RELEASE_STR)_COREBOOT/FV/UEFIPAYLOAD.fd: \
281 prep print
282 cd $(WORKSPACE); \
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 \
288 echo "Failed!"; \
289 exit 1; \
291 echo "Success!"; \
293 $(WORKSPACE)/Build/UefiPayloadPkgX64/UniversalPayload.elf: \
294 prep print
295 cd $(WORKSPACE); \
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 \
300 echo "Failed!"; \
301 exit 1; \
303 echo "Success!"; \
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; \
310 cd $(WORKSPACE) && \
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
325 clean:
326 test -d $(WORKSPACE) && (cd $(WORKSPACE); rm -rf Build; rm -f Conf/tools_def.txt) || exit 0
328 distclean:
329 rm -rf $(WORKSPACE)
331 .PHONY: $(EDK2_PATH) checktools logo UefiPayloadPkg UniversalPayload clean distclean