#!/usr/bin/make -f

# https://wiki.debian.org/HardeningWalkthrough
export DEB_BUILD_MAINT_OPTIONS = hardening=+all

# Some tests are flaky on some architectures, with failures
# which are difficult to reproduce. Let's run the tests only
# on the architectures where they behave well.
ifeq (,$(filter amd64 arm64 ppc64el,$(DEB_HOST_ARCH)))
	export DEB_BUILD_OPTIONS += nocheck
endif

%:
	dh $@

override_dh_auto_configure:
	# Vis configure script it not generated by autoconf, so it does not
	# accept all the options given by dh_auto_configure. It *almost* works,
	# but we end up with a wrong mandir. This is a possible workaround:
	#
	# dh_auto_configure -- --mandir='$$(PREFIX)/share/man/'
	#
	# but still we're calling the configure script with a lot of options
	# it doesn't actually understand. I prefer to just run the script
	# manually, and dh_auto_configure(1) agrees (see the DESCRIPTION).
	#
	# So:
	#
	./configure --prefix=/usr

override_dh_auto_install:
	dh_auto_install -- DOCUMENTATION=README.md

	# Remove extra files
	rm -v debian/vis/usr/share/vis/lexers/LICENSE
	rm -v debian/vis/usr/share/vis/lexers/README.md

execute_after_dh_auto_clean:
	# Cleanup the test suite submodule.
	# Remove if https://github.com/martanne/vis/pull/848 lands.
	$(MAKE) -C test clean
