#!/usr/bin/make -f
#DH_VERBOSE = 1

include /usr/share/GNUstep/debian/config.mk
export DEB_BUILD_MAINT_OPTIONS = hardening=+all
export LINKSQLCLIENT := 1

sover := 1.9

%:
	dh $@

override_dh_auto_build:
	cp debian/libsqlclient-dev.install.in debian/libsqlclient-dev.install
ifdef docs
	cp debian/libsqlclient-dev.links.in debian/libsqlclient-dev.links
else
# Remove /usr/share if "nodoc" is in DEB_BUILD_OPTIONS.
	sed -i '$$d' debian/libsqlclient-dev.install
endif
	dh_auto_build -- $(optim) $(verbose) $(docs) \
	  $(shell dpkg-buildflags --export=cmdline)

override_dh_auto_install:
	dh_auto_install -- $(docs)

override_dh_auto_clean:
	dh_auto_clean -- $(docs)
	$(RM) -r Bundles
	dh_clean test test.conf debian/libsqlclient-dev.{install,links}

override_dh_auto_test:
# Test at least the SQLite bundle; the others require a server running.
	echo "GNUSTEP_SYSTEM_LIBRARY=$(CURDIR)" > test.conf
	chmod 0644 test.conf
	mkdir -p Bundles/SQLClient$(sover)
	cp -a SQLite.bundle Bundles/SQLClient$(sover)
	LD_LIBRARY_PATH=$(CURDIR)/obj:$$LD_LIBRARY_PATH \
	  GNUSTEP_CONFIG_FILE=$(CURDIR)/test.conf ./obj/testSQLite
