From: Daniel Stenberg Date: Fri, 6 Feb 2004 12:13:20 +0000 (+0000) Subject: Rewrote the gethostbyname() check after Andrés García's provided patch X-Git-Tag: upstream/7.37.1~13535 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=9f2780a2ee8ed7b3374b46823b3608f6a06d3a86;p=platform%2Fupstream%2Fcurl.git Rewrote the gethostbyname() check after Andrés García'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. --- diff --git a/configure.ac b/configure.ac index ec0fa22..2cc42af 100644 --- a/configure.ac +++ b/configure.ac @@ -212,33 +212,65 @@ dnl ********************************************************************** dnl Checks for libraries. dnl ********************************************************************** -dnl gethostbyname in the nsl lib? -AC_CHECK_FUNC(gethostbyname, , [ AC_CHECK_LIB(nsl, gethostbyname) ]) - -if test "$ac_cv_lib_nsl_gethostbyname" != "yes" -a "$ac_cv_func_gethostbyname" != "yes"; then +dnl gethostbyname without lib or in the nsl lib? +AC_CHECK_FUNC(gethostbyname, + [HAVE_GETHOSTBYNAME="1" + ], + [ AC_CHECK_LIB(nsl, gethostbyname, + [HAVE_GETHOSTBYNAME="1" + LIBS="$LIBS -lnsl" + ]) + ]) + +if test "$HAVE_GETHOSTBYNAME" != "1" +then 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 -dnl At least one system has been identified to require BOTH nsl and -dnl socket libs 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 - AC_MSG_CHECKING([trying both nsl and socket libs]) +dnl At least one system has been identified to require BOTH nsl and socket +dnl libs at the same time to link properly. +if test "$HAVE_GETHOSTBYNAME" != "1" +then + AC_MSG_CHECKING([trying gethostbyname with both nsl and socket libs]) my_ac_save_LIBS=$LIBS LIBS="-lnsl -lsocket $LIBS" AC_TRY_LINK( , [gethostbyname();], - my_ac_link_result=success, - my_ac_link_result=failure ) + [ dnl found it! + 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 - AC_MSG_RESULT([no]) - AC_MSG_ERROR([couldn't find libraries for gethostbyname()]) - dnl restore LIBS - LIBS=$my_ac_save_LIBS - else - AC_MSG_RESULT([yes]) - fi +if test "$HAVE_GETHOSTBYNAME" != "1" +then + dnl This is for Msys/Mingw + AC_MSG_CHECKING([for gethostbyname in ws2_32]) + my_ac_save_LIBS=$LIBS + LIBS="-lws2_32 $LIBS" + AC_TRY_LINK([#include ], + [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 dnl resolve lib? @@ -850,12 +882,13 @@ then AC_DEFINE(DISABLED_THREADSAFE, 1, \ Set to explicitly specify we don't want to use thread-safe functions) else + if test "$ipv6" != "yes"; then + dnl dig around for gethostbyname_r() + CURL_CHECK_GETHOSTBYNAME_R() - dnl dig around for gethostbyname_r() - CURL_CHECK_GETHOSTBYNAME_R() - - dnl dig around for gethostbyaddr_r() - CURL_CHECK_GETHOSTBYADDR_R() + dnl dig around for gethostbyaddr_r() + CURL_CHECK_GETHOSTBYADDR_R() + fi dnl poke around for inet_ntoa_r() CURL_CHECK_INET_NTOA_R()