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