+2008-12-23 Bruno Haible <bruno@clisp.org>
+
+ Module getaddrinfo requires linking with $(GETADDRINFO_LIB).
+ * m4/getaddrinfo.m4 (gl_GETADDRINFO): Put link options into
+ GETADDRINFO_LIB, not in LIBS.
+ * modules/getaddrinfo (Link): Set to $(GETADDRINFO_LIB).
+ * modules/canon-host (Link): Likewise.
+ * NEWS: Mention the change.
+ * modules/getaddrinfo-tests (test_getaddrinfo_LDADD): Add the
+ GETADDRINFO_LIB.
+
2008-12-22 Bruno Haible <bruno@clisp.org>
* doc/posix-functions/iswalnum_l.texi: Mention limitation of wchar_t.
-# getaddrinfo.m4 serial 18
+# getaddrinfo.m4 serial 19
dnl Copyright (C) 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
AC_REQUIRE([gl_HEADER_SYS_SOCKET])dnl for HAVE_SYS_SOCKET_H, HAVE_WINSOCK2_H
AC_REQUIRE([gl_HEADER_NETDB])dnl for HAVE_NETDB_H
AC_MSG_NOTICE([checking how to do getaddrinfo, freeaddrinfo and getnameinfo])
+ GETADDRINFO_LIB=
+ gai_saved_LIBS="$LIBS"
+
+ dnl Where is getaddrinfo()?
+ dnl - On Solaris, it is in libsocket.
+ dnl - On Haiku, it is in libnetwork.
+ dnl - On BeOS, it is in libnet.
+ dnl - On native Windows, it is in ws2_32.dll.
+ dnl - Otherwise it is in libc.
+ AC_SEARCH_LIBS(getaddrinfo, [socket network net],
+ [if test "$ac_cv_search_getaddrinfo" != "none required"; then
+ GETADDRINFO_LIB="$ac_cv_search_getaddrinfo"
+ fi])
+ LIBS="$gai_saved_LIBS $GETADDRINFO_LIB"
- AC_SEARCH_LIBS(getaddrinfo, [nsl socket])
AC_CACHE_CHECK([for getaddrinfo], [gl_cv_func_getaddrinfo], [
AC_TRY_LINK([
#include <sys/types.h>
LIBS="$am_save_LIBS"
])
if test "$gl_cv_w32_getaddrinfo" = "yes"; then
- LIBS="$LIBS -lws2_32"
+ GETADDRINFO_LIB="-lws2_32"
+ LIBS="$gai_saved_LIBS $GETADDRINFO_LIB"
else
AC_LIBOBJ(getaddrinfo)
fi
AC_LIBOBJ(gai_strerror)
fi
+ LIBS="$gai_saved_LIBS"
+
gl_PREREQ_GETADDRINFO
+
+ AC_SUBST([GETADDRINFO_LIB])
])
# Prerequisites of lib/netdb.in.h and lib/getaddrinfo.c.
AC_REQUIRE([gl_HEADER_SYS_SOCKET])dnl for HAVE_SYS_SOCKET_H, HAVE_WINSOCK2_H
AC_REQUIRE([gl_HOSTENT]) dnl for HOSTENT_LIB
AC_REQUIRE([gl_SERVENT]) dnl for SERVENT_LIB
- LIBS="$LIBS $HOSTENT_LIB $SERVENT_LIB"
AC_REQUIRE([AC_C_RESTRICT])
AC_REQUIRE([gl_SOCKET_FAMILIES])
AC_REQUIRE([gl_HEADER_SYS_SOCKET])
if test $ac_cv_type_struct_addrinfo = no; then
HAVE_STRUCT_ADDRINFO=0
fi
+
+ dnl Append $HOSTENT_LIB to GETADDRINFO_LIB, avoiding gratuitous duplicates.
+ case " $GETADDRINFO_LIB " in
+ *" $HOSTENT_LIB "*) ;;
+ *) GETADDRINFO_LIB="$GETADDRINFO_LIB $HOSTENT_LIB" ;;
+ esac
+
+ dnl Append $SERVENT_LIB to GETADDRINFO_LIB, avoiding gratuitous duplicates.
+ case " $GETADDRINFO_LIB " in
+ *" $SERVENT_LIB "*) ;;
+ *) GETADDRINFO_LIB="$GETADDRINFO_LIB $SERVENT_LIB" ;;
+ esac
])