-
Notifications
You must be signed in to change notification settings - Fork 1
/
hdf5.rb
90 lines (79 loc) · 2.73 KB
/
hdf5.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
class Hdf5 < Formula
desc "File format designed to store large amounts of data"
homepage "http://www.hdfgroup.org/HDF5"
url "http://www.hdfgroup.org/ftp/HDF5/releases/hdf5-1.8.16/src/hdf5-1.8.16.tar.bz2"
sha256 "13aaae5ba10b70749ee1718816a4b4bfead897c2fcb72c24176e759aec4598c6"
bottle do
sha256 "e8002d53436a27af893f5c666cc1b50c6a707065d81de401c36c78ed981cd730" => :el_capitan
sha256 "ff5813bae448a875b7a9e1fcc943800fc0785d9b0db12da9c7a3c8961d95b516" => :yosemite
sha256 "61edd672204beafbb31cfe8b1159118225896a10f0554f1f3816a3306e5d810e" => :mavericks
end
deprecated_option "enable-fortran" => "with-fortran"
deprecated_option "enable-threadsafe" => "with-threadsafe"
deprecated_option "enable-parallel" => "with-mpi"
deprecated_option "enable-fortran2003" => "with-fortran2003"
deprecated_option "enable-cxx" => "with-cxx"
option :universal
option "with-check", "Run build-time tests"
option "with-threadsafe", "Trade performance for C API thread-safety"
option "with-fortran2003", "Compile Fortran 2003 bindings (requires --with-fortran)"
option "with-mpi", "Compile with parallel support (unsupported with thread-safety)"
option "without-cxx", "Disable the C++ interface"
option :cxx11
depends_on :fortran => :optional
depends_on "szip"
depends_on :mpi => [:optional, :cc, :cxx, :f90]
def install
ENV.universal_binary if build.universal?
args = %W[
--prefix=#{prefix}
--enable-production
--enable-debug=no
--disable-dependency-tracking
--with-zlib=/usr
--with-szlib=#{Formula["szip"].opt_prefix}
--enable-static=yes
--enable-shared=yes
--enable-unsupported
]
args << "--enable-threadsafe" << "--with-pthread=/usr" if build.with? "threadsafe"
if build.with? "cxx"
args << "--enable-cxx"
else
args << "--disable-cxx"
end
if build.with? "fortran"
args << "--enable-fortran"
args << "--enable-fortran2003" if build.with? "fortran2003"
else
args << "--disable-fortran"
end
if build.with? "mpi"
args << "--enable-parallel"
ENV["CC"] = ENV["MPICC"]
ENV["CXX"] = ENV["MPICXX"]
ENV["FC"] = ENV["MPIFC"]
end
system "./configure", *args
system "make"
system "make", "check" if build.with?("check") || build.bottle?
system "make", "install"
end
test do
(testpath/"test.c").write <<-EOS.undent
#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
if build.with? :cxx11
system "#{bin}/h5cc", "test.c"
else
system "#{bin}/h5c++", "test.c"
end
assert_match(/#{version}/, shell_output("./a.out"))
end
end