#!/usr/bin/make -f

p=$(shell sed '1s/Source: \(.*\)/\1/; 2,$$d' debian/control)

build:
	make $p LIBDIR="/etc/uucp" && touch build

clean:
	-rm -f build
	-$(MAKE) -i distclean
	-rm -rf debian/tmp* *~ *.orig ./#*# tmp.* debian/files*
	find -name '*~' -print0 | xargs -r0 rm --

binary-indep:

binary-arch: build
	-rm -rf debian/tmp
	install -d debian/tmp
	cd debian/tmp && install -d etc/uucp usr/doc/$(p)
	cp debian/copyright debian/tmp/usr/doc/$(p)/copyright
	cp debian/changelog debian/tmp/usr/doc/$(p)/changelog.Debian
	gzip -9f debian/tmp/usr/doc/$(p)/changelog.Debian
	make install prefix=debian/tmp
	gzip -9f debian/tmp/usr/man/man1/* debian/tmp/usr/man/man5/*
	dpkg-shlibdeps $(p)
	install -d debian/tmp/DEBIAN 
	cd debian/tmp &&\
	  md5sum `find * -name DEBIAN -prune -o -type f -print`\
	   > DEBIAN/md5sums
	cp debian/postinst debian/conffiles debian/tmp/DEBIAN
	dpkg-gencontrol
	chown -R root.root debian/tmp
	chmod -R g-ws,a+r,u+w debian/tmp
	dpkg-deb --build debian/tmp ..

# Below here is fairly generic really
binary:		binary-indep binary-arch

source diff:
	@echo >&2 'source and diff are obsolete - use dpkg-source -b'; false

.PHONY: binary source diff clean
