From ef06be83bcbd285f49d53e9145f4537fbd299f68 Mon Sep 17 00:00:00 2001
From: Alan Coopersmith <alan.coopersmith@sun.com>
Date: Fri, 30 Oct 2009 22:19:51 -0700
Subject: [PATCH] Fix detection of network libraries & functions on Solaris/OpenSolaris
---
common/network/Makefile.am | 1 +
configure.ac | 13 ++++++++++++-
2 files changed, 13 insertions(+), 1 deletions(-)
diff --git a/common/network/Makefile.am b/common/network/Makefile.am
index ab8d5ae..a2cad30 100644
--- a/common/network/Makefile.am
+++ b/common/network/Makefile.am
@@ -6,4 +6,6 @@ libnetwork_la_SOURCES = $(HDRS) TcpSocket.cxx
libnetwork_la_CPPFLAGS = -I$(top_srcdir)/common
+libnetwork_la_LIBADD = $(SOCKET_LIB) $(INET_LIB)
+
EXTRA_DIST = CMakeLists.txt
diff --git a/configure.ac b/configure.ac
index 1f9786e..f5285c3 100644
--- a/configure.ac
+++ b/configure.ac
@@ -168,16 +168,24 @@ AC_SUBST(READDISPLAY_DEFINE)
dnl Under Lynx/OS 2.3, we have to link with -lbsd to resolve
dnl gethostbyname, inet_addr, htons etc. Check if it's necessary.
+dnl Under Solaris and other SVR4 OS'es, those require -lnsl and
+dnl the socket functions require -lsocket
dnl NOTE: Did not want to use AC_SEARCH_LIBS which would add
dnl -lbsd to LIBS. We set INET_LIB instead.
AC_LANG_SAVE
AC_LANG_C
AC_CHECK_FUNC(gethostbyname,INET_LIB_REQ=,INET_LIB_REQ=yes)
if test "$INET_LIB_REQ" = yes; then
- AC_CHECK_LIB(bsd,gethostbyname,INET_LIB=-lbsd,INET_LIB=)
+ AC_CHECK_LIB(bsd,gethostbyname,INET_LIB=-lbsd,
+ AC_CHECK_LIB(nsl,gethostbyname,INET_LIB=-lnsl,INET_LIB=))
+fi
+AC_CHECK_FUNC(connect,SOCKET_LIB_REQ=,SOCKET_LIB_REQ=yes)
+if test "$SOCKET_LIB_REQ" = yes; then
+ AC_CHECK_LIB(socket,connect,SOCKET_LIB=-lsocket,SOCKET_LIB=,$INET_LIB)
fi
AC_LANG_RESTORE
AC_SUBST(INET_LIB)
+AC_SUBST(SOCKET_LIB)
AC_CHECK_FUNC(setenv, AC_DEFINE([HAVE_SETENV], [1], [Is setenv() present?]))
@@ -215,7 +223,10 @@ AC_SEARCH_LIBS([inet_aton], [resolv])
AC_CHECK_FUNCS([inet_aton])
# IPv6 related functions
+save_LIBS="$LIBS"
+LIBS="$LIBS $SOCKET_LIB $INET_LIB"
AC_CHECK_FUNCS([inet_ntop getaddrinfo])
+LIBS="$save_LIBS"
AC_CHECK_TYPES([socklen_t], [], [], [[#include <sys/socket.h>]])