class GribApi < Formula desc "Encode and decode grib messages (editions 1 and 2)" homepage "https://software.ecmwf.int/wiki/display/GRIB/Home" url "https://mirrors.ocf.berkeley.edu/debian/pool/main/g/grib-api/grib-api_1.24.0.orig.tar.xz" mirror "https://mirrorservice.org/sites/ftp.debian.org/debian/pool/main/g/grib-api/grib-api_1.24.0.orig.tar.xz" sha256 "304206c363ee388098d01778b5514edc626ced72b9fbb07d716d4f7210ee7579" bottle do sha256 "2ba802878787d0f0599dffc474b0f372a40abb575d1acc839f6cf2ed1330a970" => :high_sierra sha256 "f9a22edc756da433207555785222c2ccac0af98e651f8c6e5994bc017b3c600d" => :sierra sha256 "1913def4507c7804afc67de42edfc33bada218a982914bb30527e7cdec28ba10" => :el_capitan end option "with-static", "Build static instead of shared library." depends_on "cmake" => :build depends_on "numpy" depends_on "jasper" => :recommended depends_on "libpng" => :optional depends_on :fortran def install # Fix "no member named 'inmem_' in 'jas_image_t'" inreplace "src/grib_jasper_encoding.c", "image.inmem_ = 1;", "" inreplace "CMakeLists.txt", "find_package( OpenJPEG )", "" mkdir "build" do args = std_cmake_args args << "-DBUILD_SHARED_LIBS=OFF" if build.with? "static" if build.with? "libpng" args << "-DPNG_PNG_INCLUDE_DIR=#{Formula["libpng"].opt_include}" args << "-DENABLE_PNG=ON" end system "cmake", "..", "-DENABLE_NETCDF=OFF", *args system "make", "install" end end test do grib_samples_path = shell_output("#{bin}/grib_info -t").strip system bin/"grib_ls", "#{grib_samples_path}/GRIB1.tmpl" system bin/"grib_ls", "#{grib_samples_path}/GRIB2.tmpl" end end