]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blame - debian/rules.d/2-binary-arch.mk
UBUNTU: [Packaging] Fix config file assembly
[mirror_ubuntu-bionic-kernel.git] / debian / rules.d / 2-binary-arch.mk
CommitLineData
0d34a427
LO
1# We don't want make removing intermediary stamps
2.SECONDARY :
3
4# Prepare the out-of-tree build directory
5ifeq ($(do_full_source),true)
6build_cd = cd $(builddir)/build-$*; #
7build_O =
8else
9build_cd =
10build_O = O=$(builddir)/build-$*
11endif
12
13# Typically supplied from the arch makefile, e.g., debian.master/control.d/armhf.mk
14ifneq ($(gcc),)
15kmake += CC=$(CROSS_COMPILE)$(gcc)
16endif
17
18shlibdeps_opts = $(if $(CROSS_COMPILE),-- -l$(CROSS_COMPILE:%-=/usr/%)/lib)
19
27170546
AW
20debian/scripts/fix-filenames: debian/scripts/fix-filenames.c
21 $(CC) -o $@ $^
22
0d34a427
LO
23$(stampdir)/stamp-prepare-%: config-prepare-check-%
24 @echo Debug: $@
25 @touch $@
26$(stampdir)/stamp-prepare-tree-%: target_flavour = $*
27170546 27$(stampdir)/stamp-prepare-tree-%: $(commonconfdir)/config.common.$(family) $(archconfdir)/config.common.$(arch) $(archconfdir)/config.flavour.% debian/scripts/fix-filenames
0d34a427
LO
28 @echo Debug: $@
29 install -d $(builddir)/build-$*
30 touch $(builddir)/build-$*/ubuntu-build
31 [ "$(do_full_source)" != 'true' ] && true || \
32 rsync -a --exclude debian --exclude debian.master --exclude $(DEBIAN) * $(builddir)/build-$*
ce0108d2 33 cat $(wordlist 1,3,$^) | sed -e 's/.*CONFIG_VERSION_SIGNATURE.*/CONFIG_VERSION_SIGNATURE="Ubuntu $(release)-$(revision)-$* $(raw_kernelversion)"/' > $(builddir)/build-$*/.config
0d34a427
LO
34 find $(builddir)/build-$* -name "*.ko" | xargs rm -f
35 $(build_cd) $(kmake) $(build_O) -j1 silentoldconfig prepare scripts
36 touch $@
37
38# Used by developers as a shortcut to prepare a tree for compilation.
39prepare-%: $(stampdir)/stamp-prepare-%
40 @echo Debug: $@
41# Used by developers to allow efficient pre-building without fakeroot.
42build-%: $(stampdir)/stamp-build-%
43 @echo Debug: $@
44
0d34a427
LO
45# Do the actual build, including image and modules
46$(stampdir)/stamp-build-%: target_flavour = $*
0d34a427 47$(stampdir)/stamp-build-%: bldimg = $(call custom_override,build_image,$*)
0d34a427
LO
48$(stampdir)/stamp-build-%: $(stampdir)/stamp-prepare-%
49 @echo Debug: $@ build_image $(build_image) bldimg $(bldimg)
50 $(build_cd) $(kmake) $(build_O) $(conc_level) $(bldimg) modules $(if $(filter true,$(do_dtbs)),dtbs)
51
0d34a427
LO
52 @touch $@
53
a64043c5
AW
54define build_dkms_sign =
55 $(shell set -x; if grep -q CONFIG_MODULE_SIG=y $(1)/.config; then
56 echo $(1)/scripts/sign-file $(MODHASHALGO) $(MODSECKEY) $(MODPUBKEY);
57 else
58 echo "-";
59 fi
60 )
61endef
62define build_dkms =
63 $(SHELL) $(DROOT)/scripts/dkms-build $(dkms_dir) $(abi_release)-$* '$(call build_dkms_sign,$(builddir)/build-$*)' $(1) $(2) $(3) $(4)
0d34a427
LO
64endef
65
fbf28672
AW
66define install_control =
67 for which in $(3); \
68 do \
69 template="$(DROOT)/templates/$(2).$$which.in"; \
70 script="$(DROOT)/$(1).$$which"; \
71 sed -e 's/@abiname@/$(abi_release)/g' \
72 -e 's/@localversion@/-$*/g' \
73 -e 's/@image-stem@/$(instfile)/g' \
74 <"$$template" >"$$script"; \
75 done
76endef
77
27170546
AW
78# Ensure the directory prefix is exactly 100 characters long so pathnames are the
79# exact same length in any binary files produced by the builds. These will be
80# commonised later.
81dkms_20d=....................
82dkms_100d=$(dkms_20d)$(dkms_20d)$(dkms_20d)$(dkms_20d)$(dkms_20d)
83dkms_100c=$(shell echo '$(dkms_100d)' | sed -e 's/\./_/g')
84define dkms_dir_prefix =
85$(shell echo $(1)/$(dkms_100c) | \
86 sed -e 's/\($(dkms_100d)\).*/\1/' -e 's/^\(.*\)....$$/\1dkms/')
87endef
88
0d34a427 89# Install the finished build
b90b1fe0
AW
90install-%: pkgdir_bin = $(CURDIR)/debian/$(bin_pkg_name)-$*
91install-%: pkgdir = $(CURDIR)/debian/$(mods_pkg_name)-$*
92install-%: pkgdir_ex = $(CURDIR)/debian/$(mods_extra_pkg_name)-$*
3f0288f5 93install-%: pkgdir_bldinfo = $(CURDIR)/debian/$(bldinfo_pkg_name)-$*
0d34a427
LO
94install-%: bindoc = $(pkgdir)/usr/share/doc/$(bin_pkg_name)-$*
95install-%: dbgpkgdir = $(CURDIR)/debian/$(bin_pkg_name)-$*-dbgsym
7b65f554 96install-%: signingv = $(CURDIR)/debian/$(bin_pkg_name)-signing/$(release)-$(revision)
0d34a427
LO
97install-%: toolspkgdir = $(CURDIR)/debian/$(tools_flavour_pkg_name)-$*
98install-%: cloudpkgdir = $(CURDIR)/debian/$(cloud_flavour_pkg_name)-$*
99install-%: basepkg = $(hdrs_pkg_name)
100install-%: indeppkg = $(indep_hdrs_pkg_name)
101install-%: kernfile = $(call custom_override,kernel_file,$*)
102install-%: instfile = $(call custom_override,install_file,$*)
103install-%: hdrdir = $(CURDIR)/debian/$(basepkg)-$*/usr/src/$(basepkg)-$*
104install-%: target_flavour = $*
105install-%: MODHASHALGO=sha512
106install-%: MODSECKEY=$(builddir)/build-$*/certs/signing_key.pem
107install-%: MODPUBKEY=$(builddir)/build-$*/certs/signing_key.x509
108install-%: build_dir=$(builddir)/build-$*
a64043c5 109install-%: dkms_dir=$(call dkms_dir_prefix,$(builddir)/build-$*)
0d34a427 110install-%: enable_zfs = $(call custom_override,do_zfs,$*)
a64043c5 111install-%: $(stampdir)/stamp-build-% install-headers
0d34a427
LO
112 @echo Debug: $@ kernel_file $(kernel_file) kernfile $(kernfile) install_file $(install_file) instfile $(instfile)
113 dh_testdir
114 dh_testroot
2c21160b 115 dh_prep -p$(bin_pkg_name)-$*
b90b1fe0 116 dh_prep -p$(mods_pkg_name)-$*
2c21160b 117 dh_prep -p$(hdrs_pkg_name)-$*
0d34a427 118ifneq ($(skipdbg),true)
2c21160b 119 dh_prep -p$(bin_pkg_name)-$*-dbgsym
0d34a427
LO
120endif
121
122 # The main image
123 # compress_file logic required because not all architectures
124 # generate a zImage automatically out of the box
125ifeq ($(compress_file),)
126 install -m600 -D $(builddir)/build-$*/$(kernfile) \
b90b1fe0 127 $(pkgdir_bin)/boot/$(instfile)-$(abi_release)-$*
0d34a427 128else
b90b1fe0 129 install -d $(pkgdir_bin)/boot
0d34a427 130 gzip -c9v $(builddir)/build-$*/$(kernfile) > \
b90b1fe0
AW
131 $(pkgdir_bin)/boot/$(instfile)-$(abi_release)-$*
132 chmod 600 $(pkgdir_bin)/boot/$(instfile)-$(abi_release)-$*
0d34a427
LO
133endif
134
135ifeq ($(uefi_signed),true)
7b65f554 136 install -d $(signingv)
0d34a427
LO
137 # Check to see if this supports handoff, if not do not sign it.
138 # Check the identification area magic and version >= 0x020b
b90b1fe0 139 handoff=`dd if="$(pkgdir_bin)/boot/$(instfile)-$(abi_release)-$*" bs=1 skip=514 count=6 2>/dev/null | od -s | gawk '($$1 == 0 && $$2 == 25672 && $$3 == 21362 && $$4 >= 523) { print "GOOD" }'`; \
0d34a427 140 if [ "$$handoff" = "GOOD" ]; then \
b90b1fe0 141 cp -p $(pkgdir_bin)/boot/$(instfile)-$(abi_release)-$* \
7b65f554 142 $(signingv)/$(instfile)-$(abi_release)-$*.efi; \
0d34a427
LO
143 fi
144endif
d074ecae
AW
145ifeq ($(opal_signed),true)
146 install -d $(signingv)
147 cp -p $(pkgdir_bin)/boot/$(instfile)-$(abi_release)-$* \
148 $(signingv)/$(instfile)-$(abi_release)-$*.opal;
149endif
0d34a427 150
b90b1fe0 151 install -d $(pkgdir)/boot
0d34a427
LO
152 install -m644 $(builddir)/build-$*/.config \
153 $(pkgdir)/boot/config-$(abi_release)-$*
0d34a427
LO
154 install -m600 $(builddir)/build-$*/System.map \
155 $(pkgdir)/boot/System.map-$(abi_release)-$*
156 if [ "$(filter true,$(do_dtbs))" ]; then \
157 $(build_cd) $(kmake) $(build_O) $(conc_level) dtbs_install \
158 INSTALL_DTBS_PATH=$(pkgdir)/lib/firmware/$(abi_release)-$*/device-tree; \
159 ( cd $(pkgdir)/lib/firmware/$(abi_release)-$*/ && find device-tree -print ) | \
160 while read dtb_file; do \
161 echo "$$dtb_file ?" >> $(DEBIAN)/d-i/firmware/$(arch)/kernel-image; \
162 done; \
163 fi
164ifeq ($(no_dumpfile),)
165 makedumpfile -g $(pkgdir)/boot/vmcoreinfo-$(abi_release)-$* \
166 -x $(builddir)/build-$*/vmlinux
167 chmod 0600 $(pkgdir)/boot/vmcoreinfo-$(abi_release)-$*
168endif
169
170 $(build_cd) $(kmake) $(build_O) $(conc_level) modules_install $(vdso) \
171 INSTALL_MOD_STRIP=1 INSTALL_MOD_PATH=$(pkgdir)/ \
172 INSTALL_FW_PATH=$(pkgdir)/lib/firmware/$(abi_release)-$*
173
0d34a427
LO
174 #
175 # Build module blacklists:
176 # - blacklist all watchdog drivers (LP:1432837)
177 #
178 install -d $(pkgdir)/lib/modprobe.d
179 echo "# Kernel supplied blacklist for $(src_pkg_name) $(abi_release)-$* $(arch)" \
180 >$(pkgdir)/lib/modprobe.d/blacklist_$(src_pkg_name)_$(abi_release)-$*.conf
181 for conf in $(arch)-$* $(arch) common.conf; do \
182 if [ -f $(DEBIAN)/modprobe.d/$$conf ]; then \
183 echo "# modprobe.d/$$conf"; \
184 cat $(DEBIAN)/modprobe.d/$$conf; \
185 fi; \
186 done >>$(pkgdir)/lib/modprobe.d/blacklist_$(src_pkg_name)_$(abi_release)-$*.conf
187 echo "# Autogenerated watchdog blacklist" \
188 >>$(pkgdir)/lib/modprobe.d/blacklist_$(src_pkg_name)_$(abi_release)-$*.conf
189 ls -1 $(pkgdir)/lib/modules/$(abi_release)-$*/kernel/drivers/watchdog/ | \
ed131dd3 190 grep -v '^bcm2835_wdt$$' | \
0d34a427
LO
191 sed -e 's/^/blacklist /' -e 's/.ko$$//' | \
192 sort -u \
193 >>$(pkgdir)/lib/modprobe.d/blacklist_$(src_pkg_name)_$(abi_release)-$*.conf
194
195ifeq ($(do_extras_package),true)
196 #
197 # Remove all modules not in the inclusion list.
198 #
199 if [ -f $(DEBIAN)/control.d/$(target_flavour).inclusion-list ] ; then \
200 /sbin/depmod -v -b $(pkgdir) $(abi_release)-$* | \
201 sed -e "s@$(pkgdir)/lib/modules/$(abi_release)-$*/kernel/@@g" | \
202 awk '{ print $$1 " " $$NF}' >$(build_dir)/module-inclusion.depmap; \
203 mkdir -p $(pkgdir_ex)/lib/modules/$(abi_release)-$*; \
204 mv $(pkgdir)/lib/modules/$(abi_release)-$*/kernel \
205 $(pkgdir_ex)/lib/modules/$(abi_release)-$*/kernel; \
206 $(SHELL) $(DROOT)/scripts/module-inclusion --master \
207 $(pkgdir_ex)/lib/modules/$(abi_release)-$*/kernel \
208 $(pkgdir)/lib/modules/$(abi_release)-$*/kernel \
209 $(DEBIAN)/control.d/$(target_flavour).inclusion-list \
210 $(build_dir)/module-inclusion.depmap 2>&1 | \
211 tee $(target_flavour).inclusion-list.log; \
212 /sbin/depmod -b $(pkgdir) -ea -F $(pkgdir)/boot/System.map-$(abi_release)-$* \
213 $(abi_release)-$* 2>&1 |tee $(target_flavour).depmod.log; \
214 if [ `grep -c 'unknown symbol' $(target_flavour).depmod.log` -gt 0 ]; then \
215 echo "EE: Unresolved module dependencies in base package!"; \
216 exit 1; \
217 fi \
218 fi
219endif
220
221ifeq ($(no_dumpfile),)
222 makedumpfile -g $(pkgdir)/boot/vmcoreinfo-$(abi_release)-$* \
223 -x $(builddir)/build-$*/vmlinux
224 chmod 0600 $(pkgdir)/boot/vmcoreinfo-$(abi_release)-$*
225endif
226 rm -f $(pkgdir)/lib/modules/$(abi_release)-$*/build
227 rm -f $(pkgdir)/lib/modules/$(abi_release)-$*/source
228
229 # Some initramfs-tools specific modules
230 install -d $(pkgdir)/lib/modules/$(abi_release)-$*/initrd
231 if [ -f $(pkgdir)/lib/modules/$(abi_release)-$*/kernel/drivers/video/vesafb.ko ]; then\
232 $(LN) $(pkgdir)/lib/modules/$(abi_release)-$*/kernel/drivers/video/vesafb.ko \
233 $(pkgdir)/lib/modules/$(abi_release)-$*/initrd/; \
234 fi
235
0b151c76 236 echo "interest linux-update-$(abi_release)-$*" >"$(DROOT)/$(bin_pkg_name)-$*.triggers"
d502621d 237 install -d $(pkgdir_bin)/usr/lib/linux/triggers
fbf28672 238 $(call install_control,$(bin_pkg_name)-$*,image,postinst postrm preinst prerm)
d502621d 239 install -d $(pkgdir)/usr/lib/linux/triggers
b90b1fe0 240 $(call install_control,$(mods_pkg_name)-$*,extra,postinst postrm)
0d34a427
LO
241ifeq ($(do_extras_package),true)
242 # Install the postinit/postrm scripts in the extras package.
243 if [ -f $(DEBIAN)/control.d/$(target_flavour).inclusion-list ] ; then \
d502621d 244 install -d $(pkgdir_ex)/usr/lib/linux/triggers; \
b90b1fe0 245 $(call install_control,$(mods_extra_pkg_name)-$*,extra,postinst postrm); \
0d34a427
LO
246 fi
247endif
248
249 # Install the full changelog.
250ifeq ($(do_doc_package),true)
251 install -d $(bindoc)
252 cat $(DEBIAN)/changelog $(DEBIAN)/changelog.historical | \
253 gzip -9 >$(bindoc)/changelog.Debian.old.gz
254 chmod 644 $(bindoc)/changelog.Debian.old.gz
255endif
256
257ifneq ($(skipsub),true)
258 for sub in $($(*)_sub); do \
259 if ! (TO=$$sub FROM=$* ABI_RELEASE=$(abi_release) $(SHELL) \
260 $(DROOT)/scripts/sub-flavour); then exit 1; fi; \
261 /sbin/depmod -b debian/$(bin_pkg_name)-$$sub \
262 -ea -F debian/$(bin_pkg_name)-$$sub/boot/System.map-$(abi_release)-$* \
263 $(abi_release)-$*; \
fbf28672 264 $(call install_control,$(bin_pkg_name)--$$sub,image,postinst postrm preinst prerm); \
0d34a427
LO
265 done
266endif
267
268ifneq ($(skipdbg),true)
269 # Debug image is simple
270 install -m644 -D $(builddir)/build-$*/vmlinux \
271 $(dbgpkgdir)/usr/lib/debug/boot/vmlinux-$(abi_release)-$*
272 $(build_cd) $(kmake) $(build_O) modules_install $(vdso) \
273 INSTALL_MOD_PATH=$(dbgpkgdir)/usr/lib/debug
274 # Add .gnu_debuglink sections to each stripped .ko
275 # pointing to unstripped verson
276 find $(pkgdir) -name '*.ko' | sed 's|$(pkgdir)||'| while read module ; do \
277 if [[ -f "$(dbgpkgdir)/usr/lib/debug/$$module" ]] ; then \
278 $(CROSS_COMPILE)objcopy \
279 --add-gnu-debuglink=$(dbgpkgdir)/usr/lib/debug/$$module \
280 $(pkgdir)/$$module; \
281 if grep -q CONFIG_MODULE_SIG=y $(builddir)/build-$*/.config; then \
282 $(builddir)/build-$*/scripts/sign-file $(MODHASHALGO) \
283 $(MODSECKEY) \
284 $(MODPUBKEY) \
285 $(pkgdir)/$$module; \
286 fi; \
287 fi; \
288 done
289 rm -f $(dbgpkgdir)/usr/lib/debug/lib/modules/$(abi_release)-$*/build
290 rm -f $(dbgpkgdir)/usr/lib/debug/lib/modules/$(abi_release)-$*/source
291 rm -f $(dbgpkgdir)/usr/lib/debug/lib/modules/$(abi_release)-$*/modules.*
292 rm -fr $(dbgpkgdir)/usr/lib/debug/lib/firmware
293endif
294
295 # The flavour specific headers image
296 # TODO: Would be nice if we didn't have to dupe the original builddir
297 install -d -m755 $(hdrdir)
298 cat $(builddir)/build-$*/.config | \
299 sed -e 's/.*CONFIG_DEBUG_INFO=.*/# CONFIG_DEBUG_INFO is not set/g' > \
300 $(hdrdir)/.config
301 chmod 644 $(hdrdir)/.config
302 $(kmake) O=$(hdrdir) -j1 silentoldconfig prepare scripts
303 # We'll symlink this stuff
304 rm -f $(hdrdir)/Makefile
305 rm -rf $(hdrdir)/include2 $(hdrdir)/source
8892ccf2
AW
306 # We do not need the retpoline information.
307 find $(hdrdir) -name \*.o.ur-\* | xargs rm -f
0d34a427
LO
308 # Copy over the compilation version.
309 cp "$(builddir)/build-$*/include/generated/compile.h" \
310 "$(hdrdir)/include/generated/compile.h"
311 # Add UTS_UBUNTU_RELEASE_ABI since UTS_RELEASE is difficult to parse.
312 echo "#define UTS_UBUNTU_RELEASE_ABI $(abinum)" >> $(hdrdir)/include/generated/utsrelease.h
313 # powerpc kernel arch seems to need some .o files for external module linking. Add them in.
314ifeq ($(build_arch),powerpc)
315 mkdir -p $(hdrdir)/arch/powerpc/lib
316 cp $(builddir)/build-$*/arch/powerpc/lib/*.o $(hdrdir)/arch/powerpc/lib
317endif
527d1e11
AW
318 # Copy over the new retpoline extractor.
319 cp scripts/ubuntu-retpoline-extract-one $(hdrdir)/scripts
0d34a427
LO
320 # Script to symlink everything up
321 $(SHELL) $(DROOT)/scripts/link-headers "$(hdrdir)" "$(indeppkg)" "$*"
322 # The build symlink
323 install -d debian/$(basepkg)-$*/lib/modules/$(abi_release)-$*
324 $(LN) /usr/src/$(basepkg)-$* \
325 debian/$(basepkg)-$*/lib/modules/$(abi_release)-$*/build
326 # And finally the symvers
327 install -m644 $(builddir)/build-$*/Module.symvers \
328 $(hdrdir)/Module.symvers
329
330 # Now the header scripts
fbf28672 331 $(call install_control,$(hdrs_pkg_name)-$*,headers,postinst)
0d34a427
LO
332
333 # At the end of the package prep, call the tests
334 DPKG_ARCH="$(arch)" KERN_ARCH="$(build_arch)" FLAVOUR="$*" \
335 VERSION="$(abi_release)" REVISION="$(revision)" \
336 PREV_REVISION="$(prev_revision)" ABI_NUM="$(abinum)" \
337 PREV_ABI_NUM="$(prev_abinum)" BUILD_DIR="$(builddir)/build-$*" \
338 INSTALL_DIR="$(pkgdir)" SOURCE_DIR="$(CURDIR)" \
339 run-parts -v $(DROOT)/tests-build
340
341 #
342 # Remove files which are generated at installation by postinst,
343 # except for modules.order and modules.builtin
344 #
345 # NOTE: need to keep this list in sync with postrm
346 #
347 mkdir $(pkgdir)/lib/modules/$(abi_release)-$*/_
348 mv $(pkgdir)/lib/modules/$(abi_release)-$*/modules.order \
349 $(pkgdir)/lib/modules/$(abi_release)-$*/_
350 if [ -f $(pkgdir)/lib/modules/$(abi_release)-$*/modules.builtin ] ; then \
351 mv $(pkgdir)/lib/modules/$(abi_release)-$*/modules.builtin \
352 $(pkgdir)/lib/modules/$(abi_release)-$*/_; \
353 fi
354 rm -f $(pkgdir)/lib/modules/$(abi_release)-$*/modules.*
355 mv $(pkgdir)/lib/modules/$(abi_release)-$*/_/* \
356 $(pkgdir)/lib/modules/$(abi_release)-$*
357 rmdir $(pkgdir)/lib/modules/$(abi_release)-$*/_
358
359ifeq ($(do_linux_tools),true)
360 # Create the linux-tools tool links
361 install -d $(toolspkgdir)/usr/lib/linux-tools/$(abi_release)-$*
362ifeq ($(do_tools_usbip),true)
363 $(LN) ../../$(src_pkg_name)-tools-$(abi_release)/usbip $(toolspkgdir)/usr/lib/linux-tools/$(abi_release)-$*
364 $(LN) ../../$(src_pkg_name)-tools-$(abi_release)/usbipd $(toolspkgdir)/usr/lib/linux-tools/$(abi_release)-$*
365endif
2c21160b
TG
366ifeq ($(do_tools_acpidbg),true)
367 $(LN) ../../$(src_pkg_name)-tools-$(abi_release)/acpidbg $(toolspkgdir)/usr/lib/linux-tools/$(abi_release)-$*
368endif
0d34a427
LO
369ifeq ($(do_tools_cpupower),true)
370 $(LN) ../../$(src_pkg_name)-tools-$(abi_release)/cpupower $(toolspkgdir)/usr/lib/linux-tools/$(abi_release)-$*
371endif
372ifeq ($(do_tools_perf),true)
373 $(LN) ../../$(src_pkg_name)-tools-$(abi_release)/perf $(toolspkgdir)/usr/lib/linux-tools/$(abi_release)-$*
0938dca2
TLSC
374ifeq ($(do_tools_perf_jvmti),true)
375 $(LN) ../../$(src_pkg_name)-tools-$(abi_release)/libperf-jvmti.so $(toolspkgdir)/usr/lib/linux-tools/$(abi_release)-$*
376endif
0d34a427 377endif
88d5e264
QM
378ifeq ($(do_tools_bpftool),true)
379 $(LN) ../../$(src_pkg_name)-tools-$(abi_release)/bpftool $(toolspkgdir)/usr/lib/linux-tools/$(abi_release)-$*
380endif
0d34a427
LO
381ifeq ($(do_tools_x86),true)
382 $(LN) ../../$(src_pkg_name)-tools-$(abi_release)/x86_energy_perf_policy $(toolspkgdir)/usr/lib/linux-tools/$(abi_release)-$*
383 $(LN) ../../$(src_pkg_name)-tools-$(abi_release)/turbostat $(toolspkgdir)/usr/lib/linux-tools/$(abi_release)-$*
384endif
385endif
386ifeq ($(do_cloud_tools),true)
387ifeq ($(do_tools_hyperv),true)
388 # Create the linux-hyperv tool links
389 install -d $(cloudpkgdir)/usr/lib/linux-tools/$(abi_release)-$*
390 $(LN) ../../$(src_pkg_name)-tools-$(abi_release)/hv_kvp_daemon $(cloudpkgdir)/usr/lib/linux-tools/$(abi_release)-$*
391 $(LN) ../../$(src_pkg_name)-tools-$(abi_release)/hv_vss_daemon $(cloudpkgdir)/usr/lib/linux-tools/$(abi_release)-$*
392 $(LN) ../../$(src_pkg_name)-tools-$(abi_release)/hv_fcopy_daemon $(cloudpkgdir)/usr/lib/linux-tools/$(abi_release)-$*
393 $(LN) ../../$(src_pkg_name)-tools-$(abi_release)/lsvmbus $(cloudpkgdir)/usr/lib/linux-tools/$(abi_release)-$*
394endif
395endif
396
a64043c5
AW
397 # Build a temporary "installed headers" directory.
398 install -d $(dkms_dir) $(dkms_dir)/headers $(dkms_dir)/build $(dkms_dir)/source
399 cp -rp "$(hdrdir)" "$(indep_hdrdir)" "$(dkms_dir)/headers"
400
8f75472f
AR
401 $(if $(filter true,$(enable_zfs)),$(call build_dkms, $(mods_pkg_name)-$*, $(pkgdir)/lib/modules/$(abi_release)-$*/kernel, spl, pool/universe/s/spl-linux/spl-dkms_$(dkms_spl_linux_version)_all.deb))
402 $(if $(filter true,$(enable_zfs)),$(call build_dkms, $(mods_pkg_name)-$*, $(pkgdir)/lib/modules/$(abi_release)-$*/kernel, zfs, pool/universe/z/zfs-linux/zfs-dkms_$(dkms_zfs_linux_version)_all.deb))
403
e8eea6b4 404ifeq ($(do_dkms_nvidia),true)
997b8c41 405 $(call build_dkms, $(bldinfo_pkg_name)-$*, $(pkgdir_bldinfo)/usr/lib/linux/$(abi_release)-$*/signatures, nvidia-390, pool/restricted/n/nvidia-graphics-drivers-390/nvidia-kernel-source-390_$(dkms_nvidia_version)_$(arch).deb pool/restricted/n/nvidia-graphics-drivers-390/nvidia-dkms-390_$(dkms_nvidia_version)_$(arch).deb)
e8eea6b4
AW
406endif
407
e846e525
AW
408 # Build the final ABI information.
409 install -d $(abidir)
410 sed -e 's/^\(.\+\)[[:space:]]\+\(.\+\)[[:space:]]\(.\+\)$$/\3 \2 \1/' \
411 $(builddir)/build-$*/Module.symvers | sort > $(abidir)/$*
412
413 # Build the final ABI modules information.
414 find $(pkgdir_bin) $(pkgdir) $(pkgdir_ex) -name \*.ko | \
415 sed -e 's/.*\/\([^\/]*\)\.ko/\1/' | sort > $(abidir)/$*.modules
416
7ea1dbf2
AW
417 # Build the final ABI firmware information.
418 find $(pkgdir_bin) $(pkgdir) $(pkgdir_ex) -name \*.ko | \
419 while read ko; do \
420 /sbin/modinfo $$ko | grep ^firmware || true; \
421 done | sort -u >$(abidir)/$*.fwinfo
422
048c8b70
AW
423 # Build the final ABI compiler information.
424 ko=$$(find $(pkgdir_bin) $(pkgdir) $(pkgdir_ex) -name \*.ko | head -1); \
425 readelf -p .comment "$$ko" | gawk ' \
426 ($$1 == "[") { \
427 printf("%s", $$3); \
428 for (n=4; n<=NF; n++) { \
429 printf(" %s", $$n); \
430 } \
431 print "" \
432 }' | sort -u >$(abidir)/$*.compiler
433
e846e525
AW
434 # Build the final ABI retpoline information.
435 if grep -q CONFIG_RETPOLINE=y $(builddir)/build-$*/.config; then \
436 echo "# retpoline v1.0" >$(abidir)/$*.retpoline; \
437 $(SHELL) $(DROOT)/scripts/retpoline-extract $(builddir)/build-$* $(CURDIR) | \
438 sort >>$(abidir)/$*.retpoline; \
439 else \
440 echo "# RETPOLINE NOT ENABLED" >$(abidir)/$*.retpoline; \
441 fi
442
3f0288f5
AW
443 # Build the buildinfo package content.
444 install -d $(pkgdir_bldinfo)/usr/lib/linux/$(abi_release)-$*
445 install -m644 $(builddir)/build-$*/.config \
446 $(pkgdir_bldinfo)/usr/lib/linux/$(abi_release)-$*/config
447 install -m644 $(abidir)/$* \
448 $(pkgdir_bldinfo)/usr/lib/linux/$(abi_release)-$*/abi
449 install -m644 $(abidir)/$*.modules \
450 $(pkgdir_bldinfo)/usr/lib/linux/$(abi_release)-$*/modules
7ea1dbf2
AW
451 install -m644 $(abidir)/$*.fwinfo \
452 $(pkgdir_bldinfo)/usr/lib/linux/$(abi_release)-$*/fwinfo
3f0288f5
AW
453 install -m644 $(abidir)/$*.retpoline \
454 $(pkgdir_bldinfo)/usr/lib/linux/$(abi_release)-$*/retpoline
048c8b70
AW
455 install -m644 $(abidir)/$*.compiler \
456 $(pkgdir_bldinfo)/usr/lib/linux/$(abi_release)-$*/compiler
3f0288f5 457
44efa9e7
SB
458ifeq ($(fit_signed),true)
459 install -d $(signingv)
460 cp -p $(pkgdir_bin)/boot/$(instfile)-$(abi_release)-$* \
461 $(signingv)/$(instfile)-$(abi_release)-$*;
462 # Build FIT image now that the modules folder exists
463 $(SHELL) $(DROOT)/scripts/build-fit \
464 $(CURDIR)/$(DEBIAN)/$(fit_its) \
465 "$(foreach f, $(fit_dtb_files), $(builddir)/build-$*/$(f))" \
466 $(abi_release)-$(target_flavour) \
467 $(CURDIR)/$(DROOT)/linux-modules-$(abi_release)-$* \
468 $(signingv)
469 cp -p $(signingv)/fit-$(abi_release)-$*.fit $(pkgdir_bin)/boot/
470endif
471
0d34a427
LO
472headers_tmp := $(CURDIR)/debian/tmp-headers
473headers_dir := $(CURDIR)/debian/linux-libc-dev
474
475hmake := $(MAKE) -C $(CURDIR) O=$(headers_tmp) \
476 KERNELVERSION=$(abi_release) INSTALL_HDR_PATH=$(headers_tmp)/install \
477 SHELL="$(SHELL)" ARCH=$(header_arch)
478
479install-arch-headers:
480 @echo Debug: $@
481 dh_testdir
482 dh_testroot
a6e57702 483ifeq ($(do_libc_dev_package),true)
2c21160b 484 dh_prep -plinux-libc-dev
a6e57702 485endif
0d34a427
LO
486
487 rm -rf $(headers_tmp)
488 install -d $(headers_tmp) $(headers_dir)/usr/include/
489
490 $(hmake) $(defconfig)
491 mv $(headers_tmp)/.config $(headers_tmp)/.config.old
492 sed -e 's/^# \(CONFIG_MODVERSIONS\) is not set$$/\1=y/' \
493 -e 's/.*CONFIG_LOCALVERSION_AUTO.*/# CONFIG_LOCALVERSION_AUTO is not set/' \
494 $(headers_tmp)/.config.old > $(headers_tmp)/.config
495 $(hmake) silentoldconfig
496 $(hmake) headers_install
497
498 ( cd $(headers_tmp)/install/include/ && \
499 find . -name '.' -o -name '.*' -prune -o -print | \
500 cpio -pvd --preserve-modification-time \
501 $(headers_dir)/usr/include/ )
bb372cae
SB
502 mkdir -p $(headers_dir)/usr/include/$(DEB_HOST_MULTIARCH)
503 rm -rf $(headers_dir)/usr/include/$(DEB_HOST_MULTIARCH)/asm
0d34a427
LO
504 mv $(headers_dir)/usr/include/asm $(headers_dir)/usr/include/$(DEB_HOST_MULTIARCH)/
505
506 rm -rf $(headers_tmp)
507
0805cf7c
AW
508define dh_all
509 dh_installchangelogs -p$(1)
510 dh_installdocs -p$(1)
511 dh_compress -p$(1)
512 dh_fixperms -p$(1) -X/boot/
513 dh_shlibdeps -p$(1) $(shlibdeps_opts)
514 dh_installdeb -p$(1)
515 dh_installdebconf -p$(1)
516 $(lockme) dh_gencontrol -p$(1) -- -Vlinux:rprovides='$(rprovides)'
517 dh_md5sums -p$(1)
518 dh_builddeb -p$(1)
519endef
520define newline
521
522
523endef
524define dh_all_inline
525 $(subst ${newline},; \${newline},$(call dh_all,$(1)))
526endef
527
0d34a427
LO
528binary-arch-headers: install-arch-headers
529 @echo Debug: $@
530 dh_testdir
531 dh_testroot
532ifeq ($(do_libc_dev_package),true)
533ifneq ($(DEBIAN),debian.master)
534 echo "non-master branch building linux-libc-dev, aborting"
535 exit 1
536endif
0805cf7c 537 $(call dh_all,linux-libc-dev)
0d34a427
LO
538endif
539
540binary-%: pkgimg = $(bin_pkg_name)-$*
b90b1fe0
AW
541binary-%: pkgimg_mods = $(mods_pkg_name)-$*
542binary-%: pkgimg_ex = $(mods_extra_pkg_name)-$*
f16de3c1 543binary-%: pkgdir_ex = $(CURDIR)/debian/$(extra_pkg_name)-$*
3f0288f5 544binary-%: pkgbldinfo = $(bldinfo_pkg_name)-$*
0d34a427
LO
545binary-%: pkghdr = $(hdrs_pkg_name)-$*
546binary-%: dbgpkg = $(bin_pkg_name)-$*-dbgsym
547binary-%: dbgpkgdir = $(CURDIR)/debian/$(bin_pkg_name)-$*-dbgsym
548binary-%: pkgtools = $(tools_flavour_pkg_name)-$*
549binary-%: pkgcloud = $(cloud_flavour_pkg_name)-$*
2c21160b 550binary-%: rprovides = $(if $(filter true,$(call custom_override,do_zfs,$*)),$(comma) spl-modules$(comma) spl-dkms$(comma) zfs-modules$(comma) zfs-dkms)
0d34a427 551binary-%: target_flavour = $*
e846e525 552binary-%: checks-%
0d34a427
LO
553 @echo Debug: $@
554 dh_testdir
555 dh_testroot
556
0805cf7c
AW
557 $(call dh_all,$(pkgimg))
558 $(call dh_all,$(pkgimg_mods))
b90b1fe0 559
0d34a427 560ifeq ($(do_extras_package),true)
f16de3c1
KM
561 ifeq ($(ship_extras_package),false)
562 # If $(ship_extras_package) is explicitly set to false, then do not
563 # construct the linux-image-extra package; instead just log all of the
564 # "extra" modules which were pointlessly built yet won't be shipped.
565 find $(pkgdir_ex) -name '*.ko' | sort \
566 | sed 's|^$(pkgdir_ex)/|NOT-SHIPPED |' \
567 | tee -a $(target_flavour).not-shipped.log;
568 else
0d34a427 569 if [ -f $(DEBIAN)/control.d/$(target_flavour).inclusion-list ] ; then \
0805cf7c 570 $(call dh_all_inline,$(pkgimg_ex)); \
0d34a427 571 fi
f16de3c1 572 endif
0d34a427
LO
573endif
574
3f0288f5 575 $(call dh_all,$(pkgbldinfo))
0805cf7c 576 $(call dh_all,$(pkghdr))
0d34a427
LO
577
578ifneq ($(skipsub),true)
579 @set -e; for sub in $($(*)_sub); do \
0805cf7c
AW
580 pkg=$(bin_pkg_name)-$$sub; \
581 $(call dh_all_inline,$$pkg); \
0d34a427
LO
582 done
583endif
584
585ifneq ($(skipdbg),true)
0805cf7c 586 $(call dh_all,$(dbgpkg))
0d34a427
LO
587
588 # Hokay...here's where we do a little twiddling...
589 # Renaming the debug package prevents it from getting into
590 # the primary archive, and therefore prevents this very large
591 # package from being mirrored. It is instead, through some
592 # archive admin hackery, copied to http://ddebs.ubuntu.com.
593 #
594 mv ../$(dbgpkg)_$(release)-$(revision)_$(arch).deb \
595 ../$(dbgpkg)_$(release)-$(revision)_$(arch).ddeb
596 set -e; \
597 ( \
598 $(lockme_cmd) 9 || exit 1; \
599 if grep -qs '^Build-Debug-Symbols: yes$$' /CurrentlyBuilding; then \
600 sed -i '/^$(dbgpkg)_/s/\.deb /.ddeb /' debian/files; \
601 else \
602 grep -v '^$(dbgpkg)_.*$$' debian/files > debian/files.new; \
603 mv debian/files.new debian/files; \
604 fi; \
605 ) 9>$(lockme_file)
606 # Now, the package wont get into the archive, but it will get put
607 # into the debug system.
608endif
609
610ifeq ($(do_linux_tools),true)
0805cf7c 611 $(call dh_all,$(pkgtools))
0d34a427
LO
612endif
613ifeq ($(do_cloud_tools),true)
0805cf7c 614 $(call dh_all,$(pkgcloud))
0d34a427
LO
615endif
616
617ifneq ($(full_build),false)
618 # Clean out this flavours build directory.
619 rm -rf $(builddir)/build-$*
620 # Clean out the debugging package source directory.
621 rm -rf $(dbgpkgdir)
622endif
623
624#
625# per-architecture packages
626#
627builddirpa = $(builddir)/tools-perarch
628
629$(stampdir)/stamp-prepare-perarch:
630 @echo Debug: $@
631ifeq ($(do_any_tools),true)
632 rm -rf $(builddirpa)
633 install -d $(builddirpa)
634 rsync -a --exclude debian --exclude debian.master --exclude $(DEBIAN) --exclude .git -a ./ $(builddirpa)/
635endif
636 touch $@
637
638$(stampdir)/stamp-build-perarch: $(stampdir)/stamp-prepare-perarch install-arch-headers
639 @echo Debug: $@
640ifeq ($(do_linux_tools),true)
641ifeq ($(do_tools_usbip),true)
642 chmod 755 $(builddirpa)/tools/usb/usbip/autogen.sh
643 cd $(builddirpa)/tools/usb/usbip && ./autogen.sh
644 chmod 755 $(builddirpa)/tools/usb/usbip/configure
645 cd $(builddirpa)/tools/usb/usbip && ./configure --prefix=$(builddirpa)/tools/usb/usbip/bin
646 cd $(builddirpa)/tools/usb/usbip && make install CFLAGS="-g -O2 -static" CROSS_COMPILE=$(CROSS_COMPILE)
647endif
2c21160b
TG
648ifeq ($(do_tools_acpidbg),true)
649 cd $(builddirpa)/tools/power/acpi && make clean && make CFLAGS="-g -O2 -static -I$(builddirpa)/include" CROSS_COMPILE=$(CROSS_COMPILE) acpidbg
650endif
0d34a427
LO
651ifeq ($(do_tools_cpupower),true)
652 # Allow for multiple installed versions of cpupower and libcpupower.so:
653 # Override LIB_MIN in order to to generate a versioned .so named
654 # libcpupower.so.$(abi_release) and link cpupower with that.
655 make -C $(builddirpa)/tools/power/cpupower \
656 CROSS_COMPILE=$(CROSS_COMPILE) \
657 CROSS=$(CROSS_COMPILE) \
658 LIB_MIN=$(abi_release) CPUFREQ_BENCH=false
659endif
660ifeq ($(do_tools_perf),true)
661 cd $(builddirpa) && $(kmake) $(defconfig)
662 mv $(builddirpa)/.config $(builddirpa)/.config.old
663 sed -e 's/^# \(CONFIG_MODVERSIONS\) is not set$$/\1=y/' \
664 -e 's/.*CONFIG_LOCALVERSION_AUTO.*/# CONFIG_LOCALVERSION_AUTO is not set/' \
665 $(builddirpa)/.config.old > $(builddirpa)/.config
666 cd $(builddirpa) && $(kmake) silentoldconfig
667 cd $(builddirpa) && $(kmake) prepare
668 cd $(builddirpa)/tools/perf && \
259bf445 669 $(kmake) prefix=/usr HAVE_NO_LIBBFD=1 HAVE_CPLUS_DEMANGLE_SUPPORT=1 CROSS_COMPILE=$(CROSS_COMPILE) NO_LIBPYTHON=1 NO_LIBPERL=1 PYTHON=python2.7
0d34a427 670endif
88d5e264
QM
671ifeq ($(do_tools_bpftool),true)
672 $(kmake) CROSS_COMPILE=$(CROSS_COMPILE) -C $(builddirpa)/tools/bpf/bpftool
673endif
0d34a427
LO
674ifeq ($(do_tools_x86),true)
675 cd $(builddirpa)/tools/power/x86/x86_energy_perf_policy && make CROSS_COMPILE=$(CROSS_COMPILE)
676 cd $(builddirpa)/tools/power/x86/turbostat && make CROSS_COMPILE=$(CROSS_COMPILE)
677endif
678endif
679ifeq ($(do_cloud_tools),true)
680ifeq ($(do_tools_hyperv),true)
681 cd $(builddirpa)/tools/hv && make CFLAGS="-I$(headers_dir)/usr/include -I$(headers_dir)/usr/include/$(DEB_HOST_MULTIARCH)" CROSS_COMPILE=$(CROSS_COMPILE) hv_kvp_daemon hv_vss_daemon hv_fcopy_daemon
682endif
683endif
684 @touch $@
685
686install-perarch: toolspkgdir = $(CURDIR)/debian/$(tools_pkg_name)
687install-perarch: cloudpkgdir = $(CURDIR)/debian/$(cloud_pkg_name)
688install-perarch: $(stampdir)/stamp-build-perarch
689 @echo Debug: $@
690 # Add the tools.
691ifeq ($(do_linux_tools),true)
692 install -d $(toolspkgdir)/usr/lib
693 install -d $(toolspkgdir)/usr/lib/$(src_pkg_name)-tools-$(abi_release)
694ifeq ($(do_tools_usbip),true)
695 install -m755 $(builddirpa)/tools/usb/usbip/bin/sbin/usbip \
696 $(toolspkgdir)/usr/lib/$(src_pkg_name)-tools-$(abi_release)
697 install -m755 $(builddirpa)/tools/usb/usbip/bin/sbin/usbipd \
698 $(toolspkgdir)/usr/lib/$(src_pkg_name)-tools-$(abi_release)
699endif
2c21160b
TG
700ifeq ($(do_tools_acpidbg),true)
701 install -m755 $(builddirpa)/tools/power/acpi/acpidbg \
702 $(toolspkgdir)/usr/lib/$(src_pkg_name)-tools-$(abi_release)
703endif
0d34a427
LO
704ifeq ($(do_tools_cpupower),true)
705 install -m755 $(builddirpa)/tools/power/cpupower/cpupower \
706 $(toolspkgdir)/usr/lib/$(src_pkg_name)-tools-$(abi_release)
707 # Install only the full versioned libcpupower.so.$(abi_release), not
708 # the usual symlinks to it.
709 install -m644 $(builddirpa)/tools/power/cpupower/libcpupower.so.$(abi_release) \
710 $(toolspkgdir)/usr/lib/
711endif
712ifeq ($(do_tools_perf),true)
713 install -m755 $(builddirpa)/tools/perf/perf $(toolspkgdir)/usr/lib/$(src_pkg_name)-tools-$(abi_release)
0938dca2
TLSC
714ifeq ($(do_tools_perf_jvmti),true)
715 install -m755 $(builddirpa)/tools/perf/libperf-jvmti.so $(toolspkgdir)/usr/lib/$(src_pkg_name)-tools-$(abi_release)
716endif
0d34a427 717endif
88d5e264
QM
718ifeq ($(do_tools_bpftool),true)
719 install -m755 $(builddirpa)/tools/bpf/bpftool/bpftool $(toolspkgdir)/usr/lib/$(src_pkg_name)-tools-$(abi_release)
720endif
0d34a427
LO
721ifeq ($(do_tools_x86),true)
722 install -m755 $(builddirpa)/tools/power/x86/x86_energy_perf_policy/x86_energy_perf_policy \
723 $(toolspkgdir)/usr/lib/$(src_pkg_name)-tools-$(abi_release)
724 install -m755 $(builddirpa)/tools/power/x86/turbostat/turbostat \
725 $(toolspkgdir)/usr/lib/$(src_pkg_name)-tools-$(abi_release)
726endif
727endif
728ifeq ($(do_cloud_tools),true)
729ifeq ($(do_tools_hyperv),true)
730 install -d $(cloudpkgdir)/usr/lib
731 install -d $(cloudpkgdir)/usr/lib/$(src_pkg_name)-tools-$(abi_release)
732 install -m755 $(builddirpa)/tools/hv/hv_kvp_daemon \
733 $(cloudpkgdir)/usr/lib/$(src_pkg_name)-tools-$(abi_release)
734 install -m755 $(builddirpa)/tools/hv/hv_vss_daemon \
735 $(cloudpkgdir)/usr/lib/$(src_pkg_name)-tools-$(abi_release)
736 install -m755 $(builddirpa)/tools/hv/hv_fcopy_daemon \
737 $(cloudpkgdir)/usr/lib/$(src_pkg_name)-tools-$(abi_release)
738 install -m755 $(builddirpa)/tools/hv/lsvmbus \
739 $(cloudpkgdir)/usr/lib/$(src_pkg_name)-tools-$(abi_release)
740endif
741endif
742
743binary-perarch: toolspkg = $(tools_pkg_name)
744binary-perarch: cloudpkg = $(cloud_pkg_name)
745binary-perarch: install-perarch
746 @echo Debug: $@
747ifeq ($(do_linux_tools),true)
0805cf7c 748 $(call dh_all,$(toolspkg))
0d34a427
LO
749endif
750ifeq ($(do_cloud_tools),true)
0805cf7c 751 $(call dh_all,$(cloudpkg))
0d34a427
LO
752endif
753
7b65f554
AW
754binary-debs: signing = $(CURDIR)/debian/$(bin_pkg_name)-signing
755binary-debs: signingv = $(CURDIR)/debian/$(bin_pkg_name)-signing/$(release)-$(revision)
756binary-debs: signing_tar = $(src_pkg_name)_$(release)-$(revision)_$(arch).tar.gz
0d34a427
LO
757binary-debs: binary-perarch $(addprefix binary-,$(flavours))
758 @echo Debug: $@
b90b1fe0 759ifeq ($(any_signed),true)
7b65f554 760 install -d $(signingv)/control
b90b1fe0 761 { echo "tarball"; } >$(signingv)/control/options
7b65f554
AW
762 cd $(signing) && tar czvf ../../../$(signing_tar) .
763 dpkg-distaddfile $(signing_tar) raw-signing -
0d34a427
LO
764endif
765
766build-arch-deps-$(do_flavour_image_package) += $(addprefix $(stampdir)/stamp-build-,$(flavours))
767build-arch: $(build-arch-deps-true)
768 @echo Debug: $@
769
770ifeq ($(AUTOBUILD),)
771binary-arch-deps-$(do_flavour_image_package) += binary-udebs
772else
773binary-arch-deps-$(do_flavour_image_package) = binary-debs
774endif
775binary-arch-deps-$(do_libc_dev_package) += binary-arch-headers
776ifneq ($(do_common_headers_indep),true)
777binary-arch-deps-$(do_flavour_header_package) += binary-headers
778endif
779binary-arch: $(binary-arch-deps-true)
780 @echo Debug: $@
781