#!/usr/bin/make -f

shellescape='$(subst ','\'',$(1))'
shellexport=$(1)=$(call shellescape,${$(1)})

ifeq (,$(findstring terse,${DEB_BUILD_OPTIONS}))
export DH_VERBOSE=1
export V=1
export VERBOSE=1
endif

LC_ALL:=C
export LC_ALL

DEB_BUILD_ARCH?=$(shell dpkg-architecture -qDEB_BUILD_ARCH)
DEB_BUILD_GNU_TYPE?=$(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE)
DEB_HOST_ARCH?=$(shell dpkg-architecture -qDEB_HOST_ARCH)
DEB_HOST_GNU_TYPE?=$(shell dpkg-architecture -qDEB_HOST_GNU_TYPE)

# is ${CC} defined anywhere (other than implicit rules?)
ifneq (,$(findstring $(origin CC),default undefined))
# no - then default to gcc (or cross-gcc)
ifneq (${DEB_BUILD_ARCH},${DEB_HOST_ARCH})
CC=			${DEB_HOST_GNU_TYPE}-gcc
else
CC?=			gcc
endif
endif

EXTRA_CFLAGS+=		-Wall

export DEB_CFLAGS_MAINT_APPEND := ${EXTRA_CFLAGS}
export DEB_BUILD_MAINT_OPTIONS := hardening=+all
include /usr/share/dpkg/buildflags.mk

# detect i386 and force-enable VIA PadLock support
ifneq (,$(findstring i386,${DEB_HOST_ARCH}))
CONFIGURE_ARGS+=	--enable-viapadlock
endif

%:
	dh $@ --with autoreconf

override_dh_auto_configure:
	dh_auto_configure -- ${CONFIGURE_ARGS}

override_dh_installinit:
	dh_installinit --error-handler=true
