#!/usr/bin/make -f
# See debhelper(7) (uncomment to enable)
# output every command that modifies files on the build system.
#export DH_VERBOSE = 1

export DEB_HOST_MULTIARCH ?= $(shell dpkg-architecture -qDEB_HOST_MULTIARCH)

# see FEATURE AREAS in dpkg-buildflags(1)
#export DEB_BUILD_MAINT_OPTIONS = hardening=+all

# see ENVIRONMENT in dpkg-buildflags(1)
# package maintainers to append CFLAGS
#export DEB_CFLAGS_MAINT_APPEND  = -Wall -pedantic
# package maintainers to append LDFLAGS
#export DEB_LDFLAGS_MAINT_APPEND = -Wl,--as-needed


%:
	dh $@ --buildsystem=cmake --parallel


# NOTE: the superlu-dist cmake scripts generate a configuration error:
#   CMake Error in SRC/CMakeLists.txt:
#    Found relative path while evaluating include directories of "superlu_dist":
#      "OFF"
# with error code 1, which causes the build to halt.
# But the configuration seems fine (GNUInstallDirs are used to define standard install dirs).
# For now, work around the error by ignoring it (append "|| /bin/true")
override_dh_auto_configure:
	dh_auto_configure -- \
	    -DBUILD_SHARED_LIBS=ON -DCMAKE_SKIP_RPATH=ON \
	    -Denable_parmetislib=OFF \
	    -DCMAKE_C_COMPILER=mpicc -DCMAKE_FORTRAN_COMPILER=mpifort \
	    -Denable_blaslib=OFF -DTPL_BLAS_LIBRARIES=/usr/lib/$(DEB_HOST_MULTIARCH)/libblas.so \
	    -DCMAKE_INSTALL_INCLUDEDIR=include/superlu-dist \
	  || /bin/true


override_dh_auto_test:
	dh_auto_test || /bin/true

