#!/usr/bin/make -f

export DH_VERBOSE=1

export DEB_BUILD_MAINT_OPTIONS = hardening=+all

# Fail on undefined symbols in the module
export DEB_LDFLAGS_MAINT_APPEND = -Wl,-z,defs

DEB_HOST_MULTIARCH ?= $(shell dpkg-architecture -qDEB_HOST_MULTIARCH)

SECDIR = /lib/$(DEB_HOST_MULTIARCH)/security

%:
	dh $@  --with autoreconf

override_dh_auto_test:
#	#fails under OBS

#override_dh_autoreconf:
#	find ! -ipath "./debian/*" -a ! \( -path '*/.git/*' -o -path '*/.hg/*' -o -path '*/.bzr/*' -o -path '*/.svn/*' -o -path '*/CVS/*' \) -a  -type f -exec md5sum {} \; > debian/autoreconf.before
#	autoreconf -i
#	find ! -ipath "./debian/*" -a ! \( -path '*/.git/*' -o -path '*/.hg/*' -o -path '*/.bzr/*' -o -path '*/.svn/*' -o -path '*/CVS/*' \) -a  -type f -exec md5sum {} \; > debian/autoreconf.after

override_dh_auto_configure:
	dh_auto_configure -- \
		--with-pam-mods-dir=$(SECDIR) \
		--with-openssl

override_dh_auto_install:
	$(MAKE) install DESTDIR=$(CURDIR)/debian/libpam-mysql

override_dh_install:
	rm -f debian/libpam-mysql/$(SECDIR)/pam_mysql.la || true
	dh_install --

override_dh_missing:
	dh_missing --fail-missing

override_dh_fixperms:
	dh_fixperms
	chmod 640 debian/libpam-mysql/etc/pam-mysql.conf
