|
| 1 | +class Silo < Formula |
| 2 | + desc "LLNL mesh and field Silo I/O library. Allows creating databases for VisIt." |
| 3 | + homepage "https://wci.llnl.gov/simulation/computer-codes/silo" |
| 4 | + url "https://wci.llnl.gov/content/assets/docs/simulation/computer-codes/silo/silo-4.10.2/silo-4.10.2-bsd.tar.gz" |
| 5 | + sha256 "4b901dfc1eb4656e83419a6fde15a2f6c6a31df84edfad7f1dc296e01b20140e" |
| 6 | + revision 4 |
| 7 | + |
| 8 | + bottle do |
| 9 | + sha256 "624de8ce662b6ce4f51cd100faf7c212ea7ad745ee66965c6cb0c045dddc830d" => :sierra |
| 10 | + sha256 "0c11bc3e37dfd10984a1475a0f6c15714c58e955a28395e5548f29d2dd8d4e0b" => :el_capitan |
| 11 | + sha256 "392947bac24a93a7a5e70ddeb6825ada3cc97de9c7a1cb7a2b0d9806a91b5ac0" => :yosemite |
| 12 | + sha256 "b4cc0e28f1e29c8c2cf51b82787ec6bb1bf80310c775ad796f48a704e06e9d4c" => :x86_64_linux |
| 13 | + end |
| 14 | + |
| 15 | + option "with-static", "Build as static instead of dynamic library" |
| 16 | + option "without-lite-headers", "Do not install PDB lite headers" |
| 17 | + |
| 18 | + depends_on :x11 => :optional |
| 19 | + depends_on "gcc" if OS.mac? # for gfortran |
| 20 | + depends_on "readline" |
| 21 | + depends_on "hdf5" => :recommended |
| 22 | + |
| 23 | + def install |
| 24 | + args = ["--prefix=#{prefix}"] |
| 25 | + args << "--enable-optimization" |
| 26 | + args << "--with-zlib" |
| 27 | + args << "--enable-install-lite-headers" if build.with? "lite-headers" |
| 28 | + args << "--enable-shared" if build.without? "static" |
| 29 | + args << "--enable-x" if build.with? "x11" |
| 30 | + args << "--with-hdf5=#{Formula["hdf5"].opt_prefix}" if build.with? "hdf5" |
| 31 | + |
| 32 | + ENV.append "LDFLAGS", "-L#{Formula["readline"].opt_lib} -lreadline" |
| 33 | + system "./configure", *args |
| 34 | + system "make", "install" |
| 35 | + if build.with? "hdf5" |
| 36 | + rm lib/"libsiloh5.settings" |
| 37 | + else |
| 38 | + rm lib/"libsilo.settings" |
| 39 | + end |
| 40 | + end |
| 41 | + |
| 42 | + test do |
| 43 | + (testpath/"test.c").write <<~EOS |
| 44 | + #include <silo.h> |
| 45 | +
|
| 46 | + int main(void) |
| 47 | + { |
| 48 | + DBfile *silodb; |
| 49 | + silodb = DBCreate("test.silo", DB_CLOBBER, DB_LOCAL, NULL, DB_PDB); |
| 50 | + if (!silodb) |
| 51 | + return 1; |
| 52 | +
|
| 53 | + DBClose(silodb); |
| 54 | + return 0; |
| 55 | + } |
| 56 | + EOS |
| 57 | + test_args = ["test.c", "-I#{opt_include}", "-L#{opt_lib}", "-o", "test"] |
| 58 | + if build.with? "hdf5" |
| 59 | + test_args << "-lsiloh5" |
| 60 | + test_args << "-L#{Formula["hdf5"].opt_lib}" |
| 61 | + test_args << "-lhdf5" |
| 62 | + else |
| 63 | + test_args << "-lsilo" |
| 64 | + end |
| 65 | + test_args << "-lm" |
| 66 | + system ENV.cc, *test_args |
| 67 | + system "./test" |
| 68 | + end |
| 69 | +end |
0 commit comments