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>
6 WFLAGS := -Wall -Wextra -Wno-unused-parameter -Wno-missing-field-initializers
8 # XXX: Stack Protector Strong is only available in gcc >= 4.9
9 cc_version = $(shell $(CC) -dumpversion 2>/dev/null)
10 cc_version_lt = $(shell dpkg --compare-versions "$(cc_version)" lt-nl "$(1)" && echo yes)
11 hardening_old = $(if $(call cc_version_lt,4.9),-stackprotectorstrong)
13 # Use the in-tree dpkg-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
20 DEB_BUILD_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE)
21 DEB_HOST_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE)
22 DEB_HOST_ARCH_OS ?= $(shell dpkg-architecture -qDEB_HOST_ARCH_OS)
23 DEB_HOST_MULTIARCH ?= $(shell dpkg-architecture -qDEB_HOST_MULTIARCH)
25 # Support cross-compiling.
26 ifeq ($(DEB_BUILD_GNU_TYPE), $(DEB_HOST_GNU_TYPE))
27 confflags += --build=$(DEB_HOST_GNU_TYPE)
29 confflags += --build=$(DEB_BUILD_GNU_TYPE) --host=$(DEB_HOST_GNU_TYPE)
32 # Do not enable everything on all platforms.
33 ifeq ($(DEB_HOST_ARCH_OS),linux)
34 confflags += --with-libselinux
36 ifeq (,$(filter maintainer-build,$(DEB_BUILD_OPTIONS)))
37 confflags += --disable-silent-rules
40 # Enable parallel test suite
42 ifneq (,$(filter parallel=%,$(DEB_BUILD_OPTIONS)))
43 NUMJOBS = $(patsubst parallel=%,%,$(filter parallel=%,$(DEB_BUILD_OPTIONS)))
44 MAKEFLAGS += -j$(NUMJOBS)
47 D := $(CURDIR)/debian/tmp
49 # Create configure script if necessary, automake handles rebuilding it.
55 # Configure the build tree
56 build-tree/config.status: configure
60 cd build-tree && ../configure $(confflags) \
61 $(shell $(dpkg_buildflags) --export=configure) \
63 --mandir=\$${datadir}/man \
64 --infodir=\$${datadir}/info \
67 --localstatedir=/var \
68 --libexecdir=\$${exec_prefix}/lib \
69 --with-devlibdir=\$${prefix}/lib/$(DEB_HOST_MULTIARCH) \
75 # Build the package in build-tree
76 build-indep build-arch build: build-tree/config.status
79 cd build-tree && $(MAKE)
85 ifeq (,$(filter nocheck,$(DEB_BUILD_OPTIONS)))
86 cd build-tree && $(MAKE) VERBOSE=1 TESTSUITEFLAGS=--verbose \
87 TEST_PARALLEL=$(NUMJOBS) check
90 # Install the package underneath debian/tmp
97 cd build-tree && $(MAKE) DESTDIR=$(D) install
99 define dpkg-installmanl10n
100 for f in `sed -e 's:\*:*/*:' debian/$(1).manpages`; do \
102 install -D $$f `echo $$f | sed -e 's:^debian/tmp:debian/$(1):'`; \
106 # Put together the dpkg and dselect packages
112 dh_installlogrotate -a
113 dh_installchangelogs -a ChangeLog*
115 $(call dpkg-installmanl10n,dpkg)
116 $(call dpkg-installmanl10n,dselect)
129 # Put together the dpkg-dev package
130 binary-indep: install
135 dh_installchangelogs -i ChangeLog*
137 $(call dpkg-installmanl10n,dpkg-dev)
141 # The perl modules should not depend on a specific interpreter.
142 dh_perl -i -Nlibdpkg-perl
150 binary: binary-arch binary-indep
153 # Clean up the mess we made
157 [ ! -f Makefile ] || $(MAKE) distclean
162 .PHONY: build check install binary-arch binary-indep binary clean