#!/usr/bin/env modbuild

pbuild::set_download_url "http://crd-legacy.lbl.gov/~xiaoye/SuperLU/superlu_${V_PKG}.tar.gz"
pbuild::add_to_group 'Compiler'
pbuild::install_docfiles 'README'

if (( V_MAJOR < 5 )); then
	pbuild::compile_in_sourcetree
	pbuild::configure() {
		cat <<EOF > "${SRC_DIR}/make.inc"
PLAT		= 
SuperLUroot 	= \${PREFIX}
SUPERLULIB   	= \$(SuperLUroot)/lib/libsuperlu.a
BLASDEF	     	= -DUSE_VENDOR_BLAS
BLASLIB      	= \${OPENBLAS_PREFIX}/lib/libopenblas.a
TMGLIB          = libtmglib.a
METISLIB	=
PARMETISLIB	=
FLIBS	 	= 
LIBS            = \$(DSUPERLULIB) \$(BLASLIB) \$(PARMETISLIB) \$(METISLIB)
ARCH         	= ar
ARCHFLAGS    	= cr
RANLIB       	= ranlib
CC           	= ${CC}
CFLAGS          = -pipe -O3
NOOPTS		= 
FORTRAN         = ${FC}
F90FLAGS	= 
LOADER	        = ${FC}
LOADOPTS	= -fopenmp 
CDEFS        = -DAdd_ 
EOF
}

	pbuild::pre_compile() {
		mkdir -p "${PREFIX}/lib"
	}

	pbuild::post_install() {
		mkdir -p "${PREFIX}/include"
		install -m 0444 "${SRC_DIR}"/SRC/*.h "${PREFIX}/include"
	}

fi

