#!/usr/bin/make -f
# Uncomment this to turn on verbose mode.
#export DH_VERBOSE=1

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

# Reset the docs variable if it's an arch:any build.
ifeq (,$(filter steptalk-doc,$(shell dh_listpackages)))
docs :=
endif

%:
	dh $@

override_dh_auto_build:
	dh_auto_build -- $(verbose) $(optim) $(docs) \
	  INTERFACE_VERSION=0d $(shell dpkg-buildflags --export=cmdline)
	dh_auto_build -- -C Examples/Shell $(verbose) $(optim) \
	  $(shell dpkg-buildflags --export=cmdline)

override_dh_auto_install:
	dh_auto_install -- $(verbose) $(docs) \
	  INTERFACE_VERSION=0d DESTDIR=$(CURDIR)/debian/tmp
	dh_auto_install -- -C Examples/Shell $(verbose) \
	  DESTDIR=$(CURDIR)/debian/tmp
# Remove a useless Resources symlink which ends up broken if the -dev
# package is not installed.
	$(RM) debian/tmp$(GNUSTEP_SYSTEM_LIBRARY)/Frameworks/*/Resources
ifneq (,$(docs))
	cp debian/steptalk-doc.install.in debian/steptalk-doc.install
	cp debian/steptalk-doc.links.in debian/steptalk-doc.links
endif

override_dh_auto_clean:
	dh_auto_clean -- $(docs)
	dh_auto_clean -- -C Examples/Shell
	$(RM) debian/steptalk-doc.install debian/steptalk-doc.links

override_dh_auto_test:
	dh_auto_install -- INTERFACE_VERSION=0d DESTDIR=$(CURDIR)/test
	echo "GNUSTEP_LOCAL_LIBRARY=$(CURDIR)/test$(GNUSTEP_SYSTEM_LIBRARY)" \
	  > test.conf
	chmod 0644 test.conf
	./debian/tests/scripts
	$(RM) test.conf
	$(RM) -r test

override_dh_installexamples-indep:
# We ship stshell in the steptalk package so there are build artifacts.
	dh_installexamples -XChangeLog -X.cvsignore -Xobj

execute_before_dh_link:
	gsdh_gnustep -psteptalk-gui-module --bug-script
	gsdh_gnustep --remaining-packages
