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