#!/usr/bin/make -f
# -*- makefile -*-

# Uncomment this to turn on verbose mode.
#export DH_VERBOSE=1

export CFLAGS+=-UGDK_DISABLE_DEPRECATED
export DEB_BUILD_HARDENING=1

# This is a bit hacky.
override_dh_auto_configure:
	NOCONFIGURE=y ./autogen.sh
	dh_auto_configure -- \
		--enable-maintainer-mode \
		--disable-introspection \
		--enable-gtk-doc \
		--enable-gtk-doc-html \
		--enable-gtk-doc-pdf

override_dh_auto_install:
	for py in $(shell pyversions -r); do \
		PYTHON=$$py dh_auto_configure -Dpython/; \
		dh_auto_build -Dpython/; \
		dh_auto_install -Dpython/; \
		dh_auto_clean -Dpython/; \
		find $(CURDIR)/debian/tmp/usr/lib/$$py \( -name "*.a" -o -name "*.la" \) -delete ; \
	done
	dh_auto_install
	rm -rf $(CURDIR)/debian/python-osmgpsmap/usr/share/pyshared/gtk-2.0/

override_dh_auto_clean:
	dh_auto_clean
	find . \( -name "*.o" -o -name "*.lo" -o -name "*.la" \) -delete
	find . \( -name "*.in" -a -not -name "osmgpsmap.pc.in" -a -not -name "version.xml.in" \) -delete
	find . \( -name ".deps" -o -name ".libs" -o -name "autom4te.cache" \) -type d | xargs rm -rf

	find . -name "Makefile" -delete
	find . \( -name "config.guess" -o -name "config.h" -o -name "config.log" \
		-o -name "config.sub" -o -name "config.status" -o -name "configure" \) -delete
	find . \( -name "install-sh" -o -name "libtool" -o -name "ltmain.sh" \
		-o -name "missing" -o -name "INSTALL" \
		-o -name "aclocal.m4" -o -name "depcomp" \) -delete
	rm -rf docs/reference/tmpl/

override_dh_strip:
	dh_strip --keep-debug --dbg-package=libosmgpsmap2-dbg

%:
	dh $@ \
		--with python2
