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


ifneq (,$(findstring debug,$(DEB_BUILD_OPTIONS)))
	CFLAGS += -g
endif
ifeq (,$(findstring nostrip,$(DEB_BUILD_OPTIONS)))
	INSTALL_PROGRAM += -s
endif

configure: configure-stamp
configure-stamp:
	dh_testdir
	# Add here commands to configure the package.

	touch configure-stamp


build: build-stamp

build-stamp: configure-stamp 
	dh_testdir

	# Add here commands to compile the package.
	$(MAKE)
	/usr/bin/docbook-to-man debian/manthconvert.sgml > thconvert.1
	$(MAKE) doc
	#we should generate html here too if possible

	touch build-stamp

clean:
	dh_testdir
	dh_testroot
	rm -f build-stamp configure-stamp

	# Add here commands to clean up after the build process.
	$(MAKE) clean
	cd thbook && rm -f thbook.pdf thbook.log

	dh_clean

install: build
	dh_testdir
	dh_testroot
	dh_clean -k


# 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_installdirs

	# Add here commands to install the package into debian/therion.
#this stuff no longer needed from 0.2.14	
#	install -d -o root -g root -m 755 debian/therion/usr/share/texmf/metapost/therion
#	install -d -o root -g root -m 755 debian/therion/usr/share/texmf/tex/therion
#	install -p -o root -g root -m 644 mpost/*.mp debian/therion/usr/share/texmf/metapost/therion/
#	install -p -o root -g root -m 644 tex/*.tex debian/therion/usr/share/texmf/tex/therion/

	dh_install therion  usr/bin
	dh_install xtherion/xtherion usr/bin
	install -p -o root -g root -m 755 makeconvert.pl debian/therion/usr/bin/thconvert

	dh_install lib/grades.th usr/share/therion
	dh_install lib/layouts.thcfg usr/share/therion
	dh_install lib/therion.th usr/share/therion

	dh_install therion.ini etc
	dh_install xtherion/xtherion.ini etc
	
	dh_installdocs 
	dh_installexamples tests thconfig therion.ini
	dh_installmenu
	dh_installmime
	dh_installman
	dh_installchangelogs CHANGES
	dh_strip
	dh_compress -X.pdf -X.th -X.th2
	dh_fixperms
	dh_installdeb
	dh_shlibdeps
	dh_gencontrol
	dh_md5sums
	dh_builddeb

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

get-orig-source: 
	wget -nc -nd http://therion.speleo.sk/download.php?package=therion 
