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

include /usr/share/GNUstep/debian/config.mk
export GNUSTEP_MAKEFILES := $(GS_MAKE_DIR)
export GNUSTEP_INSTALLATION_DOMAIN := SYSTEM
export DEB_LDFLAGS_MAINT_APPEND = -Wl,--no-undefined -Wl,--as-needed
export LINKSQLCLIENT := 1

sover := 1.7

ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS)))
optim := debug=yes
endif

%:
	dh $@ 

override_dh_auto_build:
	$(MAKE) $(optim) messages=yes $(shell dpkg-buildflags --export=cmdline)

override_dh_clean:
	$(RM) -r Bundles
	dh_clean test test.conf

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

override_dh_strip:
	dh_strip --dbg-package=libsqlclient$(sover)-dbg
