#!/usr/bin/make -f
# -*- Mode: Makefile; indent-tabs-mode: t; tab-width: 4 -*-

include /usr/share/dpkg/buildflags.mk

export DPKG_GENSYMBOLS_CHECK_LEVEL=1
export DEB_BUILD_MAINT_OPTIONS = hardening=+all

%:
	dh $@

override_dh_missing:
	dh_missing --fail-missing

override_dh_install:
	# drop any translations for locales we don't care about
	for mo in debian/tmp/usr/share/locale/*; do \
		export locale="$$(basename $${mo} .po)"; \
		if ! grep -q "^$${locale}[ ._]" /usr/share/i18n/SUPPORTED; then \
			rm -r "$${mo}"; \
		fi; \
	done

	mkdir -p "$(CURDIR)/debian/tmp/usr/share/doc/libgeonames-dev/html/"
	mv $(CURDIR)/debian/tmp/usr/share/gtk-doc/html/geonames/* $(CURDIR)/debian/tmp/usr/share/doc/libgeonames-dev/html/
	rmdir $(CURDIR)/debian/tmp/usr/share/gtk-doc/html/geonames/
	find "$(CURDIR)/debian/tmp/usr/share/doc/libgeonames-dev/html/" -name *.md5 -delete; \
	    rdfind -makesymlinks true "$(CURDIR)/debian/tmp/usr/share/doc/libgeonames-dev/html/"; \
	    symlinks -rc "$(CURDIR)/debian/tmp/usr/share/doc/libgeonames-dev/html/"

	dh_install

override_dh_auto_test:
ifeq (,$(filter nocheck,$(DEB_BUILD_OPTIONS)))
	# Have to specify LC_ALL manually until https://launchpad.net/bugs/1566590
	# is fixed.
	LC_ALL=en_US.UTF-8 dh_auto_test -- VERBOSE=1
endif

override_dh_auto_clean:
	dh_auto_clean
	rm -f results.txt

get-orig-source:
	uscan --noconf --force-download --rename --download-current-version --destdir=..
