1dnl Renamed to AC_TYPE_SOCKLEN_T and some tweaks - David H - 2001-12-12
2dnl
3dnl @synopsis TYPE_SOCKLEN_T
4dnl
5dnl Check whether sys/socket.h defines type socklen_t. Please note
6dnl that some systems require sys/types.h to be included before
7dnl sys/socket.h can be compiled.
8dnl
9dnl @version $Id: aclocal.m4,v 1.3 2001/12/16 01:35:44 alphix Exp $
10dnl @author Lars Brinkhoff <lars@nocrew.org>
11dnl
12AC_DEFUN([AC_TYPE_SOCKLEN_T],
13[
14AC_CACHE_CHECK([for socklen_t],
15ac_cv_type_socklen_t, [
16        AC_TRY_COMPILE([
17                      #include <sys/types.h>
18                      #include <sys/socket.h>
19              ],
20              [
21                      socklen_t len = 42; return 0;
22              ],
23              ac_cv_type_socklen_t="yes", ac_cv_type_socklen_t="no")
24        ])
25
26        if test "x$ac_cv_type_socklen_t" = "xno"; then
27              AC_DEFINE(socklen_t, int, [the type of the last argument to getsockopt etc])
28        fi
29])
30dnl end of AC_TYPE_SOCKLEN_T
31
32
33dnl Renamed to AC_CHECK_SOCKET_LIBS and partially rewritten - David H - 2001-12-12
34dnl
35dnl @synopsis ETR_SOCKET_NSL
36dnl
37dnl This macro figures out what libraries are required on this platform
38dnl to link sockets programs.  It's usually -lsocket and/or -lnsl or
39dnl neither.  We test for all three combinations.
40dnl
41dnl @version $Id: aclocal.m4,v 1.3 2001/12/16 01:35:44 alphix Exp $
42dnl @author Warren Young <warren@etr-usa.com>
43dnl
44AC_DEFUN([AC_CHECK_SOCKET_LIBS],
45[
46AC_CACHE_CHECK([for extra libraries needed for socket functions],
47ac_cv_socket_libs, [
48        oLIBS=$LIBS
49
50        AC_TRY_LINK([
51                        #include <sys/types.h>
52                        #include <sys/socket.h>
53                        #include <netinet/in.h>
54                        #include <arpa/inet.h>
55                ],
56                [
57                        struct in_addr add;
58                        int sd = socket(AF_INET, SOCK_STREAM, 0);
59                        inet_ntoa(add);
60                ],
61                ac_cv_socket_libs="none", ac_cv_socket_libs=no)
62
63        if test "x$ac_cv_socket_libs" = "xno"
64        then
65                LIBS="$oLIBS -lsocket"
66                AC_TRY_LINK([
67                                #include <sys/types.h>
68                                #include <sys/socket.h>
69                                #include <netinet/in.h>
70                                #include <arpa/inet.h>
71                        ],
72                        [
73                                struct in_addr add;
74                                int sd = socket(AF_INET, SOCK_STREAM, 0);
75                                inet_ntoa(add);
76                        ],
77                        ac_cv_socket_libs=-lsocket, ac_cv_socket_libs=no)
78        fi
79
80        if test "x$ac_cv_socket_libs" = "xno"
81        then
82                LIBS="$oLIBS -lsocket -lnsl"
83                AC_TRY_LINK([
84                                #include <sys/types.h>
85                                #include <sys/socket.h>
86                                #include <netinet/in.h>
87                                #include <arpa/inet.h>
88                        ],
89                        [
90                                struct in_addr add;
91                                int sd = socket(AF_INET, SOCK_STREAM, 0);
92                                inet_ntoa(add);
93                        ],
94                        ac_cv_socket_libs="-lsocket -lnsl", ac_cv_socket_libs=no)
95        fi
96
97])
98
99        if test "x$ac_cv_socket_libs" = "xno"
100        then
101                AC_MSG_ERROR([cannot find socket libraries])
102	fi
103]) dnl AC_CHECK_SOCKET_LIBS
104
105
106dnl Written by me - David H - 2001-12-12
107dnl
108dnl @synopsis AC_LIB_WRAP
109dnl
110dnl This macro makes sure that libwrap is found and also checks if
111dnl libnsl is needed for libwrap to function correctly.
112dnl
113dnl @author David H�rdeman <david@2gen.com>
114dnl
115AC_DEFUN([AC_LIB_WRAP],
116[
117AC_CACHE_VAL(ac_cv_libwrap_libs,
118[
119
120        oLIBS=$LIBS
121	AC_CHECK_HEADER([tcpd.h],,AC_MSG_ERROR([cannot find tcpd.h]),)
122	AC_MSG_CHECKING([for libwrap libraries])
123
124	LIBS="$oLIBS -lwrap"
125        AC_TRY_LINK([
126			#include <syslog.h>
127                        #include <tcpd.h>
128       			int allow_severity = LOG_INFO;
129			int deny_severity = LOG_WARNING;
130         	],
131                [
132			struct request_info request;
133			hosts_access(&request);
134                ],
135                ac_cv_libwrap_libs=-lwrap, ac_cv_libwrap_libs=no)
136
137        if test "x$ac_cv_libwrap_libs" = "xno"
138        then
139                LIBS="$oLIBS -lwrap -lnsl"
140                AC_TRY_LINK([
141				#include <syslog.h>
142                                #include <tcpd.h>
143				int allow_severity = LOG_INFO;
144				int deny_severity = LOG_WARNING;
145                        ],
146                        [
147				struct request_info request;
148				hosts_access(&request);
149                        ],
150                        ac_cv_libwrap_libs="-lwrap -lnsl", ac_cv_libwrap_libs=no)
151        fi
152])
153
154        if test "x$ac_cv_libwrap_libs" = "xno"
155        then
156                AC_MSG_ERROR([cannot find libraries])
157	else
158		AC_MSG_RESULT($ac_cv_libwrap_libs)
159	fi
160]) dnl AC_LIB_WRAP
161