forked from ahmadia/homebrew-science
-
Notifications
You must be signed in to change notification settings - Fork 0
/
silo.rb
69 lines (61 loc) · 2.26 KB
/
silo.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
class Silo < Formula
desc "LLNL mesh and field Silo I/O library. Allows creating databases for VisIt."
homepage "https://wci.llnl.gov/simulation/computer-codes/silo"
url "https://wci.llnl.gov/content/assets/docs/simulation/computer-codes/silo/silo-4.10.2/silo-4.10.2-bsd.tar.gz"
sha256 "4b901dfc1eb4656e83419a6fde15a2f6c6a31df84edfad7f1dc296e01b20140e"
revision 4
bottle do
sha256 "624de8ce662b6ce4f51cd100faf7c212ea7ad745ee66965c6cb0c045dddc830d" => :sierra
sha256 "0c11bc3e37dfd10984a1475a0f6c15714c58e955a28395e5548f29d2dd8d4e0b" => :el_capitan
sha256 "392947bac24a93a7a5e70ddeb6825ada3cc97de9c7a1cb7a2b0d9806a91b5ac0" => :yosemite
sha256 "b4cc0e28f1e29c8c2cf51b82787ec6bb1bf80310c775ad796f48a704e06e9d4c" => :x86_64_linux
end
option "with-static", "Build as static instead of dynamic library"
option "without-lite-headers", "Do not install PDB lite headers"
depends_on :x11 => :optional
depends_on :fortran
depends_on "readline"
depends_on "hdf5" => :recommended
def install
args = ["--prefix=#{prefix}"]
args << "--enable-optimization"
args << "--with-zlib"
args << "--enable-install-lite-headers" if build.with? "lite-headers"
args << "--enable-shared" if build.without? "static"
args << "--enable-x" if build.with? "x11"
args << "--with-hdf5=#{Formula["hdf5"].opt_prefix}" if build.with? "hdf5"
ENV.append "LDFLAGS", "-L#{Formula["readline"].opt_lib} -lreadline"
system "./configure", *args
system "make", "install"
if build.with? "hdf5"
rm lib/"libsiloh5.settings"
else
rm lib/"libsilo.settings"
end
end
test do
(testpath/"test.c").write <<-EOS.undent
#include <silo.h>
int main(void)
{
DBfile *silodb;
silodb = DBCreate("test.silo", DB_CLOBBER, DB_LOCAL, NULL, DB_PDB);
if (!silodb)
return 1;
DBClose(silodb);
return 0;
}
EOS
test_args = ["test.c", "-I#{opt_include}", "-L#{opt_lib}", "-o", "test"]
if build.with? "hdf5"
test_args << "-lsiloh5"
test_args << "-L#{Formula["hdf5"].opt_lib}"
test_args << "-lhdf5"
else
test_args << "-lsilo"
end
test_args << "-lm"
system ENV.cc, *test_args
system "./test"
end
end