[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
getaddrinfo needs a special library
From: |
Bruno Haible |
Subject: |
getaddrinfo needs a special library |
Date: |
Tue, 23 Dec 2008 01:49:43 +0100 |
User-agent: |
KMail/1.9.9 |
Hi Simon,
I propose this change to the getaddrinfo module with two effects:
- Allow package maintainers to decide which programs to link with -lsocket
(on Solaris) or -lws2_32 (on native Windows). Not all programs in a
package need to link with the library that contains getaddrinfo.
The patch defines a variable GETADDRINFO_LIB. Maintainers who don't want
want to use this variable per-program can, of course, add it to $LIBS.
- Port to Haiku: on Haiku, it's -lnetwork which is needed. And on BeOS,
it's -lnet.
OK to commit this?
2008-12-22 Bruno Haible <address@hidden>
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.
--- NEWS.orig 2008-12-23 01:48:41.000000000 +0100
+++ NEWS 2008-12-23 00:41:34.000000000 +0100
@@ -6,6 +6,9 @@
Date Modules Changes
+2008-12-22 getaddrinfo When using this module, you now need to link with
+ canon-host $(GETADDRINFO_LIB).
+
2008-12-21 mbiter The header files "mbiter.h", "mbuiter.h",
mbuiter "mbfile.h" can now be included without checking
mbfile HAVE_MBRTOWC. The macro HAVE_MBRTOWC will no
--- m4/getaddrinfo.m4.orig 2008-12-23 01:48:41.000000000 +0100
+++ m4/getaddrinfo.m4 2008-12-23 01:48:39.000000000 +0100
@@ -1,4 +1,4 @@
-# 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,
@@ -9,8 +9,21 @@
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>
@@ -39,7 +52,8 @@
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
@@ -69,7 +83,11 @@
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.
@@ -78,7 +96,6 @@
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])
@@ -134,4 +151,16 @@
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
])
--- modules/canon-host.orig 2008-12-23 01:48:41.000000000 +0100
+++ modules/canon-host 2008-12-23 00:38:43.000000000 +0100
@@ -19,6 +19,9 @@
Include:
#include "canon-host.h"
+Link:
+$(GETADDRINFO_LIB)
+
License:
LGPL
--- modules/getaddrinfo.orig 2008-12-23 01:48:41.000000000 +0100
+++ modules/getaddrinfo 2008-12-23 00:38:43.000000000 +0100
@@ -28,6 +28,9 @@
Include:
<netdb.h>
+Link:
+$(GETADDRINFO_LIB)
+
License:
LGPLv2+
--- modules/getaddrinfo-tests.orig 2008-12-23 01:48:41.000000000 +0100
+++ modules/getaddrinfo-tests 2008-12-23 00:38:43.000000000 +0100
@@ -9,7 +9,7 @@
Makefile.am:
TESTS += test-getaddrinfo
check_PROGRAMS += test-getaddrinfo
-test_getaddrinfo_LDADD = $(LDADD) @LIBINTL@
+test_getaddrinfo_LDADD = $(LDADD) @GETADDRINFO_LIB@ @LIBINTL@
License:
LGPL
- getaddrinfo needs a special library,
Bruno Haible <=