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

CFLAGS = -Wall -g
LDFLAGS = -Wl,-z,defs -Wl,--as-needed

ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS)))
	CFLAGS += -O0
else
	CFLAGS += -O2 -fno-omit-frame-pointer
endif

%:
	dh $@

override_dh_auto_configure:
	chmod +x debian/autogen.sh
	debian/autogen.sh

	ln -sf /usr/share/misc/config.sub .
	ln -sf /usr/share/misc/config.guess .
	rm -f config.cache

	dh_auto_configure -- --disable-update-mimedb

override_dh_auto_clean:
	dh_auto_clean

	find -type d -name autom4te.cache -print0 | xargs -0 rm -rf \;
	find -type f \( -name aclocal.m4 -o -name INSTALL -o -name missing \
		-o -name install-sh -o -name depcomp -o -name ltmain.sh \
		-o -name configure -o -name Makefile.in -o -name Makefile \
		\) -print0 | xargs -0 rm -f
	find \( -name config.sub -o -name config.guess \
		-o -name config.cache -o -name config.log \) -print0 \
		| xargs -0 -r rm -f \;
