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

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

export PYBUILD_NAME=pyfftw
export PYBUILD_BEFORE_BUILD=find -name "*.c" -delete
export PYBUILD_AFTER_INSTALL_python3=dh_numpy3

PYVER_DEFAULT=$(shell py3versions -d -v)

%:
	dh $@ --buildsystem=pybuild

ifeq ($(filter nodoc,$(DEB_BUILD_PROFILES)),)
execute_after_dh_auto_build: export http_proxy=127.0.0.1:9
execute_after_dh_auto_build: export https_proxy=127.0.0.1:9
execute_after_dh_auto_build:
	PYTHONPATH=$(shell pybuild --pyver `py3versions --default -v` --print build_dir | awk '{print $$3}' ) \
          make -C docs html
endif


# pyFFTW tests assume an intel arch
# This does not hold on all arches, so ignore test failures
# on arches where they are expected to fail.
# Known failures are:
#  - arm64 ppc64el s390x ia64 powerpc: input_alignment != 16, simd_aligned not true
#  - hurd-i386: limited_time >= time_limit*2
ARCH_LIST_IGNORE_TEST_FAILURE = arm64 mips64el ppc64el s390x hurd-i386 ia64 powerpc

empty :=
space := $(empty)$(empty)

# by default, do not ignore test failure
IGNORE_TEST_ERROR=/bin/false
ifneq (,$(findstring $(space)$(DEB_HOST_ARCH)$(space), $(space)$(ARCH_LIST_IGNORE_TEST_FAILURE)$(space)))
# do ignore test failure on selected arches
IGNORE_TEST_ERROR=/bin/true
export PYBUILD_TEST_ARGS=-k 'not (test_auto_align_input or test_aligned_flag or test_flags or test_alignment or test_get_alignment)'
endif

override_dh_auto_test:
	dh_auto_test || $(IGNORE_TEST_ERROR)