+AC_PROG_INSTALL
+AC_CHECK_HEADERS([net/if.h net/route.h])
+AC_CHECK_HEADERS([sys/socket.h])
+AC_CHECK_HEADERS([linux/if_tun.h], [], [],
+[#if HAVE_SYS_SOCKET_H
+# include <sys/socket.h>
+#endif
+])
+AC_CHECK_HEADERS([stropts.h sys/sockio.h net/if_tun.h])
+AC_C_BIGENDIAN
+AC_PROG_CC_NO_WRITEABLE_STRINGS(WRITESTRINGS)
+
+AC_ARG_ENABLE(hacky-parallel,
+ [AS_HELP_STRING([--enable-hacky-parallel],
+ [parallelise slow cryptography (default is no)])], [
+ case "$enableval" in
+ n|0|no) ;;
+ y|1|yes) CFLAGS="$CFLAGS -DHACKY_PARALLEL" ;;
+ *) ;;
+ esac
+])
+
+AC_DEFUN([REQUIRE_HEADER],[AC_CHECK_HEADER($1,,[AC_MSG_ERROR($1 not found)])])
+
+dnl the order in which libraries is checked is important
+dnl eg. adns on Solaris 2.5.1 depends on -lnsl and -lsocket
+AC_CHECK_LIB(gmp,mpz_init_set_str)
+AC_CHECK_LIB(gmp2,mpz_init_set_str)
+AC_CHECK_LIB(gmp,__gmpz_init_set_str)
+REQUIRE_HEADER([gmp.h])
+dnl Would love to barf if no gmp was found, but how to test? Requiring the header will do for now.
+SECNET_C_GETFUNC(inet_ntoa,nsl)
+AC_CHECK_LIB(socket,socket)
+SECNET_C_GETFUNC(inet_aton,resolv)
+AC_CHECK_LIB(adns,adns_init)
+REQUIRE_HEADER([adns.h])
+
+AC_CHECK_FUNCS([fmemopen funopen])
+
+AC_MSG_NOTICE([Checking requirements for IPv6 support...])
+enable_ipv6=true
+m4_define(NO_IPV6,[enable_ipv6=false])
+AC_CHECK_DECL(AF_INET6, [],[NO_IPV6],[#include <netinet/in.h>])
+AC_CHECK_FUNC(adns_addr2text, [],[NO_IPV6])
+if $enable_ipv6; then
+ AC_MSG_NOTICE([Enabling IPv6 support])
+ AC_DEFINE(CONFIG_IPV6, 1,
+ [Define to 1 to use IPv6 support in system and adns])
+else
+ AC_MSG_WARN([Disabling IPv6 support])
+fi
+
+SUBDIRMK_MAKEFILES(common.make)