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

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

include /usr/share/dpkg/pkg-info.mk

export PYBUILD_NAME=satpy
export PYBUILD_AFTER_INSTALL=rm -rf \
{destdir}/{install_dir}/benchmarks \
{destdir}/{install_dir}/dask-worker-space \
{destdir}/{install_dir}/dummy*
export PYBUILD_TEST_ARGS=-k \
"not test_retrieve and not test_offline_retrieve\
 and not test_retrieve_all and not test_download_script\
 and not test_start_time and not test_end_time\
 and not test_mimic_TPW2_nc\
 and not TestAngleGeneration\
 and not test_get_luts"


%:
	dh $@ --with python3,sphinxdoc --buildsystem=pybuild

override_dh_auto_configure:
	echo "version = '$(DEB_VERSION_UPSTREAM)'" > satpy/version.py
	dh_auto_configure

override_dh_fixperms:
	dh_fixperms
	find debian/python*satpy -name 'agri_l1.*' -exec chmod -x {} +

override_dh_auto_clean:
	dh_auto_clean

	$(RM) -r .eggs *.egg-info
	$(RM) test*.mitiff
	$(RM) -r .pytest_cache
	$(RM) satpy/version.py

override_dh_auto_build: export http_proxy=127.0.0.1:9
override_dh_auto_build: export https_proxy=127.0.0.1:9
override_dh_auto_build:
	dh_auto_build
ifeq (,$(filter nodoc,$(DEB_BUILD_OPTIONS)))
	PSP_CONFIG_FILE=$(CURDIR)/debian/pyspectral_dummycfg.yaml \
	PYTHONPATH=. python3 -m sphinx -N -bhtml doc/source build/html # HTML generator
	# PYTHONPATH=. python3 -m sphinx -N -bman doc/source build/man # Manpage generator
endif

override_dh_auto_test:
ifeq (,$(filter nocheck,$(DEB_BUILD_OPTIONS)))
ifneq (,$(filter $(DEB_BUILD_ARCH),armhf))
	dh_auto_test || echo "Ignoring test failures"
else
	dh_auto_test
endif
endif
