#!/usr/bin/make -f

# $Progeny: rules 3839 2003-11-17 04:25:01Z dsp $

export DH_COMPAT=3

INSTALL=                /usr/bin/install
INSTALL_DATA=           ${INSTALL} -m 644 -o root -g root
INSTALL_MODULE=         ${INSTALL_DATA}
INSTALL_SCRIPT=         ${INSTALL} -m 755 -o root -g root

debian/config: debian/config.in debian/perl-common
	cat debian/config.in | sed 's/\\/\\\\/' | \
	    (IFS=""; while read line; do \
	        if [ `echo $$line | grep '#COMMON#' | wc -l` -ne 0 ]; then \
	            cat debian/perl-common; \
	        else \
	            echo "$$line"; \
	        fi; \
	    done) > debian/config

debian/postinst: debian/postinst.in debian/perl-common
	cat debian/postinst.in | sed 's/\\/\\\\/' | \
	    (IFS=""; while read line; do \
	        if [ `echo $$line | grep '#COMMON#' | wc -l` -ne 0 ]; then \
	            cat debian/perl-common; \
	        else \
	            echo "$$line"; \
	        fi; \
	    done) > debian/postinst

build: build-stamp
build-stamp:
	dh_testdir

	touch build-stamp

clean:
	dh_testdir
	dh_testroot

	rm -f debian/config
	rm -f debian/postinst

	rm -f build-stamp

	dh_clean

install: build
	dh_testdir
	dh_testroot
	dh_clean -k
	dh_installdirs

	$(INSTALL_DATA) configlet/main.py debian/aptconf/usr/share/configlets/aptconf
	$(INSTALL_DATA) configlet/main.glade debian/aptconf/usr/share/configlets/aptconf
	$(INSTALL_DATA) configlet/aptconf-strings.h debian/aptconf/usr/share/configlets/aptconf
	$(INSTALL_DATA) debian.xml debian/aptconf/usr/share/aptconf
	$(INSTALL_DATA) configlet/topic.dat debian/aptconf/usr/share/gnome/help/aptconf/C
	$(INSTALL_DATA) configlet/aptconf.sgml debian/aptconf/usr/share/gnome/help/aptconf/C

	for image in configlet/images/*.png; do \
	    $(INSTALL_DATA) $$image debian/aptconf/usr/share/gnome/help/aptconf/C/images; \
	done

	cd debian/aptconf/usr/share/gnome/help/aptconf/C && gnome-db2html aptconf.sgml

binary-indep: build install debian/config debian/postinst
	dh_testdir
	dh_testroot
	dh_installdebconf	
	dh_installdocs
	dh_installchangelogs 
	dh_compress
	dh_fixperms
	dh_installdeb
	dh_gencontrol
	dh_md5sums
	dh_builddeb

binary-arch: build install
# Nothing to do here

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