homebrew-core/Formula/getdns.rb
2017-06-16 08:39:34 -07:00

82 lines
2.5 KiB
Ruby

class Getdns < Formula
desc "Modern asynchronous DNS API"
homepage "https://getdnsapi.net"
url "https://getdnsapi.net/releases/getdns-1-1-1/getdns-1.1.1.tar.gz"
sha256 "fa414c30d5f2d2b2453b5cec77362b4cc0f44d440be5893233748d82bd6a1a56"
bottle do
sha256 "2a1613d58172712b33f30b4fcb9c9ca75130967e935127a583dd098ff07805ee" => :sierra
sha256 "429fd53521d7de2d16e2857a7c99159447e410b39c7625988489522823d136e1" => :el_capitan
sha256 "6cecdf22e2699604880964b4758b99655923c5f6fd853c3f680abdd28605b567" => :yosemite
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 "openssl"
depends_on "unbound" => :recommended
depends_on "libidn" => :recommended
depends_on "libevent" => :recommended
depends_on "libuv" => :optional
depends_on "libev" => :optional
def install
if build.head?
system "glibtoolize", "-ci"
system "autoreconf", "-fi"
end
args = [
"--with-ssl=#{Formula["openssl"].opt_prefix}",
"--with-trust-anchor=#{etc}/getdns-root.key",
]
args << "--enable-stub-only" if build.without? "unbound"
args << "--without-libidn" if build.without? "libidn"
args << "--with-libevent" if build.with? "libevent"
args << "--with-libuv" if build.with? "libuv"
args << "--with-libev" if build.with? "libev"
# Current Makefile layout prevents simultaneous job execution
# https://github.com/getdnsapi/getdns/issues/166
ENV.deparallelize
system "./configure", "--prefix=#{prefix}", *args
system "make", "install"
end
test do
(testpath/"test.c").write <<-EOS.undent
#include <getdns/getdns.h>
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