1#! /usr/bin/make -f
2
3#export DH_VERBOSE=1
4
5export DEB_BUILD_MAINT_OPTIONS = hardening=+all
6DPKG_EXPORT_BUILDFLAGS = 1
7include /usr/share/dpkg/buildflags.mk
8
9CFLAGS += -Wall -g
10
11ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS)))
12  CFLAGS += -O0
13else
14  CFLAGS += -O2
15endif
16
17ifneq (,$(filter parallel=%,$(DEB_BUILD_OPTIONS)))
18  NUMJOBS = $(patsubst parallel=%,%,$(filter parallel=%,$(DEB_BUILD_OPTIONS)))
19  MAKEFLAGS += -j$(NUMJOBS)
20endif
21
22DEB_BUILD_GNU_TYPE := $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE)
23DEB_HOST_GNU_TYPE := $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE)
24DEB_HOST_ARCH := $(shell dpkg-architecture -qDEB_HOST_ARCH)
25
26arch64_map = i386=x86_64 powerpc=powerpc64 sparc=sparc64 s390=s390x
27ifneq (,$(filter $(DEB_HOST_ARCH)=%, $(arch64_map)))
28  HOST64 = $(strip $(patsubst $(DEB_HOST_ARCH)=%, %, \
29	     $(filter $(DEB_HOST_ARCH)=%, $(arch64_map))))-linux-gnu
30  CC64 = gcc -m64
31  extra_build_targets += build64-stamp
32endif
33
34ifeq ($(DEB_HOST_GNU_TYPE),$(DEB_BUILD_GNU_TYPE))
35  CONFIG_OPTS = --build=$(DEB_BUILD_GNU_TYPE)
36else
37  CONFIG_OPTS = --build=$(DEB_BUILD_GNU_TYPE) --host=$(DEB_HOST_GNU_TYPE)
38endif
39
40all build: build-stamp $(extra_build_targets)
41
42%-stamp: %/Makefile
43	$(MAKE) -C $*
44ifeq (,$(findstring nocheck,$(DEB_BUILD_OPTIONS)))
45	$(MAKE) -C $* check
46endif
47	touch $@
48
49build/Makefile:
50	mkdir -p $(@D)
51	cd $(@D); sh ../configure --prefix=/usr $(CONFIG_OPTS)
52
53build64/Makefile:
54	mkdir -p $(@D)
55	cd $(@D); CC="$(CC64)" sh ../configure --prefix=/usr --build=$(DEB_BUILD_GNU_TYPE) --host=$(HOST64)
56
57clean:
58	dh_testdir
59	dh_testroot
60	rm -rf build build64 strace64.1
61	dh_clean
62
63binary: binary-indep binary-arch
64
65binary-indep:
66
67binary-arch: build
68	test -f build-stamp || make $(MFLAGS) -f debian/rules build
69
70	# prepare 64bit executable and manpage, if it has been built
71	test -f build64-stamp && ( mv build64/strace build64/strace64 ; \
72		cp strace.1 strace64.1 ) || true
73
74	dh_testdir -s
75	dh_testroot -s
76	dh_installdirs -s
77	dh_installdocs -s
78	dh_installman -s
79	dh_installexamples -s
80	dh_installchangelogs -s
81	dh_install -s
82	dh_link -s
83	dh_strip -s
84	dh_compress -s
85	dh_fixperms -s
86	dh_installdeb -s
87	dh_shlibdeps -s
88	dh_gencontrol -s
89	dh_md5sums -s
90	dh_builddeb -s
91