[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: sockets module and Solaris
From: |
Bruno Haible |
Subject: |
Re: sockets module and Solaris |
Date: |
Mon, 29 Sep 2008 11:34:17 +0200 |
User-agent: |
KMail/1.5.4 |
Hi Simon,
> Ah, yes, I remember this. The module was never tested on Solaris
> before. Btw, possibly you'll need -lnsl too? I recall that the idiom
> to get anything moderately complex to build on Solaris was to add -lnsl
> -lsockets.
No, -lnsl is not needed always, and in particular not for test-sys_select or
test-sockets. The relevant symbol list of libnsl (taken from
http://www.haible.de/bruno/gnu/various-symlists.tar.gz):
auth*
clnt*
endhostent
endnetconfig
endnetpath
endrpcent
freehostent
freeipsecalgent
freenetconfigent
get_myaddress
getdomainname
gethostbyaddr
gethostbyaddr_r
gethostbyname
gethostbyname_r
gethostent
gethostent_r
gethostname
getipnodebyaddr
getipnodebyname
getipsecalgbyname
getipsecalgbynum
getipsecprotobyname
getipsecprotobynum
getnetconfig
getnetconfigent
getnetname
getnetpath
getpublickey
getpublickey_g
getrpcbyname
getrpcbyname_r
getrpcbynumber
getrpcbynumber_r
getrpcent
getrpcent_r
getrpcport
getsecretkey
getsecretkey_g
host2netname
inet_addr
inet_netof
inet_ntoa
inet_ntoa_r
inet_ntop
inet_pton
key_*
nc_*
netdir_*
nis_*
pmap_*
rpc*
setdomainname
sethostent
setnetconfig
setnetpath
setrpcent
svc*
t_*
xdr*
xprt_*
yp_*
Basically, one can say that
- -lsocket is needed for sockets where you decide yourself about the
ports and about the format of data transmitted over the sockets,
- -lnsl is needed for the various kinds of standardized services implemented
over the network.
> > Here is a proposed patch (assuming it passes testing on Solaris and mingw).
> > OK to commit?
>
> Please do.
Committed as follows. (There were three mistakes in the draft patch.)
2008-09-29 Bruno Haible <address@hidden>
* m4/sockets.m4 (gl_SOCKETS): Check also for the need to use -lsocket.
Set LIBSOCKET instead of augmenting LIBS.
* modules/sockets (Link): New section.
* modules/sockets-tests (test_sockets_LDADD): New variable.
* modules/sys_select-tests (test_sys_select_LDADD): New variable.
* modules/poll-tests (test_poll_LDADD): New variable.
* NEWS: Document the change.
*** m4/sockets.m4.orig 2008-09-29 11:32:59.000000000 +0200
--- m4/sockets.m4 2008-09-28 22:11:46.000000000 +0200
***************
*** 1,4 ****
! # sockets.m4 serial 1
dnl Copyright (C) 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,
--- 1,4 ----
! # sockets.m4 serial 2
dnl Copyright (C) 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,
***************
*** 6,31 ****
AC_DEFUN([gl_SOCKETS],
[
! AC_REQUIRE([gl_HEADER_SYS_SOCKET])dnl for HAVE_SYS_SOCKET_H, HAVE_WINSOCK2_H
!
! AC_CACHE_CHECK([if we need to call WSAStartup in winsock2.h and -lws2_32],
! [gl_cv_func_wsastartup], [
! am_save_LIBS="$LIBS"
! LIBS="$LIBS -lws2_32"
! AC_TRY_LINK([
#ifdef HAVE_WINSOCK2_H
# include <winsock2.h>
#endif], [
! WORD wVersionRequested = MAKEWORD(1, 1);
! WSADATA wsaData;
! int err = WSAStartup(wVersionRequested, &wsaData);
! WSACleanup ();],
! gl_cv_func_wsastartup=yes, gl_cv_func_wsastartup=no)
! LIBS="$am_save_LIBS"])
! if test "$gl_cv_func_wsastartup" = "yes"; then
! AC_DEFINE([WINDOWS_SOCKETS], 1, [Define if WSAStartup is needed.])
! LIBS="$LIBS -lws2_32"
fi
gl_PREREQ_SOCKETS
])
--- 6,61 ----
AC_DEFUN([gl_SOCKETS],
[
! gl_PREREQ_SYS_H_WINSOCK2 dnl for HAVE_WINSOCK2_H
! LIBSOCKET=
! if test $HAVE_WINSOCK2_H = 1; then
! dnl Native Windows API (not Cygwin).
! AC_CACHE_CHECK([if we need to call WSAStartup in winsock2.h and -lws2_32],
! [gl_cv_func_wsastartup], [
! gl_save_LIBS="$LIBS"
! LIBS="$LIBS -lws2_32"
! AC_TRY_LINK([
#ifdef HAVE_WINSOCK2_H
# include <winsock2.h>
#endif], [
! WORD wVersionRequested = MAKEWORD(1, 1);
! WSADATA wsaData;
! int err = WSAStartup(wVersionRequested, &wsaData);
! WSACleanup ();],
! gl_cv_func_wsastartup=yes, gl_cv_func_wsastartup=no)
! LIBS="$gl_save_LIBS"
! ])
! if test "$gl_cv_func_wsastartup" = "yes"; then
! AC_DEFINE([WINDOWS_SOCKETS], 1, [Define if WSAStartup is needed.])
! LIBSOCKET='-lws2_32'
! fi
! else
! dnl Unix API.
! dnl Solaris has most socket functions in libsocket.
! AC_CACHE_CHECK([whether setsockopt requires -lsocket],
[gl_cv_lib_socket], [
! gl_cv_lib_socket=no
! AC_TRY_LINK([extern
! #ifdef __cplusplus
! "C"
! #endif
! char setsockopt();], [setsockopt();],
! [],
! [gl_save_LIBS="$LIBS"
! LIBS="$LIBS -lsocket"
! AC_TRY_LINK([extern
! #ifdef __cplusplus
! "C"
! #endif
! char setsockopt();], [setsockopt();],
! [gl_cv_lib_socket=yes])
! LIBS="$gl_save_LIBS"
! ])
! ])
! if test $gl_cv_lib_socket = yes; then
! LIBSOCKET='-lsocket'
! fi
fi
+ AC_SUBST([LIBSOCKET])
gl_PREREQ_SOCKETS
])
*** modules/sockets.orig 2008-09-29 11:32:59.000000000 +0200
--- modules/sockets 2008-09-28 19:41:31.000000000 +0200
***************
*** 1,5 ****
Description:
! Wrappers for Windows socket functions
Files:
lib/sockets.c
--- 1,5 ----
Description:
! General facilities for using sockets
Files:
lib/sockets.c
***************
*** 18,23 ****
--- 18,26 ----
Include:
"sockets.h"
+ Link:
+ $(LIBSOCKET)
+
License:
LGPL
*** modules/sockets-tests.orig 2008-09-29 11:32:59.000000000 +0200
--- modules/sockets-tests 2008-09-28 19:44:26.000000000 +0200
***************
*** 8,10 ****
--- 8,11 ----
Makefile.am:
TESTS += test-sockets
check_PROGRAMS += test-sockets
+ test_sockets_LDADD = $(LDADD) @LIBSOCKET@
*** modules/sys_select-tests.orig 2008-09-29 11:32:59.000000000 +0200
--- modules/sys_select-tests 2008-09-28 19:43:06.000000000 +0200
***************
*** 16,21 ****
--- 16,22 ----
Makefile.am:
TESTS += test-sys_select
check_PROGRAMS += test-sys_select
+ test_sys_select_LDADD = $(LDADD) @LIBSOCKET@
License:
LGPL
*** modules/poll-tests.orig 2008-09-29 11:32:59.000000000 +0200
--- modules/poll-tests 2008-09-29 11:32:45.000000000 +0200
***************
*** 18,20 ****
--- 18,21 ----
Makefile.am:
TESTS += test-poll
check_PROGRAMS += test-poll
+ test_poll_LDADD = $(LDADD) @LIBSOCKET@