summaryrefslogtreecommitdiff
path: root/debian/rules
blob: b997182f4f603919515c1313810393533e50ddc3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
#! /usr/bin/make -f

#export DH_VERBOSE=1

CFLAGS = -Wall -g

ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS)))
  CFLAGS += -O0
else
  CFLAGS += -O2
endif

ifneq (,$(filter parallel=%,$(DEB_BUILD_OPTIONS)))
  NUMJOBS = $(patsubst parallel=%,%,$(filter parallel=%,$(DEB_BUILD_OPTIONS)))
  MAKEFLAGS += -j$(NUMJOBS)
endif

DEB_BUILD_GNU_TYPE := $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE)
DEB_HOST_GNU_TYPE := $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE)
DEB_HOST_ARCH := $(shell dpkg-architecture -qDEB_HOST_ARCH)

arch64_map = i386=x86_64 powerpc=powerpc64 sparc=sparc64 s390=s390x
ifneq (,$(filter $(DEB_HOST_ARCH)=%, $(arch64_map)))
  HOST64 = $(strip $(patsubst $(DEB_HOST_ARCH)=%, %, \
	     $(filter $(DEB_HOST_ARCH)=%, $(arch64_map))))-linux-gnu
  CC64 = gcc -m64
  extra_build_targets += build64-stamp
endif

ifeq ($(DEB_HOST_GNU_TYPE),$(DEB_BUILD_GNU_TYPE))
  CONFIG_OPTS = --build=$(DEB_BUILD_GNU_TYPE)
else
  CONFIG_OPTS = --build=$(DEB_BUILD_GNU_TYPE) --host=$(DEB_HOST_GNU_TYPE)
endif

all build: build-stamp $(extra_build_targets)

%-stamp: %/Makefile
	$(MAKE) -C $*
ifeq (,$(findstring nocheck,$(DEB_BUILD_OPTIONS)))
	$(MAKE) -C $* check
endif
	touch $@

build/Makefile:
	mkdir -p $(@D)
	cd $(@D); sh ../configure --prefix=/usr $(CONFIG_OPTS)

build64/Makefile:
	mkdir -p $(@D)
	cd $(@D); CC="$(CC64)" sh ../configure --prefix=/usr --build=$(DEB_BUILD_GNU_TYPE) --host=$(HOST64)

clean:
	dh_testdir
	dh_testroot
	rm -rf build build64 strace64.1
	dh_clean

binary: binary-indep binary-arch

binary-indep:

binary-arch: build
	test -f build-stamp || make $(MFLAGS) -f debian/rules build

	# prepare 64bit executable and manpage, if it has been built
	test -f build64-stamp && ( mv build64/strace build64/strace64 ; \
		cp strace.1 strace64.1 ) || true

	dh_testdir -s
	dh_testroot -s
	dh_installdirs -s
	dh_installdocs -s
	dh_installman -s
	dh_installexamples -s
	dh_installchangelogs -s
	dh_install -s
	dh_link -s
	dh_strip -s
	dh_compress -s
	dh_fixperms -s
	dh_installdeb -s
	dh_shlibdeps -s
	dh_gencontrol -s
	dh_md5sums -s
	dh_builddeb -s