#!/usr/bin/make -f
# Made with the aid of debmake, by Christoph Lameter,
# based on the sample debian/rules file for GNU hello by Ian Jackson.

package=pccts

build:
	$(checkdir)
	
	touch build
	make

clean:
	$(checkdir)
	-rm -f build
	-make clean
	-rm -f `find . -name "*~"`
	-rm -rf debian/tmp debian/files* core debian/substvars
	-rm bin/*
	-rm antlr/*.o
	-rm dlg/*.o
	-rm support/genmk/*.o

binary-indep: checkroot build
	$(checkdir)
	-rm -rf debian/tmp/usr/include/pccts
	install -d debian/tmp/usr/include/pccts
	cp h/* debian/tmp/usr/include/pccts
	install -d debian/tmp/usr/lib/pccts
	cp -R support debian/tmp/usr/lib/pccts
	cp -R testcpp debian/tmp/usr/lib/pccts
	install -d debian/tmp/usr/doc/pccts
	cp history.* pccts1.txt SERVICES README debian/tmp/usr/doc/pccts
	cp debian/copyright debian/tmp/usr/doc/pccts
	cp debian/README.debian debian/tmp/usr/doc/pccts
	install -d debian/tmp/usr/man/man1
	cp pccts.1 debian/tmp/usr/man/man1
	cp antlr/antlr.1 debian/tmp/usr/man/man1
	cp dlg/dlg.1 debian/tmp/usr/man/man1

binary-arch: checkroot build
	$(checkdir)
	-rm -rf debian/tmp/usr/bin
	install -d debian/tmp/usr/bin
	install -d debian/tmp/DEBIAN
	cd debian/tmp && install -d `cat ../dirs`
	mv bin/* `pwd`/debian/tmp/usr/bin
	dpkg-gencontrol
	chown -R root.root debian/tmp
	chmod -R go=rX debian/tmp
	dpkg --build debian/tmp ..

define checkdir
	test -f debian/rules
endef

binary: binary-indep binary-arch

checkroot:
	$(checkdir)
	test root = "`whoami`"

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