#!/usr/bin/make -f
# -*- makefile -*-

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

# This has to be exported to make some magic below work.
export DH_OPTIONS

# Enable hardening build flags
export DEB_BUILD_MAINT_OPTIONS=hardening=+all

# Append hardening buildflags to CFLAGS, only one used by the build system.
CFLAGS += $(LDFLAGS)
CFLAGS += $(CPPFLAGS)

%:
	dh $@ --with autoreconf \
	      --parallel

override_dh_clean:
	dh_clean -Xautom4te.cache \
		 $(CURDIR)/test/wfs_100/config_wfs_100.xml \
		 $(CURDIR)/test/wfs_100/install_wfs_100.sh \
		 $(CURDIR)/test/wfs_110/config_wfs_110.xml \
		 $(CURDIR)/test/wfs_110/install_wfs_110.sh

override_dh_auto_configure:
	dh_auto_configure -- --with-shp2pgsql=/usr/bin/shp2pgsql

override_dh_auto_install:
	# make install does almost nothing, so we do it here
	# $(MAKE) DESTDIR=$(CURDIR)/debian/tinyows install

	cp $(CURDIR)/tinyows $(CURDIR)/debian/tinyows/usr/lib/cgi-bin/

	mkdir -p $(CURDIR)/debian/tinyows/usr/share/tinyows
	cp -rf $(CURDIR)/schema $(CURDIR)/debian/tinyows/usr/share/tinyows/

	# remove extra license files
	rm -f $(CURDIR)/debian/tinyows/usr/share/tinyows/schema/LICENSE

override_dh_installchangelogs:
	dh_installchangelogs NEWS

override_dh_install:
	dh_install --list-missing

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

