#!/usr/bin/make -f
# Sample debian/rules that uses debhelper.
# GNU copyright 1997 to 1999 by Joey Hess.

# Uncomment this to turn on verbose mode.
export DH_VERBOSE=1
export DH_COMPAT=2

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

prefix = /usr
bindir = $(prefix)/bin
fontdir = $(prefix)/share/figlet
docdir = $(prefix)/share/doc/figfonts
docdir-cjk = $(prefix)/share/doc/figfonts-cjk

# where the figfonts source dir is

sourcedir = $(shell pwd)

build: build-stamp
build-stamp:
	dh_testdir

	touch build-stamp

clean:
	dh_testdir
	-rm -f build-stamp
	-rm -f install-stamp
	dh_clean

install: build
	dh_testdir
	dh_testroot
	dh_clean -k
	dh_installdirs -A

	# now we install the files of the package figfonts
	
	$(installbin) contributed/bdffonts/bdf2flf.pl \
	              debian/figfonts/$(bindir)/bdf2flf
	$(installdoc) contributed/*.flf contributed/*.flc \
	              debian/figfonts/$(fontdir)
	$(installdoc) contributed/bdffonts/*.flf \
	              debian/figfonts/$(fontdir)
	$(installdoc) international/*.flf \
	              debian/figfonts/$(fontdir)
	$(installdoc) ms-dos/*.flf \
	              debian/figfonts/$(fontdir)
	
	cd debian/figfonts/$(fontdir) && \
	  for file in *.flf *.flc; \
	  do zip -9 $$file.zip $$file; mv $$file.zip $$file; done 
	
	# and now the files of the package figfonts-cjk
	
	cd debian/figfonts-cjk/$(fontdir) && \
	   tar xvzf $(sourcedir)/international/cjkfonts.tar.gz \*.flf \*.flc
	cd debian/figfonts-cjk/$(docdir-cjk) && \
	   tar xvzf $(sourcedir)/international/cjkfonts.tar.gz \
	   README.cjk
	
	cd debian/figfonts-cjk/$(fontdir) && \
	for file in *.flf *.flc; \
	  do zip -9 $$file.zip $$file; mv $$file.zip $$file; done
	
	touch install-stamp

# Build architecture-independent files here.
binary-indep: build install
# We have nothing to do by default.

# Build architecture-dependent files here.
binary-arch: build install
	dh_testdir
	dh_testroot
	dh_installdocs
	dh_installmanpages
#	dh_undocumented
	dh_installchangelogs
	dh_compress
	dh_fixperms
	# You may want to make some executables suid here.
	dh_installdeb
	dh_shlibdeps
	dh_gencontrol
	dh_builddeb

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