#!/usr/bin/make -f

export DEB_BUILD_MAINT_OPTIONS = hardening=+all

%:
	dh $@

override_dh_auto_build-arch:
	dh_auto_build -- PREFIX=/usr DESTDIR=/usr PLATFORM=-DUNIX latex2rtf

override_dh_auto_build-indep:
	$(MAKE) -C doc all latex2rtf.html web/manpage.html web/latex2png.html
	for file in doc/latex2pn.txt doc/latex2rtf.info doc/latex2rtf.pdf doc/latex2rtf.texi \
	            doc/latex2rtf.txt doc/web/latex2png.html doc/web/manpage.html; do \
		cp -a $$file $$file.orig; \
	done
	fromdos doc/latex2rtf.texi
	dh_auto_build -- PREFIX=/usr DESTDIR=/usr PLATFORM=-DUNIX doc

# TODO: disentagle installation of docs from rest of package
override_dh_auto_install:
	mkdir --parents $(CURDIR)/debian/tmp/usr/share/doc/latex2rtf-doc/
	dh_auto_install -- SUPPORTDIR=/usr/share/doc/latex2rtf-doc/ PREFIX=/usr DESTDIR=$(CURDIR)/debian/tmp/
	chmod a-x $(CURDIR)/debian/tmp/usr/share/latex2rtf/cfg/*

override_dh_auto_clean:
	dh_auto_clean -- realclean || true

override_dh_clean::
	dh_clean
	rm -f doc/latex2rtf.pdf doc/latex2rtf.html doc/latex2rtf.info doc/latex2rtf.txt doc/web/latex2png.html doc/web/manpage.html
	for file in doc/latex2pn.txt doc/latex2rtf.info doc/latex2rtf.pdf doc/latex2rtf.texi \
	            doc/latex2rtf.txt doc/web/latex2png.html doc/web/manpage.html; do \
		test ! -f $$file.orig || mv $$file.orig $$file; \
	done

override_dh_auto_test:
	dh_auto_test -- LATEX2RTF='RTFPATH="../cfg" ../latex2rtf'
