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