homebrew-core/Formula/libxc.rb

55 lines
1.6 KiB
Ruby

class Libxc < Formula
desc "Library of exchange and correlation functionals for codes"
homepage "https://tddft.org/programs/libxc/"
url "https://gitlab.com/libxc/libxc/-/archive/4.3.4/libxc-4.3.4.tar.bz2"
sha256 "0efe8b33d151de8787e33c4ba8e2161ffb9da978753f3bd12c5c0a018e7d3ef5"
license "MPL-2.0"
revision 1
bottle do
cellar :any
sha256 "77bb1192676ef031b3254e36f443b48163c2e6926afc959feaa84b4952a5b642" => :catalina
sha256 "069042e1d8511e2025e289cb3daec98728304df3a7521aced7103581686d74c8" => :mojave
sha256 "e84708fbaa5746ef8d25b57d34a5127501096ffacaa448b17d5b87ad4e81ae0b" => :high_sierra
end
depends_on "autoconf" => :build
depends_on "automake" => :build
depends_on "libtool" => :build
depends_on "gcc" # for gfortran
def install
system "autoreconf", "-fiv"
system "./configure", "--prefix=#{prefix}",
"--enable-shared",
"FCCPP=gfortran -E -x c",
"CC=#{ENV.cc}"
system "make", "install"
end
test do
(testpath/"test.c").write <<~EOS
#include <stdio.h>
#include <xc.h>
int main()
{
int major, minor, micro;
xc_version(&major, &minor, &micro);
printf(\"%d.%d.%d\", major, minor, micro);
}
EOS
system ENV.cc, "test.c", "-L#{lib}", "-lxc", "-I#{include}", "-o", "ctest"
system "./ctest"
(testpath/"test.f90").write <<~EOS
program lxctest
use xc_f90_types_m
use xc_f90_lib_m
end program lxctest
EOS
system "gfortran", "test.f90", "-L#{lib}", "-lxc", "-I#{include}",
"-o", "ftest"
system "./ftest"
end
end