#!/usr/bin/make -f

%:
	dh ${@} 

override_dh_auto_clean:
	[ ! -f Makefile ] || make maintainer-clean
	dh_auto_clean
	rm -f INSTALL \
	Makefile.in \
	aclocal.m4 \
	compile \
	config \
	guess \
	config.h.in \
	config.sub \
	configure \
	depcomp \
	doc/Makefile.in \
	install-sh \
	lib/Makefile.in \
	ltmain.sh \
	missing \
	pic/Makefile.in \
	util/Makefile.in

override_dh_auto_configure:
	autoreconf -fi
	dh_auto_configure -- --disable-x11 --disable-rpath  \
	     $(shell dpkg-buildflags --export=configure)

override_dh_auto_install:
	dh_auto_install

	# Installing additional documentation
	mkdir -p debian/giflib-tools/usr/share/doc/giflib-tools/html
	cp -a doc/*.txt debian/giflib-tools/usr/share/doc/giflib-tools/
	cp -a doc/*.html debian/giflib-tools/usr/share/doc/giflib-tools/html

	# Creating manpages "on the fly"
	for i in `ls debian/tmp/usr/bin`; do \
	  if [ ! -e debian/$$i.1 ]; then \
	    sed -f debian/htmltoman.sed doc/$$i.html > debian/$$i.1 && \
	    echo debian/$$i.1 >> debian/giflib-tools.manpages; \
	  fi \
	done

override_dh_strip:
	dh_strip --dbg-package=giflib-dbg

override_dh_makeshlibs:
	dh_makeshlibs -V 'libgif4 (>=4.1.6)'
