diff options
author | Yang Tse <yangsita@gmail.com> | 2008-05-18 20:13:13 +0000 |
---|---|---|
committer | Yang Tse <yangsita@gmail.com> | 2008-05-18 20:13:13 +0000 |
commit | 0458805686697c09bd3afff858469277a120f10d (patch) | |
tree | 93b97d6fb6be6d843d8f5f387777d41c7210ad4c /configure.ac | |
parent | 9fe8db39d1953b455d9f279fdbfed4c69947d774 (diff) | |
download | c-ares-0458805686697c09bd3afff858469277a120f10d.tar.gz c-ares-0458805686697c09bd3afff858469277a120f10d.tar.bz2 c-ares-0458805686697c09bd3afff858469277a120f10d.zip |
on winsock systems linking is done using library 'ws2_32' when
winsock2.h is available, and library 'winsock' is used when only
winsock.h is available.
Diffstat (limited to 'configure.ac')
-rw-r--r-- | configure.ac | 52 |
1 files changed, 38 insertions, 14 deletions
diff --git a/configure.ac b/configure.ac index 462e3cd..5689a9e 100644 --- a/configure.ac +++ b/configure.ac @@ -226,20 +226,44 @@ 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 <winsock2.h>], - [gethostbyname("www.dummysite.com");], - [ dnl worked! - ws2="yes" - AC_MSG_RESULT([yes]) - HAVE_GETHOSTBYNAME="1"], - [ dnl failed, restore LIBS - LIBS=$my_ac_save_LIBS - AC_MSG_RESULT(no)] - ) + dnl This is for winsock systems + if test "$ac_cv_header_windows_h" = "yes"; then + if test "$ac_cv_header_winsock_h" = "yes"; then + winsock_LIB="-lwinsock" + fi + if test "$ac_cv_header_winsock2_h" = "yes"; then + winsock_LIB="-lws2_32" + fi + if test ! -z "$winsock_LIB"; then + my_ac_save_LIBS=$LIBS + LIBS="$winsock_LIB $LIBS" + AC_MSG_CHECKING([for gethostbyname in $winsock_LIB]) + AC_TRY_LINK([ +#ifdef HAVE_WINDOWS_H +#ifndef WIN32_LEAN_AND_MEAN +#define WIN32_LEAN_AND_MEAN +#endif +#include <windows.h> +#ifdef HAVE_WINSOCK2_H +#include <winsock2.h> +#else +#ifdef HAVE_WINSOCK_H +#include <winsock.h> +#endif +#endif +#endif + ],[ + gethostbyname("www.dummysite.com"); + ],[ + AC_MSG_RESULT([yes]) + HAVE_GETHOSTBYNAME="1" + ],[ + AC_MSG_RESULT([no]) + winsock_LIB="" + LIBS=$my_ac_save_LIBS + ]) + fi + fi fi if test "$HAVE_GETHOSTBYNAME" != "1" |