#!/usr/bin/make -f

ifeq (,$(filter terse,${DEB_BUILD_OPTIONS}))
export DH_VERBOSE=1
export V=1
export VERBOSE=1
endif

LC_ALL:=C.UTF-8
export LC_ALL
TZ:=UTC
export TZ

OUR_CPPFLAGS:=
OUR_CXXFLAGS:=
OUR_LDFLAGS:=

# unclutter build log; these are upstream’s to fix
OUR_CPPFLAGS+=	-Wno-deprecated-declarations

#XXX TODO: drop with new upstream version (once merged)
# cf. debian/patches/fix-build.diff
OUR_CXXFLAGS+=	-ffloat-store

# only needed when backporting to buster and older
#OUR_LDFLAGS+=	-Wl,--as-needed

dpkgbuildflagsmkescape=$(subst \,\\\,$(1))
export DEB_BUILD_MAINT_OPTIONS:=hardening=+all
export DEB_CPPFLAGS_MAINT_APPEND:=$(call dpkgbuildflagsmkescape,${OUR_CPPFLAGS})
export DEB_CXXFLAGS_MAINT_APPEND:=$(call dpkgbuildflagsmkescape,${OUR_CXXFLAGS})
export DEB_LDFLAGS_MAINT_APPEND:=$(call dpkgbuildflagsmkescape,${OUR_LDFLAGS})
include /usr/share/dpkg/buildflags.mk
ifneq (,$(wildcard /usr/share/dpkg/buildtools.mk))
include /usr/share/dpkg/buildtools.mk
endif

%:
	dh $@ -Dsources

# fixup https://github.com/davy7125/polyphone/commit/7a5e009f92bd628bdd60eb52cb53cc766dcb61e9
execute_before_dh_auto_configure:
	cp sources/contrib/com.polyphone_soundfonts.polyphone.pro \
	   sources/contrib/com.polyphone_soundfonts.polyphone.desktop

execute_before_dh_auto_clean:
	-rm -f sources/contrib/com.polyphone_soundfonts.polyphone.desktop
