#! /usr/bin/make -f
## Written by Gergely Nagy <algernon@debian.org>
## This is under GPL v2.

PACKAGE		:= colorize
PKGDIR		:= ${CURDIR}/debian/${PACKAGE}

build: ;

clean:
	test -e debian/control && test "x`whoami`" = "xroot"
	rm -rf ${PKGDIR} debian/files

binary-colorize:
	test -e debian/control && test "x`whoami`" = "xroot"
## Install stuff
	install -d ${PKGDIR}/usr/share/doc/${PACKAGE} \
		${PKGDIR}/DEBIAN ${PKGDIR}/usr/bin
# ..the changelogs..
	gzip -9fc debian/changelog >${PKGDIR}/usr/share/doc/${PACKAGE}/changelog.Debian.gz
# ..the copyright file..
	install -m 0644 debian/copyright ${PKGDIR}/usr/share/doc/${PACKAGE}
# ..README.Debian
	install -m 0644 debian/README.Debian ${PKGDIR}/usr/share/doc/${PACKAGE}
# ..the compatibility symlink
	ln -s ccze ${PKGDIR}/usr/bin/colorize
## Fix permissions
	find ${PKGDIR} -print0 2>/dev/null | xargs -0r chown \
						   --no-dereference 0.0
	find ${PKGDIR} ! -type l -print 0 2>/dev/null | xargs -0r \
		chmod go=rX,u+rw,a-s
## Generate DEBIAN/md5sums
	cd ${PKGDIR} >/dev/null ;\
	 find * -type f ! -regex '^DEBIAN/.*' -print0 | xargs -r0 md5sum > DEBIAN/md5sums
## Generate DEBIAN/control
	dpkg-gencontrol -isp -p${PACKAGE} -P${PKGDIR}
## Build the binary package
	dpkg --build ${PKGDIR} ..

binary-indep:
binary-arch: binary-colorize

binary: binary-indep binary-arch

.PHONY: binary binary-arch binary-indep clean build install binary-colorize
.SUFFIXES:
