#!/usr/bin/make -f
# Model by Ian Jackson.
# Debhelper model by Joey Hess.
# Autoconf details by Ben Pfaff.
# Released under the GNU GPL.
# dh7 support by Marcin Mielniczuk

PATH:=/usr/bin/dh7:/usr/bin:$(PATH)
export PATH
SBOX_REDIRECT_IGNORE=/usr/bin/perl
export SBOX_REDIRECT_IGNORE

configure: configure-stamp
configure-stamp:
	dh_testdir
	perl -pi~ -e "s/^my \\\$$VERSION.*/my \\\$$VERSION = '`date`';/;" \
		lib/Autom4te/C4che.pm
	touch configure `find . -name Makefile.in`
	AWK=awk EMACS=no ./configure --prefix=/usr --with-lispdir=
	touch configure-stamp

build: configure-stamp build-stamp
build-stamp:
	dh_testdir
	make
	touch build-stamp

clean:
	dh_testdir
	dh_testroot
	rm -f build-stamp configure-stamp
	[ ! -f Makefile ] || $(MAKE) distclean
	rm -f *.m4f
	rm -f doc/*.info
	rm -rf debian/autoconf # due to package name change this isn't cleaned automatically
	dh_clean

install: build
	dh_testdir
	dh_testroot
	dh_prep

binary-arch:
	# Nothing to do

binary-indep: build install
	dh_testdir
	dh_testroot

	$(MAKE) CFLAGS=-O2 LDFLAGS=-s DESTDIR="`pwd`/debian/autoconf2.67" install
	rm -rf debian/autoconf2.67/usr/{man,share/man,info,share/info}

	install -d debian/autoconf2.67/usr/share/emacs/site-lisp/autoconf
	install -m 644 lib/emacs/autotest-mode.el debian/autoconf2.67/usr/share/emacs/site-lisp/autoconf
	install -d debian/autoconf2.67/etc/emacs/site-start.d
	install -m 644 debian/autoconf2.67.emacsen-startup debian/autoconf2.67/etc/emacs/site-start.d/50autoconf.el

	dh_installdocs NEWS debian/NEWS.Debian README
	dh_installman debian/man/*.1
	dh_installchangelogs
	dh_link
	dh_compress
	dh_fixperms
	dh_installdeb
	dh_shlibdeps
	dh_gencontrol
	maemo-optify
	dh_md5sums
	dh_builddeb

binary: binary-indep
.PHONY: build clean binary-arch binary-indep binary install
