homebrew-core/Formula/gromacs.rb

82 lines
3.0 KiB
Ruby

class Gromacs < Formula
desc "Versatile package for molecular dynamics calculations"
homepage "https://www.gromacs.org/"
url "https://ftp.gromacs.org/pub/gromacs/gromacs-2022.4.tar.gz"
sha256 "c511be602ff29402065b50906841def98752639b92a95f1b0a1060d9b5e27297"
license "LGPL-2.1-or-later"
livecheck do
url "https://ftp.gromacs.org/pub/gromacs/"
regex(/href=.*?gromacs[._-]v?(\d+(?:\.\d+)*)\.t/i)
end
bottle do
sha256 arm64_ventura: "4c11b01249186a6984cdaf3062969c457d59438e42eb9497ffa73adb7836395b"
sha256 arm64_monterey: "06c18fe289340416d188eb55fff50a2808d223f16b690fff1bb02ba233cd0a5f"
sha256 arm64_big_sur: "61c09e6ba0d3799ff637dc7c0af1b781dcbf4c102c205081803b044265931848"
sha256 ventura: "1d429bb615beba8b5007eb42bf060a56bd367667acc3a8a8a215e86261a1ad77"
sha256 monterey: "ba1472ad7282316737271f920c9c1dbebf7c157119a957813727e8f7cf68e67b"
sha256 big_sur: "741c47df9987fac450f9fce8984f0fcc918983e3e522bc7524f9dd2fcc8b3505"
sha256 catalina: "de3e440a66779a4dcbc55c4190d7bca01d8bb44170206339c1647ee85e8447b8"
sha256 x86_64_linux: "6aa6b4b23b8ce02729917cb948c25ff156186f5ecce07e89870bd4ed4357944a"
end
depends_on "cmake" => :build
depends_on "fftw"
depends_on "gcc" # for OpenMP
depends_on "openblas"
fails_with :clang
fails_with gcc: "5"
fails_with gcc: "6"
def install
# Non-executable GMXRC files should be installed in DATADIR
inreplace "scripts/CMakeLists.txt", "CMAKE_INSTALL_BINDIR",
"CMAKE_INSTALL_DATADIR"
# Avoid superenv shim reference
gcc = Formula["gcc"]
cc = gcc.opt_bin/"gcc-#{gcc.any_installed_version.major}"
cxx = gcc.opt_bin/"g++-#{gcc.any_installed_version.major}"
inreplace "src/gromacs/gromacs-hints.in.cmake" do |s|
s.gsub! "@CMAKE_LINKER@", "/usr/bin/ld"
s.gsub! "@CMAKE_C_COMPILER@", cc
s.gsub! "@CMAKE_CXX_COMPILER@", cxx
end
inreplace "src/buildinfo.h.cmakein" do |s|
s.gsub! "@BUILD_C_COMPILER@", cc
s.gsub! "@BUILD_CXX_COMPILER@", cxx
end
inreplace "src/gromacs/gromacs-config.cmake.cmakein", "@GROMACS_CXX_COMPILER@", cxx
args = %W[
-DGROMACS_CXX_COMPILER=#{cxx}
-DGMX_VERSION_STRING_OF_FORK=#{tap.user}
]
# Force SSE2/SSE4.1 for compatibility when building Intel bottles
args << "-DGMX_SIMD=#{MacOS.version.requires_sse41? ? "SSE4.1" : "SSE2"}" if Hardware::CPU.intel? && build.bottle?
system "cmake", "-S", ".", "-B", "build", *std_cmake_args, *args
system "cmake", "--build", "build"
system "cmake", "--install", "build"
bash_completion.install "build/scripts/GMXRC" => "gromacs-completion.bash"
bash_completion.install bin/"gmx-completion-gmx.bash" => "gmx-completion-gmx.bash"
bash_completion.install bin/"gmx-completion.bash" => "gmx-completion.bash"
zsh_completion.install "build/scripts/GMXRC.zsh" => "_gromacs"
end
def caveats
<<~EOS
GMXRC and other scripts installed to:
#{HOMEBREW_PREFIX}/share/gromacs
EOS
end
test do
system "#{bin}/gmx", "help"
end
end