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