1
# socketlib.m4 serial 1
2
dnl Copyright (C) 2008-2011 Free Software Foundation, Inc.
3
dnl This file is free software; the Free Software Foundation
4
dnl gives unlimited permission to copy and/or distribute it,
5
dnl with or without modifications, as long as this notice is preserved.
8
dnl Determines the library to use for socket functions.
9
dnl Sets and AC_SUBSTs LIBSOCKET.
11
AC_DEFUN([gl_SOCKETLIB],
13
gl_PREREQ_SYS_H_WINSOCK2 dnl for HAVE_WINSOCK2_H
15
if test $HAVE_WINSOCK2_H = 1; then
16
dnl Native Windows API (not Cygwin).
17
AC_CACHE_CHECK([if we need to call WSAStartup in winsock2.h and -lws2_32],
18
[gl_cv_func_wsastartup], [
21
AC_LINK_IFELSE([AC_LANG_PROGRAM([[
22
#ifdef HAVE_WINSOCK2_H
23
# include <winsock2.h>
25
WORD wVersionRequested = MAKEWORD(1, 1);
27
int err = WSAStartup(wVersionRequested, &wsaData);
29
gl_cv_func_wsastartup=yes, gl_cv_func_wsastartup=no)
32
if test "$gl_cv_func_wsastartup" = "yes"; then
33
AC_DEFINE([WINDOWS_SOCKETS], [1], [Define if WSAStartup is needed.])
38
dnl Solaris has most socket functions in libsocket.
39
dnl Haiku has most socket functions in libnetwork.
40
dnl BeOS has most socket functions in libnet.
41
AC_CACHE_CHECK([for library containing setsockopt], [gl_cv_lib_socket], [
43
AC_LINK_IFELSE([AC_LANG_PROGRAM([[extern
47
char setsockopt();]], [[setsockopt();]])],
50
LIBS="$gl_save_LIBS -lsocket"
51
AC_LINK_IFELSE([AC_LANG_PROGRAM([[extern
55
char setsockopt();]], [[setsockopt();]])],
56
[gl_cv_lib_socket="-lsocket"])
57
if test -z "$gl_cv_lib_socket"; then
58
LIBS="$gl_save_LIBS -lnetwork"
59
AC_LINK_IFELSE([AC_LANG_PROGRAM([[extern
63
char setsockopt();]], [[setsockopt();]])],
64
[gl_cv_lib_socket="-lnetwork"])
65
if test -z "$gl_cv_lib_socket"; then
66
LIBS="$gl_save_LIBS -lnet"
67
AC_LINK_IFELSE([AC_LANG_PROGRAM([[extern
71
char setsockopt();]], [[setsockopt();]])],
72
[gl_cv_lib_socket="-lnet"])
77
if test -z "$gl_cv_lib_socket"; then
78
gl_cv_lib_socket="none needed"
81
if test "$gl_cv_lib_socket" != "none needed"; then
82
LIBSOCKET="$gl_cv_lib_socket"