From 97d36a72d4e6c7e2ba8731a114f9fba3702293c2 Mon Sep 17 00:00:00 2001 From: "Todd C. Miller" Date: Mon, 1 Feb 1999 00:46:13 +0000 Subject: [PATCH] When linking with both -lsocket and -lnsl be sure to do so in that order. Also, when we can't find socket() or inet_addr() and have to try linking with both libs, issue a warning. --- configure | 112 +++++++++++++++++++++++++-------------------------- configure.in | 8 ++-- 2 files changed, 60 insertions(+), 60 deletions(-) diff --git a/configure b/configure index 40d2e19ca..533e881e5 100755 --- a/configure +++ b/configure @@ -6147,70 +6147,70 @@ fi fi fi -echo $ac_n "checking for inet_addr""... $ac_c" 1>&6 -echo "configure:6152: checking for inet_addr" >&5 -if eval "test \"`echo '$''{'ac_cv_func_inet_addr'+set}'`\" = set"; then +echo $ac_n "checking for socket""... $ac_c" 1>&6 +echo "configure:6152: checking for socket" >&5 +if eval "test \"`echo '$''{'ac_cv_func_socket'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < /* Override any gcc2 internal prototype to avoid an error. */ /* We use char because int might match the return type of a gcc2 builtin and then its argument prototype would still apply. */ -char inet_addr(); +char socket(); int main() { /* The GNU C library defines this for functions which it implements to always fail with ENOSYS. Some functions are actually named something starting with __ and the normal name is an alias. */ -#if defined (__stub_inet_addr) || defined (__stub___inet_addr) +#if defined (__stub_socket) || defined (__stub___socket) choke me #else -inet_addr(); +socket(); #endif ; return 0; } EOF if { (eval echo configure:6180: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then rm -rf conftest* - eval "ac_cv_func_inet_addr=yes" + eval "ac_cv_func_socket=yes" else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* - eval "ac_cv_func_inet_addr=no" + eval "ac_cv_func_socket=no" fi rm -f conftest* fi -if eval "test \"`echo '$ac_cv_func_'inet_addr`\" = yes"; then +if eval "test \"`echo '$ac_cv_func_'socket`\" = yes"; then echo "$ac_t""yes" 1>&6 : else echo "$ac_t""no" 1>&6 -echo $ac_n "checking for inet_addr in -lnsl""... $ac_c" 1>&6 -echo "configure:6198: checking for inet_addr in -lnsl" >&5 -ac_lib_var=`echo nsl'_'inet_addr | sed 'y%./+-%__p_%'` +echo $ac_n "checking for socket in -lsocket""... $ac_c" 1>&6 +echo "configure:6198: checking for socket in -lsocket" >&5 +ac_lib_var=`echo socket'_'socket | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else ac_save_LIBS="$LIBS" -LIBS="-lnsl $LIBS" +LIBS="-lsocket $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest; then @@ -6228,12 +6228,12 @@ LIBS="$ac_save_LIBS" fi if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then echo "$ac_t""yes" 1>&6 - SUDO_LIBS="${SUDO_LIBS} -lnsl"; LIBS="${LIBS} -lnsl" + SUDO_LIBS="${SUDO_LIBS} -lsocket"; LIBS="${LIBS} -lsocket" else echo "$ac_t""no" 1>&6 -echo $ac_n "checking for inet_addr in -linet""... $ac_c" 1>&6 -echo "configure:6236: checking for inet_addr in -linet" >&5 -ac_lib_var=`echo inet'_'inet_addr | sed 'y%./+-%__p_%'` +echo $ac_n "checking for socket in -linet""... $ac_c" 1>&6 +echo "configure:6236: checking for socket in -linet" >&5 +ac_lib_var=`echo inet'_'socket | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -6245,10 +6245,10 @@ cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest; then @@ -6269,24 +6269,24 @@ if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then SUDO_LIBS="${SUDO_LIBS} -linet"; LIBS="${LIBS} -linet" else echo "$ac_t""no" 1>&6 -echo $ac_n "checking for inet_addr in -lnsl""... $ac_c" 1>&6 -echo "configure:6274: checking for inet_addr in -lnsl" >&5 -ac_lib_var=`echo nsl'_'inet_addr | sed 'y%./+-%__p_%'` +echo "configure: warning: unable to find socket() trying -lsocket -lnsl" 1>&2 echo $ac_n "checking for socket in -lsocket""... $ac_c" 1>&6 +echo "configure:6274: checking for socket in -lsocket" >&5 +ac_lib_var=`echo socket'_'socket | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else ac_save_LIBS="$LIBS" -LIBS="-lnsl socket $LIBS" +LIBS="-lsocket -lnsl $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest; then @@ -6315,70 +6315,70 @@ fi fi -echo $ac_n "checking for socket""... $ac_c" 1>&6 -echo "configure:6320: checking for socket" >&5 -if eval "test \"`echo '$''{'ac_cv_func_socket'+set}'`\" = set"; then +echo $ac_n "checking for inet_addr""... $ac_c" 1>&6 +echo "configure:6320: checking for inet_addr" >&5 +if eval "test \"`echo '$''{'ac_cv_func_inet_addr'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < /* Override any gcc2 internal prototype to avoid an error. */ /* We use char because int might match the return type of a gcc2 builtin and then its argument prototype would still apply. */ -char socket(); +char inet_addr(); int main() { /* The GNU C library defines this for functions which it implements to always fail with ENOSYS. Some functions are actually named something starting with __ and the normal name is an alias. */ -#if defined (__stub_socket) || defined (__stub___socket) +#if defined (__stub_inet_addr) || defined (__stub___inet_addr) choke me #else -socket(); +inet_addr(); #endif ; return 0; } EOF if { (eval echo configure:6348: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then rm -rf conftest* - eval "ac_cv_func_socket=yes" + eval "ac_cv_func_inet_addr=yes" else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* - eval "ac_cv_func_socket=no" + eval "ac_cv_func_inet_addr=no" fi rm -f conftest* fi -if eval "test \"`echo '$ac_cv_func_'socket`\" = yes"; then +if eval "test \"`echo '$ac_cv_func_'inet_addr`\" = yes"; then echo "$ac_t""yes" 1>&6 : else echo "$ac_t""no" 1>&6 -echo $ac_n "checking for socket in -lsocket""... $ac_c" 1>&6 -echo "configure:6366: checking for socket in -lsocket" >&5 -ac_lib_var=`echo socket'_'socket | sed 'y%./+-%__p_%'` +echo $ac_n "checking for inet_addr in -lnsl""... $ac_c" 1>&6 +echo "configure:6366: checking for inet_addr in -lnsl" >&5 +ac_lib_var=`echo nsl'_'inet_addr | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else ac_save_LIBS="$LIBS" -LIBS="-lsocket $LIBS" +LIBS="-lnsl $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest; then @@ -6396,12 +6396,12 @@ LIBS="$ac_save_LIBS" fi if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then echo "$ac_t""yes" 1>&6 - SUDO_LIBS="${SUDO_LIBS} -lsocket"; LIBS="${LIBS} -lsocket" + SUDO_LIBS="${SUDO_LIBS} -lnsl"; LIBS="${LIBS} -lnsl" else echo "$ac_t""no" 1>&6 -echo $ac_n "checking for socket in -linet""... $ac_c" 1>&6 -echo "configure:6404: checking for socket in -linet" >&5 -ac_lib_var=`echo inet'_'socket | sed 'y%./+-%__p_%'` +echo $ac_n "checking for inet_addr in -linet""... $ac_c" 1>&6 +echo "configure:6404: checking for inet_addr in -linet" >&5 +ac_lib_var=`echo inet'_'inet_addr | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -6413,10 +6413,10 @@ cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest; then @@ -6437,24 +6437,24 @@ if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then SUDO_LIBS="${SUDO_LIBS} -linet"; LIBS="${LIBS} -linet" else echo "$ac_t""no" 1>&6 -echo $ac_n "checking for socket in -lsocket""... $ac_c" 1>&6 -echo "configure:6442: checking for socket in -lsocket" >&5 -ac_lib_var=`echo socket'_'socket | sed 'y%./+-%__p_%'` +echo "configure: warning: unable to find socket() trying -lsocket -lnsl" 1>&2 echo $ac_n "checking for inet_addr in -lsocket""... $ac_c" 1>&6 +echo "configure:6442: checking for inet_addr in -lsocket" >&5 +ac_lib_var=`echo socket'_'inet_addr | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else ac_save_LIBS="$LIBS" -LIBS="-lsocket nsl $LIBS" +LIBS="-lsocket -lnsl $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest; then diff --git a/configure.in b/configure.in index 8a9734959..06a9f6902 100644 --- a/configure.in +++ b/configure.in @@ -1318,15 +1318,15 @@ if test -z "$LIB_CRYPT"; then AC_CHECK_FUNC(crypt, ,AC_CHECK_LIB(crypt, crypt, [SUDO_LIBS="${SUDO_LIBS} -lcrypt"; LIBS="${LIBS} -lcrypt"], AC_CHECK_LIB(crypt_d, crypt, [SUDO_LIBS="${SUDO_LIBS} -lcrypt_d"; LIBS="${LIBS} -lcrypt_d"], AC_CHECK_LIB(crypt, ufc, [SUDO_LIBS="${SUDO_LIBS} -lufc"; LIBS="${LIBS} -lufc"])))) fi dnl -dnl If inet_addr(3) not in libc, check -lnsl and -linet +dnl If socket(2) not in libc, check -lsocket and -linet dnl May need to link with *both* -lnsl and -lsocket due to unresolved symbols dnl -AC_CHECK_FUNC(inet_addr, ,AC_CHECK_LIB(nsl, inet_addr, [SUDO_LIBS="${SUDO_LIBS} -lnsl"; LIBS="${LIBS} -lnsl"], AC_CHECK_LIB(inet, inet_addr, [SUDO_LIBS="${SUDO_LIBS} -linet"; LIBS="${LIBS} -linet"], AC_CHECK_LIB(nsl, inet_addr, [SUDO_LIBS="${SUDO_LIBS} -lsocket -lnsl"; LIBS="${LIBS} -lsocket -lnsl"], , socket)))) +AC_CHECK_FUNC(socket, ,AC_CHECK_LIB(socket, socket, [SUDO_LIBS="${SUDO_LIBS} -lsocket"; LIBS="${LIBS} -lsocket"], AC_CHECK_LIB(inet, socket, [SUDO_LIBS="${SUDO_LIBS} -linet"; LIBS="${LIBS} -linet"], AC_MSG_WARN(unable to find socket() trying -lsocket -lnsl) AC_CHECK_LIB(socket, socket, [SUDO_LIBS="${SUDO_LIBS} -lsocket -lnsl"; LIBS="${LIBS} -lsocket -lnsl"], , -lnsl)))) dnl -dnl If socket(2) not in libc, check -lsocket and -linet +dnl If inet_addr(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(socket, ,AC_CHECK_LIB(socket, socket, [SUDO_LIBS="${SUDO_LIBS} -lsocket"; LIBS="${LIBS} -lsocket"], AC_CHECK_LIB(inet, socket, [SUDO_LIBS="${SUDO_LIBS} -linet"; LIBS="${LIBS} -linet"], AC_CHECK_LIB(socket, socket, [SUDO_LIBS="${SUDO_LIBS} -lsocket -lnsl"; LIBS="${LIBS} -lsocket -lnsl"], , nsl)))) +AC_CHECK_FUNC(inet_addr, ,AC_CHECK_LIB(nsl, inet_addr, [SUDO_LIBS="${SUDO_LIBS} -lnsl"; LIBS="${LIBS} -lnsl"], AC_CHECK_LIB(inet, inet_addr, [SUDO_LIBS="${SUDO_LIBS} -linet"; LIBS="${LIBS} -linet"], AC_MSG_WARN(unable to find socket() trying -lsocket -lnsl) AC_CHECK_LIB(socket, inet_addr, [SUDO_LIBS="${SUDO_LIBS} -lsocket -lnsl"; LIBS="${LIBS} -lsocket -lnsl"], , -lnsl)))) dnl dnl If syslog(3) not in libc, check -lsocket, -lnsl and -linet dnl -- 2.40.0