#!/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.
# Modified by Troy Hanson

package=htget

installbin    = install -s -g root -o root -m 755
installscript = install    -g root -o root -m 755
installdoc    = install    -g root -o root -m 644

build:
	$(checkdir)
	
	touch build

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)
# There are no architecture-independent files to be uploaded
# generated by this package.  If there were any they would be
# made here.

binary-arch: checkroot build
	$(checkdir)
	-rm -rf debian/tmp
	install -d debian/tmp
	install -d debian/tmp/usr/bin
	install -d debian/tmp/usr/share/man/man1
	install -d debian/tmp/usr/share/doc/htget
	install -d debian/tmp/etc
	install -d debian/tmp/DEBIAN
	make all 
	$(installbin) htget debian/tmp/usr/bin
	$(installdoc) htget.1 debian/tmp/usr/share/man/man1
	gzip -9 debian/tmp/usr/share/man/man1/*
	$(installdoc) README debian/tmp/usr/share/doc/htget/README
	$(installdoc) debian/copyright debian/tmp/usr/share/doc/htget
	$(installdoc) debian/changelog debian/tmp/usr/share/doc/htget/changelog.Debian
	gzip -9 debian/tmp/usr/share/doc/htget/changelog.Debian
	$(installdoc) debian/README.debian debian/tmp/usr/share/doc/htget/README.Debian
	$(installscript) debian/prerm debian/tmp/DEBIAN/
	$(installscript) debian/postinst debian/tmp/DEBIAN/
	dpkg-shlibdeps htget
	dpkg-gencontrol -isp
	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`"
