#!/usr/bin/make -f

export CFLAGS := $(shell dpkg-buildflags --get CFLAGS)
export CXXFLAGS := $(shell dpkg-buildflags --get CXXFLAGS)
export CPPFLAGS := $(shell dpkg-buildflags --get CPPFLAGS)
export LDFLAGS := $(shell dpkg-buildflags --get LDFLAGS)

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

%:
	dh $@

override_dh_auto_configure:
	mv aclocal.m4 aclocal.m4.old
	mv configure configure.old
	mv Makefile.in Makefile.in.old
	cp /usr/share/libtool/config/ltmain.sh .
	aclocal
	autoconf
	automake --add-missing
	./configure \
		--prefix=/usr \
		--libdir=\$${prefix}/lib/$(DEB_HOST_MULTIARCH)

clean:
	dh_testdir
	dh_auto_clean
	dh_clean config.guess config.sub ltmain.sh
	[ ! -f aclocal.m4.old ] || mv aclocal.m4.old aclocal.m4
	[ ! -f configure.old ] || mv configure.old configure
	[ ! -f Makefile.in.old ] || mv Makefile.in.old Makefile.in

