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