AC_PROG_MAKE_SET
AC_PROG_RANLIB
-AC_CHECK_HEADERS(libgen.h sys/select.h socks.h netinet6/in6.h)
+AC_CHECK_HEADERS(libgen.h sys/select.h socks.h)
AC_CHECK_LIB(nsl, gethostbyname)
AC_CHECK_LIB(socket, socket)
-
AC_CHECK_TYPE(fd_set, int)
+AC_REPLACE_FUNCS(basename getaddrinfo)
-dnl checking if the system supports ipv6 address space or not
-AC_CACHE_CHECK([for struct in6_addr], ac_cv_struct_in6_addr,
-[AC_TRY_COMPILE([#include <sys/types.h>
-#include <sys/socket.h>
-#include <netinet/in.h>
-#include <netinet6/in6.h>], [struct in6_addr v6; v6.s6_addr32[3];],
-ac_cv_struct_in6_addr=yes, ac_cv_struct_in6_addr=no)])
-test "x$ac_cv_struct_in6_addr" = "xyes" && AC_DEFINE(HAVE_IN6_ADDR)
+AC_CACHE_CHECK([for struct addrinfo], ac_cv_struct_addrinfo,
+[AC_TRY_COMPILE([#include <netdb.h>
+], [struct addrinfo a],
+ac_cv_struct_addrinfo=yes, ac_cv_struct_addrinfo=no)])
+if test "$ac_cv_struct_addrinfo" = "yes"; then
+ AC_DEFINE(HAVE_ADDRINFO)
+else
+ AC_DEFINE(NEED_ADDRINFO_H)
+fi
-dnl checking if the system supports tcp over ipv6 support or not
-AC_CACHE_CHECK([for struct sockaddr_in6], ac_cv_struct_sockaddr_in6,
-[AC_TRY_COMPILE([#include <sys/types.h>
-#include <sys/socket.h>
-#include <netinet/in.h>
-#include <netinet6/in6.h>], [struct sockaddr_in6 v6; v6.sin6_addr;],
-ac_cv_struct_sockaddr_in6=yes, ac_cv_struct_sockaddr_in6=no)])
-test "x$ac_cv_struct_sockaddr_in6" = "xyes" && AC_DEFINE(HAVE_SOCKADDR_IN6)
+AC_CACHE_CHECK([for NI_MAXSERV], ac_cv_ni_maxserv,
+[AC_EGREP_CPP(yes, [#include <netdb.h>
+#ifdef NI_MAXSERV
+yes
+#endif
+], ac_cv_ni_maxserv=yes, ac_cv_ni_maxserv=no)])
+test "$ac_cv_ni_maxserv" = "yes" || AC_DEFINE(NEED_ADDRINFO_H)
+
+AC_CACHE_CHECK([for NI_NOFQDN], ac_cv_ni_nofqdn,
+[AC_EGREP_CPP(yes, [#include <netdb.h>
+#ifdef NI_NOFQDN
+yes
+#endif
+], ac_cv_ni_nofqdn=yes, ac_cv_ni_nofqdn=no)])
+test "$ac_cv_ni_nofqdn" = "yes" || AC_DEFINE(NEED_ADDRINFO_H)
-dnl
-dnl Test for OpenSSL
-dnl
AC_ARG_WITH(openssl,[ --with-openssl=PATH use OpenSSL from PATH])
-case "$with_openssl" in
- yes|"")
- with_openssl=${prefix}/ssl
-esac
-
-CPPFLAGS="${CPPFLAGS} -I${with_openssl}/include"
-AC_CHECK_HEADER(openssl/ssl.h,,with_openssl="no")
-
-LDFLAGS="${LDFLAGS} -L${with_openssl}/lib"
-AC_CHECK_LIB(crypto,BIO_accept,LIBS=" -lcrypto ${LIBS}",with_openssl="no")
-AC_CHECK_LIB(ssl,SSL_CTX_new,LIBS=" -lssl ${LIBS}",with_openssl="no")
-
-AC_MSG_CHECKING(for openssl)
-AC_MSG_RESULT($with_openssl)
-
-if test "$with_openssl" != "no"; then
- AC_DEFINE(HAVE_SSL)
-else
-AC_MSG_ERROR("Unable to find openssl libraries.")
-exit 1;
+if test -n "$with_openssl"; then
+ CPPFLAGS="${CPPFLAGS} -I${with_openssl}/include"
+ LDFLAGS="${LDFLAGS} -L${with_openssl}/lib"
fi
-AC_REPLACE_FUNCS(basename getaddrinfo)
+AC_CHECK_HEADER(openssl/ssl.h, [
+ AC_CHECK_LIB(crypto, BIO_accept, LIBS="-lcrypto ${LIBS}")
+ AC_CHECK_LIB(ssl, SSL_CTX_new, LIBS="-lssl ${LIBS}")],
+ AC_MSG_ERROR([OpenSSL not installed - please install first]))
AC_OUTPUT(Makefile)