Annotation of embedaddon/sudo/m4/ax_func_getaddrinfo.m4, revision 1.1.1.1
1.1 misho 1: #
2: # SYNOPSIS
3: #
4: # AX_FUNC_GETADDRINFO
5: #
6: # DESCRIPTION
7: #
8: # Checks for the getaddrinfo function in the standard C library,
9: # as well as the socket and inet libraries, if they are present.
10: # If extra libraries are required, they are added to LIBS.
11: # If no getaddrinfo function is found, it is added to LIBOBJS.
12: # Note: Tru64 UNIX contains two versions of getaddrinfo and we must
13: # include netdb.h to get the proper definition.
14: #
15: # LICENSE
16: #
17: # Placed in the public domain by Todd C. Miller on November 20, 2013.
18: #
19:
20: AC_DEFUN([AX_FUNC_GETADDRINFO],
21: [AC_MSG_CHECKING(for getaddrinfo)
22: AC_CACHE_VAL(ax_cv_func_getaddrinfo,
23: [AC_LINK_IFELSE([AC_LANG_SOURCE([[#include <sys/types.h>
24: #include <sys/socket.h>
25: #include <netdb.h>
26: int main() { return getaddrinfo(0, 0, 0, 0); }]])], [ax_cv_func_getaddrinfo=yes], [ax_cv_func_getaddrinfo=no])])
27: AC_MSG_RESULT([$ax_cv_func_getaddrinfo])
28: if test X"$ax_cv_func_getaddrinfo" = X"yes"; then
29: AC_DEFINE(HAVE_GETADDRINFO, 1, [Define to 1 if you have the `getaddrinfo' function.])
30: else
31: # Not found in libc, check libsocket and libinet
32: _found=no
33: for _libs in "-lsocket" "-linet" "-lsocket -lnsl"; do
34: _cv="ax_cv_lib_getaddrinfo`echo \"$_libs\"|sed -e 's/-l/_/g' -e 's/ *//g'`"
35: AC_MSG_CHECKING([for getaddrinfo in $_libs])
36: AC_CACHE_VAL([$_cv], [
37: _nlibs=
38: for _l in $_libs; do
39: case "$LIBS" in
40: *"$_l"*) ;;
41: *) _nlibs="$_nlibs $_l";;
42: esac
43: done
44: _libs="${_nlibs# }"
45: if test -z "$_libs"; then
46: # No new libs to check
47: eval $_cv=no
48: else
49: AX_FUNC_GETADDRINFO_OLIBS="$LIBS"
50: LIBS="$LIBS $_libs"
51: AC_LINK_IFELSE([AC_LANG_SOURCE([[#include <sys/types.h>
52: #include <sys/socket.h>
53: #include <netdb.h>
54: int main() { return getaddrinfo(0, 0, 0, 0); }]])], [eval $_cv=yes], [eval $_cv=no])
55: LIBS="$AX_FUNC_GETADDRINFO_OLIBS"
56: fi
57: ])
58: if eval test \$$_cv = "yes"; then
59: AC_MSG_RESULT([yes])
60: AC_DEFINE(HAVE_GETADDRINFO)
61: test -n "$_libs" && LIBS="$LIBS $_libs"
62: break
63: fi
64: AC_MSG_RESULT([no])
65: done
66: if eval test \$$_cv != "yes"; then
67: AC_LIBOBJ(getaddrinfo)
68: fi
69: fi
70: ])
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>