#!/usr/bin/make -f

export QT_SELECT := qt5

%:
	dh $@

override_dh_auto_build:
	$(MAKE) DEB_CXXFLAGS="" \
		DEB_COMPILE_FLAGS="$(shell dpkg-buildflags --get CPPFLAGS) \
			$(shell dpkg-buildflags --get CXXFLAGS)" \
		DEB_LINK_FLAGS="$(shell dpkg-buildflags --get LDFLAGS)"
	# Remove rpath.
	chrpath -d derived/bin/openmsx-debugger
	# Generate manpage.
	stx2any -T man debian/openmsx-debugger.txt > debian/openmsx-debugger.1

override_dh_auto_clean:
	rm -rf derived debian/openmsx-debugger.1
	find build -name \*.pyc -exec rm {} \;

NEW_VERSION := 0.1~git$(shell date +%Y%m%d)
get-orig-source:
	test ! -e orig-source-tmp
	mkdir orig-source-tmp
	cd orig-source-tmp && wget https://github.com/openMSX/debugger/archive/master.zip
	cd orig-source-tmp && unzip master.zip
	mv orig-source-tmp/debugger-master orig-source-tmp/openmsx-debugger-$(NEW_VERSION)
	tar -C orig-source-tmp -cvzf openmsx-debugger_$(NEW_VERSION).orig.tar.gz openmsx-debugger-$(NEW_VERSION)
	rm -r orig-source-tmp
