#!/usr/bin/make -f
# See debhelper(7) (uncomment to enable)
# output every command that modifies files on the build system.
#export DH_VERBOSE = 1


# see FEATURE AREAS in dpkg-buildflags(1)
#export DEB_BUILD_MAINT_OPTIONS = hardening=+all

# see ENVIRONMENT in dpkg-buildflags(1)
# package maintainers to append CFLAGS
#export DEB_CFLAGS_MAINT_APPEND  = -Wall -pedantic
# package maintainers to append LDFLAGS
#export DEB_LDFLAGS_MAINT_APPEND = -Wl,--as-needed


%:
	dh $@ 

# set $HOME to a dummy directory, because cmake tries to write stuff to $HOME
override_dh_auto_build: FAKEHOME = HOME=$(CURDIR)/fakehome
override_dh_auto_build:
	[ -d fakehome ] || mkdir fakehome
	$(FAKEHOME) cmake -Hmtxclient -B.deps -DCMAKE_VERBOSE_MAKEFILE=ON -DBUILD_LIB_TESTS=OFF -DBUILD_SHARED_LIBS=OFF
	$(FAKEHOME) cmake --build .deps
	$(FAKEHOME) cmake -H. -Bbuild -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCMAKE_INSTALL_PREFIX=.deps/usr -DCMAKE_VERBOSE_MAKEFILE=ON
	$(FAKEHOME) cmake --build build
	rm -rf fakehome

override_dh_auto_test:
	#

override_dh_auto_clean:
	rm -rf .deps build fakehome

make-orig-source: VERSION = `dpkg-parsechangelog | grep ^Version | sed 's/Version: \(.*\)-[^-]*/\1/'`
make-orig-source:
	tar czf ../nheko_$(VERSION).orig.tar.gz --exclude-vcs --exclude-backups --exclude /debian --exclude /mtxclient -C .. `basename $(CURDIR)`
	tar czf ../nheko_$(VERSION).orig-mtxclient.tar.gz --exclude-vcs --exclude-backups mtxclient
