]> granicus.if.org Git - sudo/commitdiff
Check libraries for inet_pton() if not in libc.
authorTodd C. Miller <Todd.Miller@courtesan.com>
Mon, 3 Feb 2014 12:42:39 +0000 (05:42 -0700)
committerTodd C. Miller <Todd.Miller@courtesan.com>
Mon, 3 Feb 2014 12:42:39 +0000 (05:42 -0700)
configure
configure.ac

index d1a6def876b98f46da1bfa2caf3873e68099b0c8..791f65fa40d6869e18eba17ed9cc954849d83011 100755 (executable)
--- 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 :
 
index 4657409ef47c7b01afe99b357dcb01fa75a83c53..2ac883db162836caced927c62378f4a71c66a504 100644 (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).