#!/usr/bin/make -f
# -*- makefile -*-
# Uncomment this to turn on verbose mode.
# export DH_VERBOSE=1

# see FEATURE AREAS in dpkg-buildflags(1)
export DEB_BUILD_MAINT_OPTIONS = hardening=+all
export DEB_LDFLAGS_MAINT_APPEND = -Wl,--as-needed -Wl,-O1 -Wl,-z,defs
export QT_SELECT := 5

include /usr/share/dpkg/default.mk

PYVER=$(shell pyversions -vd)

%:
	dh $@ --with python2 --no-parallel

override_dh_auto_configure:
	dh_auto_configure -- PYTHON_VERSION=$(PYVER)

override_dh_auto_build:
	dh_auto_build
	doxygen doxygen.cfg

override_dh_install:
	chrpath -d $(CURDIR)/debian/tmp/usr/lib/python*/*-packages/plist.so
	# Remove files we won't install
	rm -f $(CURDIR)/debian/tmp/usr/lib/python*/*-packages/plist.a
	rm -f $(CURDIR)/debian/tmp/usr/lib/python*/*-packages/plist.la
	rm -f $(CURDIR)/debian/tmp/usr/lib/*/*.la
	rm -f $(CURDIR)/debian/tmp/usr/lib/*/*.a
	# Continue with dh_install
	dh_install

override_dh_missing:
	dh_missing --fail-missing

manpage_name = plistutil-$(DEB_VERSION_UPSTREAM).1

debian/$(manpage_name): debian/plistutil.1
	cp $< $@

override_dh_installman: debian/$(manpage_name)
	dh_installman

override_dh_link:
	dh_link
	dh_link -p libplist-utils /usr/share/man/man1/$(manpage_name).gz /usr/share/man/man1/plistutil.1.gz

override_dh_python2:
	# Only build for the current version of python, not all supported.
	dh_python2 --no-guessing-versions

override_dh_strip:
	dh_strip --dbgsym-migration='libplist-dbg (<< 2.0.0-4~)'

override_dh_makeshlibs:
	dh_makeshlibs -- -c4

override_dh_auto_clean:
	dh_auto_clean
	rm -Rf docs/
	rm -f test/data/*.out

#override_dh_auto_test:
#Make the test suit fatal on supported arches (See README.Debian)
#ifneq (,$(filter $(DEB_HOST_ARCH),amd64 i386 kfreebsd-amd64 kfreebsd-amd64))
#	dh_auto_test
#else
#	dh_auto_test || true
#endif
