diff --git a/Formula/cglm.rb b/Formula/cglm.rb new file mode 100644 index 0000000000..4b172013b7 --- /dev/null +++ b/Formula/cglm.rb @@ -0,0 +1,38 @@ +class Cglm < Formula + desc "Optimized OpenGL/Graphics Math (glm) for C" + homepage "https://github.com/recp/cglm" + url "https://github.com/recp/cglm/archive/v0.4.4.tar.gz" + sha256 "b62dff42202f9302ed1dfbad039134c45ff92c809052598aa1c469aab91a65d3" + + depends_on "autoconf" => :build + depends_on "automake" => :build + depends_on "libtool" => :build + + def install + system "autoreconf", "-fiv" + system "./configure", "--disable-dependency-tracking", + "--disable-silent-rules", + "--prefix=#{prefix}" + system "make", "install" + end + + test do + (testpath/"test.c").write <<~EOS + #include + #include + + int main() { + vec3 x = {1.0f, 0.0f, 0.0f}, + y = {0.0f, 1.0f, 0.0f}, + z = {0.0f, 0.0f, 1.0f}; + vec3 r; + + glm_cross(x, y, r); + assert(glm_vec_eqv_eps(r, z)); + return 0; + } + EOS + system ENV.cc, "-I#{include}", testpath/"test.c", "-o", "test" + system "./test" + end +end