#!/usr/bin/make -f

#export DH_VERBOSE=1

include /usr/share/dpkg/pkg-info.mk
DEB_HOST_MULTIARCH ?= $(shell dpkg-architecture -qDEB_HOST_MULTIARCH)
LIBDIR=/usr/lib/$(DEB_HOST_MULTIARCH)
DESTDIR=$(CURDIR)/debian/tmp
CMAKEDIR:=$(DESTDIR)/$(LIBDIR)/cmake/metkit
BUILDDIR:=debian/build

# The magic debhelper  rule
%:
	dh $@ --buildsystem=ecbuild --with=python3  --builddirectory=$(BUILDDIR)

BUILD_FLAGS:= -DENABLE_RPATH=OFF \
                -DENABLE_MARS2GRIB_PYTHON=ON \
                -DENABLE_RELATIVE_RPATHS=OFF \
		-DENABLE_BUILD_GRIB2_TOOLS=ON \
		-DENABLE_PYTHON_METKIT_INTERFACE=ON \
		-DENABLE_METKIT_DOCUMENTATION=ON

override_dh_auto_configure:
	dh_auto_configure -- \
                      ${BUILD_FLAGS} 

execute_after_dh_auto_install:
	( cd $(BUILDDIR)/pymetkit-python-package-staging/ && \
		python3 ./setup.py install --install-lib=$(DESTDIR)/usr/lib/python3/dist-packages )
	sed -i -e 's%$${_IMPORT_PREFIX}/include%/usr/include/${DEB_HOST_MULTIARCH}%g'   $(CMAKEDIR)/metkit-targets.cmake
	mv $(DESTDIR)/usr/bin/compare-mars-requests.py $(DESTDIR)/usr/bin/compare-mars-requests

override_dh_auto_test:
	echo "Metkit fetches data from the internet, and hence the tests can't be run contained at build-time"
