homebrew-core/Formula/gdk-pixbuf.rb

115 lines
3.9 KiB
Ruby

class GdkPixbuf < Formula
desc "Toolkit for image loading and pixel buffer manipulation"
homepage "https://gtk.org"
url "https://download.gnome.org/sources/gdk-pixbuf/2.42/gdk-pixbuf-2.42.9.tar.xz"
sha256 "28f7958e7bf29a32d4e963556d241d0a41a6786582ff6a5ad11665e0347fc962"
license "LGPL-2.1-or-later"
bottle do
sha256 arm64_monterey: "4334da20455e617c5f1f57946a00fc38e8fea1209fef3a71e445bc2c7f9c38d0"
sha256 arm64_big_sur: "88eff9d23c848e9ac08e0942aec394764f11d92594b7396dfa56fbda186ab298"
sha256 monterey: "9264fc9ee4225861eb92af4e7975b8d5b1d1d4c3ac7688f995409dd675c6699e"
sha256 big_sur: "71b86b2e14a8dbc7d6e8266547fadfd545aead3b7351df3b7c63ebc35b8c02e6"
sha256 catalina: "12b0f0f5e221b3b5f4cb8f0d37c7070dabefe944c53680dd8cfa6e449cebd55b"
sha256 x86_64_linux: "35e1c0a98e6035a693dedb9212165dc0d557941b7d72dad0d6a4594b72eb4709"
end
depends_on "gobject-introspection" => :build
depends_on "meson" => :build
depends_on "ninja" => :build
depends_on "pkg-config" => :build
depends_on "glib"
depends_on "jpeg-turbo"
depends_on "libpng"
depends_on "libtiff"
on_linux do
depends_on "shared-mime-info"
end
# gdk-pixbuf has an internal version number separate from the overall
# version number that specifies the location of its module and cache
# files, this will need to be updated if that internal version number
# is ever changed (as evidenced by the location no longer existing)
def gdk_so_ver
"2.0"
end
def gdk_module_ver
"2.10.0"
end
def install
inreplace "gdk-pixbuf/meson.build",
"-DGDK_PIXBUF_LIBDIR=\"@0@\"'.format(gdk_pixbuf_libdir)",
"-DGDK_PIXBUF_LIBDIR=\"@0@\"'.format('#{HOMEBREW_PREFIX}/lib')"
ENV["DESTDIR"] = "/"
system "meson", *std_meson_args, "build",
"-Drelocatable=false",
"-Dnative_windows_loaders=false",
"-Dinstalled_tests=false",
"-Dman=false",
"-Dgtk_doc=false",
"-Dpng=enabled",
"-Dtiff=enabled",
"-Djpeg=enabled",
"-Dintrospection=enabled"
system "meson", "compile", "-C", "build", "-v"
system "meson", "install", "-C", "build"
# Other packages should use the top-level modules directory
# rather than dumping their files into the gdk-pixbuf keg.
inreplace lib/"pkgconfig/gdk-pixbuf-#{gdk_so_ver}.pc" do |s|
libv = s.get_make_var "gdk_pixbuf_binary_version"
s.change_make_var! "gdk_pixbuf_binarydir",
HOMEBREW_PREFIX/"lib/gdk-pixbuf-#{gdk_so_ver}"/libv
end
end
# The directory that loaders.cache gets linked into, also has the "loaders"
# directory that is scanned by gdk-pixbuf-query-loaders in the first place
def module_dir
"#{HOMEBREW_PREFIX}/lib/gdk-pixbuf-#{gdk_so_ver}/#{gdk_module_ver}"
end
def post_install
ENV["GDK_PIXBUF_MODULEDIR"] = "#{module_dir}/loaders"
system "#{bin}/gdk-pixbuf-query-loaders", "--update-cache"
end
test do
(testpath/"test.c").write <<~EOS
#include <gdk-pixbuf/gdk-pixbuf.h>
int main(int argc, char *argv[]) {
GType type = gdk_pixbuf_get_type();
return 0;
}
EOS
gettext = Formula["gettext"]
glib = Formula["glib"]
libpng = Formula["libpng"]
pcre = Formula["pcre"]
flags = (ENV.cflags || "").split + (ENV.cppflags || "").split + (ENV.ldflags || "").split
flags += %W[
-I#{gettext.opt_include}
-I#{glib.opt_include}/glib-2.0
-I#{glib.opt_lib}/glib-2.0/include
-I#{include}/gdk-pixbuf-2.0
-I#{libpng.opt_include}/libpng16
-I#{pcre.opt_include}
-D_REENTRANT
-L#{gettext.opt_lib}
-L#{glib.opt_lib}
-L#{lib}
-lgdk_pixbuf-2.0
-lglib-2.0
-lgobject-2.0
]
flags << "-lintl" if OS.mac?
system ENV.cc, "test.c", "-o", "test", *flags
system "./test"
end
end