#!/usr/bin/make -f

# Verbose build. See:
# http://qa.debian.org/bls/bytag/W-compiler-flags-hidden.html
export V=1

DEB_HOST_ARCH ?= $(shell dpkg-architecture -qDEB_HOST_ARCH)

# If building for kfreebsd-i386, disable OpenMP.
# On this architecture, if OpenMP is enabled the map2alm_iter2 function
# fails to converge, so the check_alm2mapalm unit test runs indefinitely.
ifeq ($(DEB_HOST_ARCH),kfreebsd-i386)
EXTRA_CONFIGURE_ARGS=--disable-openmp
else
EXTRA_CONFIGURE_ARGS=
endif

# If DEB_BUILD_OPTIONS=parallel=n is set, then use that many OpenMP threads
# in the unit test suite too.
ifneq (,$(filter parallel=%,$(DEB_BUILD_OPTIONS)))
NUMJOBS = $(patsubst parallel=%,%,$(filter parallel=%,$(DEB_BUILD_OPTIONS)))
export OMP_NUM_THREADS=$(NUMJOBS)
endif

%:
	dh $@ --with autoreconf

override_dh_auto_configure:
	dh_auto_configure -- $(EXTRA_CONFIGURE_ARGS)

override_dh_strip:
	dh_strip --dbg-package=libhealpix-cxx0-dbg
