Check libraries for inet_pton() if not in libc.

This commit is contained in:
Todd C. Miller
2014-02-03 05:42:39 -07:00
parent 719e58740b
commit b590182abf
2 changed files with 91 additions and 0 deletions

71
configure vendored
View File

@@ -18602,6 +18602,77 @@ $as_echo "no" >&6; }
fi
ac_fn_c_check_func "$LINENO" "inet_pton" "ac_cv_func_inet_pton"
if test "x$ac_cv_func_inet_pton" = xyes; then :
else
for libs in "-lsocket" "-linet" "-lsocket -lnsl"; do
_libs=
for lib in $libs; do
case "$NET_LIBS" in
*"$lib"*) ;;
*) _libs="$_libs $lib";;
esac
done
libs="${_libs# }"
test -z "$libs" && continue
lib="`echo \"$libs\"|sed -e 's/^-l//' -e 's/ .*$//'`"
extralibs="`echo \"$libs\"|sed 's/^-l[^ ]*//'`"
_sudo_check_lib_extras=`echo "$extralibs"|sed -e 's/ *//g' -e 's/-l/_/g'`
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for inet_pton in -l$lib${5+ }$extralibs" >&5
$as_echo_n "checking for inet_pton in -l$lib${5+ }$extralibs... " >&6; }
if { as_var=sudo_cv_lib_$lib''_inet_pton$_sudo_check_lib_extras; eval \${$as_var+:} false; }; then :
$as_echo_n "(cached) " >&6
else
SUDO_CHECK_LIB_OLIBS="$LIBS"
LIBS="$LIBS -l$lib${5+ }$extralibs"
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
/* Override any GCC internal prototype to avoid an error.
Use char because int might match the return type of a GCC
builtin and then its argument prototype would still apply. */
#ifdef __cplusplus
extern "C"
#endif
char inet_pton ();
int
main ()
{
return inet_pton ();
;
return 0;
}
_ACEOF
if ac_fn_c_try_link "$LINENO"; then :
eval sudo_cv_lib_$lib''_inet_pton$_sudo_check_lib_extras=yes
else
eval sudo_cv_lib_$lib''_inet_pton$_sudo_check_lib_extras=no
fi
rm -f core conftest.err conftest.$ac_objext \
conftest$ac_exeext conftest.$ac_ext
LIBS="$SUDO_CHECK_LIB_OLIBS"
fi
if eval test \$sudo_cv_lib_$lib''_inet_pton$_sudo_check_lib_extras = "yes"; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
$as_echo "yes" >&6; }
NET_LIBS="${NET_LIBS} $libs"; LIBS="${LIBS} $libs"; break
else
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
fi
done
fi
ac_fn_c_check_func "$LINENO" "inet_aton" "ac_cv_func_inet_aton"
if test "x$ac_cv_func_inet_aton" = xyes; then :

View File

@@ -2527,6 +2527,26 @@ AC_CHECK_FUNC(socket, [], [
done
])
dnl
dnl If inet_pton(3) not in libc, check -lnsl and -linet
dnl May need to link with *both* -lnsl and -lsocket due to unresolved symbols
dnl
AC_CHECK_FUNC(inet_pton, [], [
for libs in "-lsocket" "-linet" "-lsocket -lnsl"; do
_libs=
for lib in $libs; do
case "$NET_LIBS" in
*"$lib"*) ;;
*) _libs="$_libs $lib";;
esac
done
libs="${_libs# }"
test -z "$libs" && continue
lib="`echo \"$libs\"|sed -e 's/^-l//' -e 's/ .*$//'`"
extralibs="`echo \"$libs\"|sed 's/^-l[[^ ]]*//'`"
SUDO_CHECK_LIB($lib, inet_pton, [NET_LIBS="${NET_LIBS} $libs"; LIBS="${LIBS} $libs"; break], [], [$extralibs])
done
])
dnl
dnl If inet_aton(3) not in libc, check -lnsl and -linet
dnl May need to link with *both* -lnsl and -lsocket due to unresolved symbols
dnl Some systems have inet_aton() in libresolv (older Solaris).