]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blob - debian/rules.d/2-binary-arch.mk
pktcdvd: Fix possible Spectre-v1 for pkt_devs
[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-%: pkgdir_bldinfo = $(CURDIR)/debian/$(bldinfo_pkg_name)-$*
101 install-%: bindoc = $(pkgdir)/usr/share/doc/$(bin_pkg_name)-$*
102 install-%: dbgpkgdir = $(CURDIR)/debian/$(bin_pkg_name)-$*-dbgsym
103 install-%: signingv = $(CURDIR)/debian/$(bin_pkg_name)-signing/$(release)-$(revision)
104 install-%: toolspkgdir = $(CURDIR)/debian/$(tools_flavour_pkg_name)-$*
105 install-%: cloudpkgdir = $(CURDIR)/debian/$(cloud_flavour_pkg_name)-$*
106 install-%: basepkg = $(hdrs_pkg_name)
107 install-%: indeppkg = $(indep_hdrs_pkg_name)
108 install-%: kernfile = $(call custom_override,kernel_file,$*)
109 install-%: instfile = $(call custom_override,install_file,$*)
110 install-%: hdrdir = $(CURDIR)/debian/$(basepkg)-$*/usr/src/$(basepkg)-$*
111 install-%: target_flavour = $*
112 install-%: MODHASHALGO=sha512
113 install-%: MODSECKEY=$(builddir)/build-$*/certs/signing_key.pem
114 install-%: MODPUBKEY=$(builddir)/build-$*/certs/signing_key.x509
115 install-%: build_dir=$(builddir)/build-$*
116 install-%: enable_zfs = $(call custom_override,do_zfs,$*)
117 install-%: splopts = INSTALL_MOD_STRIP=1
118 install-%: splopts += INSTALL_MOD_PATH=$(pkgdir)/
119 install-%: splopts += INSTALL_MOD_DIR=kernel/zfs
120 install-%: splopts += $(conc_level)
121 install-%: zfsopts = $(splopts)
122 install-%: $(stampdir)/stamp-build-%
123 @echo Debug: $@ kernel_file $(kernel_file) kernfile $(kernfile) install_file $(install_file) instfile $(instfile)
124 dh_testdir
125 dh_testroot
126 dh_prep -p$(bin_pkg_name)-$*
127 dh_prep -p$(mods_pkg_name)-$*
128 dh_prep -p$(hdrs_pkg_name)-$*
129 ifneq ($(skipdbg),true)
130 dh_prep -p$(bin_pkg_name)-$*-dbgsym
131 endif
132
133 # The main image
134 # compress_file logic required because not all architectures
135 # generate a zImage automatically out of the box
136 ifeq ($(compress_file),)
137 install -m600 -D $(builddir)/build-$*/$(kernfile) \
138 $(pkgdir_bin)/boot/$(instfile)-$(abi_release)-$*
139 else
140 install -d $(pkgdir_bin)/boot
141 gzip -c9v $(builddir)/build-$*/$(kernfile) > \
142 $(pkgdir_bin)/boot/$(instfile)-$(abi_release)-$*
143 chmod 600 $(pkgdir_bin)/boot/$(instfile)-$(abi_release)-$*
144 endif
145
146 ifeq ($(uefi_signed),true)
147 install -d $(signingv)
148 # Check to see if this supports handoff, if not do not sign it.
149 # Check the identification area magic and version >= 0x020b
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" }'`; \
151 if [ "$$handoff" = "GOOD" ]; then \
152 cp -p $(pkgdir_bin)/boot/$(instfile)-$(abi_release)-$* \
153 $(signingv)/$(instfile)-$(abi_release)-$*.efi; \
154 fi
155 endif
156 ifeq ($(opal_signed),true)
157 install -d $(signingv)
158 cp -p $(pkgdir_bin)/boot/$(instfile)-$(abi_release)-$* \
159 $(signingv)/$(instfile)-$(abi_release)-$*.opal;
160 endif
161
162 install -d $(pkgdir)/boot
163 install -m644 $(builddir)/build-$*/.config \
164 $(pkgdir)/boot/config-$(abi_release)-$*
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
175 ifeq ($(no_dumpfile),)
176 makedumpfile -g $(pkgdir)/boot/vmcoreinfo-$(abi_release)-$* \
177 -x $(builddir)/build-$*/vmlinux
178 chmod 0600 $(pkgdir)/boot/vmcoreinfo-$(abi_release)-$*
179 endif
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/ | \
203 grep -v '^bcm2835_wdt$$' | \
204 sed -e 's/^/blacklist /' -e 's/.ko$$//' | \
205 sort -u \
206 >>$(pkgdir)/lib/modprobe.d/blacklist_$(src_pkg_name)_$(abi_release)-$*.conf
207
208 ifeq ($(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
232 endif
233
234 ifeq ($(no_dumpfile),)
235 makedumpfile -g $(pkgdir)/boot/vmcoreinfo-$(abi_release)-$* \
236 -x $(builddir)/build-$*/vmlinux
237 chmod 0600 $(pkgdir)/boot/vmcoreinfo-$(abi_release)-$*
238 endif
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
249 echo "interest linux-update-$(abi_release)-$*" >"$(DROOT)/$(bin_pkg_name)-$*.triggers"
250 install -d $(pkgdir_bin)/usr/lib/linux/triggers
251 $(call install_control,$(bin_pkg_name)-$*,image,postinst postrm preinst prerm)
252 install -d $(pkgdir)/usr/lib/linux/triggers
253 $(call install_control,$(mods_pkg_name)-$*,extra,postinst postrm)
254 ifeq ($(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 \
257 install -d $(pkgdir_ex)/usr/lib/linux/triggers; \
258 $(call install_control,$(mods_extra_pkg_name)-$*,extra,postinst postrm); \
259 fi
260 endif
261
262 # Install the full changelog.
263 ifeq ($(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
268 endif
269
270 ifneq ($(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)-$*; \
277 $(call install_control,$(bin_pkg_name)--$$sub,image,postinst postrm preinst prerm); \
278 done
279 endif
280
281 ifneq ($(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
306 endif
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
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.
327 ifeq ($(build_arch),powerpc)
328 mkdir -p $(hdrdir)/arch/powerpc/lib
329 cp $(builddir)/build-$*/arch/powerpc/lib/*.o $(hdrdir)/arch/powerpc/lib
330 endif
331 # Copy over the new retpoline extractor.
332 cp scripts/ubuntu-retpoline-extract-one $(hdrdir)/scripts
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
344 $(call install_control,$(hdrs_pkg_name)-$*,headers,postinst)
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
372 ifeq ($(do_linux_tools),true)
373 # Create the linux-tools tool links
374 install -d $(toolspkgdir)/usr/lib/linux-tools/$(abi_release)-$*
375 ifeq ($(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)-$*
378 endif
379 ifeq ($(do_tools_acpidbg),true)
380 $(LN) ../../$(src_pkg_name)-tools-$(abi_release)/acpidbg $(toolspkgdir)/usr/lib/linux-tools/$(abi_release)-$*
381 endif
382 ifeq ($(do_tools_cpupower),true)
383 $(LN) ../../$(src_pkg_name)-tools-$(abi_release)/cpupower $(toolspkgdir)/usr/lib/linux-tools/$(abi_release)-$*
384 endif
385 ifeq ($(do_tools_perf),true)
386 $(LN) ../../$(src_pkg_name)-tools-$(abi_release)/perf $(toolspkgdir)/usr/lib/linux-tools/$(abi_release)-$*
387 endif
388 ifeq ($(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)-$*
391 endif
392 endif
393 ifeq ($(do_cloud_tools),true)
394 ifeq ($(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)-$*
401 endif
402 endif
403
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 firmware information.
414 find $(pkgdir_bin) $(pkgdir) $(pkgdir_ex) -name \*.ko | \
415 while read ko; do \
416 /sbin/modinfo $$ko | grep ^firmware || true; \
417 done | sort -u >$(abidir)/$*.fwinfo
418
419 # Build the final ABI compiler information.
420 ko=$$(find $(pkgdir_bin) $(pkgdir) $(pkgdir_ex) -name \*.ko | head -1); \
421 readelf -p .comment "$$ko" | gawk ' \
422 ($$1 == "[") { \
423 printf("%s", $$3); \
424 for (n=4; n<=NF; n++) { \
425 printf(" %s", $$n); \
426 } \
427 print "" \
428 }' | sort -u >$(abidir)/$*.compiler
429
430 # Build the final ABI retpoline information.
431 if grep -q CONFIG_RETPOLINE=y $(builddir)/build-$*/.config; then \
432 echo "# retpoline v1.0" >$(abidir)/$*.retpoline; \
433 $(SHELL) $(DROOT)/scripts/retpoline-extract $(builddir)/build-$* $(CURDIR) | \
434 sort >>$(abidir)/$*.retpoline; \
435 else \
436 echo "# RETPOLINE NOT ENABLED" >$(abidir)/$*.retpoline; \
437 fi
438
439 # Build the buildinfo package content.
440 install -d $(pkgdir_bldinfo)/usr/lib/linux/$(abi_release)-$*
441 install -m644 $(builddir)/build-$*/.config \
442 $(pkgdir_bldinfo)/usr/lib/linux/$(abi_release)-$*/config
443 install -m644 $(abidir)/$* \
444 $(pkgdir_bldinfo)/usr/lib/linux/$(abi_release)-$*/abi
445 install -m644 $(abidir)/$*.modules \
446 $(pkgdir_bldinfo)/usr/lib/linux/$(abi_release)-$*/modules
447 install -m644 $(abidir)/$*.fwinfo \
448 $(pkgdir_bldinfo)/usr/lib/linux/$(abi_release)-$*/fwinfo
449 install -m644 $(abidir)/$*.retpoline \
450 $(pkgdir_bldinfo)/usr/lib/linux/$(abi_release)-$*/retpoline
451 install -m644 $(abidir)/$*.compiler \
452 $(pkgdir_bldinfo)/usr/lib/linux/$(abi_release)-$*/compiler
453
454 headers_tmp := $(CURDIR)/debian/tmp-headers
455 headers_dir := $(CURDIR)/debian/linux-libc-dev
456
457 hmake := $(MAKE) -C $(CURDIR) O=$(headers_tmp) \
458 KERNELVERSION=$(abi_release) INSTALL_HDR_PATH=$(headers_tmp)/install \
459 SHELL="$(SHELL)" ARCH=$(header_arch)
460
461 install-arch-headers:
462 @echo Debug: $@
463 dh_testdir
464 dh_testroot
465 ifeq ($(do_libc_dev_package),true)
466 dh_prep -plinux-libc-dev
467 endif
468
469 rm -rf $(headers_tmp)
470 install -d $(headers_tmp) $(headers_dir)/usr/include/
471
472 $(hmake) $(defconfig)
473 mv $(headers_tmp)/.config $(headers_tmp)/.config.old
474 sed -e 's/^# \(CONFIG_MODVERSIONS\) is not set$$/\1=y/' \
475 -e 's/.*CONFIG_LOCALVERSION_AUTO.*/# CONFIG_LOCALVERSION_AUTO is not set/' \
476 $(headers_tmp)/.config.old > $(headers_tmp)/.config
477 $(hmake) silentoldconfig
478 $(hmake) headers_install
479
480 ( cd $(headers_tmp)/install/include/ && \
481 find . -name '.' -o -name '.*' -prune -o -print | \
482 cpio -pvd --preserve-modification-time \
483 $(headers_dir)/usr/include/ )
484 mkdir $(headers_dir)/usr/include/$(DEB_HOST_MULTIARCH)
485 mv $(headers_dir)/usr/include/asm $(headers_dir)/usr/include/$(DEB_HOST_MULTIARCH)/
486
487 rm -rf $(headers_tmp)
488
489 define dh_all
490 dh_installchangelogs -p$(1)
491 dh_installdocs -p$(1)
492 dh_compress -p$(1)
493 dh_fixperms -p$(1) -X/boot/
494 dh_shlibdeps -p$(1) $(shlibdeps_opts)
495 dh_installdeb -p$(1)
496 dh_installdebconf -p$(1)
497 $(lockme) dh_gencontrol -p$(1) -- -Vlinux:rprovides='$(rprovides)'
498 dh_md5sums -p$(1)
499 dh_builddeb -p$(1)
500 endef
501 define newline
502
503
504 endef
505 define dh_all_inline
506 $(subst ${newline},; \${newline},$(call dh_all,$(1)))
507 endef
508
509 binary-arch-headers: install-arch-headers
510 @echo Debug: $@
511 dh_testdir
512 dh_testroot
513 ifeq ($(do_libc_dev_package),true)
514 ifneq ($(DEBIAN),debian.master)
515 echo "non-master branch building linux-libc-dev, aborting"
516 exit 1
517 endif
518 $(call dh_all,linux-libc-dev)
519 endif
520
521 binary-%: pkgimg = $(bin_pkg_name)-$*
522 binary-%: pkgimg_mods = $(mods_pkg_name)-$*
523 binary-%: pkgimg_ex = $(mods_extra_pkg_name)-$*
524 binary-%: pkgdir_ex = $(CURDIR)/debian/$(extra_pkg_name)-$*
525 binary-%: pkgbldinfo = $(bldinfo_pkg_name)-$*
526 binary-%: pkghdr = $(hdrs_pkg_name)-$*
527 binary-%: dbgpkg = $(bin_pkg_name)-$*-dbgsym
528 binary-%: dbgpkgdir = $(CURDIR)/debian/$(bin_pkg_name)-$*-dbgsym
529 binary-%: pkgtools = $(tools_flavour_pkg_name)-$*
530 binary-%: pkgcloud = $(cloud_flavour_pkg_name)-$*
531 binary-%: rprovides = $(if $(filter true,$(call custom_override,do_zfs,$*)),$(comma) spl-modules$(comma) spl-dkms$(comma) zfs-modules$(comma) zfs-dkms)
532 binary-%: target_flavour = $*
533 binary-%: checks-%
534 @echo Debug: $@
535 dh_testdir
536 dh_testroot
537
538 $(call dh_all,$(pkgimg))
539 $(call dh_all,$(pkgimg_mods))
540
541 ifeq ($(do_extras_package),true)
542 ifeq ($(ship_extras_package),false)
543 # If $(ship_extras_package) is explicitly set to false, then do not
544 # construct the linux-image-extra package; instead just log all of the
545 # "extra" modules which were pointlessly built yet won't be shipped.
546 find $(pkgdir_ex) -name '*.ko' | sort \
547 | sed 's|^$(pkgdir_ex)/|NOT-SHIPPED |' \
548 | tee -a $(target_flavour).not-shipped.log;
549 else
550 if [ -f $(DEBIAN)/control.d/$(target_flavour).inclusion-list ] ; then \
551 $(call dh_all_inline,$(pkgimg_ex)); \
552 fi
553 endif
554 endif
555
556 $(call dh_all,$(pkgbldinfo))
557 $(call dh_all,$(pkghdr))
558
559 ifneq ($(skipsub),true)
560 @set -e; for sub in $($(*)_sub); do \
561 pkg=$(bin_pkg_name)-$$sub; \
562 $(call dh_all_inline,$$pkg); \
563 done
564 endif
565
566 ifneq ($(skipdbg),true)
567 $(call dh_all,$(dbgpkg))
568
569 # Hokay...here's where we do a little twiddling...
570 # Renaming the debug package prevents it from getting into
571 # the primary archive, and therefore prevents this very large
572 # package from being mirrored. It is instead, through some
573 # archive admin hackery, copied to http://ddebs.ubuntu.com.
574 #
575 mv ../$(dbgpkg)_$(release)-$(revision)_$(arch).deb \
576 ../$(dbgpkg)_$(release)-$(revision)_$(arch).ddeb
577 set -e; \
578 ( \
579 $(lockme_cmd) 9 || exit 1; \
580 if grep -qs '^Build-Debug-Symbols: yes$$' /CurrentlyBuilding; then \
581 sed -i '/^$(dbgpkg)_/s/\.deb /.ddeb /' debian/files; \
582 else \
583 grep -v '^$(dbgpkg)_.*$$' debian/files > debian/files.new; \
584 mv debian/files.new debian/files; \
585 fi; \
586 ) 9>$(lockme_file)
587 # Now, the package wont get into the archive, but it will get put
588 # into the debug system.
589 endif
590
591 ifeq ($(do_linux_tools),true)
592 $(call dh_all,$(pkgtools))
593 endif
594 ifeq ($(do_cloud_tools),true)
595 $(call dh_all,$(pkgcloud))
596 endif
597
598 ifneq ($(full_build),false)
599 # Clean out this flavours build directory.
600 rm -rf $(builddir)/build-$*
601 # Clean out the debugging package source directory.
602 rm -rf $(dbgpkgdir)
603 endif
604
605 #
606 # per-architecture packages
607 #
608 builddirpa = $(builddir)/tools-perarch
609
610 $(stampdir)/stamp-prepare-perarch:
611 @echo Debug: $@
612 ifeq ($(do_any_tools),true)
613 rm -rf $(builddirpa)
614 install -d $(builddirpa)
615 rsync -a --exclude debian --exclude debian.master --exclude $(DEBIAN) --exclude .git -a ./ $(builddirpa)/
616 endif
617 touch $@
618
619 $(stampdir)/stamp-build-perarch: $(stampdir)/stamp-prepare-perarch install-arch-headers
620 @echo Debug: $@
621 ifeq ($(do_linux_tools),true)
622 ifeq ($(do_tools_usbip),true)
623 chmod 755 $(builddirpa)/tools/usb/usbip/autogen.sh
624 cd $(builddirpa)/tools/usb/usbip && ./autogen.sh
625 chmod 755 $(builddirpa)/tools/usb/usbip/configure
626 cd $(builddirpa)/tools/usb/usbip && ./configure --prefix=$(builddirpa)/tools/usb/usbip/bin
627 cd $(builddirpa)/tools/usb/usbip && make install CFLAGS="-g -O2 -static" CROSS_COMPILE=$(CROSS_COMPILE)
628 endif
629 ifeq ($(do_tools_acpidbg),true)
630 cd $(builddirpa)/tools/power/acpi && make clean && make CFLAGS="-g -O2 -static -I$(builddirpa)/include" CROSS_COMPILE=$(CROSS_COMPILE) acpidbg
631 endif
632 ifeq ($(do_tools_cpupower),true)
633 # Allow for multiple installed versions of cpupower and libcpupower.so:
634 # Override LIB_MIN in order to to generate a versioned .so named
635 # libcpupower.so.$(abi_release) and link cpupower with that.
636 make -C $(builddirpa)/tools/power/cpupower \
637 CROSS_COMPILE=$(CROSS_COMPILE) \
638 CROSS=$(CROSS_COMPILE) \
639 LIB_MIN=$(abi_release) CPUFREQ_BENCH=false
640 endif
641 ifeq ($(do_tools_perf),true)
642 cd $(builddirpa) && $(kmake) $(defconfig)
643 mv $(builddirpa)/.config $(builddirpa)/.config.old
644 sed -e 's/^# \(CONFIG_MODVERSIONS\) is not set$$/\1=y/' \
645 -e 's/.*CONFIG_LOCALVERSION_AUTO.*/# CONFIG_LOCALVERSION_AUTO is not set/' \
646 $(builddirpa)/.config.old > $(builddirpa)/.config
647 cd $(builddirpa) && $(kmake) silentoldconfig
648 cd $(builddirpa) && $(kmake) prepare
649 cd $(builddirpa)/tools/perf && \
650 $(kmake) prefix=/usr HAVE_NO_LIBBFD=1 HAVE_CPLUS_DEMANGLE_SUPPORT=1 CROSS_COMPILE=$(CROSS_COMPILE) NO_LIBPYTHON=1 NO_LIBPERL=1 PYTHON=python2.7
651 endif
652 ifeq ($(do_tools_x86),true)
653 cd $(builddirpa)/tools/power/x86/x86_energy_perf_policy && make CROSS_COMPILE=$(CROSS_COMPILE)
654 cd $(builddirpa)/tools/power/x86/turbostat && make CROSS_COMPILE=$(CROSS_COMPILE)
655 endif
656 endif
657 ifeq ($(do_cloud_tools),true)
658 ifeq ($(do_tools_hyperv),true)
659 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
660 endif
661 endif
662 @touch $@
663
664 install-perarch: toolspkgdir = $(CURDIR)/debian/$(tools_pkg_name)
665 install-perarch: cloudpkgdir = $(CURDIR)/debian/$(cloud_pkg_name)
666 install-perarch: $(stampdir)/stamp-build-perarch
667 @echo Debug: $@
668 # Add the tools.
669 ifeq ($(do_linux_tools),true)
670 install -d $(toolspkgdir)/usr/lib
671 install -d $(toolspkgdir)/usr/lib/$(src_pkg_name)-tools-$(abi_release)
672 ifeq ($(do_tools_usbip),true)
673 install -m755 $(builddirpa)/tools/usb/usbip/bin/sbin/usbip \
674 $(toolspkgdir)/usr/lib/$(src_pkg_name)-tools-$(abi_release)
675 install -m755 $(builddirpa)/tools/usb/usbip/bin/sbin/usbipd \
676 $(toolspkgdir)/usr/lib/$(src_pkg_name)-tools-$(abi_release)
677 endif
678 ifeq ($(do_tools_acpidbg),true)
679 install -m755 $(builddirpa)/tools/power/acpi/acpidbg \
680 $(toolspkgdir)/usr/lib/$(src_pkg_name)-tools-$(abi_release)
681 endif
682 ifeq ($(do_tools_cpupower),true)
683 install -m755 $(builddirpa)/tools/power/cpupower/cpupower \
684 $(toolspkgdir)/usr/lib/$(src_pkg_name)-tools-$(abi_release)
685 # Install only the full versioned libcpupower.so.$(abi_release), not
686 # the usual symlinks to it.
687 install -m644 $(builddirpa)/tools/power/cpupower/libcpupower.so.$(abi_release) \
688 $(toolspkgdir)/usr/lib/
689 endif
690 ifeq ($(do_tools_perf),true)
691 install -m755 $(builddirpa)/tools/perf/perf $(toolspkgdir)/usr/lib/$(src_pkg_name)-tools-$(abi_release)
692 endif
693 ifeq ($(do_tools_x86),true)
694 install -m755 $(builddirpa)/tools/power/x86/x86_energy_perf_policy/x86_energy_perf_policy \
695 $(toolspkgdir)/usr/lib/$(src_pkg_name)-tools-$(abi_release)
696 install -m755 $(builddirpa)/tools/power/x86/turbostat/turbostat \
697 $(toolspkgdir)/usr/lib/$(src_pkg_name)-tools-$(abi_release)
698 endif
699 endif
700 ifeq ($(do_cloud_tools),true)
701 ifeq ($(do_tools_hyperv),true)
702 install -d $(cloudpkgdir)/usr/lib
703 install -d $(cloudpkgdir)/usr/lib/$(src_pkg_name)-tools-$(abi_release)
704 install -m755 $(builddirpa)/tools/hv/hv_kvp_daemon \
705 $(cloudpkgdir)/usr/lib/$(src_pkg_name)-tools-$(abi_release)
706 install -m755 $(builddirpa)/tools/hv/hv_vss_daemon \
707 $(cloudpkgdir)/usr/lib/$(src_pkg_name)-tools-$(abi_release)
708 install -m755 $(builddirpa)/tools/hv/hv_fcopy_daemon \
709 $(cloudpkgdir)/usr/lib/$(src_pkg_name)-tools-$(abi_release)
710 install -m755 $(builddirpa)/tools/hv/lsvmbus \
711 $(cloudpkgdir)/usr/lib/$(src_pkg_name)-tools-$(abi_release)
712 endif
713 endif
714
715 binary-perarch: toolspkg = $(tools_pkg_name)
716 binary-perarch: cloudpkg = $(cloud_pkg_name)
717 binary-perarch: install-perarch
718 @echo Debug: $@
719 ifeq ($(do_linux_tools),true)
720 $(call dh_all,$(toolspkg))
721 endif
722 ifeq ($(do_cloud_tools),true)
723 $(call dh_all,$(cloudpkg))
724 endif
725
726 binary-debs: signing = $(CURDIR)/debian/$(bin_pkg_name)-signing
727 binary-debs: signingv = $(CURDIR)/debian/$(bin_pkg_name)-signing/$(release)-$(revision)
728 binary-debs: signing_tar = $(src_pkg_name)_$(release)-$(revision)_$(arch).tar.gz
729 binary-debs: binary-perarch $(addprefix binary-,$(flavours))
730 @echo Debug: $@
731 ifeq ($(any_signed),true)
732 install -d $(signingv)/control
733 { echo "tarball"; } >$(signingv)/control/options
734 cd $(signing) && tar czvf ../../../$(signing_tar) .
735 dpkg-distaddfile $(signing_tar) raw-signing -
736 endif
737
738 build-arch-deps-$(do_flavour_image_package) += $(addprefix $(stampdir)/stamp-build-,$(flavours))
739 build-arch: $(build-arch-deps-true)
740 @echo Debug: $@
741
742 ifeq ($(AUTOBUILD),)
743 binary-arch-deps-$(do_flavour_image_package) += binary-udebs
744 else
745 binary-arch-deps-$(do_flavour_image_package) = binary-debs
746 endif
747 binary-arch-deps-$(do_libc_dev_package) += binary-arch-headers
748 ifneq ($(do_common_headers_indep),true)
749 binary-arch-deps-$(do_flavour_header_package) += binary-headers
750 endif
751 binary-arch: $(binary-arch-deps-true)
752 @echo Debug: $@
753