#!/usr/bin/make -f

CFLAGS+=$(CPPFLAGS)

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

override_dh_auto_configure:
	dh_auto_configure -- --prefix=/usr --enable-openmp --enable-python $(shell dpkg-buildflags --export=configure)

VERSION := $(shell grep '^AC_INIT' configure.ac | \
	sed 's/AC_INIT(saga, \([0-9|\.]*\)\,.*)/\1/g')
UPSTREAM_URL ?=$(shell uscan --dehs | sed -n 's/.*<upstream-url>\(.*\)<\/upstream-url>.*/\1/p')
UPSTREAM_VERSION ?=$(shell uscan --dehs | sed -n 's/.*<upstream-version>\(.*\)<\/upstream-version>.*/\1/p')

debian/% :: debian/%.in
	sed -e 's/@VERSION@/$(VERSION)/' $< >$@

override_dh_auto_build: man
	dh_auto_build

man:
	pod2man --section=1 --release=$(VERSION) --center " " debian/saga_gui.pod >saga_gui.1
	pod2man --section=1 --release=$(VERSION) --center " " debian/saga_cmd.pod >saga_cmd.1
	dh_auto_build

override_dh_python2:
	dh_python2 --no-guessing-versions

override_dh_clean:
	dh_clean
	rm -f src/saga_core/saga_api/saga_api.py
	rm -f saga_cmd.1
	rm -f saga_gui.1

override_dh_makeshlibs:
	dh_makeshlibs -Xpython-saga

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