#!/usr/bin/make -f

export DEB_BUILD_MAINT_OPTIONS = hardening=+all

export DEB_CFLAGS_MAINT_APPEND = -fno-strict-aliasing
export DEB_CXXFLAGS_MAINT_APPEND = -fno-strict-aliasing

include /usr/share/dpkg/architecture.mk

# Determine the version of XPLC automatically
PKG_VERSION := $(shell awk -F, '/AC_INIT/{print $$2}' configure.ac \
		 | sed 's/[ 	]//g')

%:
	dh $@

# Make sure the install files are in the right place
execute_before_dh_auto_install:
	cp -f debian/libxplc.install debian/libxplc$(PKG_VERSION)t64.install
	cp -f debian/libxplc-dev.install debian/libxplc$(PKG_VERSION)-dev.install
	cp -f debian/libxplc-dev.examples debian/libxplc$(PKG_VERSION)-dev.examples

# Turn symlinks into the real binary
execute_after_dh_auto_install:
	ln -f debian/tmp/usr/bin/uuidgen debian/tmp/usr/bin/uuidcdef
	ln -f debian/tmp/usr/share/man/man1/uuidgen.1 debian/tmp/usr/share/man/man1/uuidcdef

execute_after_dh_shlibdeps:
	/sbin/ldconfig -v -n debian/libxplc$(PKG_VERSION)t64/usr/lib/$(DEB_HOST_MULTIARCH)

execute_after_dh_auto_clean:
	rm -f debian/libxplc$(PKG_VERSION)t64.install
	rm -f debian/libxplc$(PKG_VERSION)-dev.install
	rm -f debian/libxplc$(PKG_VERSION)-dev.examples

# Don't install the CVS/ and .cvsignore from the examples
override_dh_installexamples:
	dh_installexamples -XCVS -X.cvsignore

override_dh_installdocs:
	dh_installdocs -A CREDITS NEWS README TODO

override_dh_auto_test:
	$(MAKE) tests
