#!/usr/bin/make -f

# $Progeny$

export DH_COMPAT=2

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 stores Python modules in versioned directories
PYTHON_VERSION=2.4

configure: configure-stamp
configure-stamp:
	dh_testdir
	buildtools/setup
	./configure --prefix=/usr --mandir=/usr/share/man
	sed s/@VER@/${PYTHON_VERSION}/ \
	  < debian/pythonVER-configlet.dirs \
	  > debian/python${PYTHON_VERSION}-configlet.dirs
	touch $@

build: configure build-stamp
build-stamp:
	dh_testdir
	make all
	touch $@

clean: configure
	dh_testdir
	dh_testroot
	make maintainer-clean
	dh_clean
	rm -f debian/python${PYTHON_VERSION}-configlet.dirs
	rm -f configure-stamp build-stamp

install: build
	dh_testdir
	dh_testroot
	dh_clean -k
	dh_installdirs

	${INSTALL_MODULE} configlet.py \
		${CURDIR}/debian/python${PYTHON_VERSION}-configlet/usr/lib/python${PYTHON_VERSION}/site-packages
	${INSTALL_SCRIPT} configlets-text \
		${CURDIR}/debian/python${PYTHON_VERSION}-configlet/usr/bin
	${INSTALL_SCRIPT} test-configlets \
		${CURDIR}/debian/python${PYTHON_VERSION}-configlet/usr/bin
	${INSTALL_SCRIPT} update-configlets \
		${CURDIR}/debian/python${PYTHON_VERSION}-configlet/usr/sbin
	${INSTALL_SCRIPT} configlets-druid \
		${CURDIR}/debian/configlet-frontends/usr/sbin
	${INSTALL_SCRIPT} configlet-capplet \
		${CURDIR}/debian/configlet-frontends/usr/bin
	${INSTALL_SCRIPT} update-configlet-frontends \
		${CURDIR}/debian/configlet-frontends/usr/share/configlet-frontends
	${INSTALL_SCRIPT} update-firstboot \
		${CURDIR}/debian/configlet-frontends/usr/share/configlet-frontends
	${INSTALL_MODULE} firstboot.py \
		${CURDIR}/debian/configlet-frontends/usr/share/configlet-frontends
	${INSTALL_MODULE} fbhelper.py \
		${CURDIR}/debian/configlet-frontends/usr/share/configlet-frontends
#	${INSTALL_DATA} progeny-notrans-icon.png \
#		${CURDIR}/debian/configlet-frontends/usr/share/pixmaps

	${INSTALL_DATA} debian.directory \
		${CURDIR}/debian/configlet-frontends/usr/share/control-center/Debian/.directory
	${INSTALL_DATA} debian.directory \
		${CURDIR}/debian/configlet-frontends/usr/share/gnome/apps/Settings/Debian/.directory

	${INSTALL_DATA} documentation/configlet-capplet.1 \
		${CURDIR}/debian/configlet-frontends/usr/share/man/man1
	${INSTALL_DATA} documentation/update-configlets.1 \
		${CURDIR}/debian/python${PYTHON_VERSION}-configlet/usr/share/man/man1
	${INSTALL_DATA} documentation/configlets-druid.1 \
		${CURDIR}/debian/configlet-frontends/usr/share/man/man1
	${INSTALL_DATA} documentation/test-configlets.1 \
		${CURDIR}/debian/python${PYTHON_VERSION}-configlet/usr/share/man/man1
	${INSTALL_DATA} documentation/configlets-text.1 \
		${CURDIR}/debian/python${PYTHON_VERSION}-configlet/usr/share/man/man1

	${INSTALL_DATA} documentation/book/book.html \
		${CURDIR}/debian/python${PYTHON_VERSION}-configlet/usr/share/doc/python${PYTHON_VERSION}-configlet/book
	${INSTALL_DATA} documentation/book/api/*.html \
		${CURDIR}/debian/python${PYTHON_VERSION}-configlet/usr/share/doc/python${PYTHON_VERSION}-configlet/book/api

binary-indep: build install
	dh_testdir
	dh_testroot
	install -m 755 -d debian/configlet-frontends/usr/share/lintian/overrides
	install -m 644 debian/configlet-frontends.lintian-overrides debian/configlet-frontends/usr/share/lintian/overrides/configlet-frontends
	dh_installdocs
	dh_installman
	dh_installchangelogs
	dh_compress
	dh_fixperms
	dh_installdeb
	dh_gencontrol
	dh_md5sums
	dh_builddeb

binary-arch: build install
	# nothing to do for binary-arch

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