#!/usr/bin/make -f

export DEB_BUILD_MAINT_OPTIONS = hardening=+all

XTDS_DATA = debian/tmp/usr/share/xtds

%:
	dh $@ --buildsystem=meson

override_dh_auto_configure:
	dh_auto_configure -- --libexecdir=libexec

# The interface comes as Java classes in $BASD/classes, with FlatLaf (not in
# Debian) in the classpath: gather the classes in xtds.jar and run it alone
execute_after_dh_auto_install:
	jar --create --file $(XTDS_DATA)/xtds.jar -C $(XTDS_DATA)/classes .
	rm -r $(XTDS_DATA)/classes
	sed -i -e '/^FLATLAF_JAR=/d' \
	       -e 's|^CLASSPATH=.*|CLASSPATH="$$BASD/xtds.jar"|' \
	       debian/tmp/usr/bin/xtds

# Some data files of the packages are executable upstream
execute_after_dh_fixperms-indep:
	find debian/xtds-data/usr/share/xtds/packages \
	     \( -path '*/ctrp/*' -o -path '*/exp/*' -o -path '*/para/*' \) \
	     -type f -exec chmod a-x {} +

# run_xtds_job.py.1 is not a manual page in the language "py"
override_dh_installman:
	dh_installman --language=C
