#!/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.

package=illuminator

DEB_HOST_ARCH := $(shell dpkg-architecture -qDEB_HOST_ARCH)

ifeq ($(DEB_HOST_ARCH), sparc)
	LLAM=-llam
else
	LLAM=
endif


patch:
	dh_testdir
	if [ ! -e illuminator.m4.backup ]; then \
	  for thefiles in illuminator.m4 debian/rules \
	     debian/illuminator-doc.docs debian/illuminator-doc.doc-base; do \
	    cp -p $$thefiles $$thefiles.backup; \
	  done; \
	fi
	if [ ! -d .pc ]; then \
	  QUILT_PATCHES=debian/patches quilt push -a; \
	fi

stamp-configure: patch
	dh_testdir
	./configure --prefix=/usr
	touch $@

build: stamp-configure
	dh_testdir
	LLAM=$(LLAM) $(MAKE)
	touch $@

clean:
	dh_testdir
	rm -f stamp-configure build debian/libluminate-dev.substvars
	rm -f config.log config.status.lineno libtool cxref.css illuminator-tex.html
	if [ -e Makefile ]; then $(MAKE) distclean; fi
	rm -rf illuminator illuminator-doc-0.11.0
	if [ -d .pc ]; then \
	  QUILT_PATCHES=debian/patches quilt pop -a && rm -rf .pc; \
	fi
	if [ -e illuminator.m4.backup ]; then \
	  for thefiles in illuminator.m4 debian/rules \
	     debian/illuminator-doc.docs debian/illuminator-doc.doc-base; do \
	    mv -f $$thefiles.backup $$thefiles; \
	  done; \
	fi
	dh_clean

stamp-doc: stamp-configure
	$(MAKE) $@
	rm -f illuminator-doc-0.11.0/illuminator.ps \
	  `find illuminator-doc-0.11.0 -empty -print`
	sed s/pdf/pdf.gz/ < illuminator-doc-0.11.0/index.html > illuminator-doc-0.11.0/index.html.new
	mv -f illuminator-doc-0.11.0/index.html.new illuminator-doc-0.11.0/index.html
	sed s/dvi/dvi.gz/ < illuminator-doc-0.11.0/index.html > illuminator-doc-0.11.0/index.html.new
	mv -f illuminator-doc-0.11.0/index.html.new illuminator-doc-0.11.0/index.html
	grep -v ">PostScript<" illuminator-doc-0.11.0/index.html > illuminator-doc-0.11.0/index.html.new
	mv -f illuminator-doc-0.11.0/index.html.new illuminator-doc-0.11.0/index.html

binary-indep: stamp-doc
	dh_testdir -i
	dh_testroot -i
	dh_installdirs -i
	dh_installdocs -i
	dh_installchangelogs -i
	dh_compress -i
	dh_fixperms -i
	dh_installdeb -i
	dh_gencontrol -i
	dh_md5sums -i
	dh_builddeb -i

install: build
	$(MAKE) install prefix=`pwd`/debian/tmp/usr

binary-arch: install
	dh_testdir -a
	dh_testroot -a
	dh_installdirs -a
	dh_movefiles -a
	dh_installdocs -a
	dh_installman -pilluminator-demo 3dgf.1 chts.1 chui.1 tsview.1 tsview-ng.1
	dh_installchangelogs -a
	dh_strip -a
	dh_makeshlibs -a
	dh_compress -a
	dh_fixperms -a
	dh_installdeb -a
	dh_shlibdeps -a
	dh_gencontrol -a
	dh_md5sums -a
	dh_builddeb -a

binary: binary-indep binary-arch

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