#!/usr/bin/make -f

derives_from_ubuntu := $(shell (dpkg-vendor --derives-from Ubuntu && echo "yes") || echo "no")

# Enabling PIE globally doesn't work, but ./configure already enables PIE
# where necessary.
export DEB_BUILD_MAINT_OPTIONS = hardening=+all,-pie
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)

%:
	dh $@ --without autoreconf

override_dh_auto_install:
	dh_auto_install -- install BUILDROOT=$(shell pwd)/debian/tmp

override_dh_install:
	dh_install

	# Ensure that we don't ship anything in /var/run or /run
	rm -rf debian/cups*/var/run
	rm -rf debian/cups*/run

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

