class Getdns < Formula desc "Modern asynchronous DNS API" homepage "https://getdnsapi.net" url "https://getdnsapi.net/releases/getdns-1-4-2/getdns-1.4.2.tar.gz" sha256 "1685b82dfe297cffc4bae08a773cdc88a3edf9a4e5a1ea27d8764bb5affc0e80" revision 2 bottle do sha256 "cc690c9b6c86e801aa432c49f36ef57ec3426b8d5f6f3e7d80a16b3588134c09" => :mojave sha256 "db09cf3974b2cdf304d8bd95605e0b0bcd15014917eb95a4afe9e91617a55b74" => :high_sierra sha256 "8708ee62ca807cb817f5ad706a2f671062de82c73b76d72294cf701e6cde35a0" => :sierra sha256 "45c118918b75e30acf417f20a0e822b1aaa29af40444c1de3a6cb07b0000e805" => :el_capitan end head do url "https://github.com/getdnsapi/getdns.git", :branch => "develop" depends_on "autoconf" => :build depends_on "automake" => :build depends_on "libtool" => :build end depends_on "libevent" depends_on "libidn" depends_on "openssl" depends_on "unbound" def install if build.head? system "glibtoolize", "-ci" system "autoreconf", "-fi" end system "./configure", "--prefix=#{prefix}", "--with-libevent", "--with-ssl=#{Formula["openssl"].opt_prefix}", "--with-trust-anchor=#{etc}/getdns-root.key", "--without-stubby" system "make" ENV.deparallelize system "make", "install" end test do (testpath/"test.c").write <<~EOS #include #include int main(int argc, char *argv[]) { getdns_context *context; getdns_dict *api_info; char *pp; getdns_return_t r = getdns_context_create(&context, 0); if (r != GETDNS_RETURN_GOOD) { return -1; } api_info = getdns_context_get_api_information(context); if (!api_info) { return -1; } pp = getdns_pretty_print_dict(api_info); if (!pp) { return -1; } puts(pp); free(pp); getdns_dict_destroy(api_info); getdns_context_destroy(context); return 0; } EOS system ENV.cc, "-I#{include}", "-o", "test", "test.c", "-L#{lib}", "-lgetdns" system "./test" end end