homebrew-core/Formula/libmatio.rb

71 lines
2.4 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.21/matio-1.5.21.tar.gz"
sha256 "21809177e55839e7c94dada744ee55c1dea7d757ddaab89605776d50122fb065"
license "BSD-2-Clause"
revision 1
bottle do
sha256 cellar: :any, arm64_big_sur: "b3a64b70d10cdfc86f00a4131724c3924e84d7cdc432eab12952859f368019f6"
sha256 cellar: :any, big_sur: "06e8056f9862feace810dd233860e9b77af58e20e3eb916f48525c586e08eb42"
sha256 cellar: :any, catalina: "84f08acf62972b2fda425f589809892255c401f268b4fbe9465cfdca1a03a3de"
sha256 cellar: :any, mojave: "36629f8d449fa124cf0557deec222bb732c0ded477b5109011448726bd4f51d8"
sha256 cellar: :any_skip_relocation, x86_64_linux: "b5737ad4a0096f6ff36ec2d208baf1678f0c267b88c1d02a006fdf57172f966d"
end
depends_on "hdf5"
resource "homebrew-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("homebrew-test_mat_file")
(testpath/"mat.c").write <<~'EOS'
#include <stdlib.h>
#include <matio.h>
size_t dims[2] = {5, 5};
double data[25] = {0.0, };
mat_t *mat;
matvar_t *matvar;
int main(int argc, char **argv) {
if (!(mat = Mat_Open(argv[1], MAT_ACC_RDONLY)))
abort();
Mat_Close(mat);
mat = Mat_CreateVer("test_writenan.mat", NULL, MAT_FT_DEFAULT);
if (mat) {
matvar = Mat_VarCreate("foo", MAT_C_DOUBLE, MAT_T_DOUBLE, 2,
dims, data, MAT_F_DONT_COPY_DATA);
Mat_VarWrite(mat, matvar, MAT_COMPRESSION_NONE);
Mat_VarFree(matvar);
Mat_Close(mat);
} else {
abort();
}
mat = Mat_CreateVer("foo", NULL, MAT_FT_MAT73);
return EXIT_SUCCESS;
}
EOS
system ENV.cc, "mat.c", "-o", "mat", "-I#{include}", "-L#{lib}", "-lmatio"
system "./mat", "poc_data.mat.sfx"
end
end