#!/usr/bin/make -f

DEB_CONFIGURE_USER_FLAGS := --with-etsf-file-format --with-openbabel --with-xsf --with-cube --with-archives --enable-introspection --disable-static --docdir=\$${prefix}/share/doc/v-sim-doc

export PYTHON=python3

export DEB_CFLAGS_MAINT_APPEND = -std=gnu17

#install/v-sim-doc::
#	rm -rf debian/tmp/usr/share/gtk-doc

binary-install/python3-v-sim::
	dh_python3 -ppython3-v-sim --no-guessing-deps

export DEB_BUILD_MAINT_OPTIONS=hardening=+all

%:
	dh  $@

override_dh_auto_configure:
	dh_auto_configure -- $(DEB_CONFIGURE_USER_FLAGS)

# test suite has some failures but its not clear if this has ever passed for the
# Debian package since it was never run before.  Thus ignore errors for the moment
override_dh_auto_test:
ifeq (,$(filter nocheck,$(DEB_BUILD_OPTIONS)))
	dh_auto_test || true
endif

override_dh_auto_install:
	dh_auto_install -- DESTDIR=$(CURDIR)/debian/tmp/

# Avoid postinst-has-useless-call-to-ldconfig
override_dh_makeshlibs:
	dh_makeshlibs -p v-sim-plugins -n
	dh_makeshlibs --remaining-packages

override_dh_installdocs:
	# README is a symlink which makes no sense inside the final packages
	cp README debian/tmp
	cp AUTHORS debian/tmp
	dh_installdocs

# Avoid compressing files that are required as clear texts by V_Sim.
override_dh_compress:
	dh_compress -Xlicence.fr.txt -Xlicence.en.txt -XChangeLog.fr -XChangeLog.en

override_dh_missing:
	find debian/tmp -name "*.la" -delete
	find debian/tmp -type d -name __pycache__ | xargs rm -rf
	dh_missing
