#!/usr/bin/make -f

# Enable hardening. Disable link time optimization flags.
# However, note that the actual flags _are_ passed to the
# compiler in build/flavour-debian.mk.
# So link time optimization is enabled.
export DEB_BUILD_MAINT_OPTIONS = hardening=+all optimize=-lto

%:
	dh $@

override_dh_auto_build:
	dh_testdir
	$(MAKE) V=2 OPENMSX_FLAVOUR=debian
	docbook-to-man doc/openmsx.sgml > debian/openmsx.1
	$(MAKE) -C Contrib/dmk
	$(MAKE) -C Contrib/tsx

override_dh_auto_clean:
	dh_testdir
	dh_testroot
	$(MAKE) clean
	rm -rf Contrib/dmk/build/
	rm -rf Contrib/tsx/build/
	rm -rf derived/
	rm -f debian/openmsx.1
	rm -f src/unittest/catch.hpp
	rm -rf build/__pycache__
	dh_clean 

override_dh_auto_install:
	$(MAKE) install DESTDIR=$(CURDIR)/debian/tmp OPENMSX_FLAVOUR=debian
	rm debian/tmp/usr/share/openmsx/skins/DejaVuSans.ttf.gz
	rm debian/tmp/usr/share/openmsx/skins/DejaVuSansMono.ttf.gz
	rm debian/tmp/usr/share/doc/openmsx-data/release-history.txt
	rm debian/tmp/usr/share/doc/openmsx-data/GPL.txt
	chmod a-x debian/tmp/usr/share/openmsx/machines/*.xml
	dh_install -X release-history.txt
	dh_installchangelogs -i doc/release-history.txt
	dh_installman -a debian/openmsx.1
	dh_link -a usr/share/doc/openmsx-data usr/share/doc/openmsx

override_dh_auto_test:
	# No testsuite available.
	# This makes sure dh doesn't attempt to run it anyway (see #718133)
