dpkg (1.18.25) stretch; urgency=medium
[dpkg] / debian / rules
CommitLineData
1479465f
GJ
1#!/usr/bin/make -f
2# debian/rules for the dpkg suite.
3# Copyright © 2004 Scott James Remnant <scott@netsplit.com>
4# Copyright © 2006-2012 Guillem Jover <guillem@debian.org>
5
6WFLAGS := -Wall -Wextra -Wno-unused-parameter -Wno-missing-field-initializers
7
8# XXX: Stack Protector Strong is only available in gcc >= 4.9
9cc_version = $(shell $(CC) -dumpversion 2>/dev/null)
10cc_version_lt = $(shell dpkg --compare-versions "$(cc_version)" lt-nl "$(1)" && echo yes)
11hardening_old = $(if $(call cc_version_lt,4.9),-stackprotectorstrong)
12
13# Use the in-tree dpkg-buildflags
14dpkg_buildflags = \
15 DEB_BUILD_MAINT_OPTIONS="hardening=+all,$(hardening_old)" \
16 DEB_CFLAGS_MAINT_APPEND="$(WFLAGS)" \
17 DEB_CXXFLAGS_MAINT_APPEND="$(WFLAGS)" \
18 $(CURDIR)/run-script scripts/dpkg-buildflags.pl
19
20DEB_BUILD_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE)
21DEB_HOST_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE)
22DEB_HOST_ARCH_OS ?= $(shell dpkg-architecture -qDEB_HOST_ARCH_OS)
23DEB_HOST_MULTIARCH ?= $(shell dpkg-architecture -qDEB_HOST_MULTIARCH)
24
25# Support cross-compiling.
26ifeq ($(DEB_BUILD_GNU_TYPE), $(DEB_HOST_GNU_TYPE))
27 confflags += --build=$(DEB_HOST_GNU_TYPE)
28else
29 confflags += --build=$(DEB_BUILD_GNU_TYPE) --host=$(DEB_HOST_GNU_TYPE)
30endif
31
32# Do not enable everything on all platforms.
33ifeq ($(DEB_HOST_ARCH_OS),linux)
34 confflags += --with-libselinux
35endif
36ifeq (,$(filter maintainer-build,$(DEB_BUILD_OPTIONS)))
37 confflags += --disable-silent-rules
38endif
39
40# Enable parallel test suite
41NUMJOBS = 1
42ifneq (,$(filter parallel=%,$(DEB_BUILD_OPTIONS)))
43 NUMJOBS = $(patsubst parallel=%,%,$(filter parallel=%,$(DEB_BUILD_OPTIONS)))
44 MAKEFLAGS += -j$(NUMJOBS)
45endif
46
47D := $(CURDIR)/debian/tmp
48
49# Create configure script if necessary, automake handles rebuilding it.
50configure:
51 dh_testdir
52
53 autoreconf -v -i
54
55# Configure the build tree
56build-tree/config.status: configure
57 dh_testdir
58
59 install -d build-tree
60 cd build-tree && ../configure $(confflags) \
61 $(shell $(dpkg_buildflags) --export=configure) \
62 --prefix=/usr \
63 --mandir=\$${datadir}/man \
64 --infodir=\$${datadir}/info \
65 --sysconfdir=/etc \
66 --sbindir=/sbin \
67 --localstatedir=/var \
68 --libexecdir=\$${exec_prefix}/lib \
69 --with-devlibdir=\$${prefix}/lib/$(DEB_HOST_MULTIARCH) \
70 --without-libmd \
71 --with-libz \
72 --with-liblzma \
73 --with-libbz2
74
75# Build the package in build-tree
76build-indep build-arch build: build-tree/config.status
77 dh_testdir
78
79 cd build-tree && $(MAKE)
80
81# Run the test suites
82check: build
83 dh_testdir
84
85ifeq (,$(filter nocheck,$(DEB_BUILD_OPTIONS)))
86 cd build-tree && $(MAKE) VERBOSE=1 TESTSUITEFLAGS=--verbose \
87 TEST_PARALLEL=$(NUMJOBS) check
88endif
89
90# Install the package underneath debian/tmp
91install: check
92 dh_testdir
93 dh_testroot
94 dh_prep
95 dh_installdirs
96
97 cd build-tree && $(MAKE) DESTDIR=$(D) install
98
99define dpkg-installmanl10n
100for f in `sed -e 's:\*:*/*:' debian/$(1).manpages`; do \
101 test -e $$f && \
102 install -D $$f `echo $$f | sed -e 's:^debian/tmp:debian/$(1):'`; \
103done
104endef
105
106# Put together the dpkg and dselect packages
107binary-arch: install
108 dh_testdir -a
109 dh_testroot -a
110 dh_install -a
111 dh_installcron -a
112 dh_installlogrotate -a
113 dh_installchangelogs -a ChangeLog*
114 dh_installdocs -a
115 $(call dpkg-installmanl10n,dpkg)
116 $(call dpkg-installmanl10n,dselect)
117 dh_installman -a
118 dh_link -a
119 dh_lintian -a
120 dh_strip -a
121 dh_compress -a
122 dh_fixperms -a
123 dh_installdeb -a
124 dh_shlibdeps -a
125 dh_gencontrol -a
126 dh_md5sums -a
127 dh_builddeb -a
128
129# Put together the dpkg-dev package
130binary-indep: install
131 dh_testdir -i
132 dh_testroot -i
133 dh_install -i
134 dh_installcron -i
135 dh_installchangelogs -i ChangeLog*
136 dh_installdocs -i
137 $(call dpkg-installmanl10n,dpkg-dev)
138 dh_installman -i
139 dh_link -i
140 dh_lintian -i
141 # The perl modules should not depend on a specific interpreter.
142 dh_perl -i -Nlibdpkg-perl
143 dh_compress -i
144 dh_fixperms -i
145 dh_installdeb -i
146 dh_gencontrol -i
147 dh_md5sums -i
148 dh_builddeb -i
149
150binary: binary-arch binary-indep
151
152
153# Clean up the mess we made
154clean:
155 dh_testdir
156
157 [ ! -f Makefile ] || $(MAKE) distclean
158 rm -rf build-tree
159 dh_clean
160
161
162.PHONY: build check install binary-arch binary-indep binary clean