#!/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 DEB_BUILD_MAINT_OPTIONS = hardening=+all

CPPFLAGS:=$(shell dpkg-buildflags --get CPPFLAGS)
CXXFLAGS:=$(shell dpkg-buildflags --get CXXFLAGS) $(CPPFLAGS) -pthread
LDFLAGS:=$(shell dpkg-buildflags --get LDFLAGS) -Wl,--as-needed -pthread

CMAKEOPT= -DCMAKE_CXX_FLAGS="$(CXXFLAGS)"\
          -DCMAKE_SHARED_LINKER_FLAGS="$(LDFLAGS)" \
          -DCMAKE_EXE_LINKER_FLAGS="$(LDFLAGS)" \
          -DCMAKE_BUILD_TYPE=Release \

DEBIAN_CODENAME = $(shell echo $$DIST)
ifeq "$(DEBIAN_CODENAME)" ""
	DEBIAN_CODENAME = $(shell dpkg-parsechangelog | awk '/^Distribution: / {print $$2}')
endif

%:
	dh $@ --parallel


override_dh_auto_configure:
	dh_auto_configure -- $(CMAKEOPT)

override_dh_auto_test:

override_dh_install:
	dh_install
	#mv $(CURDIR)/debian/scantailor-universal/usr/bin/scantailor \
	#$(CURDIR)/debian/scantailor-universal/usr/bin/scantailor-universal
	#mv $(CURDIR)/debian/scantailor-universal/usr/bin/scantailor-cli \
	#$(CURDIR)/debian/scantailor-universal/usr/bin/scantailor-universal-cli

override_dh_builddeb:
	dh_builddeb -- -Zxz -z9
