root/cherokee/trunk/m4/etr_socket_nsl.m4

Revision 41, 3.4 kB (checked in by alo, 3 years ago)

--

Line 
1 dnl @synopsis ETR_SOCKET_NSL
2 dnl
3 dnl This macro figures out what libraries are required on this platform
4 dnl to link sockets programs.  It's usually -lsocket and/or -lnsl or
5 dnl neither.  We test for all three combinations.
6 dnl
7 dnl @version $Id: etr_socket_nsl.m4,v 1.1 2003/08/15 21:06:19 alo Exp $
8 dnl @author Warren Young <warren@etr-usa.com>
9 dnl
10 AC_DEFUN([ETR_SOCKET_NSL],
11 [
12 AC_CACHE_CHECK(for libraries containing socket functions,
13 ac_cv_socket_libs, [
14         oCFLAGS=$CFLAGS
15
16         AC_TRY_LINK([
17                         #include <sys/types.h>
18                         #include <sys/socket.h>
19                         #include <netinet/in.h>
20                         #include <arpa/inet.h>
21                 ],
22                 [
23                         struct in_addr add;
24                         int sd = socket(AF_INET, SOCK_STREAM, 0);
25                         inet_ntoa(add);
26                 ],
27                 ac_cv_socket_libs=-lc, ac_cv_socket_libs=no)
28
29         if test x"$ac_cv_socket_libs" = "xno"
30         then
31                 CFLAGS="$oCFLAGS -lsocket"
32                 AC_TRY_LINK([
33                                 #include <sys/types.h>
34                                 #include <sys/socket.h>
35                                 #include <netinet/in.h>
36                                 #include <arpa/inet.h>
37                         ],
38                         [
39                                 struct in_addr add;
40                                 int sd = socket(AF_INET, SOCK_STREAM, 0);
41                                 inet_ntoa(add);
42                         ],
43                         ac_cv_socket_libs=-lsocket, ac_cv_socket_libs=no)
44         fi
45
46         if test x"$ac_cv_socket_libs" = "xno"
47         then
48                 CFLAGS="$oCFLAGS -lsocket -lnsl"
49                 AC_TRY_LINK([
50                                 #include <sys/types.h>
51                                 #include <sys/socket.h>
52                                 #include <netinet/in.h>
53                                 #include <arpa/inet.h>
54                         ],
55                         [
56                                 struct in_addr add;
57                                 int sd = socket(AF_INET, SOCK_STREAM, 0);
58                                 inet_ntoa(add);
59                         ],
60                         ac_cv_socket_libs="-lsocket -lnsl", ac_cv_socket_libs=no)
61         fi
62
63         if test x"$ac_cv_socket_libs" = "xno"
64         then
65                 CFLAGS="$oCFLAGS -lws2_32"
66                 AC_TRY_LINK([
67                                                   #include <windows.h>
68                                                   #include <stdlib.h>
69                                                   #include <stdio.h>
70                                                   #include <string.h>
71                                                   #include <malloc.h>
72                                                   #include <winsock2.h>
73                                                   #include <ws2tcpip.h>
74                                                   #include <process.h>
75                                                   #include <io.h>
76                                                   #include <direct.h>
77                         ],
78                         [
79                                 struct in_addr add;
80                                 int sd = socket(AF_INET, SOCK_STREAM, 0);
81                                 inet_ntoa(add);
82                         ],
83                         ac_cv_socket_libs="-lws2_32", ac_cv_socket_libs=no)
84         fi
85
86         CFLAGS=$oCFLAGS
87 ])
88
89         if test x"$ac_cv_socket_libs" = "xno"
90         then
91                 AC_MSG_ERROR([Cannot find socket libraries])
92         elif test x"$ac_cv_socket_libs" = "x-lc"
93         then
94                 ETR_SOCKET_LIBS=""
95         else
96                 ETR_SOCKET_LIBS="$ac_cv_socket_libs"
97         fi
98
99         AC_SUBST(ETR_SOCKET_LIBS)
100 ]) dnl ETR_SOCKET_NSL
Note: See TracBrowser for help on using the browser.