#!/usr/bin/env modbuild

SOURCE_URL="file://$PMODULES_DISTFILESDIR/$P-V.tar.bz2"

pbuild::configure() {
	cat <<EOF > "${MODULE_SRCDIR}/SuiteSparse_config/SuiteSparse_config.mk"
CF = \$(CFLAGS) \$(CPPFLAGS) \$(TARGET_ARCH) -O3 -fexceptions -fPIC -DNTIMER
RANLIB = ranlib
ARCHIVE = \$(AR) \$(ARFLAGS)
CP = cp -f
MV = mv -f
F77 = gfortran
F77FLAGS = \$(FFLAGS) -O
F77LIB =
LIB = -lm
INSTALL_LIB = \${PREFIX}/lib
INSTALL_INCLUDE = \${PREFIX}/include
BLAS = -lopenblas -lgfortran
XERBLA = 
GPU_BLAS_PATH =
GPU_CONFIG =
UMFPACK_CONFIG = -DNCHOLMOD
CHOLMOD_CONFIG = \$(GPU_CONFIG)
SPQR_CONFIG =
TBB =
EOF
}

pbuild::build() {
	cd "${MODULE_SRCDIR}/UMFPACK"
	make TARGET=CORE2 BINARY=64 USE_THREAD=0 NO_SHARED=1
}

pbuild::install() {
	cd "${MODULE_SRCDIR}/UMFPACK"
	install -d "${PREFIX}/include"
	install -d "${PREFIX}/lib"
	make PREFIX="${PREFIX}" install
}

pbuild::add_to_group 'Compiler'
pbuild::compile_in_sourcetree
pbuild::make_all
pbuild::cleanup_src
