class Libnice < Formula desc "GLib ICE implementation" homepage "https://wiki.freedesktop.org/nice/" url "https://nice.freedesktop.org/releases/libnice-0.1.15.tar.gz" sha256 "f7280f3f58f594409c719a03009aa819c599078b410796f408251277807587da" bottle do cellar :any sha256 "7ad4af0b7d763700cadd513c9e7a0aded9bc29638ecff250b7fb3897157bd3ac" => :mojave sha256 "3873699688e7d9cc866dbbf7c4ad9a2f09f1c7ec86e548c25570d2435113f76c" => :high_sierra sha256 "33228c4e83ecc832b6ccf49e641d1cc186c362f256ec407f867b6ee8b3baffcb" => :sierra end depends_on "pkg-config" => :build depends_on "glib" depends_on "gnutls" depends_on "gstreamer" def install system "./configure", "--disable-dependency-tracking", "--disable-silent-rules", "--prefix=#{prefix}" system "make", "install" end test do # Based on https://github.com/libnice/libnice/blob/master/examples/simple-example.c (testpath/"test.c").write <<~EOS #include int main(int argc, char *argv[]) { NiceAgent *agent; GMainLoop *gloop; gloop = g_main_loop_new(NULL, FALSE); // Create the nice agent agent = nice_agent_new(g_main_loop_get_context (gloop), NICE_COMPATIBILITY_RFC5245); if (agent == NULL) g_error("Failed to create agent"); g_main_loop_unref(gloop); g_object_unref(agent); return 0; } EOS gettext = Formula["gettext"] glib = Formula["glib"] flags = %W[ -I#{gettext.opt_include} -I#{glib.opt_include}/glib-2.0 -I#{glib.opt_lib}/glib-2.0/include -I#{include}/nice -D_REENTRANT -L#{gettext.opt_lib} -L#{glib.opt_lib} -L#{lib} -lgio-2.0 -lglib-2.0 -lgobject-2.0 -lintl -lnice ] system ENV.cc, *flags, "test.c", "-o", "test" system "./test" end end