File: rules

package info (click to toggle)
gnucap-python 0.0.2-1.1
  • links: PTS, VCS
  • area: main
  • in suites: buster, sid
  • size: 2,672 kB
  • sloc: python: 7,873; sh: 4,384; cpp: 1,786; makefile: 252
file content (83 lines) | stat: -rwxr-xr-x 2,283 bytes parent folder | download
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
#!/usr/bin/make -f

PYVERS:= $(shell pyversions -v -r debian/control) \
          $(shell py3versions -v -r debian/control)

PYDEF:= $(shell py3versions -d -v)

export DEB_BUILD_MAINT_OPTIONS = hardening=+all

include /usr/share/dpkg/pkg-info.mk

#export DH_VERBOSE=1

# process makefile dependencies with n jobs in parallel, if DEB_BUILD_OPTIONS
# contains "parallel=n". (set -jn.)
ifneq (,$(filter parallel=%,$(DEB_BUILD_OPTIONS)))
        MAKEFLAGS += -j$(patsubst parallel=%,%,$(filter parallel=%,$(DEB_BUILD_OPTIONS)))
endif


%:
	dh $@ --with python2,python3

build: build-arch build-indep

ab-python%:
	dh_auto_build --builddirectory=build$*

ac-python%:
	dh_auto_configure --builddirectory=build$* -- PYTHON=python$*

at-python%:
	# Skip tests since they have numerical inaccuracy causing FTBFS on some architectures:
	$(MAKE) -C build$*

ar-python%:
	rm -rf out$*
	rm -rf debian/tmp$*

override_dh_auto_install:
	mkdir -p debian/tmp/usr/lib
	for i in ${PYVERS}; do \
		echo $$i; \
		$(MAKE) -C build$$i install DESTDIR=$(CURDIR)/debian/tmp$$i; \
		( cd debian/tmp$$i/usr/lib/*/gnucap[0-9]; mv c_python.so c_python$$i.so ); \
		cp -r debian/tmp$$i/usr/lib/* debian/tmp/usr/lib; \
		rm -rf "debian/tmp$$i/usr/lib/*"; \
	done

	cd debian/tmp/usr/lib/*/gnucap[0-9]; ln -sf c_python${PYDEF}.so c_python.so
	mv debian/tmp${PYDEF}/usr/share debian/tmp/usr

	printf "0.0.0\n=====\n* initial release\n" > debian/tmp/usr/share/doc/gnucap-python/NEWS

override_dh_auto_configure: $(PYVERS:%=ac-python%)
override_dh_auto_build: $(PYVERS:%=ab-python%)
override_dh_auto_test: $(PYVERS:%=at-python%)

override_dh_clean: $(PYVERS:%=ar-python%)
	dh_clean
	rm -rf build*
	find . -name *.pyc -delete
	find . -name *.pyo -delete
	rm -f debian/tmp.*

override_dh_shlibdeps: debian/tmp.lib
	dh_shlibdeps
	dh_numpy
	dh_numpy3

	# inject extra library dependency
	cat $< >> debian/python-gnucap.substvars
	cat $< >> debian/python3-gnucap.substvars

# dpkg-shlibdeps misses the dlopen in gnucap/__init__.py
# "ctypes.PyDLL("@LIBGNUCAP_SONAME@", mode=ctypes.RTLD_GLOBAL)"
# need to act on a dummy binary (tmp.out) instead
debian/tmp.lib: debian/tmp.out
	dpkg-shlibdeps $< -O -pdlopen > $@

# create dummy binary, linked against gnucap
debian/tmp.out:
	echo 'int main(){}' | gcc -lgnucap -x c - -o $@