#!/usr/bin/make -f

#workaround to start MPI-applications in chroot
export OMPI_MCA_plm_rsh_agent=/bin/false

export DEB_BUILD_MAINT_OPTIONS=hardening=+bindnow

DEB_HOST_MULTIARCH := $(shell dpkg-architecture -qDEB_HOST_MULTIARCH)

extra_flags +=						\
   -DCMAKE_Fortran_COMPILER=gfortran			\
   -DBUILD_SHARED_LIBS:BOOL=ON				\
   -DBUILD_STATIC_LIBS:BOOL=ON				\
   -DFCMIX_ENABLE:BOOL=ON				\
   -DMPI_ENABLE:BOOL=ON					\
   -DLAPACK_ENABLE:BOOL=ON				\
							\
   -DEXAMPLES_ENABLE:BOOL=OFF				\
   -DEXAMPLES_INSTALL:BOOL=OFF				\
							\
   -DOPENMP_ENABLE:BOOL=ON				\
   -DPTHREAD_ENABLE:BOOL=ON				\
                                                        \
   -DKLU_ENABLE:BOOL=ON					\
   -DKLU_INCLUDE_DIR=/usr/include/suitesparse		\
   -DKLU_LIBRARY_DIR=/usr/lib/$(DEB_HOST_MULTIARCH)	\
                                                        \
   -DPETSC_ENABLE:BOOL=ON				\
                                                        \
   -DSUPERLUMT_ENABLE:BOOL=OFF				\
                                                        \
   -DHYPRE_ENABLE:BOOL=ON                               \
   -DHYPRE_INCLUDE_DIR=/usr/include/hypre               \
   -DHYPRE_LIBRARY='-lHYPRE -lHYPRE_IJ_mv -lHYPRE_utilities -lHYPRE_parcsr_mv -lHYPRE_seq_mv'

BUILDDIR = $(CURDIR)/debian/build


%:
	dh $@ --buildsystem=cmake  --builddirectory=$(BUILDDIR)

override_dh_auto_configure:
	dh_auto_configure -- $(extra_flags)

override_dh_auto_install:
	dh_auto_install
# I strip out all the RPATH/RUNPATH tags from my shared objects. These all point
# to libraries that actually live in standard locations, so the tags are not
# needed
	find debian/tmp/ -name '*.so' -o -name '*.so.*' -exec chrpath -d '{}' \;

#
#to generate symbols
#	dpkg-gensymbols -plibsundials-parallel -O

override_dh_compress:
	dh_compress -Xexamples/

override_dh_auto_clean:
	dh_auto_clean
	rm -rf $(BUILDDIR)
