1
0
mirror of https://github.com/moparisthebest/curl synced 2024-12-21 23:58:49 -05:00

Rewrote the gethostbyname() check after Andrs Garca's provided patch

for finding it using mingw on windows.
I also made the script skip the search for gethostbyname_r and gethostbyaddr_r
when ipv6 is enabled.
This commit is contained in:
Daniel Stenberg 2004-02-06 12:13:20 +00:00
parent 1a6969a887
commit 9f2780a2ee

View File

@ -212,33 +212,65 @@ dnl **********************************************************************
dnl Checks for libraries. dnl Checks for libraries.
dnl ********************************************************************** dnl **********************************************************************
dnl gethostbyname in the nsl lib? dnl gethostbyname without lib or in the nsl lib?
AC_CHECK_FUNC(gethostbyname, , [ AC_CHECK_LIB(nsl, gethostbyname) ]) AC_CHECK_FUNC(gethostbyname,
[HAVE_GETHOSTBYNAME="1"
],
[ AC_CHECK_LIB(nsl, gethostbyname,
[HAVE_GETHOSTBYNAME="1"
LIBS="$LIBS -lnsl"
])
])
if test "$ac_cv_lib_nsl_gethostbyname" != "yes" -a "$ac_cv_func_gethostbyname" != "yes"; then if test "$HAVE_GETHOSTBYNAME" != "1"
then
dnl gethostbyname in the socket lib? dnl gethostbyname in the socket lib?
AC_CHECK_FUNC(gethostbyname, , [ AC_CHECK_LIB(socket, gethostbyname) ]) AC_CHECK_LIB(socket, gethostbyname,
[HAVE_GETHOSTBYNAME="1"
LIBS="$LIBS -lsocket"
])
fi fi
dnl At least one system has been identified to require BOTH nsl and dnl At least one system has been identified to require BOTH nsl and socket
dnl socket libs to link properly. dnl libs at the same time to link properly.
if test "$ac_cv_lib_nsl_gethostbyname" != "yes" -a "$ac_cv_lib_socket_gethostbyname" != "yes" -a "$ac_cv_func_gethostbyname" != "yes"; then if test "$HAVE_GETHOSTBYNAME" != "1"
AC_MSG_CHECKING([trying both nsl and socket libs]) then
AC_MSG_CHECKING([trying gethostbyname with both nsl and socket libs])
my_ac_save_LIBS=$LIBS my_ac_save_LIBS=$LIBS
LIBS="-lnsl -lsocket $LIBS" LIBS="-lnsl -lsocket $LIBS"
AC_TRY_LINK( , AC_TRY_LINK( ,
[gethostbyname();], [gethostbyname();],
my_ac_link_result=success, [ dnl found it!
my_ac_link_result=failure ) HAVE_GETHOSTBYNAME="1",
AC_MSG_RESULT([yes])],
[ dnl failed!
AC_MSG_RESULT([no])
dnl restore LIBS
LIBS=$my_ac_save_LIBS]
)
fi
if test "$my_ac_link_result" = "failure"; then if test "$HAVE_GETHOSTBYNAME" != "1"
AC_MSG_RESULT([no]) then
AC_MSG_ERROR([couldn't find libraries for gethostbyname()]) dnl This is for Msys/Mingw
dnl restore LIBS AC_MSG_CHECKING([for gethostbyname in ws2_32])
LIBS=$my_ac_save_LIBS my_ac_save_LIBS=$LIBS
else LIBS="-lws2_32 $LIBS"
AC_MSG_RESULT([yes]) AC_TRY_LINK([#include <winsock2.h>],
fi [gethostbyname("www.dummysite.com");],
[ dnl worked!
AC_MSG_CHECKING([yes])
HAVE_GETHOSTBYNAME="1"],
[ dnl failed, restore LIBS
LIBS=$my_ac_save_LIBS
AC_MSG_RESULT(no)]
)
fi
if test "$HAVE_GETHOSTBYNAME" = "1"; then
AC_DEFINE(HAVE_GETHOSTBYNAME, 1, [If you have gethostbyname])
else
AC_MSG_ERROR([couldn't find libraries for gethostbyname()])
fi fi
dnl resolve lib? dnl resolve lib?
@ -850,12 +882,13 @@ then
AC_DEFINE(DISABLED_THREADSAFE, 1, \ AC_DEFINE(DISABLED_THREADSAFE, 1, \
Set to explicitly specify we don't want to use thread-safe functions) Set to explicitly specify we don't want to use thread-safe functions)
else else
if test "$ipv6" != "yes"; then
dnl dig around for gethostbyname_r()
CURL_CHECK_GETHOSTBYNAME_R()
dnl dig around for gethostbyname_r() dnl dig around for gethostbyaddr_r()
CURL_CHECK_GETHOSTBYNAME_R() CURL_CHECK_GETHOSTBYADDR_R()
fi
dnl dig around for gethostbyaddr_r()
CURL_CHECK_GETHOSTBYADDR_R()
dnl poke around for inet_ntoa_r() dnl poke around for inet_ntoa_r()
CURL_CHECK_INET_NTOA_R() CURL_CHECK_INET_NTOA_R()