homebrew-core/Formula/libmatio.rb
2017-10-22 09:17:51 -07:00

50 lines
1.5 KiB
Ruby

class Libmatio < Formula
desc "C library for reading and writing MATLAB MAT files"
homepage "https://matio.sourceforge.io/"
url "https://downloads.sourceforge.net/project/matio/matio/1.5.11/matio-1.5.11.tar.gz"
sha256 "0ccced0c55c9c2cdc21348b7e16447843402d729ffaadd6135767faad7c9cf0b"
bottle do
cellar :any
sha256 "532117e692497b68749dc0dc396d1099f7339ee8bb252cf29d4f9292cfe4e9ae" => :high_sierra
sha256 "b98585e1162ee51929f2ba589eaa23e34d1cb42b98b93bb89780cf0e6b877535" => :sierra
sha256 "405ebd987019e5793a269ae1ebb9a2da15b51f6b04bf72dd32105ef368b3a889" => :el_capitan
end
depends_on "hdf5"
resource "test_mat_file" do
url "https://web.uvic.ca/~monahana/eos225/poc_data.mat.sfx"
sha256 "a29df222605476dcfa660597a7805176d7cb6e6c60413a3e487b62b6dbf8e6fe"
end
def install
args = %W[
--prefix=#{prefix}
--enable-extended-sparse=yes
--enable-mat73=yes
--with-hdf5=#{Formula["hdf5"].opt_prefix}
--with-zlib=/usr
]
system "./configure", *args
system "make", "install"
end
test do
testpath.install resource("test_mat_file")
(testpath/"mat.c").write <<~'EOS'
#include <stdlib.h>
#include <matio.h>
int main(int argc, char **argv) {
mat_t *matfp;
if (!(matfp = Mat_Open(argv[1], MAT_ACC_RDONLY)))
abort();
Mat_Close(matfp);
return EXIT_SUCCESS;
}
EOS
system ENV.cc, "mat.c", "-o", "mat", "-I#{include}", "-L#{lib}", "-lmatio"
system "./mat", "poc_data.mat.sfx"
end
end