#!/usr/bin/make -f

# Enabling PIE globally doesn't work, but ./configure already enables PIE
# where necessary.
export DEB_BUILD_MAINT_OPTIONS = hardening=+all,-pie

# as needed is the default now and is just needed for backports
#export DEB_LDFLAGS_MAINT_APPEND = -Wl,--as-needed

# The build system uses only DSOFLAGS but not LDFLAGS to build some libraries.
# Add LDFLAGS to enable (hardening) build flags.
export DSOFLAGS = $(shell dpkg-buildflags --get LDFLAGS)

DEB_HOST_ARCH_OS ?= $(shell dpkg-architecture -qDEB_HOST_ARCH_OS)
DEB_BUILD_GNU_TYPE  ?= $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE)


# autoreconf intentionally deactivated, upstream knows more about the real reason
%:
	dh $@ --without autoreconf

override_dh_auto_clean:
	[ ! -f Makedefs ] || dh_auto_clean
	[ ! -f Makedefs ] || make distclean

# for whatever reason mupdf is not really detected here
override_dh_auto_configure:
	dh_auto_configure -- --with-pdfrip=auto

override_dh_auto_test:
	echo "libcups tests do not really work here, so deactivating them for now"

override_dh_shlibdeps:
	find
	pwd
	dh_shlibdeps --dpkg-shlibdeps-params=--ignore-missing-info -l$(shell pwd)/debian/tmp/usr/lib/$(DEB_BUILD_GNU_TYPE)/
