#!/usr/bin/make -f
# See debhelper(7) (uncomment to enable)
# output every command that modifies files on the build system.
export DH_VERBOSE = 1

export LC_ALL=C.UTF-8
export DEB_BUILD_MAINT_OPTIONS = hardening=+all
# package maintainers to append CFLAGS
export DEB_CFLAGS_MAINT_APPEND  = -Wall -pedantic
# package maintainers to append LDFLAGS
export DEB_LDFLAGS_MAINT_APPEND = -Wl,--as-needed

export PYBUILD_NAME=isospec

# Taken from CDBS file for R.
rversion	:= $(shell dpkg-query -W -f='$${Version}' r-base-dev)
rapiversion	:= $(shell dpkg-query -W -f='$${Provides}' r-base-core | grep -o 'r-api[^, ]*')

%:
	dh $@ --with python3 --buildsystem=pybuild --sourcedirectory=IsoSpecPy

# Handle the C++ library apart
override_dh_auto_build:
	cd IsoSpec++ && make
# Upstream has not include a Doxygen config file. Add it ourselves
# Note that as 20190205, the doxyfile has been dumbed down to only produce HTML
# doc. Check the 20190205 string for the commented lines.
	cp debian/doxyfile man
# Generate the dev-doc in the man/hml and man/latex directories
	doxygen man/doxyfile
# Remove Doxygen-generated file that has no use.
	#rm man/man/man3/_home_rusconi_*

# sed-based replacement of the cloudflare URL with the MathJax.js file from the
# libjs-mathjax package
	sh debian/replace-mathjax-cloudflare-url-local-file.sh

# Actually craft the refman.pdf file.
#
# No, at the moment no, there is a bug in the Doxygen-generated LaTeX code
# and I do not know how to fix it. HTML documentation is largely enough.
#	cd man/latex && make

override_dh_auto_install:
	dh_auto_install -O--buildsystem=R --sourcedirectory=IsoSpecR
# Remove the license file.
	rm debian/tmp/usr/lib/R/site-library/IsoSpecR/LICENCE
	mv debian/tmp tmp-install
	dh_auto_install

