class Gl2ps < Formula desc "OpenGL to PostScript printing library" homepage "http://www.geuz.org/gl2ps/" url "http://geuz.org/gl2ps/src/gl2ps-1.4.0.tgz" sha256 "03cb5e6dfcd87183f3b9ba3b22f04cd155096af81e52988cc37d8d8efe6cf1e2" bottle do cellar :any sha256 "4481d5e37838c2189005dd2eadbc37f45e0a1189ea9565ab8dee60d010b96036" => :sierra sha256 "e3a68d4e95ce16e3e144e42bc7c81282e7e495971cea02b0c8f39663425d2017" => :el_capitan sha256 "c1131b4a3053bff982689fa05c75b97e612f4b1501900187c60481a5e51a382d" => :yosemite end depends_on "cmake" => :build depends_on "libpng" def install # Prevent linking against X11's libglut.dylib when it's present # Reported to upstream's mailing list gl2ps@geuz.org (1st April 2016) # http://www.geuz.org/pipermail/gl2ps/2016/000433.html # Reported to cmake's bug tracker, as well (1st April 2016) # https://public.kitware.com/Bug/view.php?id=16045 system "cmake", ".", "-DGLUT_glut_LIBRARY=/System/Library/Frameworks/GLUT.framework", *std_cmake_args system "make", "install" end test do (testpath/"test.c").write <<-EOS.undent #include #include int main(int argc, char *argv[]) { glutInit(&argc, argv); glutInitDisplayMode(GLUT_DEPTH); glutInitWindowSize(400, 400); glutInitWindowPosition(100, 100); glutCreateWindow(argv[0]); GLint viewport[4]; glGetIntegerv(GL_VIEWPORT, viewport); FILE *fp = fopen("test.eps", "wb"); GLint buffsize = 0, state = GL2PS_OVERFLOW; while( state == GL2PS_OVERFLOW ){ buffsize += 1024*1024; gl2psBeginPage ( "Test", "Homebrew", viewport, GL2PS_EPS, GL2PS_BSP_SORT, GL2PS_SILENT | GL2PS_SIMPLE_LINE_OFFSET | GL2PS_NO_BLENDING | GL2PS_OCCLUSION_CULL | GL2PS_BEST_ROOT, GL_RGBA, 0, NULL, 0, 0, 0, buffsize, fp, "test.eps" ); gl2psText("Homebrew Test", "Courier", 12); state = gl2psEndPage(); } fclose(fp); return 0; } EOS system ENV.cc, "-L#{lib}", "-lgl2ps", "-framework", "OpenGL", "-framework", "GLUT", "-framework", "Cocoa", "test.c", "-o", "test" system "./test" assert File.exist?("test.eps") && File.size("test.eps") > 0 end end