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