ADDED aclocal/xax_check_func_in_lib.m4 Index: aclocal/xax_check_func_in_lib.m4 ================================================================== --- /dev/null +++ aclocal/xax_check_func_in_lib.m4 @@ -0,0 +1,31 @@ +dnl XAX_CHECK_FUNC_IN_LIB(headers..., libraries..., function, [, ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]) +AC_DEFUN([XAX_CHECK_FUNC_IN_LIB], [ + m4_define([CACHE_VARIABLE], [xax_cv_func_]$3[_in]) + AC_CACHE_CHECK([for $3 in $2], CACHE_VARIABLE, [ + save_LIBS="${LIBS}" + LIBS="${save_LIBS} $2" + m4_define([HEADERS], []) + m4_foreach_w([HEADER], [$1], [ + m4_append([HEADERS], [#include <]HEADER[> +]) + ]) + AC_LINK_IFELSE([AC_LANG_PROGRAM([HEADERS], [[ + $3; + ]])], [ + CACHE_VARIABLE='yes' + ], [ + CACHE_VARIABLE='no' + ]) + LIBS="${save_LIBS}" + ]) + if test "x$CACHE_VARIABLE" = 'xyes'; then + LIBS="${LIBS} $2" + AC_DEFINE(AS_TR_CPP([HAVE_$3]), [1], [Define if we have $3]) + m4_foreach_w([HEADER], [$1], [ + AC_DEFINE(AS_TR_CPP([HAVE_]HEADER), [1], [Define if we have <]HEADER[>]) + ]) + m4_default([$4], :) + else + m4_default([$5], :) + fi +]) Index: autogen.sh ================================================================== --- autogen.sh +++ autogen.sh @@ -19,10 +19,11 @@ 'http://git.savannah.gnu.org/gitweb/?p=autoconf-archive.git;a=blob_plain;f=m4/ax_check_link_flag.m4' 'http://git.savannah.gnu.org/gitweb/?p=autoconf-archive.git;a=blob_plain;f=m4/ax_openmp.m4' ) localFiles=( + aclocal/xax_check_func_in_lib.m4 ) failed='0' for command in "${commands[@]}"; do if [ ! -f "$(which "${command}" 2>/dev/null)" ]; then Index: configure.ac ================================================================== --- configure.ac +++ configure.ac @@ -104,75 +104,23 @@ ]) dnl Random number generation mechanisms AC_CHECK_FUNCS(getrandom,, [ AC_CHECK_FUNCS(getentropy,, [ - AC_CACHE_CHECK([for CryptGenRandom], nanotcl_cv_func_CryptGenRandom, [ - save_LIBS="${LIBS}" - LIBS="${save_LIBS} -ladvapi32" - AC_LINK_IFELSE([AC_LANG_PROGRAM([[ -#include -#include - ]], [[ - HCRYPTPROV provider; - BOOL ret; - ret = CryptGenRandom(provider, 0, NULL); - if (ret) { - return(0); - } else { - return(1); - } - ]])], [ - nanotcl_cv_func_CryptGenRandom='yes' - ], [ - nanotcl_cv_func_CryptGenRandom='no' - ]) - LIBS="${save_LIBS}" - ]) - if test "x$nanotcl_cv_func_CryptGenRandom" = 'xyes'; then - LIBS="${LIBS} -ladvapi32" - AC_DEFINE(HAVE_WINDOWS_H, [1], [Define if we have ]) - AC_DEFINE(HAVE_WINCRYPT_H, [1], [Define if we have ]) - AC_DEFINE(HAVE_CRYPTGENRANDOM, [1], [Define if we have CryptGenRandom]) - fi + XAX_CHECK_FUNC_IN_LIB(windows.h wincrypt.h, -ladvapi32, CryptGenRandom) ]) ]) dnl Check for name resolution capabilities AC_CHECK_FUNCS(getaddrinfo, [ AC_CHECK_FUNCS(getnameinfo, [ AC_CHECK_HEADERS(sys/types.h sys/socket.h netdb.h) ]) ], [ - AC_CACHE_CHECK([for getaddrinfo on Windows], nanotcl_cv_func_getaddrinfo, [ - save_LIBS="${LIBS}" - LIBS="${save_LIBS} -lws2_32" - AC_LINK_IFELSE([AC_LANG_PROGRAM([[ -#include -#include - ]], [[ - int gai_ret; - gai_ret = getaddrinfo(NULL, NULL, NULL, NULL); - if (gai_ret == 0) { - return(1); - } else { - return(0); - } - ]])], [ - nanotcl_cv_func_getaddrinfo='yes' - ], [ - nanotcl_cv_func_getaddrinfo='no' - ]) - LIBS="${save_LIBS}" - ]) - if test "x$nanotcl_cv_func_getaddrinfo" = 'xyes'; then - LIBS="${LIBS} -lws2_32" - AC_DEFINE(HAVE_GETADDRINFO, [1], [Define if we have getaddrinfo]) - AC_DEFINE(HAVE_GETNAMEINFO, [1], [Define if we have getnameinfo]) - AC_DEFINE(HAVE_WINDOWS_H, [1], [Define if we have ]) - AC_DEFINE(HAVE_WS2TCPIP_H, [1], [Define if we have ]) - fi + XAX_CHECK_FUNC_IN_LIB(ws2tcpip.h windows.h, -lws2_32, getaddrinfo, [ + XAX_CHECK_FUNC_IN_LIB(ws2tcpip.h windows.h, -lws2_32, getnameinfo) + ]) ]) dnl Handle specifying where TCLLIB is, for testing AC_SUBST(TCLLIB_PATH) TCLLIB_PATH='/dev/null'