115 lines
4.3 KiB
Ruby
115 lines
4.3 KiB
Ruby
class Hdf5 < Formula
|
|
desc "File format designed to store large amounts of data"
|
|
homepage "https://www.hdfgroup.org/HDF5"
|
|
url "https://support.hdfgroup.org/ftp/HDF5/releases/hdf5-1.12/hdf5-1.12.2/src/hdf5-1.12.2.tar.bz2"
|
|
sha256 "1a88bbe36213a2cea0c8397201a459643e7155c9dc91e062675b3fb07ee38afe"
|
|
license "BSD-3-Clause"
|
|
revision 2
|
|
version_scheme 1
|
|
|
|
# This regex isn't matching filenames within href attributes (as we normally
|
|
# do on HTML pages) because this page uses JavaScript to handle the download
|
|
# buttons and the HTML doesn't contain the related URLs.
|
|
livecheck do
|
|
url "https://www.hdfgroup.org/downloads/hdf5/source-code/"
|
|
regex(/>\s*hdf5[._-]v?(\d+(?:\.\d+)+)\.t/i)
|
|
end
|
|
|
|
bottle do
|
|
rebuild 1
|
|
sha256 cellar: :any, arm64_ventura: "eeb6d86fe48f393589e1e8fbedd26f17c41fea525be02a539cbd4d2e46ee3d89"
|
|
sha256 cellar: :any, arm64_monterey: "0988092d7820628de58e2b7317e54187fb15501a5acc6fd9f81fc7123d18a1d3"
|
|
sha256 cellar: :any, arm64_big_sur: "64c557b69dad39bc1bbb6a19694ddb5e0651dca961d98fba71a7e7c25d35129b"
|
|
sha256 cellar: :any, ventura: "f5c508938bb6a0801afe86a3ba7f2bb0095ad91f907dc422c4fd94d0aa93f160"
|
|
sha256 cellar: :any, monterey: "e89540a3626665e98679fdd64f9b2d007bd12d489e1a67b4f5a48b09021a686c"
|
|
sha256 cellar: :any, big_sur: "61cb53a7c7915fcc8e0a8f623a382c4e73d7047c6723ede57c070918678743f8"
|
|
sha256 cellar: :any, catalina: "b3be3911f2100587685f7c4d089001becb7a3405f3fd2e7dfbcacceb672894b0"
|
|
sha256 cellar: :any_skip_relocation, x86_64_linux: "507a340a5132018ee60fab34e90effc08fa06c6401bbf3e920b012a90a0525a9"
|
|
end
|
|
|
|
depends_on "autoconf" => :build
|
|
depends_on "automake" => :build
|
|
depends_on "libtool" => :build
|
|
depends_on "gcc" # for gfortran
|
|
depends_on "libaec"
|
|
|
|
uses_from_macos "zlib"
|
|
|
|
conflicts_with "hdf5-mpi", because: "hdf5-mpi is a variant of hdf5, one can only use one or the other"
|
|
|
|
def install
|
|
inreplace %w[c++/src/h5c++.in fortran/src/h5fc.in bin/h5cc.in],
|
|
"${libdir}/libhdf5.settings",
|
|
"#{pkgshare}/libhdf5.settings"
|
|
|
|
inreplace "src/Makefile.am",
|
|
"settingsdir=$(libdir)",
|
|
"settingsdir=#{pkgshare}"
|
|
|
|
system "autoreconf", "--force", "--install", "--verbose"
|
|
|
|
args = %W[
|
|
--disable-dependency-tracking
|
|
--disable-silent-rules
|
|
--enable-build-mode=production
|
|
--enable-fortran
|
|
--enable-cxx
|
|
--prefix=#{prefix}
|
|
--with-szlib=#{Formula["libaec"].opt_prefix}
|
|
]
|
|
args << "--with-zlib=#{Formula["zlib"].opt_prefix}" if OS.linux?
|
|
|
|
system "./configure", *args
|
|
|
|
# Avoid shims in settings file
|
|
inreplace "src/libhdf5.settings", Superenv.shims_path/ENV.cxx, ENV.cxx
|
|
inreplace "src/libhdf5.settings", Superenv.shims_path/ENV.cc, ENV.cc
|
|
|
|
system "make", "install"
|
|
end
|
|
|
|
test do
|
|
(testpath/"test.c").write <<~EOS
|
|
#include <stdio.h>
|
|
#include "hdf5.h"
|
|
int main()
|
|
{
|
|
printf("%d.%d.%d\\n", H5_VERS_MAJOR, H5_VERS_MINOR, H5_VERS_RELEASE);
|
|
return 0;
|
|
}
|
|
EOS
|
|
system "#{bin}/h5cc", "test.c"
|
|
assert_equal version.to_s, shell_output("./a.out").chomp
|
|
|
|
(testpath/"test.f90").write <<~EOS
|
|
use hdf5
|
|
integer(hid_t) :: f, dspace, dset
|
|
integer(hsize_t), dimension(2) :: dims = [2, 2]
|
|
integer :: error = 0, major, minor, rel
|
|
|
|
call h5open_f (error)
|
|
if (error /= 0) call abort
|
|
call h5fcreate_f ("test.h5", H5F_ACC_TRUNC_F, f, error)
|
|
if (error /= 0) call abort
|
|
call h5screate_simple_f (2, dims, dspace, error)
|
|
if (error /= 0) call abort
|
|
call h5dcreate_f (f, "data", H5T_NATIVE_INTEGER, dspace, dset, error)
|
|
if (error /= 0) call abort
|
|
call h5dclose_f (dset, error)
|
|
if (error /= 0) call abort
|
|
call h5sclose_f (dspace, error)
|
|
if (error /= 0) call abort
|
|
call h5fclose_f (f, error)
|
|
if (error /= 0) call abort
|
|
call h5close_f (error)
|
|
if (error /= 0) call abort
|
|
CALL h5get_libversion_f (major, minor, rel, error)
|
|
if (error /= 0) call abort
|
|
write (*,"(I0,'.',I0,'.',I0)") major, minor, rel
|
|
end
|
|
EOS
|
|
system "#{bin}/h5fc", "test.f90"
|
|
assert_equal version.to_s, shell_output("./a.out").chomp
|
|
end
|
|
end
|