#!/usr/bin/make -f

%:
	dh $@

export DEB_BUILD_MAINT_OPTIONS = hardening=+all
DOCTEMP = $(CURDIR)/debian/doctmp
include /usr/share/dpkg/pkg-info.mk

# Extended precision on i386 results in weird bugs, so we build
# with -ffloat-store.
ifneq (,$(filter $(DEB_BUILD_ARCH),i386))
CFLAGS += -ffloat-store
endif

override_dh_auto_configure:
	dh_auto_configure -- \
		--with-zlib=system \
		--with-doc=$(DOCTEMP) \
		--prefix=/usr
	convert -resize 32x32 gui/images/appicon.png debian/gpsbabel.xpm


override_dh_installman:
	export PATH="$(CURDIR)/gpsbabel:$$PATH" ;\
	help2man 	--manual='gpsbabel documentation' \
			--section=1 \
			--name='GPS route and waypoint data converter' \
			--source='http://www.gpsbabel.org' \
			--locale=C \
			-N \
			--version-string=$(DEB_VERSION) \
			--opt-include=$(CURDIR)/debian/gpsbabel.help2man \
			-o debian/gpsbabel.1 \
			./gpsbabel
	dh_installman

override_dh_auto_build-arch:
	dh_auto_build
	if dpkg -s qtwebengine5-dev; then $(MAKE) gui; fi

override_dh_auto_build-indep:
	$(MAKE) doc
	$(MAKE) gpsbabel.html

# Ignore broken unit tests on other architectures
override_dh_auto_test:
ifneq (,$(filter $(DEB_BUILD_ARCH),amd64 armel armhf i386 mips64el mipsel m68k sh4))
	dh_auto_test
else
	dh_auto_test || true
endif
