class GlibNetworking < Formula desc "Network related modules for glib" homepage "https://launchpad.net/glib-networking" url "https://download.gnome.org/sources/glib-networking/2.60/glib-networking-2.60.1.tar.xz" sha256 "d71c6b2faa5ac29100314f08a1be020a2afd0291f025614c0af0d17b14435d92" bottle do sha256 "b2febb7b2d46ba67493aab9944a9093c4bf33d31f2cd389eca78c54cf4487474" => :mojave sha256 "3687873da0de2405eba7e4cd4c3f675b5466357a74f6f2283f063797e67c295d" => :high_sierra sha256 "9112ab4c53c7fa7ec8af2fc5aec278d514f58d88ca1adf1a2b80db65c58c1ce8" => :sierra end depends_on "meson" => :build depends_on "ninja" => :build depends_on "pkg-config" => :build depends_on "python" => :build depends_on "glib" depends_on "gnutls" depends_on "gsettings-desktop-schemas" link_overwrite "lib/gio/modules" def install # stop meson_post_install.py from doing what needs to be done in the post_install step ENV["DESTDIR"] = "/" mkdir "build" do system "meson", "--prefix=#{prefix}", "-Dlibproxy=disabled", "-Dopenssl=disabled", "-Dgnome_proxy=disabled", ".." system "ninja", "-v" system "ninja", "install", "-v" end end def post_install system Formula["glib"].opt_bin/"gio-querymodules", HOMEBREW_PREFIX/"lib/gio/modules" end test do (testpath/"gtls-test.c").write <<~EOS #include int main (int argc, char *argv[]) { if (g_tls_backend_supports_tls (g_tls_backend_get_default())) return 0; else return 1; } EOS # From `pkg-config --cflags --libs gio-2.0` flags = [ "-D_REENTRANT", "-I#{HOMEBREW_PREFIX}/include/glib-2.0", "-I#{HOMEBREW_PREFIX}/lib/glib-2.0/include", "-I#{HOMEBREW_PREFIX}/opt/gettext/include", "-L#{HOMEBREW_PREFIX}/lib", "-L#{HOMEBREW_PREFIX}/opt/gettext/lib", "-lgio-2.0", "-lgobject-2.0", "-lglib-2.0" ] system ENV.cc, "gtls-test.c", "-o", "gtls-test", *flags system "./gtls-test" end end