#!/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=sorcerer

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

binary-indep: checkroot build
	$(checkdir)
	-rm -rf debian/tmp/usr/include/sorcerer
	install -d debian/tmp/usr/include/sorcerer
	cp h/* lib/errsupport.c debian/tmp/usr/include/sorcerer
	install -d debian/tmp/usr/lib/sorcerer/support
	cp -R test testcpp debian/tmp/usr/lib/sorcerer/support
	install -d debian/tmp/usr/doc/sorcerer
	cp SERVICES README debian/tmp/usr/doc/sorcerer
	cp debian/copyright debian/tmp/usr/doc/sorcerer
	cp debian/README.debian debian/tmp/usr/doc/sorcerer

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`
	strip sor
	mv sor `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
