#!/usr/bin/make -f

include /usr/share/dpkg/architecture.mk

# Uncomment this to turn on verbose mode.
#export DH_VERBOSE = 1

export DEB_BUILD_MAINT_OPTIONS = hardening=+all
export DEB_CFLAGS_MAINT_APPEND = \
	-DJUCE_INCLUDE_ZLIB_CODE=0 $(shell pkg-config --cflags zlib) \
	-DJUCE_INCLUDE_JPEGLIB_CODE=0 $(shell pkg-config --cflags libjpeg) \
	-DJUCE_INCLUDE_PNGLIB_CODE=0 $(shell pkg-config --cflags libpng) \
	-pthread
export DEB_CXXFLAGS_MAINT_APPEND = \
	-DJUCE_INCLUDE_ZLIB_CODE=0 $(shell pkg-config --cflags zlib) \
	-DJUCE_INCLUDE_JPEGLIB_CODE=0 $(shell pkg-config --cflags libjpeg) \
	-DJUCE_INCLUDE_PNGLIB_CODE=0 $(shell pkg-config --cflags libpng) \
	-pthread
export DEB_LDFLAGS_MAINT_APPEND = \
	$(shell pkg-config --libs zlib) \
	$(shell pkg-config --libs libjpeg) \
	$(shell pkg-config --libs libpng) \
	-lpthread -ldl -Wl,--as-needed

%:
	dh $@

override_dh_auto_configure:
	dh_auto_configure -- -DLIB_SUFFIX="/$(DEB_HOST_MULTIARCH)"

override_dh_auto_build-indep:
ifeq (,$(findstring nodoc,$(DEB_BUILD_PROFILES)))
	dh_auto_build -- doc
endif

# NOTE: This override is required to ensure only non-empty directories are
# effectively installed.
override_dh_install-arch:
	find debian/tmp -type d -empty -delete
	dh_install --arch

override_dh_installdocs-indep:
ifeq (,$(findstring nodoc,$(DEB_BUILD_PROFILES)))
	dh_installdocs --indep
	dh_doxygen --indep
endif
