#!/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

shellescape='$(subst ','\'',$(1))'
shellexport=$(1)=$(call shellescape,${$(1)})

DEB_HOST_ARCH?=$(shell dpkg-architecture -qDEB_HOST_ARCH)
DEB_HOST_ARCH_OS?=$(shell dpkg-architecture -qDEB_HOST_ARCH_OS)

OUR_CPPFLAGS:=
OUR_CFLAGS:=
OUR_CXXFLAGS:=
OUR_LDFLAGS:=

OUR_CPPFLAGS+=	-Wno-unused-result

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

# only needed in backports to buster and older
OUR_LDFLAGS+=	-Wl,--as-needed
export QT_SELECT=5

CONFIG_ARGS+=	CONFIG+=disable_version_check
# blocked by #686777
#CONFIG_ARGS+=	CONFIG+=opus_shared_lib

dpkgbuildflagsmkescape=$(subst \,\\\,$(1))
export DEB_BUILD_MAINT_OPTIONS:=hardening=+all
export DEB_CPPFLAGS_MAINT_APPEND:=$(call dpkgbuildflagsmkescape,${OUR_CPPFLAGS})
export DEB_CFLAGS_MAINT_APPEND:=$(call dpkgbuildflagsmkescape,${OUR_CFLAGS})
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 $@

override_dh_auto_configure:
	cd src/res/translation && lrelease *.ts
	dh_auto_configure -- ${CONFIG_ARGS}

execute_after_dh_link:
	jdupes -rl debian/jamulus/usr/share/doc/jamulus/homepage
