-m4_define([_SUBDIRSMK_SUBDIR],
-[subdirsmk_subdirs="$subdirsmk_subdirs '$1'"
-AC_CONFIG_FILES([$1Subdir.mk:$1Subdir.mk.tmp])])dnl
-dnl
-dnl [AC_CONFIG_COMMANDS([$1Subdir.mk],)
+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)
+
+AC_OUTPUT(,
+ echo timestamp >config.stamp)
+
+AH_TOP([
+#ifndef _CONFIG_H
+#define _CONFIG_H
+])
+
+AH_BOTTOM([
+/* -*- c -*- */