#!/usr/bin/make -f

export DEB_BUILD_MAINT_OPTIONS = hardening=+all

%:
	dh $@

override_dh_auto_configure:
	./bootstrap.sh

	touch configure.in && \
	touch aclocal.m4 && \
	touch configure

	head -n 1 debian/changelog | sed 's/[^(]*(\([^-]*\)-.*/\1/' > .tarball-version
	autoreconf -fi

	CFLAGS=-I.. dh_auto_configure --builddirectory=mtr -- $(shell dpkg-buildflags --export=configure >/dev/null 2>&1 && dpkg-buildflags --export=configure) $(confflags)

	CFLAGS=-I.. dh_auto_configure --builddirectory=mtr-tiny -- $(shell dpkg-buildflags --export=configure >/dev/null 2>&1 && dpkg-buildflags --export=configure) $(confflags) --without-gtk

override_dh_auto_build:
	dh_auto_build -- -C mtr
	dh_auto_build -- -C mtr-tiny

override_dh_auto_clean:
	rm -f Makefile.in
	rm -f aclocal.m4
	rm -f configure
	rm -f configure.in
	rm -rf mtr
	rm -rf mtr-tiny
	rm -f .tarball-version
	dh_auto_clean

override_dh_installdirs-arch:
	dh_installdirs -a
	dh_auto_install --builddirectory=mtr --destdir=debian/mtr
	dh_auto_install --builddirectory=mtr-tiny --destdir=debian/mtr-tiny

override_dh_installchangelogs-arch:
	dh_installchangelogs -a NEWS

override_dh_fixperms-arch:
	dh_fixperms -a
