#!/usr/bin/make -f

export DEB_BUILD_MAINT_OPTIONS = hardening=+all

BUILDDIR = obj-$(DEB_HOST_MULTIARCH)

ifeq ($(shell pandoc -v 2>/dev/null),)
INSTALL_MANPAGES="-DINSTALL_MANPAGES=OFF"
endif

%:
	dh $@ --buildsystem=cmake

override_dh_auto_configure:
	dh_auto_configure -B $(BUILDDIR)-static -- \
		$(INSTALL_MANPAGES)
	dh_auto_configure -- \
		-DBUILD_SHARED_LIBS=ON \
		$(INSTALL_MANPAGES)

override_dh_auto_build:
	dh_auto_build -B $(BUILDDIR)-static
	dh_auto_build

override_dh_auto_build-indep:
	dh_auto_build -i -- -C doc
	touch doc/FLAC.tag && sed -e 's,>.*/include/,>/usr/include/,g' -i doc/FLAC.tag

override_dh_auto_install:
	dh_auto_install -B $(BUILDDIR)-static
	dh_auto_install

override_dh_auto_install-indep:
	dh_auto_install -i -- -C doc

execute_after_dh_auto_install-arch:
	mkdir -p debian/tmp/usr/share/man

override_dh_auto_test-arch:
	# drop (fake)root privileges,
	# but still skip running test suite
	# as it is *exhaustive*
	env -u LD_PRELOAD dh_auto_test -a --no-act

override_dh_auto_test-indep:
