UBUNTU: [Config] Force perf to use libiberty for demangling
[linux-flexiantxendom0-natty.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 prepare-%: $(stampdir)/stamp-prepare-%
14         @# Empty for make to be happy
15 $(stampdir)/stamp-prepare-%: $(stampdir)/stamp-prepare-tree-% prepare-checks-%
16         @touch $@
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
27         touch $@
28
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
37         @touch $@
38
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-%
47         dh_testdir
48         dh_testroot
49         dh_clean -k -p$(bin_pkg_name)-$*
50         dh_clean -k -p$(hdrs_pkg_name)-$*
51         dh_clean -k -p$(dbg_pkg_name)-$*
52
53         # The main image
54         # compress_file logic required because not all architectures
55         # generate a zImage automatically out of the box
56 ifeq ($(compress_file),)
57         install -m600 -D $(builddir)/build-$*/$(kernel_file) \
58                 $(pkgdir)/boot/$(install_file)-$(abi_release)-$*
59 else
60         install -d $(pkgdir)/boot
61         gzip -c9v $(builddir)/build-$*/$(kernel_file) > \
62                 $(pkgdir)/boot/$(install_file)-$(abi_release)-$*
63         chmod 600 $(pkgdir)/boot/$(install_file)-$(abi_release)-$*
64 endif
65
66         install -m644 $(builddir)/build-$*/.config \
67                 $(pkgdir)/boot/config-$(abi_release)-$*
68         install -m644 $(abidir)/$* \
69                 $(pkgdir)/boot/abi-$(abi_release)-$*
70         install -m600 $(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
75         chmod 0600 $(pkgdir)/boot/vmcoreinfo-$(abi_release)-$*
76 endif
77
78         $(build_cd) $(kmake) $(build_O) modules_install \
79                 INSTALL_MOD_STRIP=1 INSTALL_MOD_PATH=$(pkgdir)/ \
80                 INSTALL_FW_PATH=$(pkgdir)/lib/firmware/$(abi_release)-$*
81
82         #
83         # Remove all modules not in the inclusion list.
84         #
85         if [ -f $(DEBIAN)/control.d/$(target_flavour).inclusion-list ] ; then \
86                 $(SHELL) $(DROOT)/scripts/module-inclusion $(pkgdir)/lib/modules/$(abi_release)-$*/kernel \
87                         $(DEBIAN)/control.d/$(target_flavour).inclusion-list 2>&1 | \
88                                 tee $(target_flavour).inclusion-list.log; \
89                 /sbin/depmod -b $(pkgdir) -ea -F $(pkgdir)/boot/System.map-$(abi_release)-$* \
90                         $(abi_release)-$* 2>&1 |tee $(target_flavour).depmod.log; \
91         fi
92
93 ifeq ($(no_dumpfile),)
94         makedumpfile -g $(pkgdir)/boot/vmcoreinfo-$(abi_release)-$* \
95                 -x $(builddir)/build-$*/vmlinux
96         chmod 0600 $(pkgdir)/boot/vmcoreinfo-$(abi_release)-$*
97 endif
98         rm -f $(pkgdir)/lib/modules/$(abi_release)-$*/build
99         rm -f $(pkgdir)/lib/modules/$(abi_release)-$*/source
100
101         # Some initramfs-tools specific modules
102         install -d $(pkgdir)/lib/modules/$(abi_release)-$*/initrd
103         if [ -f $(pkgdir)/lib/modules/$(abi_release)-$*/kernel/drivers/video/vesafb.ko ]; then\
104           ln -f $(pkgdir)/lib/modules/$(abi_release)-$*/kernel/drivers/video/vesafb.ko \
105                 $(pkgdir)/lib/modules/$(abi_release)-$*/initrd/; \
106         fi
107
108         # Now the image scripts
109         install -d $(pkgdir)/DEBIAN
110         for script in postinst postrm preinst prerm; do                         \
111           sed -e 's/=V/$(abi_release)-$*/g' -e 's/=K/$(install_file)/g'         \
112               -e 's/=L/$(loader)/g'         -e 's@=B@$(build_arch)@g'           \
113                $(DROOT)/control-scripts/$$script > $(pkgdir)/DEBIAN/$$script;   \
114           chmod 755 $(pkgdir)/DEBIAN/$$script;                                  \
115         done
116
117         # Install the full changelog.
118 ifeq ($(do_doc_package),true)
119         install -d $(bindoc)
120         cat $(DEBIAN)/changelog $(DEBIAN)/changelog.historical | \
121                 gzip -9 >$(bindoc)/changelog.Debian.old.gz
122         chmod 644 $(bindoc)/changelog.Debian.old.gz
123 endif
124
125 ifneq ($(skipsub),true)
126         for sub in $($(*)_sub); do                                      \
127                 if ! (TO=$$sub FROM=$* ABI_RELEASE=$(abi_release) $(SHELL)              \
128                         $(DROOT)/scripts/sub-flavour); then exit 1; fi;         \
129                 /sbin/depmod -b debian/$(bin_pkg_name)-$$sub            \
130                         -ea -F debian/$(bin_pkg_name)-$$sub/boot/System.map-$(abi_release)-$* \
131                         $(abi_release)-$*;                                      \
132                 install -d debian/$(bin_pkg_name)-$$sub/DEBIAN; \
133                 for script in postinst postrm preinst prerm; do                 \
134                         sed -e 's/=V/$(abi_release)-$*/g'                       \
135                             -e 's/=K/$(install_file)/g'                         \
136                             -e 's/=L/$(loader)/g'                               \
137                             -e 's@=B@$(build_arch)@g'                           \
138                                 $(DROOT)/control-scripts/$$script >             \
139                                 debian/$(bin_pkg_name)-$$sub/DEBIAN/$$script;\
140                         chmod 755  debian/$(bin_pkg_name)-$$sub/DEBIAN/$$script;\
141                 done;                                                           \
142         done
143 endif
144
145 ifneq ($(skipdbg),true)
146         # Debug image is simple
147         install -m644 -D $(builddir)/build-$*/vmlinux \
148                 $(dbgpkgdir)/usr/lib/debug/boot/vmlinux-$(abi_release)-$*
149         $(build_cd) $(kmake) $(build_O) modules_install \
150                 INSTALL_MOD_PATH=$(dbgpkgdir)/usr/lib/debug
151         rm -f $(dbgpkgdir)/usr/lib/debug/lib/modules/$(abi_release)-$*/build
152         rm -f $(dbgpkgdir)/usr/lib/debug/lib/modules/$(abi_release)-$*/source
153         rm -f $(dbgpkgdir)/usr/lib/debug/lib/modules/$(abi_release)-$*/modules.*
154         rm -fr $(dbgpkgdir)/usr/lib/debug/lib/firmware
155 endif
156
157         # The flavour specific headers image
158         # TODO: Would be nice if we didn't have to dupe the original builddir
159         install -d -m755 $(hdrdir)
160         cat $(builddir)/build-$*/.config | \
161                 sed -e 's/.*CONFIG_DEBUG_INFO=.*/# CONFIG_DEBUG_INFO is not set/g' > \
162                 $(hdrdir)/.config
163         chmod 644 $(hdrdir)/.config
164         $(kmake) O=$(hdrdir) silentoldconfig prepare scripts
165         # We'll symlink this stuff
166         rm -f $(hdrdir)/Makefile
167         rm -rf $(hdrdir)/include2
168         # powerpc seems to need some .o files for external module linking. Add them in.
169 ifeq ($(arch),powerpc)
170         mkdir -p $(hdrdir)/arch/powerpc/lib
171         cp $(builddir)/build-$*/arch/powerpc/lib/*.o $(hdrdir)/arch/powerpc/lib
172 endif
173         # Script to symlink everything up
174         $(SHELL) $(DROOT)/scripts/link-headers "$(hdrdir)" "$(basepkg)" "$*"
175         # Setup the proper asm symlink
176         rm -f $(hdrdir)/include/asm
177         ln -s asm-$(asm_link) $(hdrdir)/include/asm
178         # The build symlink
179         install -d debian/$(basepkg)-$*/lib/modules/$(abi_release)-$*
180         ln -s /usr/src/$(basepkg)-$* \
181                 debian/$(basepkg)-$*/lib/modules/$(abi_release)-$*/build
182         # And finally the symvers
183         install -m644 $(builddir)/build-$*/Module.symvers \
184                 $(hdrdir)/Module.symvers
185
186         # Now the header scripts
187         install -d $(CURDIR)/debian/$(basepkg)-$*/DEBIAN
188         for script in postinst; do                                              \
189           sed -e 's/=V/$(abi_release)-$*/g' -e 's/=K/$(install_file)/g' \
190                 $(DROOT)/control-scripts/headers-$$script >                     \
191                         $(CURDIR)/debian/$(basepkg)-$*/DEBIAN/$$script;         \
192           chmod 755 $(CURDIR)/debian/$(basepkg)-$*/DEBIAN/$$script;             \
193         done
194
195         # At the end of the package prep, call the tests
196         DPKG_ARCH="$(arch)" KERN_ARCH="$(build_arch)" FLAVOUR="$*"      \
197          VERSION="$(abi_release)" REVISION="$(revision)"                \
198          PREV_REVISION="$(prev_revision)" ABI_NUM="$(abinum)"           \
199          PREV_ABI_NUM="$(prev_abinum)" BUILD_DIR="$(builddir)/build-$*" \
200          INSTALL_DIR="$(pkgdir)" SOURCE_DIR="$(CURDIR)"                 \
201          run-parts -v $(DROOT)/tests
202
203         #
204         # Remove files which are generated at installation by postinst,
205         # except for modules.order and modules.builtin
206         # 
207         # NOTE: need to keep this list in sync with postrm
208         #
209         mkdir $(pkgdir)/lib/modules/$(abi_release)-$*/_
210         mv $(pkgdir)/lib/modules/$(abi_release)-$*/modules.order \
211                 $(pkgdir)/lib/modules/$(abi_release)-$*/_
212         if [ -f $(pkgdir)/lib/modules/$(abi_release)-$*/modules.builtin ] ; then \
213             mv $(pkgdir)/lib/modules/$(abi_release)-$*/modules.builtin \
214                 $(pkgdir)/lib/modules/$(abi_release)-$*/_; \
215         fi
216         rm -f $(pkgdir)/lib/modules/$(abi_release)-$*/modules.*
217         mv $(pkgdir)/lib/modules/$(abi_release)-$*/_/* \
218                 $(pkgdir)/lib/modules/$(abi_release)-$*
219         rmdir $(pkgdir)/lib/modules/$(abi_release)-$*/_
220
221 headers_tmp := $(CURDIR)/debian/tmp-headers
222 headers_dir := $(CURDIR)/debian/linux-libc-dev
223
224 hmake := $(MAKE) -C $(CURDIR) O=$(headers_tmp) SUBLEVEL=$(SUBLEVEL) \
225         EXTRAVERSION=-$(abinum) INSTALL_HDR_PATH=$(headers_tmp)/install \
226         SHELL="$(SHELL)" ARCH=$(header_arch)
227
228 install-arch-headers:
229         dh_testdir
230         dh_testroot
231         dh_clean -k -plinux-libc-dev
232
233         rm -rf $(headers_tmp)
234         install -d $(headers_tmp) $(headers_dir)/usr/include/
235
236         $(hmake) $(defconfig)
237         mv $(headers_tmp)/.config $(headers_tmp)/.config.old
238         sed -e 's/^# \(CONFIG_MODVERSIONS\) is not set$$/\1=y/' \
239           -e 's/.*CONFIG_LOCALVERSION_AUTO.*/# CONFIG_LOCALVERSION_AUTO is not set/' \
240           $(headers_tmp)/.config.old > $(headers_tmp)/.config
241         $(hmake) silentoldconfig
242         $(hmake) headers_install
243
244         ( cd $(headers_tmp)/install/include/ && \
245                 find . -name '.' -o -name '.*' -prune -o -print | \
246                 cpio -pvd --preserve-modification-time \
247                         $(headers_dir)/usr/include/ )
248         mkdir $(headers_dir)/usr/include/$(DEB_HOST_MULTIARCH)
249         mv $(headers_dir)/usr/include/asm $(headers_dir)/usr/include/$(DEB_HOST_MULTIARCH)/
250
251         rm -rf $(headers_tmp)
252
253 binary-arch-headers: install-arch-headers
254         dh_testdir
255         dh_testroot
256 ifeq ($(do_libc_dev_package),true)
257 ifneq ($(DEBIAN),debian.master)
258         echo "non-master branch building linux-libc-dev, aborting"
259         exit 1
260 endif
261         dh_installchangelogs -plinux-libc-dev
262         dh_installdocs -plinux-libc-dev
263         dh_compress -plinux-libc-dev
264         dh_fixperms -plinux-libc-dev
265         dh_installdeb -plinux-libc-dev
266         dh_gencontrol -plinux-libc-dev -- $(libc_dev_version)
267         dh_md5sums -plinux-libc-dev
268         dh_builddeb -plinux-libc-dev
269 endif
270
271 binary-%: pkgimg = $(bin_pkg_name)-$*
272 binary-%: pkghdr = $(hdrs_pkg_name)-$*
273 binary-%: dbgpkg = $(bin_pkg_name)-$*-dbgsym
274 binary-%: dbgpkgdir = $(CURDIR)/debian/$(bin_pkg_name)-$*-dbgsym
275 binary-%: install-%
276         dh_testdir
277         dh_testroot
278
279         dh_installchangelogs -p$(pkgimg)
280         dh_installdocs -p$(pkgimg)
281         dh_compress -p$(pkgimg)
282         dh_fixperms -p$(pkgimg) -X/boot/
283         dh_installdeb -p$(pkgimg)
284         dh_shlibdeps -p$(pkgimg)
285         dh_gencontrol -p$(pkgimg)
286         dh_md5sums -p$(pkgimg)
287         dh_builddeb -p$(pkgimg) -- -Zbzip2 -z9
288
289         dh_installchangelogs -p$(pkghdr)
290         dh_installdocs -p$(pkghdr)
291         dh_compress -p$(pkghdr)
292         dh_fixperms -p$(pkghdr)
293         dh_shlibdeps -p$(pkghdr)
294         dh_installdeb -p$(pkghdr)
295         dh_gencontrol -p$(pkghdr)
296         dh_md5sums -p$(pkghdr)
297         dh_builddeb -p$(pkghdr)
298
299 ifneq ($(skipsub),true)
300         @set -e; for sub in $($(*)_sub); do             \
301                 pkg=$(bin_pkg_name)-$$sub;      \
302                 dh_installchangelogs -p$$pkg;           \
303                 dh_installdocs -p$$pkg;                 \
304                 dh_compress -p$$pkg;                    \
305                 dh_fixperms -p$$pkg -X/boot/;           \
306                 dh_shlibdeps -p$$pkg;                   \
307                 dh_installdeb -p$$pkg;                  \
308                 dh_gencontrol -p$$pkg;                  \
309                 dh_md5sums -p$$pkg;                     \
310                 dh_builddeb -p$$pkg;                    \
311         done
312 endif
313
314 ifneq ($(skipdbg),true)
315         dh_installchangelogs -p$(dbgpkg)
316         dh_installdocs -p$(dbgpkg)
317         dh_compress -p$(dbgpkg)
318         dh_fixperms -p$(dbgpkg)
319         dh_installdeb -p$(dbgpkg)
320         dh_gencontrol -p$(dbgpkg)
321         dh_md5sums -p$(dbgpkg)
322         dh_builddeb -p$(dbgpkg)
323
324         # Hokay...here's where we do a little twiddling...
325         # Renaming the debug package prevents it from getting into
326         # the primary archive, and therefore prevents this very large
327         # package from being mirrored. It is instead, through some
328         # archive admin hackery, copied to http://ddebs.ubuntu.com.
329         #
330         mv ../$(dbgpkg)_$(release)-$(revision)_$(arch).deb \
331                 ../$(dbgpkg)_$(release)-$(revision)_$(arch).ddeb
332         set -e; \
333         if grep -qs '^Build-Debug-Symbols: yes$$' /CurrentlyBuilding; then \
334                 sed -i '/^$(dbgpkg)_/s/\.deb /.ddeb /' debian/files; \
335         else \
336                 grep -v '^$(dbgpkg)_.*$$' debian/files > debian/files.new; \
337                 mv debian/files.new debian/files; \
338         fi
339         # Now, the package wont get into the archive, but it will get put
340         # into the debug system.
341 endif
342 ifneq ($(full_build),false)
343         # Clean out this flavours build directory.
344         rm -rf $(builddir)/build-$*
345         # Clean out the debugging package source directory.
346         rm -rf $(dbgpkgdir)
347 endif
348
349 $(stampdir)/stamp-flavours:
350         @echo $(flavours) > $@
351
352 #
353 # per-architecture packages
354 #
355 $(stampdir)/stamp-prepare-perarch:
356         @echo "Preparing perarch ..."
357 ifeq ($(do_tools),true)
358         rm -rf $(builddir)/tools-$*
359         install -d $(builddir)/tools-$*
360         for i in *; do ln -s $(CURDIR)/$$i $(builddir)/tools-$*/; done
361         rm $(builddir)/tools-$*/tools
362         rsync -a tools/ $(builddir)/tools-$*/tools/
363 endif
364         touch $@
365
366 $(stampdir)/stamp-build-perarch: prepare-perarch
367 ifeq ($(do_tools),true)
368         cd $(builddir)/tools-$*/tools/perf && \
369                 make HAVE_CPLUS_DEMANGLE=1 $(CROSS_COMPILE)
370 endif
371         @touch $@
372
373 install-perarch: toolspkgdir = $(CURDIR)/debian/$(tools_pkg_name)
374 install-perarch: $(stampdir)/stamp-build-perarch
375         # Add the tools.
376 ifeq ($(do_tools),true)
377         install -d $(toolspkgdir)/usr/bin
378         install -s -m755 $(builddir)/tools-$*/tools/perf/perf \
379                 $(toolspkgdir)/usr/bin/perf_$(abi_release)
380 endif
381
382 binary-perarch: toolspkg = $(tools_pkg_name)
383 binary-perarch: install-perarch
384         @# Empty for make to be happy
385 ifeq ($(do_tools),true)
386         dh_installchangelogs -p$(toolspkg)
387         dh_installdocs -p$(toolspkg)
388         dh_compress -p$(toolspkg)
389         dh_fixperms -p$(toolspkg)
390         dh_shlibdeps -p$(toolspkg)
391         dh_installdeb -p$(toolspkg)
392         dh_gencontrol -p$(toolspkg)
393         dh_md5sums -p$(toolspkg)
394         dh_builddeb -p$(toolspkg)
395 endif
396
397 binary-debs: binary-perarch $(stampdir)/stamp-flavours $(addprefix binary-,$(flavours))
398
399 build-arch-deps-$(do_flavour_image_package) += $(addprefix build-,$(flavours))
400 build-arch: $(build-arch-deps-true)
401
402 binary-arch-deps-$(do_flavour_image_package) = binary-debs
403 ifeq ($(AUTOBUILD),)
404 binary-arch-deps-$(do_flavour_image_package) += binary-udebs
405 endif
406 binary-arch-deps-$(do_libc_dev_package) += binary-arch-headers
407 ifneq ($(do_common_headers_indep),true)
408 binary-arch-deps-$(do_flavour_header_package) += binary-headers
409 endif
410 binary-arch: $(binary-arch-deps-true)