class Cairo < Formula desc "Vector graphics library with cross-device output support" homepage "https://cairographics.org/" url "https://cairographics.org/releases/cairo-1.16.0.tar.xz" sha256 "5e7b29b3f113ef870d1e3ecf8adf21f923396401604bda16d44be45e66052331" license any_of: ["LGPL-2.1-only", "MPL-1.1"] revision 5 livecheck do url "https://cairographics.org/releases/?C=M&O=D" regex(%r{href=(?:["']?|.*?/)cairo[._-]v?(\d+\.\d*[02468](?:\.\d+)*)\.t}i) end bottle do sha256 arm64_big_sur: "2fc4da6029167f696fc0b3c0553d36abb8e77c75f0096396d4eb89d0ea912612" sha256 big_sur: "cb16c1bb070a7cdca7aaf8899a70e407d73636116d62225626b2c8d31aa8d2ff" sha256 catalina: "4a117545953b9784f78db8261c03d71a1ae7af836dcd995abe7e6d710cdfd39c" sha256 mojave: "38c7b7b0f6266632a5f04df12180dc36a1ce218a1c54b13cdca18ad024067311" end head do url "https://gitlab.freedesktop.org/cairo/cairo.git" depends_on "autoconf" => :build depends_on "automake" => :build depends_on "libtool" => :build end depends_on "pkg-config" => :build depends_on "fontconfig" depends_on "freetype" depends_on "glib" depends_on "libpng" depends_on "libx11" depends_on "libxcb" depends_on "libxext" depends_on "libxrender" depends_on "lzo" depends_on "pixman" uses_from_macos "zlib" # Avoid segfaults on Big Sur. Remove at version bump. # https://gitlab.freedesktop.org/cairo/cairo/-/issues/420 patch do url "https://gitlab.freedesktop.org/cairo/cairo/-/commit/e22d7212acb454daccc088619ee147af03883974.patch" sha256 "363a6018efc52721e2eace8df3aa319c93f3ad765ef7e3ea04e2ddd4ee94d0e1" end def install args = %W[ --disable-dependency-tracking --prefix=#{prefix} --enable-gobject --enable-svg --enable-tee --disable-valgrind --enable-xcb --enable-xlib --enable-xlib-xrender ] on_macos do args += %w[ --enable-quartz-image ] end if build.head? ENV["NOCONFIGURE"] = "1" system "./autogen.sh" end system "./configure", *args system "make", "install" end test do (testpath/"test.c").write <<~EOS #include int main(int argc, char *argv[]) { cairo_surface_t *surface = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, 600, 400); cairo_t *context = cairo_create(surface); return 0; } EOS fontconfig = Formula["fontconfig"] freetype = Formula["freetype"] gettext = Formula["gettext"] glib = Formula["glib"] libpng = Formula["libpng"] pixman = Formula["pixman"] flags = %W[ -I#{fontconfig.opt_include} -I#{freetype.opt_include}/freetype2 -I#{gettext.opt_include} -I#{glib.opt_include}/glib-2.0 -I#{glib.opt_lib}/glib-2.0/include -I#{include}/cairo -I#{libpng.opt_include}/libpng16 -I#{pixman.opt_include}/pixman-1 -L#{lib} -lcairo ] system ENV.cc, "test.c", "-o", "test", *flags system "./test" end end