File: rules

package info (click to toggle)
ipxe 2.0.0%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 26,100 kB
  • sloc: ansic: 376,737; asm: 7,463; perl: 2,682; sh: 1,198; makefile: 471; python: 285; tcl: 36
file content (163 lines) | stat: -rwxr-xr-x 5,163 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
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
#!/usr/bin/make -f
# -*- makefile -*-

#export DH_VERBOSE=1

export DEB_BUILD_MAINT_OPTIONS = hardening=+all
DPKG_EXPORT_BUILDFLAGS = 1
include /usr/share/dpkg/default.mk

%:
	dh $@

# qemu EFI roms shall be built with CONFIG=qemu
# This makes it apply src/config/*, src/config/qemu/*, src/config/local/*,
# src/config/local/qemu/* in this order.
src/bin-%.rom src/bin-%.efirom: export CONFIG=qemu

# Export CROSS prefix for building.
# This controls the architecture-specific build tools to be used.
src/bin-i386-pcbios%: export CROSS=x86_64-linux-gnu-
src/bin-i386-pcbios%: export DEB_HOST_ARCH=amd64

src/bin-x86_64-efi%: export CROSS=x86_64-linux-gnu-
src/bin-x86_64-efi%: export DEB_HOST_ARCH=amd64

src/bin-arm64-efi%: export CROSS=aarch64-linux-gnu-
src/bin-arm64-efi%: export DEB_HOST_ARCH=arm64

src/bin-riscv64-efi%: export CROSS=riscv64-linux-gnu-
src/bin-riscv64-efi%: export DEB_HOST_ARCH=riscv64

src/bin-loong64-efi%: export CROSS=loongarch64-linux-gnu-
src/bin-loong64-efi%: export DEB_HOST_ARCH=loong64

# For i386, use the i686-linux-gnu- toolchain when x86_64-linux-gnu- is not
# available. This is the case when building any package for i386 host.
ifeq ($(DEB_HOST_ARCH),i386)
ifneq ($(shell dpkg-query --show --showformat '$${db:Status-Status}' gcc-x86-64-linux-gnu),installed)
src/bin-i386-pcbios%: export CROSS=i686-linux-gnu-
src/bin-i386-pcbios%: export DEB_HOST_ARCH=i386
endif
endif

ifeq ($(DEB_BUILD_ARCH),i386)
export HOST_EFI_CFLAGS = -malign-double
endif

# used in (patched) src/Makefile
export EXTRA_HOST_CFLAGS = $(shell dpkg-buildflags --get CFLAGS_FOR_BUILD) $(shell dpkg-buildflags --get LDFLAGS_FOR_BUILD) -D__BLHC_IGNORE_HOSTCC

# 1. forcibly use cross tools and ignore DEB_HOST_ARCH
# 2. also setting CXX and PKG_CONFIG even if they are not used
#    to avoid confusing names in build logs
# 3. XFLAGS from env cannot be reused since DEB_HOST_ARCH is reset
# 4. save the files that are modified by the build, restore them when
#    next build of the same <arch>-<platform> is triggered, to prevent
#    unnecessary rebuilds
define run-dh_auto_build =
if [ -e "$(dir $@)/config.tar" ]; then \
	tar -C src -xf "$(dir $@)/config.tar"; \
fi
@if [ "$$DEB_HOST_ARCH" != "$(DEB_BUILD_ARCH)" ]; then \
	echo "blhc: ignore-line-regexp: .*$$CROSS.*"; \
fi
CC="$${CROSS}gcc" \
CXX="$${CROSS}g++" \
PKG_CONFIG="$${CROSS}pkg-config" \
EXTRA_CFLAGS="$$( (dpkg-buildflags --get CFLAGS && dpkg-buildflags --get CPPFLAGS) | tr ' ' '\n' | grep -E -- "-W|-D" | grep -v -- "-Wl," | tr '\n' ' ' ) -D__BLHC_IGNORE_CC" \
dh_auto_build --sourcedirectory=src -- \
	V=1 NO_WERROR=1 VERSION="$(DEB_VERSION)" GITVERSION="dummynotused" $(subst src/,,$@)
tar -C src -cf "$(dir $@)/config.tar" config/local config/named.h include/compiler.h include/ipxe/profile.h include/assert.h
endef

src/bin-i386-pcbios%:
	$(run-dh_auto_build)

src/bin-x86_64-efi%:
	$(run-dh_auto_build)

src/bin-arm64-efi%:
	$(run-dh_auto_build)

src/bin-riscv64-efi%:
	$(run-dh_auto_build)

src/bin-loong64-efi%:
	$(run-dh_auto_build)

# efi roms are >256k since Bionic due to https + natural growth
# stay at 256k-512k after disabling https in efi via padding
define run-catrom =
@mkdir -p $(dir $@)
@echo "Combining $@ with:"
@for rom in $^; do \
	echo "  $$rom: $$(stat -c %s "$$rom" )"; \
done
src/util/catrom.pl $^ > $@
@echo "Size before padding: $$(stat -c %s $@)"
src/util/padimg.pl --blksize=262144 --byte=0xff --verbose $@
endef

src/bin-combined/%.efirom: src/bin-i386-pcbios-rom/%.rom src/bin-x86_64-efi-rom/%.efirom
	$(run-catrom)

src/bin-combined/%.iso: src/bin-i386-pcbios/%.lkrn src/bin-x86_64-efi/%.efi src/bin-arm64-efi/%.efi src/bin-riscv64-efi/%.efi src/bin-loong64-efi/%.efi
	@mkdir -p $(dir $@)
	debian/util/geniso $@ $^

define get_targets
$(shell \
  for pkg in $$(dh_listpackages $(1)); do \
    if [ -e "debian/$$pkg.$(2)" ]; then \
	  ( \
		if [ -x "debian/$$pkg.$(2)" ]; then \
		  dh-exec --with= "debian/$$pkg.$(2)"; \
		else \
		  cat "debian/$$pkg.$(2)"; \
		fi \
	  ) | grep -hoE 'src/bin\S+'; \
	fi; \
  done \
)
endef

# ================
# dh targets below
# ================

execute_before_dh_auto_build:
	@echo "blhc: ignore-line-regexp: .*__BLHC_IGNORE_HOSTCC.*"
	@echo "blhc: ignore-line-regexp: .*__BLHC_IGNORE_CC.*"

override_dh_auto_build-indep: $(call get_targets,-i,install)
override_dh_auto_build-arch: $(call get_targets,-a,install)

execute_after_dh_install-indep:
	debian/util/check-rom-sizes

override_dh_auto_clean:
	dh_auto_clean --sourcedirectory=src -- veryclean
	rm -fr src/bin-*
	find src/config/local -type f -name '*.h' -size 0 -delete

ifeq (,$(filter nocheck, $(DEB_BUILD_OPTIONS)))

test_roms-indep = $(call get_targets,-i,testroms)
test_roms-arch = $(call get_targets,-a,testroms)

override_dh_auto_build-indep: $(test_roms-indep)
override_dh_auto_build-arch: $(test_roms-arch)

debian/self_tests/%: %
	./debian/tests/ipxe-tests $<
	mkdir -p $(dir $@) && touch $@

override_dh_auto_test-indep: $(addprefix debian/self_tests/,$(test_roms-indep))
override_dh_auto_test-arch: $(addprefix debian/self_tests/,$(test_roms-arch))

override_dh_auto_clean: clean_self_tests
clean_self_tests:
	rm -rf debian/self_tests

endif