#!/usr/bin/make -f
# -*- makefile -*-
# debian/rules for perlftlib

export DH_OPTIONS=

PERL ?= /usr/bin/perl

package	:= $(firstword $(shell dh_listpackages))
prefix	:= $(PWD)/debian/$(package)/usr
share	:= $(prefix)/share

version	:= $(shell dpkg-parsechangelog | \
			sed -ne 's/Version: *\([0-9]\+:\)*//p')

tag:
	cvs -Q status | grep File: | grep -qv Up-to-date && exit 1 || exit 0
	cvs tag -F $(subst .,_,debian_version_$(version))
ifeq ($(findstring -,$(version)),)
	cvs tag -F $(subst .,_,upstream_version_$(version))
endif

build:	build-stamp
build-stamp:
	dh_testdir
	$(PERL) Makefile.PL INSTALLDIRS=vendor PERL=$(PERL)
	$(MAKE) LD_RUN_PATH=
	$(PERL) -ne 'print if /\.TH/ .. 1;' mkttfdir.pl > debian/mkttfdir.1
	$(PERL) -ne 'print if /\.TH/ .. 1;' ftinfo.pl > debian/ftinfo.1
	touch $@

clean:	checkroot
	rm -f *-stamp
	-$(MAKE) distclean
	dh_clean

install:	DH_OPTIONS=
install:	checkroot
	dh_clean
	dh_installdirs

	$(MAKE) pure_install PREFIX=$(prefix)
	dh_movefiles --sourcedir=debian/$(package) -pfttools usr/bin

binary-indep:	DH_OPTIONS=-i
binary-indep:	install
	dh_installdocs
	dh_installman debian/*.1
	dh_installchangelogs
	dh_strip
	dh_compress
	dh_fixperms
	dh_perl
	dh_installdeb
	dh_gencontrol
	dh_md5sums
	dh_builddeb

binary-arch:	DH_OPTIONS=-a
binary-arch:	install
	dh_installdocs
	dh_installexamples FreeType/ftname
	dh_installchangelogs FreeType/Changes
	dh_strip
	dh_compress
	dh_fixperms
	dh_perl
	dh_shlibdeps
	dh_installdeb
	dh_gencontrol
	dh_md5sums
	dh_builddeb

binary: binary-indep binary-arch

checkroot:
	dh_testdir
	dh_testroot

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