class Sundials < Formula desc "Nonlinear and differential/algebraic equations solver" homepage "https://computation.llnl.gov/casc/sundials/main.html" url "https://computation.llnl.gov/projects/sundials/download/sundials-5.0.0.tar.gz" sha256 "345141ec01c641d0bdfb3476c478b7e74fd6a7192a478a27cafe75d9da2d7dd3" bottle do cellar :any sha256 "b9bca7d111f7180280b814f452aaca92474b6a923ec229e4c9c93505f668024e" => :catalina sha256 "0446a14944b70fcffab57ea46fc48532c76817fb1e57ca3184231414a3e748c7" => :mojave sha256 "7e6f17174a9d1781fc1cb81e16ffde13213c4f8af2a9027bc348604aa39bde00" => :high_sierra end depends_on "cmake" => :build depends_on "gcc" # for gfortran depends_on "open-mpi" depends_on "openblas" depends_on "suite-sparse" def install blas = "-L#{Formula["openblas"].opt_lib} -lopenblas" args = std_cmake_args + %W[ -DCMAKE_C_COMPILER=#{ENV["CC"]} -DBUILD_SHARED_LIBS=ON -DKLU_ENABLE=ON -DKLU_LIBRARY_DIR=#{Formula["suite-sparse"].opt_lib} -DKLU_INCLUDE_DIR=#{Formula["suite-sparse"].opt_include} -DLAPACK_ENABLE=ON -DBLA_VENDOR=OpenBLAS -DLAPACK_LIBRARIES=#{blas};#{blas} -DMPI_ENABLE=ON ] mkdir "build" do system "cmake", "..", *args system "make", "install" end end test do cp Dir[prefix/"examples/nvector/serial/*"], testpath system ENV.cc, "-I#{include}", "test_nvector.c", "sundials_nvector.c", "test_nvector_serial.c", "-L#{lib}", "-lsundials_nvecserial" assert_match "SUCCESS: NVector module passed all tests", shell_output("./a.out 42 0") end end