#!/usr/bin/make -f
# debian/rules file - for bit-purgekernels

install_dir=install -d -m 755
install_file=install -m 644
install_script=install -m 755
install_binary=install -m 755 -s

VERSION := $(shell dpkg-parsechangelog | grep ^Version: | cut -d' ' -f2)

build:

clean:
	-rm -f foo foo.asc *.bak *~ */*~ debian/files* debian/*substvars

binary-indep:
	-rm -rf debian/tmp
	$(install_dir) debian/tmp/DEBIAN/
	$(install_script) debian/postinst debian/tmp/DEBIAN/
	$(install_script) debian/postrm debian/tmp/DEBIAN/

	$(install_dir) debian/tmp/usr/sbin/
	$(install_script) purgekernels debian/tmp/usr/sbin/
	
	$(install_dir) debian/tmp/usr/share/doc/bit-purgekernels/
	$(install_file) README.md debian/tmp/usr/share/doc/bit-purgekernels/
	$(install_file) debian/changelog debian/tmp/usr/share/doc/bit-purgekernels/changelog
	gzip -9v debian/tmp/usr/share/doc/bit-purgekernels/*
	$(install_file) debian/copyright debian/tmp/usr/share/doc/bit-purgekernels/
	cd debian/tmp; find -type f \! -regex '.*/DEBIAN/.*' -printf '%P\0' | xargs -r0 md5sum >DEBIAN/md5sums

	dpkg-gencontrol -pbit-purgekernels -isp
	chown -R root.root debian/tmp
	chmod -R go=rX debian/tmp
	dpkg --build debian/tmp ..

binary-arch:

# Below here is fairly generic really

binary:		binary-indep binary-arch

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