#!/usr/bin/make -f

dest	:= debian/tmp
doc	:= $(dest)/usr/share/doc/freenet
control	:= $(dest)/DEBIAN

clean:
	rm -rf $(dest) debian/files
	find -name "*~" -print0 | xargs -r0 rm -f

build:

binary: binary-indep binary-arch
binary-indep: clean
	@if [ `id -u` -ne 0 ]; then echo "Must be run as (fake)root"; false; fi
	rm -rf $(dest)
	@(umask 022; set -e; for d in `cat debian/dirs`; do \
	    echo "mkdir -p $(dest)$$d"; mkdir -p $(dest)$$d; \
	  done)
	@(umask 022; set -e; for f in `cat debian/conffiles`; do \
	    echo ": > $(dest)$$f"; : > $(dest)$$f; \
	  done)
	install -m644 debian/copyright debian/changelog $(doc)
	gzip -9 $(doc)/changelog
	dpkg-gencontrol -isp
	install -m644 debian/conffiles $(control)
	install debian/prerm debian/postinst debian/postrm $(control)
	dpkg-deb -b $(dest) .. 

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