#!/usr/bin/make -f

include /usr/share/java/java_defaults.mk

export DEB_BUILD_MAINT_OPTIONS = hardening=+bindnow
export PYBUILD_SYSTEM=cmake
export PYBUILD_CONFIGURE_ARGS=-DLCM_JAVA_TARGET_VERSION=$(java_compat_level) \
                              -DCMAKE_JAVA_COMPILE_FLAGS=-g

%:
	dh $@ --with=sphinxdoc --with=javahelper --buildsystem=pybuild

execute_after_dh_auto_build-indep:
	$(MAKE) -C `pybuild --print build_dir --interpreter python3` doc
	$(RM) -fr `pybuild --print build_dir --interpreter python3`/docs/_build/.doctrees

# Tests exercise the passing of messages and are broken if
# several of them are run in parallel
override_dh_auto_test:
	PYBUILD_SYSTEM=custom \
		PYBUILD_TEST_ARGS="dh_auto_test --no-parallel --buildsystem=cmake --builddirectory={build_dir}" dh_auto_test

# Leave the pkg-config file in the java package
execute_after_dh_install:
	$(RM) debian/liblcm-java/usr/lib/pkgconfig/lcm-java.pc

execute_after_dh_installdocs:
	$(RM) debian/liblcm-doc/usr/share/doc/liblcm-dev/examples/.gitignore

override_dh_auto_clean:
	dh_auto_clean
	rm -rf docs/_build
