From b590182abfd954fd542b9fdd03f64283e7b3791e Mon Sep 17 00:00:00 2001 From: "Todd C. Miller" Date: Mon, 3 Feb 2014 05:42:39 -0700 Subject: [PATCH] Check libraries for inet_pton() if not in libc. --- configure | 71 ++++++++++++++++++++++++++++++++++++++++++++++++++++ configure.ac | 20 +++++++++++++++ 2 files changed, 91 insertions(+) diff --git a/configure b/configure index d1a6def87..791f65fa4 100755 --- a/configure +++ b/configure @@ -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 : diff --git a/configure.ac b/configure.ac index 4657409ef..2ac883db1 100644 --- a/configure.ac +++ b/configure.ac @@ -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).