#!/usr/bin/make -f

DEB_HOST_GNU_TYPE   ?= $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE)
DEB_BUILD_GNU_TYPE  ?= $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE)
OPT                 = false
OPT                 = $(shell test -x /usr/bin/ocamlopt && echo true)

%:
	dh $@ --with tex,ocaml

override_dh_auto_configure:
	./configure --host=$(DEB_HOST_GNU_TYPE) \
			--build=$(DEB_BUILD_GNU_TYPE) \
			--prefix=/usr \
			--mandir=\$${prefix}/share/man \
			--infodir=\$${prefix}/share/info \
			--with-gs=/usr/bin/ghostscript \
			--sysconfdir=/etc

override_dh_auto_install:
	$(MAKE) install DESTDIR=$(CURDIR)/debian/advi \
		latexdir=/usr/share/texmf/tex/latex
ifeq ($(OPT),true)
	-rm -f $(CURDIR)/debian/advi/usr/bin/advi.byt
else
	cd $(CURDIR)/debian/advi/usr/bin && mv -f advi.byt advi
endif

override_dh_compress:
	dh_compress --exclude=usr/share/doc/advi/splash.dvi

override_dh_auto_test:
