[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: conditionally linking to mingw32 library
From: |
Alexandre Duret-Lutz |
Subject: |
Re: conditionally linking to mingw32 library |
Date: |
Wed, 01 Jun 2005 21:43:22 +0200 |
User-agent: |
Gnus/5.110003 (No Gnus v0.3) Emacs/21.3.50 (gnu/linux) |
>>> "Mark" == Mark Brand <address@hidden> writes:
[...]
Mark> <configure.ac>
Mark> if test x$target_os == xmingw32; then
Mark> WINSOCK=-lws2_32
Mark> fi
Mark> AC_SUBST(WINSOCK)
Mark> </configure.ac>
Eww. That would be $host, not $target, and anyway testing the
host type should always be your last resort. Why not test for
the presence of the ws2_32 library and use it if it's there ?
Here is a possible check assuming adding -lws2_32 to LIBS is OK
(but it's easy to define WINSOCK as above if you prefer).
AC_SEARCH_LIBS([gethostbyname], [nsl socket], [], [
dnl Can't search ws2_32 for gethostbyname using AC_SEARCH_LIBS, because
dnl it requires #include <winsocks2.h> to work.
my_old_LIBS=$LIBS
LIBS="-lws2_32 $LIBS"
ws2_res=yes
AC_MSG_CHECKING([for gethostbyname in ws2_32])
AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <winsock2.h>]],
[[gethostbyname ("");]])],
[], [LIBS=$my_ac_save_LIBS ws2_res=no])
AC_MSG_RESULT([$ws2_res])
])
--
Alexandre Duret-Lutz