100 lines
3 KiB
Ruby
100 lines
3 KiB
Ruby
class Librsvg < Formula
|
|
desc "Library to render SVG files using Cairo"
|
|
homepage "https://live.gnome.org/LibRsvg"
|
|
url "https://download.gnome.org/sources/librsvg/2.40/librsvg-2.40.16.tar.xz"
|
|
sha256 "d48bcf6b03fa98f07df10332fb49d8c010786ddca6ab34cbba217684f533ff2e"
|
|
revision 1
|
|
|
|
bottle do
|
|
sha256 "f4b8c0b69418d3cb0720af733219b2177a801f6f98f6767acaa1d538457b5c7d" => :el_capitan
|
|
sha256 "23c9650d0d5f26898e3387836fc6c7272998d7a41aa5a76bda84ba9be31fbb81" => :yosemite
|
|
sha256 "b00aa2f676d225950a9ac5ee7c6595b2bfe365252c362bc781ef8e86fdf033fc" => :mavericks
|
|
end
|
|
|
|
depends_on "pkg-config" => :build
|
|
depends_on "cairo"
|
|
depends_on "gdk-pixbuf"
|
|
depends_on "glib"
|
|
depends_on "libcroco"
|
|
depends_on "pango"
|
|
depends_on "libgsf" => :optional
|
|
depends_on "gtk+3" => :optional
|
|
|
|
def install
|
|
args = %W[
|
|
--disable-dependency-tracking
|
|
--prefix=#{prefix}
|
|
--disable-Bsymbolic
|
|
--enable-tools=yes
|
|
--enable-pixbuf-loader=yes
|
|
--enable-introspection=yes
|
|
]
|
|
args << "--enable-svgz" if build.with? "libgsf"
|
|
|
|
system "./configure", *args
|
|
|
|
# disable updating gdk-pixbuf cache, we will do this manually in post_install
|
|
# https://github.com/Homebrew/homebrew/issues/40833
|
|
inreplace "gdk-pixbuf-loader/Makefile",
|
|
"$(GDK_PIXBUF_QUERYLOADERS) > $(DESTDIR)$(gdk_pixbuf_cache_file) ;",
|
|
""
|
|
|
|
system "make", "install",
|
|
"gdk_pixbuf_binarydir=#{lib}/gdk-pixbuf-2.0/2.10.0/loaders",
|
|
"gdk_pixbuf_moduledir=#{lib}/gdk-pixbuf-2.0/2.10.0/loaders"
|
|
end
|
|
|
|
def post_install
|
|
# librsvg is not aware GDK_PIXBUF_MODULEDIR must be set
|
|
# set GDK_PIXBUF_MODULEDIR and update loader cache
|
|
ENV["GDK_PIXBUF_MODULEDIR"] = "#{HOMEBREW_PREFIX}/lib/gdk-pixbuf-2.0/2.10.0/loaders"
|
|
system "#{Formula["gdk-pixbuf"].opt_bin}/gdk-pixbuf-query-loaders", "--update-cache"
|
|
end
|
|
|
|
test do
|
|
(testpath/"test.c").write <<-EOS.undent
|
|
#include <librsvg/rsvg.h>
|
|
|
|
int main(int argc, char *argv[]) {
|
|
RsvgHandle *handle = rsvg_handle_new();
|
|
return 0;
|
|
}
|
|
EOS
|
|
cairo = Formula["cairo"]
|
|
fontconfig = Formula["fontconfig"]
|
|
freetype = Formula["freetype"]
|
|
gdk_pixbuf = Formula["gdk-pixbuf"]
|
|
gettext = Formula["gettext"]
|
|
glib = Formula["glib"]
|
|
libpng = Formula["libpng"]
|
|
pixman = Formula["pixman"]
|
|
flags = %W[
|
|
-I#{cairo.opt_include}/cairo
|
|
-I#{fontconfig.opt_include}
|
|
-I#{freetype.opt_include}/freetype2
|
|
-I#{gdk_pixbuf.opt_include}/gdk-pixbuf-2.0
|
|
-I#{gettext.opt_include}
|
|
-I#{glib.opt_include}/glib-2.0
|
|
-I#{glib.opt_lib}/glib-2.0/include
|
|
-I#{include}/librsvg-2.0
|
|
-I#{libpng.opt_include}/libpng16
|
|
-I#{pixman.opt_include}/pixman-1
|
|
-D_REENTRANT
|
|
-L#{cairo.opt_lib}
|
|
-L#{gdk_pixbuf.opt_lib}
|
|
-L#{gettext.opt_lib}
|
|
-L#{glib.opt_lib}
|
|
-L#{lib}
|
|
-lcairo
|
|
-lgdk_pixbuf-2.0
|
|
-lgio-2.0
|
|
-lglib-2.0
|
|
-lgobject-2.0
|
|
-lintl
|
|
-lm
|
|
-lrsvg-2
|
|
]
|
|
system ENV.cc, "test.c", "-o", "test", *flags
|
|
system "./test"
|
|
end
|
|
end
|