#!/usr/bin/make -f

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

export DEB_CFLAGS_MAINT_APPEND = -Wno-error=incompatible-pointer-types

# These are used for cross-compiling and for saving the configure script
# from having to guess our platform (since we know it already)
include /usr/share/dpkg/architecture.mk
DPKG_EXPORT_BUILDTOOLS=1
include /usr/share/dpkg/buildtools.mk

%:
	dh $@

# shared library versions, option 1
#version=2.0.5
#major=2
# option 2, assuming the library is created as src/.libs/libfoo.so.2.0.5 or so
version=`ls src/.libs/lib*.so.* | \
 awk '{if (match($$0,/[0-9]+\.[0-9]+\.[0-9]+$$/)) print substr($$0,RSTART)}'`
major=`ls src/.libs/lib*.so.* | \
 awk '{if (match($$0,/\.so\.[0-9]+$$/)) print substr($$0,RSTART+4)}'`

override_dh_auto_clean:
	dh_auto_clean
	# Its probably the easiest approach just to remove what is changed
	# but not really needed to fix bug #1045442
	rm -rf autom4te.cache OLD/*
	if [ -e src/vflmkcaptex.bak ] ; then mv src/vflmkcaptex.bak src/vflmkcaptex ; fi

override_dh_auto_configure:
	cp -a src/vflmkcaptex src/vflmkcaptex.bak
	CFLAGS="$(CFLAGS)" ./configure $(confflags) --prefix=/usr --mandir=\$${prefix}/share/man --infodir=\$${prefix}/share/info \
	--with-opentype \
	--with-kpathsea --with-kpathsea-includedir=/usr/include/kpathsea \
	--with-texmf-root=/usr/share/texmf \
	--with-gettext

override_dh_auto_install:
	dh_installdirs
	# Add here commands to install the package into debian/tmp
	$(MAKE) install prefix=$(CURDIR)/debian/tmp/usr
	# Remove unused files
	rm -f $(CURDIR)/debian/tmp/usr/share/VFlib/3.7.2/t1lib/mkt1enc.sh

override_dh_installchangelogs:
	dh_installchangelogs -i CHANGES

override_dh_movefiles-arch:
	dh_movefiles -pvflib3 -pvflib3-dev -pvflib3-bin

override_dh_missing:
	dh_missing --list-missing --sourcedir=debian/tmp

override_dh_installchangelogs:
	dh_installchangelogs CHANGES