# Description: suite of nonlinear differential/algebraic equation solvers
# URL: https://computation.llnl.gov/casc/sundials/
# Maintainer: John McQuah, jmcquah at disroot dot org
# Depends on: suitesparse

name=sundials
version=5.8.0
release=1
source=(https://github.com/LLNL/sundials/releases/download/v$version/$name-$version.tar.gz
        sundials-fix-cmake-targets.patch)

build() {
    cd $name-$version
    patch -p1 < $SRC/sundials-fix-cmake-targets.patch
    cd -

    cmake -B build -S $name-$version \
    -DCMAKE_INSTALL_PREFIX=/usr \
    -DCMAKE_C_FLAGS="${CFLAGS} -fPIC -fcommon" \
    -DENABLE_PTHREAD=ON	\
    -DENABLE_OPENMP=ON \
    -DBUILD_FORTRAN77_INTERFACE=ON \
    -DENABLE_KLU=ON \
    -DKLU_LIBRARY_DIR=/usr/lib \
    -DEXAMPLES_INSTALL=OFF

    cmake --build build

    DESTDIR=$PKG cmake --install build
    rm $PKG/usr/include/sundials/{LICENSE,NOTICE}
}