Build with -Wl,--as-needed.
[jelmer/subvertpy.git] / debian / rules
1 #!/usr/bin/make -f
2
3 export DEB_LDFLAGS_MAINT_APPEND = -Wl,--as-needed
4
5 CPPFLAGS:=$(shell dpkg-buildflags --get CPPFLAGS)
6 CFLAGS:=$(shell dpkg-buildflags --get CFLAGS)
7 CXXFLAGS:=$(shell dpkg-buildflags --get CXXFLAGS)
8 LDFLAGS:=$(shell dpkg-buildflags --get LDFLAGS)
9
10 # Get the supported Python versions
11 PYVERS = $(shell pyversions -r -v)
12 # Get the default Python version
13 PYVERSION = $(shell pyversions -d -v)
14
15 # Callable functions to determine the correct PYTHONPATH
16 pythonpath = $$(ls -d $(CURDIR)/build/lib.*-$(1))
17 pythonpath_dbg = $$(ls -d $(CURDIR)/build/lib_d.*-$(1) 2>/dev/null || ls -d $(CURDIR)/build/lib.*$(1)-pydebug)
18
19 export HOME=$(CURDIR)/nonexistent
20
21 %:
22         CPPFLAGS="$(CPPFLAGS)" CFLAGS="$(CFLAGS)" CXXFLAGS="$(CXXFLAGS)" \
23         LDFLAGS="$(LDFLAGS)" dh --with python2 --buildsystem=python_distutils $*
24
25 override_dh_auto_build:
26         dh_auto_build
27         $(MAKE) pydoctor
28
29 override_dh_auto_install:
30         dh_auto_install --destdir=debian/tmp
31         # Install everything excluding the *_d.so debug extensions to python-subvertpy
32         dh_install -X"*_d.so" "debian/tmp/*" -p python-subvertpy
33         # Install the debug extensions to python-subvertpy-dbg
34         dh_install "debian/tmp/usr/lib/python*/*-packages/subvertpy/*_d.so" -p python-subvertpy-dbg
35         mkdir -p debian/python-subvertpy/usr/share/doc/python-subvertpy
36         mv apidocs debian/python-subvertpy/usr/share/doc/python-subvertpy/api
37
38 override_dh_installdocs:
39         dh_installdocs --link-doc=python-subvertpy
40
41 override_dh_auto_test:
42 ifeq (,$(findstring nocheck,$(DEB_BUILD_OPTIONS)))
43                 set -e -x; \
44                 for py in $(PYVERS); do \
45                         cd $(call pythonpath,$$py); python$$py -m testtools.run subvertpy.tests.test_suite ;\
46                         cd $(call pythonpath_dbg,$$py); python$$py-dbg -m testtools.run subvertpy.tests.test_suite ;\
47                 done
48 endif
49
50 override_dh_strip:
51 ifeq (,$(filter nostrip,$(DEB_BUILD_OPTIONS)))
52         dh_strip --dbg-package=python-subvertpy-dbg
53 endif