summaryrefslogtreecommitdiff
path: root/debian/rules
blob: 474d33407e769a78cae9b7c399476b0fd3d195db (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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
#!/usr/bin/make -f
# debian/rules for the dpkg suite.
# Copyright © 2004 Scott James Remnant <scott@netsplit.com>
# Copyright © 2006-2012 Guillem Jover <guillem@debian.org>

WFLAGS := -Wall -Wextra -Wno-unused-parameter -Wno-missing-field-initializers

# Use the in-tree dpkg-buildflags
dpkg_buildflags = \
	DEB_CFLAGS_MAINT_APPEND="$(WFLAGS)" \
	DEB_CXXFLAGS_MAINT_APPEND="$(WFLAGS)" \
	$(CURDIR)/run-script perl $(CURDIR)/scripts/dpkg-buildflags.pl

# These are used for cross-compiling and for saving the configure script
# from having to guess our platform (since we know it already)
DEB_HOST_GNU_TYPE   ?= $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE)
DEB_BUILD_GNU_TYPE  ?= $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE)

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

# Don't enable everything on all platforms
DEB_HOST_ARCH_OS  ?= $(shell dpkg-architecture -qDEB_HOST_ARCH_OS)

ifeq ($(DEB_HOST_ARCH_OS),linux)
	confflags += --with-selinux
endif
ifeq (,$(filter maintainer-build,$(DEB_BUILD_OPTIONS)))
	confflags += --disable-silent-rules
endif

# Create configure script if necessary, automake handles rebuilding it.
configure:
	dh_testdir

	autoreconf -v -i

# Configure the build tree
build-tree/config.status: configure
	dh_testdir

	install -d build-tree
	cd build-tree && ../configure $(confflags) \
		$(shell $(dpkg_buildflags) --export=configure) \
		--prefix=/usr \
		--mandir=\$${datadir}/man \
		--infodir=\$${datadir}/info \
		--sysconfdir=/etc \
		--sbindir=/sbin \
		--localstatedir=/var \
		--with-zlib \
		--with-liblzma \
		--with-bz2

# Build the package in build-tree
build-indep build-arch build: build-tree/config.status
	dh_testdir

	cd build-tree && $(MAKE)

# Run the test suites
check: build
	dh_testdir

ifeq (,$(filter nocheck,$(DEB_BUILD_OPTIONS)))
	cd build-tree && $(MAKE) VERBOSE=1 check
endif

# Install the package underneath debian/tmp
install: check
	dh_testdir
	dh_testroot
	dh_prep
	dh_installdirs

	cd build-tree && $(MAKE) DESTDIR="$(CURDIR)/debian/tmp" install

ifeq (yes,$(shell dpkg-vendor --derives-from Ubuntu && echo yes))
	# Ubuntu's «i386» architecture is built for i686 (the Debian default
	# is i586).
	sed -ri 's/^(i386[[:space:]]+)[^[:space:]]+/\1i686/' \
	        $(CURDIR)/debian/tmp/usr/share/dpkg/cputable
endif

define dpkg-installmanl10n
for f in `sed -e 's:\*:*/*:' debian/$(1).manpages`; do \
	test -e $$f && \
	install -D $$f `echo $$f | sed -e 's:^debian/tmp:debian/$(1):'`; \
done
endef

# Put together the dpkg and dselect packages
binary-arch: install
	dh_testdir -a
	dh_testroot -a
	dh_install --sourcedir=debian/tmp -a
	dh_installcron -a
	dh_installlogrotate -a
	dh_installchangelogs -a ChangeLog*
	dh_installdocs -a
	$(call dpkg-installmanl10n,dpkg)
	$(call dpkg-installmanl10n,dselect)
	dh_installman -a
	dh_link -a
	dh_lintian -a
	dh_strip -a
	dh_compress -a
	dh_fixperms -a
	dh_installdeb -a
	dh_shlibdeps -a
	dh_gencontrol -a
	dh_md5sums -a
	# Make debootstrap life easier on non-Debian based systems by
	# compressing dpkg.deb with gzip instead of xz.
	dh_builddeb -pdpkg -- -Zgzip
	dh_builddeb -a -Ndpkg

# Put together the dpkg-dev package
binary-indep: install
	dh_testdir -i
	dh_testroot -i
	dh_install --sourcedir=debian/tmp -i
	dh_installcron -i
	dh_installchangelogs -i ChangeLog*
	dh_installdocs -i
	$(call dpkg-installmanl10n,dpkg-dev)
	dh_installman -i
	dh_link -i
	dh_lintian -i
	dh_strip -i
	dh_compress -i
	dh_fixperms -i
	dh_installdeb -i
	dh_gencontrol -i
	dh_md5sums -i
	dh_builddeb -i

binary: binary-arch binary-indep


# Clean up the mess we made
clean:
	dh_testdir

	[ ! -f Makefile ] || $(MAKE) distclean
	rm -rf build-tree
	dh_clean


.PHONY: build check install binary-arch binary-indep binary clean