#!/usr/bin/make -f
#export DH_VERBOSE = 1

# 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 = -W

%:
	dh $@ --buildsystem=cmake

override_dh_auto_configure:
	dh_auto_configure -- -DMFEM_USE_MPI=YES \
	    -DCMAKE_BUILD_TYPE=RelWithDebInfo \
	    -DMFEM_SOURCE_DIR=. \
	    -DBUILD_SHARED_LIBS=1 \
	    -DHYPRE_INCLUDE_DIR=/usr/include/hypre \
	    -DMFEM_ENABLE_TESTING=OFF \
	    -DCMAKE_INSTALL_PREFIX=$(pwd)/usr \
	    -DCMAKE_INSTALL_RPATH_USE_LINK_PATH=OFF \
	    -DCMAKE_INSTALL_RPATH=OFF
# maybe enable at some point later
#-DMFEM_USE_ADIOS2=ON libadios-dev
#-DMFEM_USE_MPFR=ON libmpfr-dev
#-DMFEM_USE_LIBUNWIND=ON libunwind-dev
#-DMFEM_USE_MUMPS=ON libmumps-dev
#-DMFEM_USE_SUNDIALS=ON libsundials-dev
#-DMFEM_USE_SUPERLU                 OFF or MFEM_USE_SUPERLU5                OFF libsuperlu-dev
#-DMFEM_USE_SIMD=ON libsimde-dev
# libscotch-dev
#
#	$(MAKE) config MFEM_USE_METIS=YES MFEM_USE_METIS_5=YES MFEM_DEBUG=YES MFEM_USE_LIBUNWIND=YES
# MFEM_USE_LAPACK = YES MFEM_USE_OPENMP = YES
# recommended MFEM_USE_MEMALLOC = YES
# MFEM_USE_MPFR = YES
# MFEM_USE_ADIOS2 = YES
# MFEM_USE_ZLIB = YES
# MFEM_USE_MPI = YES hypre
#
override_dh_fixperms:
	dh_fixperms
	chrpath -d debian/libmfem*/usr/lib/*/libmfem.so.*
	sed -i "s,$(CURDIR),/tmp/builddir/mfem,g" debian/libmfem-dev/usr/lib/*/cmake/mfem/MFEMConfig.cmake debian/libmfem-dev/usr/include/mfem/config/_config.hpp
