1 # We don't want make removing intermediary stamps
4 # Prepare the out-of-tree build directory
5 ifeq ($(do_full_source),true)
6 build_cd = cd $(builddir)/build-$*; #
10 build_O = O=$(builddir)/build-$*
13 prepare-%: $(stampdir)/stamp-prepare-%
14 @# Empty for make to be happy
15 $(stampdir)/stamp-prepare-%: $(stampdir)/stamp-prepare-tree-% prepare-checks-%
17 $(stampdir)/stamp-prepare-tree-%: target_flavour = $*
18 $(stampdir)/stamp-prepare-tree-%: $(commonconfdir)/config.common.$(family) $(archconfdir)/config.common.$(arch) $(archconfdir)/config.flavour.%
19 @echo "Preparing $*..."
20 install -d $(builddir)/build-$*
21 touch $(builddir)/build-$*/ubuntu-build
22 [ "$(do_full_source)" != 'true' ] && true || \
23 rsync -a --exclude debian --exclude debian.master --exclude $(DEBIAN) * $(builddir)/build-$*
24 cat $^ | sed -e 's/.*CONFIG_VERSION_SIGNATURE.*/CONFIG_VERSION_SIGNATURE="Ubuntu $(release)-$(revision)-$* $(release)$(extraversion)"/' > $(builddir)/build-$*/.config
25 find $(builddir)/build-$* -name "*.ko" | xargs rm -f
26 $(build_cd) $(kmake) $(build_O) silentoldconfig prepare scripts
29 # Do the actual build, including image and modules
30 build-%: $(stampdir)/stamp-build-%
31 @# Empty for make to be happy
32 $(stampdir)/stamp-build-%: target_flavour = $*
33 $(stampdir)/stamp-build-%: prepare-%
34 @echo "Building $*..."
35 $(build_cd) $(kmake) $(build_O) $(conc_level) $(build_image)
36 $(build_cd) $(kmake) $(build_O) $(conc_level) modules
39 # Install the finished build
40 install-%: pkgdir = $(CURDIR)/debian/$(bin_pkg_name)-$*
41 install-%: bindoc = $(pkgdir)/usr/share/doc/$(bin_pkg_name)-$*
42 install-%: dbgpkgdir = $(CURDIR)/debian/$(bin_pkg_name)-$*-dbgsym
43 install-%: basepkg = $(hdrs_pkg_name)
44 install-%: hdrdir = $(CURDIR)/debian/$(basepkg)-$*/usr/src/$(basepkg)-$*
45 install-%: target_flavour = $*
46 install-%: $(stampdir)/stamp-build-% checks-%
49 dh_clean -k -p$(bin_pkg_name)-$*
50 dh_clean -k -p$(hdrs_pkg_name)-$*
51 dh_clean -k -p$(dbg_pkg_name)-$*
54 # compress_file logic required because not all architectures
55 # generate a zImage automatically out of the box
56 ifeq ($(compress_file),)
57 install -m644 -D $(builddir)/build-$*/$(kernel_file) \
58 $(pkgdir)/boot/$(install_file)-$(abi_release)-$*
60 install -d $(pkgdir)/boot
61 gzip -c9v $(builddir)/build-$*/$(kernel_file) > \
62 $(pkgdir)/boot/$(install_file)-$(abi_release)-$*
63 chmod 644 $(pkgdir)/boot/$(install_file)-$(abi_release)-$*
66 install -m644 $(builddir)/build-$*/.config \
67 $(pkgdir)/boot/config-$(abi_release)-$*
68 install -m644 $(abidir)/$* \
69 $(pkgdir)/boot/abi-$(abi_release)-$*
70 install -m644 $(builddir)/build-$*/System.map \
71 $(pkgdir)/boot/System.map-$(abi_release)-$*
72 ifeq ($(no_dumpfile),)
73 makedumpfile -g $(pkgdir)/boot/vmcoreinfo-$(abi_release)-$* \
74 -x $(builddir)/build-$*/vmlinux
77 $(build_cd) $(kmake) $(build_O) modules_install \
78 INSTALL_MOD_STRIP=1 INSTALL_MOD_PATH=$(pkgdir)/ \
79 INSTALL_FW_PATH=$(pkgdir)/lib/firmware/$(abi_release)-$*
82 # Remove all modules not in the inclusion list.
84 if [ -f $(DEBIAN)/control.d/$(target_flavour).inclusion-list ] ; then \
85 $(SHELL) $(DROOT)/scripts/module-inclusion $(pkgdir)/lib/modules/$(abi_release)-$*/kernel \
86 $(DEBIAN)/control.d/$(target_flavour).inclusion-list 2>&1 | \
87 tee $(target_flavour).inclusion-list.log; \
88 /sbin/depmod -b $(pkgdir) -ea -F $(pkgdir)/boot/System.map-$(abi_release)-$* \
89 $(abi_release)-$* 2>&1 |tee $(target_flavour).depmod.log; \
92 ifeq ($(no_dumpfile),)
93 makedumpfile -g $(pkgdir)/boot/vmcoreinfo-$(abi_release)-$* \
94 -x $(builddir)/build-$*/vmlinux
96 rm -f $(pkgdir)/lib/modules/$(abi_release)-$*/build
97 rm -f $(pkgdir)/lib/modules/$(abi_release)-$*/source
99 # Some initramfs-tools specific modules
100 install -d $(pkgdir)/lib/modules/$(abi_release)-$*/initrd
101 if [ -f $(pkgdir)/lib/modules/$(abi_release)-$*/kernel/drivers/video/vesafb.ko ]; then\
102 ln -f $(pkgdir)/lib/modules/$(abi_release)-$*/kernel/drivers/video/vesafb.ko \
103 $(pkgdir)/lib/modules/$(abi_release)-$*/initrd/; \
106 # Now the image scripts
107 install -d $(pkgdir)/DEBIAN
108 for script in postinst postrm preinst prerm; do \
109 sed -e 's/=V/$(abi_release)-$*/g' -e 's/=K/$(install_file)/g' \
110 -e 's/=L/$(loader)/g' -e 's@=B@$(build_arch)@g' \
111 $(DROOT)/control-scripts/$$script > $(pkgdir)/DEBIAN/$$script; \
112 chmod 755 $(pkgdir)/DEBIAN/$$script; \
115 # Install the full changelog.
116 ifeq ($(do_doc_package),true)
118 cat $(DEBIAN)/changelog $(DEBIAN)/changelog.historical | \
119 gzip -9 >$(bindoc)/changelog.Debian.old.gz
120 chmod 644 $(bindoc)/changelog.Debian.old.gz
123 ifneq ($(skipsub),true)
124 for sub in $($(*)_sub); do \
125 if ! (TO=$$sub FROM=$* ABI_RELEASE=$(abi_release) $(SHELL) \
126 $(DROOT)/scripts/sub-flavour); then exit 1; fi; \
127 /sbin/depmod -b debian/$(bin_pkg_name)-$$sub \
128 -ea -F debian/$(bin_pkg_name)-$$sub/boot/System.map-$(abi_release)-$* \
130 install -d debian/$(bin_pkg_name)-$$sub/DEBIAN; \
131 for script in postinst postrm preinst prerm; do \
132 sed -e 's/=V/$(abi_release)-$*/g' \
133 -e 's/=K/$(install_file)/g' \
134 -e 's/=L/$(loader)/g' \
135 -e 's@=B@$(build_arch)@g' \
136 $(DROOT)/control-scripts/$$script > \
137 debian/$(bin_pkg_name)-$$sub/DEBIAN/$$script;\
138 chmod 755 debian/$(bin_pkg_name)-$$sub/DEBIAN/$$script;\
143 ifneq ($(skipdbg),true)
144 # Debug image is simple
145 install -m644 -D $(builddir)/build-$*/vmlinux \
146 $(dbgpkgdir)/usr/lib/debug/boot/vmlinux-$(abi_release)-$*
147 $(build_cd) $(kmake) $(build_O) modules_install \
148 INSTALL_MOD_PATH=$(dbgpkgdir)/usr/lib/debug
149 rm -f $(dbgpkgdir)/usr/lib/debug/lib/modules/$(abi_release)-$*/build
150 rm -f $(dbgpkgdir)/usr/lib/debug/lib/modules/$(abi_release)-$*/source
151 rm -f $(dbgpkgdir)/usr/lib/debug/lib/modules/$(abi_release)-$*/modules.*
152 rm -fr $(dbgpkgdir)/usr/lib/debug/lib/firmware
155 # The flavour specific headers image
156 # TODO: Would be nice if we didn't have to dupe the original builddir
157 install -d -m755 $(hdrdir)
158 cat $(builddir)/build-$*/.config | \
159 sed -e 's/.*CONFIG_DEBUG_INFO=.*/# CONFIG_DEBUG_INFO is not set/g' > \
161 chmod 644 $(hdrdir)/.config
162 $(kmake) O=$(hdrdir) silentoldconfig prepare scripts
163 # We'll symlink this stuff
164 rm -f $(hdrdir)/Makefile
165 rm -rf $(hdrdir)/include2
166 # powerpc seems to need some .o files for external module linking. Add them in.
167 ifeq ($(arch),powerpc)
168 mkdir -p $(hdrdir)/arch/powerpc/lib
169 cp $(builddir)/build-$*/arch/powerpc/lib/*.o $(hdrdir)/arch/powerpc/lib
171 # Script to symlink everything up
172 $(SHELL) $(DROOT)/scripts/link-headers "$(hdrdir)" "$(basepkg)" "$*"
173 # Setup the proper asm symlink
174 rm -f $(hdrdir)/include/asm
175 ln -s asm-$(asm_link) $(hdrdir)/include/asm
177 install -d debian/$(basepkg)-$*/lib/modules/$(abi_release)-$*
178 ln -s /usr/src/$(basepkg)-$* \
179 debian/$(basepkg)-$*/lib/modules/$(abi_release)-$*/build
180 # And finally the symvers
181 install -m644 $(builddir)/build-$*/Module.symvers \
182 $(hdrdir)/Module.symvers
184 # Now the header scripts
185 install -d $(CURDIR)/debian/$(basepkg)-$*/DEBIAN
186 for script in postinst; do \
187 sed -e 's/=V/$(abi_release)-$*/g' -e 's/=K/$(install_file)/g' \
188 $(DROOT)/control-scripts/headers-$$script > \
189 $(CURDIR)/debian/$(basepkg)-$*/DEBIAN/$$script; \
190 chmod 755 $(CURDIR)/debian/$(basepkg)-$*/DEBIAN/$$script; \
193 # At the end of the package prep, call the tests
194 DPKG_ARCH="$(arch)" KERN_ARCH="$(build_arch)" FLAVOUR="$*" \
195 VERSION="$(abi_release)" REVISION="$(revision)" \
196 PREV_REVISION="$(prev_revision)" ABI_NUM="$(abinum)" \
197 PREV_ABI_NUM="$(prev_abinum)" BUILD_DIR="$(builddir)/build-$*" \
198 INSTALL_DIR="$(pkgdir)" SOURCE_DIR="$(CURDIR)" \
199 run-parts -v $(DROOT)/tests
202 # Remove files which are generated at installation by postinst,
203 # except for modules.order and modules.builtin
205 # NOTE: need to keep this list in sync with postrm
207 mkdir $(pkgdir)/lib/modules/$(abi_release)-$*/_
208 mv $(pkgdir)/lib/modules/$(abi_release)-$*/modules.order \
209 $(pkgdir)/lib/modules/$(abi_release)-$*/_
210 if [ -f $(pkgdir)/lib/modules/$(abi_release)-$*/modules.builtin ] ; then \
211 mv $(pkgdir)/lib/modules/$(abi_release)-$*/modules.builtin \
212 $(pkgdir)/lib/modules/$(abi_release)-$*/_; \
214 rm -f $(pkgdir)/lib/modules/$(abi_release)-$*/modules.*
215 mv $(pkgdir)/lib/modules/$(abi_release)-$*/_/* \
216 $(pkgdir)/lib/modules/$(abi_release)-$*
217 rmdir $(pkgdir)/lib/modules/$(abi_release)-$*/_
219 headers_tmp := $(CURDIR)/debian/tmp-headers
220 headers_dir := $(CURDIR)/debian/linux-libc-dev
222 hmake := $(MAKE) -C $(CURDIR) O=$(headers_tmp) SUBLEVEL=$(SUBLEVEL) \
223 EXTRAVERSION=-$(abinum) INSTALL_HDR_PATH=$(headers_tmp)/install \
224 SHELL="$(SHELL)" ARCH=$(header_arch)
226 install-arch-headers:
229 dh_clean -k -plinux-libc-dev
231 rm -rf $(headers_tmp)
232 install -d $(headers_tmp) $(headers_dir)/usr/include/
234 $(hmake) $(defconfig)
235 mv $(headers_tmp)/.config $(headers_tmp)/.config.old
236 sed -e 's/^# \(CONFIG_MODVERSIONS\) is not set$$/\1=y/' \
237 -e 's/.*CONFIG_LOCALVERSION_AUTO.*/# CONFIG_LOCALVERSION_AUTO is not set/' \
238 $(headers_tmp)/.config.old > $(headers_tmp)/.config
239 $(hmake) silentoldconfig
240 $(hmake) headers_install
242 ( cd $(headers_tmp)/install/include/ && \
243 find . -name '.' -o -name '.*' -prune -o -print | \
244 cpio -pvd --preserve-modification-time \
245 $(headers_dir)/usr/include/ )
247 rm -rf $(headers_tmp)
249 binary-arch-headers: install-arch-headers
252 ifeq ($(do_libc_dev_package),true)
253 ifneq ($(DEBIAN),debian.master)
254 echo "non-master branch building linux-libc-dev, aborting"
257 dh_installchangelogs -plinux-libc-dev
258 dh_installdocs -plinux-libc-dev
259 dh_compress -plinux-libc-dev
260 dh_fixperms -plinux-libc-dev
261 dh_installdeb -plinux-libc-dev
262 dh_gencontrol -plinux-libc-dev -- $(libc_dev_version)
263 dh_md5sums -plinux-libc-dev
264 dh_builddeb -plinux-libc-dev
267 binary-%: pkgimg = $(bin_pkg_name)-$*
268 binary-%: pkghdr = $(hdrs_pkg_name)-$*
269 binary-%: dbgpkg = $(bin_pkg_name)-$*-dbgsym
270 binary-%: dbgpkgdir = $(CURDIR)/debian/$(bin_pkg_name)-$*-dbgsym
275 dh_installchangelogs -p$(pkgimg)
276 dh_installdocs -p$(pkgimg)
277 dh_compress -p$(pkgimg)
278 dh_fixperms -p$(pkgimg)
279 dh_installdeb -p$(pkgimg)
280 dh_shlibdeps -p$(pkgimg)
281 dh_gencontrol -p$(pkgimg)
282 dh_md5sums -p$(pkgimg)
283 dh_builddeb -p$(pkgimg) -- -Zbzip2 -z9
285 dh_installchangelogs -p$(pkghdr)
286 dh_installdocs -p$(pkghdr)
287 dh_compress -p$(pkghdr)
288 dh_fixperms -p$(pkghdr)
289 dh_shlibdeps -p$(pkghdr)
290 dh_installdeb -p$(pkghdr)
291 dh_gencontrol -p$(pkghdr)
292 dh_md5sums -p$(pkghdr)
293 dh_builddeb -p$(pkghdr)
295 ifneq ($(skipsub),true)
296 @set -e; for sub in $($(*)_sub); do \
297 pkg=$(bin_pkg_name)-$$sub; \
298 dh_installchangelogs -p$$pkg; \
299 dh_installdocs -p$$pkg; \
300 dh_compress -p$$pkg; \
301 dh_fixperms -p$$pkg; \
302 dh_shlibdeps -p$$pkg; \
303 dh_installdeb -p$$pkg; \
304 dh_gencontrol -p$$pkg; \
305 dh_md5sums -p$$pkg; \
306 dh_builddeb -p$$pkg; \
310 ifneq ($(skipdbg),true)
311 dh_installchangelogs -p$(dbgpkg)
312 dh_installdocs -p$(dbgpkg)
313 dh_compress -p$(dbgpkg)
314 dh_fixperms -p$(dbgpkg)
315 dh_installdeb -p$(dbgpkg)
316 dh_gencontrol -p$(dbgpkg)
317 dh_md5sums -p$(dbgpkg)
318 dh_builddeb -p$(dbgpkg)
320 # Hokay...here's where we do a little twiddling...
321 # Renaming the debug package prevents it from getting into
322 # the primary archive, and therefore prevents this very large
323 # package from being mirrored. It is instead, through some
324 # archive admin hackery, copied to http://ddebs.ubuntu.com.
326 mv ../$(dbgpkg)_$(release)-$(revision)_$(arch).deb \
327 ../$(dbgpkg)_$(release)-$(revision)_$(arch).ddeb
329 if grep -qs '^Build-Debug-Symbols: yes$$' /CurrentlyBuilding; then \
330 sed -i '/^$(dbgpkg)_/s/\.deb /.ddeb /' debian/files; \
332 grep -v '^$(dbgpkg)_.*$$' debian/files > debian/files.new; \
333 mv debian/files.new debian/files; \
335 # Now, the package wont get into the archive, but it will get put
336 # into the debug system.
338 ifneq ($(full_build),false)
339 # Clean out this flavours build directory.
340 rm -rf $(builddir)/build-$*
341 # Clean out the debugging package source directory.
345 $(stampdir)/stamp-flavours:
346 @echo $(flavours) > $@
349 # per-architecture packages
351 $(stampdir)/stamp-prepare-perarch:
352 @echo "Preparing perarch ..."
353 ifeq ($(do_tools),true)
354 install -d $(builddir)/tools-$*
355 for i in *; do ln -s $(CURDIR)/$$i $(builddir)/tools-$*/; done
356 rm $(builddir)/tools-$*/tools
357 rsync -a tools/ $(builddir)/tools-$*/tools/
361 $(stampdir)/stamp-build-perarch: prepare-perarch
362 ifeq ($(do_tools),true)
363 cd $(builddir)/tools-$*/tools/perf && make
367 install-perarch: toolspkgdir = $(CURDIR)/debian/$(tools_pkg_name)
368 install-perarch: $(stampdir)/stamp-build-perarch
370 ifeq ($(do_tools),true)
371 install -d $(toolspkgdir)/usr/bin
372 install -s -m755 $(builddir)/tools-$*/tools/perf/perf \
373 $(toolspkgdir)/usr/bin/perf_$(abi_release)
376 binary-perarch: toolspkg = $(tools_pkg_name)
377 binary-perarch: install-perarch
378 @# Empty for make to be happy
379 ifeq ($(do_tools),true)
380 dh_installchangelogs -p$(toolspkg)
381 dh_installdocs -p$(toolspkg)
382 dh_compress -p$(toolspkg)
383 dh_fixperms -p$(toolspkg)
384 dh_shlibdeps -p$(toolspkg)
385 dh_installdeb -p$(toolspkg)
386 dh_gencontrol -p$(toolspkg)
387 dh_md5sums -p$(toolspkg)
388 dh_builddeb -p$(toolspkg)
391 binary-debs: binary-perarch $(stampdir)/stamp-flavours $(addprefix binary-,$(flavours))
393 build-arch-deps-$(do_flavour_image_package) += $(addprefix build-,$(flavours))
394 build-arch: $(build-arch-deps-true)
396 binary-arch-deps-$(do_flavour_image_package) = binary-debs
398 binary-arch-deps-$(do_flavour_image_package) += binary-udebs
400 binary-arch-deps-$(do_libc_dev_package) += binary-arch-headers
401 ifneq ($(do_common_headers_indep),true)
402 binary-arch-deps-$(do_flavour_header_package) += binary-headers
404 binary-arch: $(binary-arch-deps-true)