summaryrefslogtreecommitdiff
path: root/debian/rules
blob: dde1e5b0bb5cbb0339754178c9fecb38fb63ecdb (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
#!/usr/bin/make -f

BUILDDIR = obj-$(shell dpkg-architecture  -q DEB_HOST_MULTIARCH)

export DEB_BUILD_MAINT_OPTIONS=hardening=+all
export DH_ALWAYS_EXCLUDE=__pycache__

PY3_DEFAULT = $(shell py3versions  -dv)
PY3_ALT = $(shell py3versions  -rv | sed "s/$(PY3_DEFAULT)//")

%:
	dh $@  --buildsystem=cmake --with python3

override_dh_auto_configure:
	dh_auto_configure -a -- -DNLOPT_FORTRAN=ON -DPYTHON_EXECUTABLE:FILEPATH=/usr/bin/python$(PY3_DEFAULT) -DCMAKE_SKIP_INSTALL_RPATH=TRUE
	for py3alt in $(PY3_ALT); do dh_auto_configure -a --builddirectory=$(BUILDDIR)-python$${py3alt} -- -DNLOPT_FORTRAN=ON -DPYTHON_EXECUTABLE:FILEPATH=/usr/bin/python$${py3alt} -DCMAKE_SKIP_INSTALL_RPATH=TRUE; done
	dh_auto_configure -a --builddirectory=$(BUILDDIR)-c-only -- -DNLOPT_CXX=OFF -DNLOPT_PYTHON=OFF -DNLOPT_OCTAVE=OFF -DNLOPT_GUILE=OFF -DNLOPT_SWIG=OFF -DCMAKE_SKIP_INSTALL_RPATH=TRUE

execute_after_dh_auto_build-arch:
	for py3alt in $(PY3_ALT); do dh_auto_build --builddirectory=$(BUILDDIR)-python$${py3alt}; done
	dh_auto_build --builddirectory=$(BUILDDIR)-c-only

override_dh_auto_build-indep:
	mkdocs build

override_dh_auto_install-arch:
	dh_auto_install -a
	dh_auto_install -a --builddirectory=$(BUILDDIR)-c-only --destdir=debian/tmp-c-only
	mv debian/tmp/usr/lib/$(DEB_HOST_MULTIARCH)/pkgconfig/nlopt.pc debian/tmp/usr/lib/$(DEB_HOST_MULTIARCH)/pkgconfig/nlopt_cxx.pc
	sed "s/-lnlopt/-lnlopt_cxx/" -i debian/tmp/usr/lib/$(DEB_HOST_MULTIARCH)/pkgconfig/nlopt_cxx.pc
	dh_numpy3

override_dh_auto_install-indep:

override_dh_python3-arch:
	distdir=debian/python3-nlopt/usr/lib/python3/dist-packages; \
	mkdir -p $$distdir; \
	for py3alt in $(PY3_ALT); do \
		py3short=`echo $${py3alt} | sed "s/\.//g"`; \
		cp $(BUILDDIR)-python$${py3alt}/src/swig/_nlopt.so $$distdir/_nlopt.cpython-$${py3short}.so; \
		chrpath -d $$distdir/_nlopt.cpython-$${py3short}.so; \
	done
	dh_python3 -a

override_dh_auto_test-indep:
	echo No tests to run in arch-indep build.

execute_after_dh_strip:
	find debian/octave-nlopt/usr/lib -name *.oct | \
		xargs strip --strip-unneeded --remove-section=.comment

override_dh_makeshlibs:
	dh_makeshlibs -X/usr/lib/python3/dist-packages

execute_after_dh_shlibdeps:
	dh_octave_substvar

execute_after_dh_install-arch:
	# Remove C++ header from C interface
	find debian/libnlopt-dev -name nlopt.hpp -delete

override_dh_installdocs-indep:
	dh_installdocs -X js/jquery
	grep highlight.min.js debian/nlopt-doc/usr/share/doc/nlopt-doc/site/* -R -ls | xargs -r sed "s|src=\".*highlight.min.js\"|src=\"/usr/share/javascript/highlight.js/highlight.min.js\"|" -i
	grep js/jquery debian/nlopt-doc/usr/share/doc/nlopt-doc/site/* -R -ls | xargs -r sed "s|src=\".*js/jquery*.min.js|src=\"/usr/share/javascript/jquery/jquery.min.js|" -i
	grep -i mathjax.js debian/nlopt-doc/usr/share/doc/nlopt-doc/site/* -R -ls | xargs -r sed "s|src=\"https://cdn.mathjax.org/mathjax/latest/MathJax.js|src=\"/usr/share/javascript/mathjax/MathJax.js|" -i
	grep github.min.css debian/nlopt-doc/usr/share/doc/nlopt-doc/site/* -R -ls | xargs -r sed "s|href=\".*github.min.css\"|src=\"/usr/share/javascript/highlight.js/styles/github.css\"|" -i

execute_before_dh_link-arch:
	for package in libnlopt-dev libnlopt-guile0 octave-nlopt python3-nlopt; do \
		rm -rf debian/$$package/usr/share/doc/$$package; \
	done

execute_before_dh_link-indep:
	rm -rf debian/nlopt-doc/usr/share/doc/nlopt-doc/site/fonts