diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-15 13:14:46 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-15 13:14:46 +0000 |
commit | 025c439e829e0db9ac511cd9c1b8d5fd53475ead (patch) | |
tree | fa6986b4690f991613ffb97cea1f6942427baf5d /m4/ax_func_getaddrinfo.m4 | |
parent | Initial commit. (diff) | |
download | sudo-upstream/1.9.15p5.tar.xz sudo-upstream/1.9.15p5.zip |
Adding upstream version 1.9.15p5.upstream/1.9.15p5upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'm4/ax_func_getaddrinfo.m4')
-rw-r--r-- | m4/ax_func_getaddrinfo.m4 | 70 |
1 files changed, 70 insertions, 0 deletions
diff --git a/m4/ax_func_getaddrinfo.m4 b/m4/ax_func_getaddrinfo.m4 new file mode 100644 index 0000000..7cde7b9 --- /dev/null +++ b/m4/ax_func_getaddrinfo.m4 @@ -0,0 +1,70 @@ +# +# SYNOPSIS +# +# AX_FUNC_GETADDRINFO +# +# DESCRIPTION +# +# Checks for the getaddrinfo function in the standard C library, +# as well as the socket and inet libraries, if they are present. +# If extra libraries are required, they are added to LIBS. +# If no getaddrinfo function is found, it is added to LIBOBJS. +# Note: Tru64 UNIX contains two versions of getaddrinfo and we must +# include netdb.h to get the proper definition. +# +# LICENSE +# +# Placed in the public domain by Todd C. Miller on November 20, 2013. +# + +AC_DEFUN([AX_FUNC_GETADDRINFO], +[AC_MSG_CHECKING(for getaddrinfo) +AC_CACHE_VAL(ax_cv_func_getaddrinfo, +[AC_LINK_IFELSE([AC_LANG_SOURCE([[#include <sys/types.h> +#include <sys/socket.h> +#include <netdb.h> +int main() { return getaddrinfo(0, 0, 0, 0); }]])], [ax_cv_func_getaddrinfo=yes], [ax_cv_func_getaddrinfo=no])]) +AC_MSG_RESULT([$ax_cv_func_getaddrinfo]) +if test X"$ax_cv_func_getaddrinfo" = X"yes"; then + AC_DEFINE(HAVE_GETADDRINFO, 1, [Define to 1 if you have the 'getaddrinfo' function.]) +else + # Not found in libc, check libsocket and libinet + _found=no + for _libs in "-lsocket" "-linet" "-lsocket -lnsl"; do + _cv="ax_cv_lib_getaddrinfo`echo \"$_libs\"|sed -e 's/-l/_/g' -e 's/ *//g'`" + AC_MSG_CHECKING([for getaddrinfo in $_libs]) + AC_CACHE_VAL([$_cv], [ + _nlibs= + for _l in $_libs; do + case "$LIBS" in + *"$_l"*) ;; + *) _nlibs="$_nlibs $_l";; + esac + done + _libs="${_nlibs# }" + if test -z "$_libs"; then + # No new libs to check + eval $_cv=no + else + AX_FUNC_GETADDRINFO_OLIBS="$LIBS" + LIBS="$LIBS $_libs" + AC_LINK_IFELSE([AC_LANG_SOURCE([[#include <sys/types.h> + #include <sys/socket.h> + #include <netdb.h> + int main() { return getaddrinfo(0, 0, 0, 0); }]])], [eval $_cv=yes], [eval $_cv=no]) + LIBS="$AX_FUNC_GETADDRINFO_OLIBS" + fi + ]) + if eval test \$$_cv = "yes"; then + AC_MSG_RESULT([yes]) + AC_DEFINE(HAVE_GETADDRINFO) + test -n "$_libs" && LIBS="$LIBS $_libs" + break + fi + AC_MSG_RESULT([no]) + done + if eval test \$$_cv != "yes"; then + AC_LIBOBJ(getaddrinfo) + fi +fi +]) |