#!/usr/bin/make -f

DPKG_EXPORT_BUILDFLAGS=1
include /usr/share/dpkg/buildflags.mk

WORKDIR ?= $(CURDIR)/Work

%:
	dh $@ --with autoreconf \
		--sourcedir=$(CURDIR)/texk/xdvik \
		--builddir=$(WORKDIR)

override_dh_autoreconf:
	dh_autoreconf --as-needed

override_dh_auto_configure:
	mkdir -p $(WORKDIR)/t1lib
	(cd $(CURDIR)/Work/t1lib && \
	  ../../libs/t1lib/configure --enable-shared )
	(cd $(CURDIR)/Work/t1lib && make )
	dh_auto_configure -- \
	  --with-kpathsea-libdir=/usr/lib \
	  --with-kpathsea-includes=/usr/include/kpathsea \
	  --with-xdvi-x-toolkit=xaw \
	  --disable-t1utils \
	  --with-t1lib-includes=$(WORKDIR)/t1lib \
	  --with-t1lib-libdir=$(WORKDIR)/t1lib \
	  --enable-freetype \
	  --enable-pxdvik

override_dh_auto_install:
	dh_auto_install -- DESTDIR=$(CURDIR)/debian/tmp
	mv $(CURDIR)/debian/tmp/usr/share/man/man1/pxdvi.1 \
		$(CURDIR)/debian/tmp/usr/share/man/man1/pxdvi-xaw.1

override_dh_installchangelogs:
	dh_installchangelogs $(CURDIR)/texk/xdvik/CHANGES.xdvik-jp

override_dh_auto_clean:
	dh_auto_clean
	rm -fr $(CURDIR)/Work
