File: rules

package info (click to toggle)
edk2 0~20181115.85588389-3
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 237,636 kB
  • sloc: ansic: 2,289,230; python: 445,187; perl: 157,704; asm: 59,891; cpp: 21,893; sh: 4,328; pascal: 2,169; makefile: 2,168; xml: 387; lisp: 34
file content (146 lines) | stat: -rwxr-xr-x 5,384 bytes parent folder | download
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
#!/usr/bin/make -f

SHELL=/bin/bash

# various bits that have to be pulled in to create the full source tarball
OPENSSL_VER= 1.1.0h
OPENSSL_SRC= openssl-$(OPENSSL_VER).tar.gz
OPENSSL_URL= http://www.openssl.org/source/$(OPENSSL_SRC)
SHELL_SRC  = https://svn.code.sf.net/p/efi-shell/code/trunk/Shell
SHELL_REV  = 64


# Only used for creating our build tools.
DEB_BUILD_ARCH ?= $(shell dpkg-architecture -qDEB_BUILD_ARCH)
DEB_HOST_ARCH ?= $(shell dpkg-architecture -qDEB_HOST_ARCH)
DEB_HOST_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE)

# Bumping this up to >= GCC5 will require the replacing the pre-compiled
# liblto*.a binaries that we strip from our orig.tar.xz.
EDK2_TOOLCHAIN = GCC49
export $(EDK2_TOOLCHAIN)_AARCH64_PREFIX=aarch64-linux-gnu-
export $(EDK2_TOOLCHAIN)_ARM_PREFIX=arm-linux-gnueabihf-

ifeq ($(DEB_BUILD_ARCH),amd64)
	EDK2_BUILD_ARCH=X64
endif
ifeq ($(DEB_BUILD_ARCH),i386)
	EDK2_BUILD_ARCH=IA32
endif
ifeq ($(DEB_BUILD_ARCH),arm64)
	EDK2_BUILD_ARCH=AARCH64
endif

ifeq ($(DEB_HOST_ARCH),amd64)
	EDK2_HOST_ARCH=X64
endif
ifeq ($(DEB_HOST_ARCH),i386)
	EDK2_HOST_ARCH=IA32
endif

COMMON_FLAGS = -DHTTP_BOOT_ENABLE=TRUE -DSECURE_BOOT_ENABLE=TRUE
OVMF_FLAGS   = $(COMMON_FLAGS) -DFD_SIZE_2MB -DTPM2_ENABLE=TRUE
AAVMF_FLAGS  = $(COMMON_FLAGS) -DINTEL_BDS

# Clear variables used internally by the edk2 build system
undefine WORKSPACE
undefine ECP_SOURCE
undefine EDK_SOURCE
undefine EFI_SOURCE
undefine EDK_TOOLS_PATH
undefine CONF_PATH

ver := $(shell dpkg-parsechangelog | sed -n -e's/^Version: \(.*\)-[^-]\+/\1/p')

%:
	dh $@

override_dh_auto_build: build-qemu-efi-aarch64 build-qemu-efi-arm build-ovmf

setup-build:
	make -C BaseTools ARCH=$(EDK2_BUILD_ARCH)
	# We call this twice because it modifies the shell environment,
	# and it's excessively awkward to do all the subsequent work in a
	# single shell invocation
	. ./edksetup.sh

build-ovmf: EDK2_ARCH_DIR=X64
build-ovmf: EDK2_HOST_ARCH=X64
build-ovmf: setup-build
ifneq (,$(findstring ovmf, $(shell dh_listpackages)))
	cd UefiCpuPkg/ResetVector/Vtf0 && python Build.py
	mkdir -p EdkShellBinPkg/FullShell/$(EDK2_ARCH_DIR) \
	         FatBinPkg/EnhancedFatDxe/$(EDK2_ARCH_DIR)
	set -e; . ./edksetup.sh; \
		build -a $(EDK2_HOST_ARCH) -p EdkShellPkg/EdkShellPkg.dsc -m Shell/ShellFull.inf \
			-b RELEASE -t $(EDK2_TOOLCHAIN); \
		cp -a Build/EdkShellPkg/RELEASE_$(EDK2_TOOLCHAIN)/$(EDK2_ARCH_DIR)/ShellFull.efi \
			EdkShellBinPkg/FullShell/$(EDK2_ARCH_DIR)/Shell_Full.efi; \
		build -a $(EDK2_HOST_ARCH) -p FatPkg/FatPkg.dsc -m FatPkg/EnhancedFatDxe/Fat.inf \
			-b RELEASE -t $(EDK2_TOOLCHAIN); \
		cp -a Build/Fat/RELEASE_$(EDK2_TOOLCHAIN)/$(EDK2_ARCH_DIR)/Fat.efi \
			FatBinPkg/EnhancedFatDxe/$(EDK2_ARCH_DIR)/Fat.efi; \
		build -a $(EDK2_HOST_ARCH) \
			-t $(EDK2_TOOLCHAIN) \
			-p OvmfPkg/OvmfPkgX64.dsc \
			$(OVMF_FLAGS) -b RELEASE
endif

build-qemu-efi: setup-build
	mkdir -p ShellBinPkg/UefiShell/$(EDK2_ARCH_DIR) FatBinPkg/EnhancedFatDxe/$(EDK2_ARCH_DIR)
	set -e; . ./edksetup.sh; \
		build -a $(EDK2_HOST_ARCH) -p ShellPkg/ShellPkg.dsc \
			-b RELEASE -t $(EDK2_TOOLCHAIN); \
		cp -a Build/Shell/RELEASE_$(EDK2_TOOLCHAIN)/$(EDK2_HOST_ARCH)/Shell.efi \
			ShellBinPkg/UefiShell/$(EDK2_ARCH_DIR)/Shell.efi; \
		build -a $(EDK2_HOST_ARCH) -p FatPkg/FatPkg.dsc \
			-m FatPkg/EnhancedFatDxe/Fat.inf \
			-t $(EDK2_TOOLCHAIN) -b RELEASE; \
		cp -a Build/Fat/RELEASE_$(EDK2_TOOLCHAIN)/$(EDK2_HOST_ARCH)/Fat.efi \
			FatBinPkg/EnhancedFatDxe/$(EDK2_ARCH_DIR)/Fat.efi; \
		build -a $(EDK2_HOST_ARCH) \
			-t $(EDK2_TOOLCHAIN) \
			-p ArmVirtPkg/ArmVirtQemu.dsc \
			$(AAVMF_FLAGS) -b RELEASE
	dd if=/dev/zero of=Build/ArmVirtQemu-$(EDK2_HOST_ARCH)/RELEASE_$(EDK2_TOOLCHAIN)/FV/$(FW_NAME)_CODE.fd bs=1M seek=64 count=0
	dd if=Build/ArmVirtQemu-$(EDK2_HOST_ARCH)/RELEASE_$(EDK2_TOOLCHAIN)/FV/QEMU_EFI.fd of=Build/ArmVirtQemu-$(EDK2_HOST_ARCH)/RELEASE_$(EDK2_TOOLCHAIN)/FV/$(FW_NAME)_CODE.fd conv=notrunc
	dd if=/dev/zero of=Build/ArmVirtQemu-$(EDK2_HOST_ARCH)/RELEASE_$(EDK2_TOOLCHAIN)/FV/$(FW_NAME)_VARS.fd bs=1M seek=64 count=0

build-qemu-efi-aarch64:
	$(MAKE) -f debian/rules build-qemu-efi EDK2_ARCH_DIR=AArch64 EDK2_HOST_ARCH=AARCH64 FW_NAME=AAVMF

build-qemu-efi-arm:
	$(MAKE) -f debian/rules build-qemu-efi EDK2_ARCH_DIR=Arm EDK2_HOST_ARCH=ARM FW_NAME=AAVMF32

override_dh_auto_clean:
	set -e; \
	if [ -d BaseTools/Source/C/bin ]; then \
		. ./edksetup.sh; build clean; \
		make -C BaseTools clean; \
	fi
	rm -rf Conf/.cache Build .pc-post

get-orig-source:
	# Should be executed on a checkout of the upstream master branch,
	# with the debian/ directory manually copied in.
	git clone . edk2-$(ver)
	rm -rf edk2-$(ver)/.git
	ln -s ../debian edk2-$(ver)
	# Remove known-binary files
	cd edk2-$(ver) && python3 ./debian/remove-binaries.py
	# Look for possible unknown binary files
	cd edk2-$(ver) && python3 ./debian/find-binaries.py
	rm edk2-$(ver)/debian
	# openssl
	wget $(OPENSSL_URL)
	tar zxvf $(OPENSSL_SRC) -C edk2-$(ver)/CryptoPkg/Library/OpensslLib
	rm -rf edk2-$(ver)/CryptoPkg/Library/OpensslLib/openssl && \
		ln -s openssl-$(OPENSSL_VER) \
		edk2-$(ver)/CryptoPkg/Library/OpensslLib/openssl
	# efi shell
	svn export -r$(SHELL_REV) $(SHELL_SRC) edk2-$(ver)/Shell
	cd edk2-$(ver)/Shell && patch -p1 < ../EdkShellPkg/ShellR$(SHELL_REV).patch 
	tar Jcvf ../edk2_$(ver).orig.tar.xz edk2-$(ver)
	rm -rf edk2-$(ver) $(OPENSSL_SRC)

.PHONY: setup-build build-ovmf build-qemu-efi