#!/usr/bin/make -f

package=dpkg-ftp
method_files= desc.ftp install names setup update

CFLAGS=-shared -O2
DIR:=$(shell pwd)

build:	
	$(checkdir)
	touch build

clean:
	$(checkdir)
	-rm -f build
	-rm -rf debian/tmp debian/*~ *~ *.orig ./#*# debian/files*

binary-indep:	checkroot build 
	$(checkdir)
	-rm -rf debian/tmp
	mkdir debian/tmp debian/tmp/DEBIAN
	install -d debian/tmp/usr/doc/dpkg-ftp
	cp debian/copyright debian/tmp/usr/doc/dpkg-ftp/copyright
	cp debian/changelog debian/tmp/usr/doc/dpkg-ftp/changelog.Debian
	gzip debian/tmp/usr/doc/dpkg-ftp/changelog.Debian
	install -d debian/tmp/var/lib/dpkg/methods/ftp
	install -d debian/tmp/usr/lib/dpkg/methods/ftp
	cp $(method_files) debian/tmp/usr/lib/dpkg/methods/ftp
	dpkg-gencontrol
	chown -R root.root debian/tmp
	chmod -R g-ws debian/tmp
	dpkg --build debian/tmp ..

binary-arch: checkroot build
	$(checkdir)

define checkdir
	test -f debian/rules
endef

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

binary: binary-indep binary-arch


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