#!/usr/bin/make -f
# -*- makefile -*-
#
# debian/rules file for package `console-tools'

# turn around bug in dpkg-parsechangelog
export LC_ALL=C

package=console-tools-data
VERSION=$(shell LC_ALL=C dpkg-parsechangelog | grep ^Version: | sed 's/^Version: *//')

UUENCODED=

ARCH=$(shell dpkg --print-architecture)

topdir=$(shell pwd)
builddir=${topdir}/debian/BUILD
debdir=${topdir}/debian
tmpdir=${debdir}/tmp
docdir=${tmpdir}/usr/doc/${package}
exampledir=${docdir}/examples

build: build-stamp
build-stamp: configure-stamp
	dh_testdir
	make -C ${builddir}
	touch build-stamp

configure-stamp:
	dh_testdir
	mkdir -p ${builddir}
	( cd ${builddir} && ${topdir}/configure --with-main_compressor=gzip )
	touch configure-stamp

clean:
	dh_testdir
	dh_testroot
	rm -f build-stamp configure-stamp
	-make -C ${builddir} distclean
	rm -rf ${builddir}
	dh_clean

binary-indep:	build
	dh_testdir -i
	dh_testroot -i
	dh_clean -i -k

	dh_installdirs -i

	make -C ${builddir} install DESTDIR=${tmpdir}

#     # uudecode new binary files
#	( cd ${tmpdir}/usr/share/ && for i in ${UUENCODED} ; do \
#	  uudecode ${debdir}/$${i}.uue ;\
#	  gzip -9 */$${i} ;\
#	done )

     # install Debian dotfiles
	( cd ${debdir}/keymaps-dotfiles/ && \
	  find -type f -exec sh -c "cp {} ${tmpdir}/usr/share/keymaps/{}" \; )

	dh_installdocs -i
#	dh_installexamples -i
	mv ${tmpdir}/usr/doc/console-tools-data/keymaps/hypermap.m4 \
		${tmpdir}/usr/doc/console-tools-data/examples/
	dh_installchangelogs

     # these fonts have a redistribution restriction
	rm -f ${tmpdir}/usr/share/consolefonts/Agafari-1*

	dh_compress -i
	dh_fixperms -i
	dh_installdeb -i
	dh_gencontrol -i -u '-isp'
	dh_md5sums -i
	dh_builddeb -i

binary-arch:
	:

# Below here is fairly generic really

binary:		binary-indep binary-arch

.PHONY: binary binary-arch binary-indep clean checkroot
