#!/usr/bin/make -f

export DEB_BUILD_MAINT_OPTIONS = hardening=+all

DPKG_EXPORT_BUILDFLAGS = 1
include /usr/share/dpkg/buildflags.mk

DPKG_EXPORT_BUILDTOOLS = 1
include /usr/share/dpkg/buildtools.mk

include /usr/share/dpkg/architecture.mk

%:
	dh $@ -Scmake+ninja

override_dh_auto_configure:
	dh_auto_configure -- \
	-D CMAKE_BUILD_TYPE=RelWithDebInfo \
	-D DEFAULT_SOUNDFONT=/usr/share/sounds/sf3/default-GM.sf3 \
	-D enable-ladspa=ON \
	-D enable-libinstpatch=OFF \
	-D FLUID_DAEMON_ENV_FILE=/etc/default/fluidsynth \
	$(EXTRA_CONFIGURE_ARGS)

##	-D osal=cpp11 \

#	exit 1

execute_after_dh_install:
	mv debian/fluidsynth/etc/default/fluidsynth.conf \
	   debian/fluidsynth/etc/default/fluidsynth
	sed -e "/SOUND_FONT\|OTHER_OPTS/s/^#//" \
	    -e "/OTHER_OPTS/s/'.*'/'-r 48000 -z 512'/" \
	    -i debian/fluidsynth/etc/default/fluidsynth
	mv debian/fluidsynth/usr/lib/tmpfiles.d/fluidsynth.tmpfiles \
	   debian/fluidsynth/usr/lib/tmpfiles.d/fluidsynth.conf

override_dh_auto_test:
