#!/usr/bin/make -f

SHELL = /bin/sh
package = m-tx

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

build: build-stamp
build-stamp:
	dh_testdir

	# binary
	# p2c + gcc + glibc Build Version:
	#cd src && make prepmxc
	# Free Pascal Build Version:
	cd src && make prepmx

	# documentation
	cp -a doc bindoc
	ln -s ../src/mtx.tex doc/mtx.tex
	cd doc && make pdftarget && make config && make all

	touch build-stamp

clean:
	dh_testdir
	dh_testroot
	rm -f build-stamp

	cd src && make bare
	-rm -rf bindoc
	cd doc && make bare
	-rm -f doc/mtx.tex
	-rm -f doc/make-target
	-cp -af doc/make-pdf doc/make-target
	dh_clean

install: build
	dh_testdir
	dh_testroot
	dh_prep
	dh_installdirs

	# Add here commands to install the package into debian/m-tx.
	cp -p src/prepmx debian/m-tx/usr/bin
	cp -p src/mtx.tex debian/m-tx/usr/share/texmf/tex/musixtex/m-tx
	cp -p doc/mtxlatex.sty debian/m-tx/usr/share/texmf/tex/latex/misc
	ln -fs ../../m-tx debian/m-tx/usr/share/doc/texmf/musixtex/m-tx
	cp -av bindoc/* debian/m-tx/usr/share/doc/m-tx/mtxdoc
	cp debian/m-tx.lintian debian/m-tx/usr/share/lintian/overrides/m-tx

# 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 README* FAQ doc/mtxdoc.pdf
	dh_installexamples examples/*
	dh_installman
	dh_installchangelogs
	dh_strip
	dh_compress -X.pdf
	dh_fixperms
	dh_installdeb
	dh_shlibdeps
	dh_gencontrol
	dh_md5sums
	dh_builddeb

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