#!/usr/bin/make -f

LDFLAGS+=-Wl,--as-needed
export REPACK_SH=$(CURDIR)/debian/repack.sh
export USE_SOTWOSYMLINKS=1
UPSTEAM_VERSION=$(shell dpkg-parsechangelog 2>/dev/null | sed -ne 's/Version: \([0-9.]\+\)~.*/\1/p')

DEB_HOST_MULTIARCH ?= $(shell dpkg-architecture -qDEB_HOST_MULTIARCH)

%:
	dh $@ --parallel --with autotools_dev

override_dh_auto_configure:
	dh_auto_configure -- --with-sqlite3-prefix=/usr

override_dh_strip:
	dh_strip --dbg-package=wxsqlite3-2.8-dbg

override_dh_installchangelogs:
	dh_installchangelogs Readme.txt

override_dh_auto_install:
	dh_auto_install
	sed -e "s/@VERSION@/${UPSTREAM_VERSION}/" \
		debian/wxsqlite3-2.8.pc.in > debian/wxsqlite3-2.8.pc
	sed -e "s#@LIBDIR@#lib/${DEB_HOST_MULTIARCH}#" \
		debian/wxsqlite3-2.8.pc.in > debian/wxsqlite3-2.8.pc
	chmod -x debian/wxsqlite3-2.8.pc
	mkdir -p debian/tmp/usr/lib/$(DEB_HOST_MULTIARCH)/pkgconfig
	install -m 0644 debian/wxsqlite3-2.8.pc \
		debian/tmp/usr/lib/$(DEB_HOST_MULTIARCH)/pkgconfig

override_dh_install:
	dh_install
	-chmod -x $(CURDIR)/debian/wxsqlite3-doc/usr/share/wxsqlite3-doc/html/*

override_dh_auto_test:
	debian/runtest.sh

override_dh_auto_clean:
	dh_auto_clean
	rm -f debian/wxsqlite3-2.8.pc

get-orig-source:
	uscan --force-download
