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

export LC_ALL=C.UTF-8
export HOME=$(CURDIR)/tmp

export DEB_BUILD_MAINT_OPTIONS = hardening=+all

DEB_CXXFLAGS_MAINT_APPEND=
DEB_LDFLAGS_MAINT_APPEND=
ifneq (,$(filter $(DEB_HOST_ARCH), i386))
    DEB_CXXFLAGS_MAINT_APPEND+=-ffloat-store
endif
DEB_LDFLAGS_MAINT_APPEND+= -Wl,--as-needed

export DEB_CXXFLAGS_MAINT_APPEND
export DEB_LDFLAGS_MAINT_APPEND

export QT_SELECT := qt5

%:
	dh $@

override_dh_auto_build:
	mkdir -p $(CURDIR)/tmp
	cp $(CURDIR)/debian/missing-sources/piper.capnp \
		$(CURDIR)/piper-cpp/vamp-capnp
	capnp compile -o c++ $(CURDIR)/piper-cpp/vamp-capnp/piper.capnp
	dh_auto_build

override_dh_auto_clean:
	dh_auto_clean
	rm -f $(CURDIR)/piper-cpp/vamp-capnp/piper.capnp
	rm -f $(CURDIR)/piper-cpp/vamp-capnp/piper.capnp.c++
	rm -f $(CURDIR)/piper-cpp/vamp-capnp/piper.capnp.h
	rm -rf $(CURDIR)/tmp

licensecheck:
	licensecheck --deb-machine -r * \
		> debian/copyright_newhints
	cmp debian/copyright_hints debian/copyright_newhints \
		&& rm debian/copyright_newhints
