#!/usr/bin/make -f

# DH_VERBOSE := 1

# Enable hardening build flags
export DEB_BUILD_MAINT_OPTIONS=hardening=+all

export DEB_CXXFLAGS_MAINT_APPEND=$(shell DEB_BUILD_MAINT_OPTIONS=hardening=+all dpkg-buildflags --get CPPFLAGS)

export PYBUILD_NAME=pyosmium
export PYBUILD_SYSTEM=distutils

export VERBOSE=1

%:
	dh $@ \
	    --buildsystem pybuild \
	    --with python2,python3 \
	    --parallel

override_dh_clean:
	dh_clean
	
	$(RM) -r doc/_build

override_dh_auto_build-indep:
	dh_auto_build --indep

	(cd doc && PYTHONPATH=$(CURDIR)/.pybuild/cpython3_`py3versions -vd`_pyosmium/build make html)
	(cd doc && PYTHONPATH=$(CURDIR)/.pybuild/cpython3_`py3versions -vd`_pyosmium/build make man)

override_dh_auto_test:
	PYBUILD_SYSTEM=custom \
	PYBUILD_TEST_ARGS="cd test && {interpreter} run_tests.py" dh_auto_test

override_dh_auto_install:
	PYBUILD_INSTALL_ARGS="--install-scripts=/usr/lib/{package}" dh_auto_install

override_dh_install:
	dh_install

	# Remove embedded jquery.js in favor of libjs-jquery
	$(RM) debian/*/usr/share/doc/*/html/_static/jquery.js

	# Remove embedded underscore.js in favor of libjs-underscore
	$(RM) debian/*/usr/share/doc/*/html/_static/underscore.js
