-
Notifications
You must be signed in to change notification settings - Fork 2
/
acinclude.m4
329 lines (302 loc) · 10.2 KB
/
acinclude.m4
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
# $Header$
AH_TEMPLATE([HAVE_GETHOSTBYADDR_R_5], [Set to 1 if gethostbyaddr_r takes 5 arguments])
AH_TEMPLATE([HAVE_GETHOSTBYADDR_R_7], [Set to 1 if gethostbyaddr_r takes 7 arguments])
AH_TEMPLATE([HAVE_GETHOSTBYADDR_R_8], [Set to 1 if gethostbyaddr_r takes 8 arguments])
AH_TEMPLATE([HAVE_PCAP_FREECODE_2], [Set to 1 if pcap_freecode takes 2 arguments])
AH_TEMPLATE([HAVE_PCAP_FREECODE_1], [Set to 1 if pcap_freecode takes 1 argument])
AH_TEMPLATE([HAVE_IP6_S6_ADDR32], [Set to 1 if struct in6_addr contains s6_addr32 member])
AH_TEMPLATE([HAVE_IP6__S6_UN__S6_U32], [Set to 1 if struct in6_addr contains _S6_un._S6_u32 member])
AH_TEMPLATE([HAVE_IP6___U6_ADDR___U6_ADDR32], [Set to 1 if struct in6_addr contains __u6_addr.__u6_addr32 member])
AH_TEMPLATE([NEED_REENTRANT], [Set to 1 if gethostbyaddr_r requires _REENTRANT symbol to be defined])
AC_DEFUN(AC_NETTOP_GCC_FLAGS,
[
if test "$GCC" = "yes"; then
CFLAGS="$CFLAGS -Wall"
fi
])
#
# AC_NETTOP_GETHOSTBY_LIB_CHECK
#
# Checks whether we need "-lnsl" to get "gethostby*()", which we use
# in "resolv.c".
#
# Copied from EtherReal package ;
# Done by Jakub Skopal <[email protected]> on 2002-08-22.
#
# Adapted from stuff in the AC_PATH_XTRA macro in "acspecific.m4" in
# GNU Autoconf 2.13; the comment came from there.
# Done by Guy Harris <[email protected]> on 2000-01-14.
#
AC_DEFUN(AC_NETTOP_GETHOSTBY_LIB_CHECK,
[
# [email protected] says -lnsl (and -lsocket) are needed for his 386/AT,
# to get the SysV transport functions.
# [email protected] says the Pyramid MIS-ES running DC/OSx (SVR4)
# needs -lnsl.
# The nsl library prevents programs from opening the X display
# on Irix 5.2, according to [email protected].
AC_CHECK_FUNC(gethostbyname, ,
AC_CHECK_LIB(nsl, gethostbyname, NSL_LIBS="-lnsl"))
AC_SUBST(NSL_LIBS)
])
#
# AC_NETTOP_SOCKET_LIB_CHECK
#
# Checks whether we need "-lsocket" to get "socket()", which is used
# by libpcap on some platforms - and, in effect, "gethostby*()" on
# most if not all platforms (so that it can use NIS or DNS or...
# to look up host names).
#
# Copied from EtherReal package ;
# Done by Jakub Skopal <[email protected]> on 2002-08-22.
#
# Adapted from stuff in the AC_PATH_XTRA macro in "acspecific.m4" in
# GNU Autoconf 2.13; the comment came from there.
# Done by Guy Harris <[email protected]> on 2000-01-14.
#
# We use "connect" because that's what AC_PATH_XTRA did.
#
AC_DEFUN(AC_NETTOP_SOCKET_LIB_CHECK,
[
# [email protected] says without -lsocket,
# socket/setsockopt and other routines are undefined under SCO ODT
# 2.0. But -lsocket is broken on IRIX 5.2 (and is not necessary
# on later versions), says [email protected]: it contains
# gethostby* variants that don't use the nameserver (or something).
# -lsocket must be given before -lnsl if both are needed.
# We assume that if connect needs -lnsl, so does gethostbyname.
AC_CHECK_FUNC(connect, ,
AC_CHECK_LIB(socket, connect, SOCKET_LIBS="-lsocket",
AC_MSG_ERROR(Function 'socket' not found.), $NSL_LIBS))
AC_SUBST(SOCKET_LIBS)
])
#
# AC_NETTOP_PCAP_CHECK
#
AC_DEFUN(AC_NETTOP_PCAP_CHECK,
[
if test -z "$pcap_dir"
then
#
# The user didn't specify a directory in which libpcap resides;
# we assume that the current library search path will work,
# but we may have to look for the header in a "pcap"
# subdirectory of "/usr/include" or "/usr/local/include",
# as some systems apparently put "pcap.h" in a "pcap"
# subdirectory, and we also check "$prefix/include".
#
# XXX - should we just add "$prefix/include" to the include
# search path and "$prefix/lib" to the library search path?
#
AC_MSG_CHECKING(for extraneous pcap header directories)
found_pcap_dir=""
for pcap_dir in /usr/include/pcap /usr/local/include/pcap $prefix/include
do
if test -d $pcap_dir ; then
if test x$pcap_dir != x/usr/include; then
CFLAGS="$CFLAGS -I$pcap_dir"
CPPFLAGS="$CPPFLAGS -I$pcap_dir"
fi
found_pcap_dir=" $found_pcap_dir -I$pcap_dir"
fi
done
if test "$found_pcap_dir" != "" ; then
AC_MSG_RESULT(found --$found_pcap_dir added to CFLAGS)
else
AC_MSG_RESULT(not found)
fi
else
#
# The user specified a directory in which libpcap resides,
# so add the "include" subdirectory of that directory to
# the include file search path and the "lib" subdirectory
# of that directory to the library search path.
#
# XXX - if there's also a libpcap in a directory that's
# already in CFLAGS, CPPFLAGS, or LDFLAGS, this won't
# make us find the version in the specified directory,
# as the compiler and/or linker will search that other
# directory before it searches the specified directory.
#
CFLAGS="$CFLAGS -I$pcap_dir/include"
CPPFLAGS="$CPPFLAGS -I$pcap_dir/include"
LDFLAGS="$LDFLAGS -L$pcap_dir/lib"
fi
# Pcap header checks
AC_CHECK_HEADER(pcap.h,, AC_MSG_ERROR(Header file pcap.h not found.))
AC_CHECK_LIB(pcap, pcap_open_live,, AC_MSG_ERROR(Library libpcap not found.),
$SOCKET_LIBS $NSL_LIBS)
])
dnl ************************************************************
dnl check for "localhost", if it doesn't exist, we can't do the
dnl gethostbyname_r tests!
dnl
dnl Copied from cURL package ;
dnl Done by Jakub Skopal <[email protected]> on 2002-08-28.
dnl
AC_DEFUN(AC_NETTOP_CHECK_WORKING_RESOLVER,[
AC_MSG_CHECKING([if "localhost" resolves])
AC_TRY_RUN([
#include <string.h>
#include <sys/types.h>
#include <netdb.h>
int
main () {
struct hostent *h;
h = gethostbyname("localhost");
exit (h == NULL ? 1 : 0); }],[
AC_MSG_RESULT(yes)],[
AC_MSG_RESULT(no)
AC_MSG_ERROR([can't figure out gethostbyname_r() since localhost doesn't resolve])
]
)
])
dnl
dnl Try to discover struct in6_addr members
dnl
AC_DEFUN(AC_NETTOP_CHECK_IN6_ADDR,
[
AC_MSG_CHECKING([if struct in6_addr contains s6_addr32 member])
AC_TRY_COMPILE([
#include <sys/types.h>
#include <netinet/in.h>],[
struct in6_addr adr;
adr.s6_addr32[0]=0;
],[
AC_MSG_RESULT(yes)
AC_DEFINE(HAVE_IP6_S6_ADDR32)],[
AC_MSG_RESULT(no)
AC_MSG_CHECKING([if struct in6_addr contains _S6_un._S6_u32 member])
AC_TRY_COMPILE([
#include <sys/types.h>
#include <netinet/in.h>],[
struct in6_addr adr;
adr._S6_un._S6_u32[0]=0;
],[
AC_MSG_RESULT(yes)
AC_DEFINE(HAVE_IP6__S6_UN__S6_U32)],[
AC_MSG_RESULT(no)
AC_MSG_CHECKING([if struct in6_addr contains __u6_addr.__u6_addr32 member])
AC_TRY_COMPILE([
#include <sys/types.h>
#include <netinet/in.h>],[
struct in6_addr adr;
adr.__u6_addr.__u6_addr32[0]=0;
],[
AC_MSG_RESULT(yes)
AC_DEFINE(HAVE_IP6___U6_ADDR___U6_ADDR32)],[
AC_MSG_RESULT(no)
AC_MSG_ERROR([can't figure out members of struct in6_addr])
]
)
]
)
]
)
])
dnl
dnl Find number of arguments of pcap_freecode
dnl
AC_DEFUN(AC_NETTOP_CHECK_PCAP_FREECODE,
[
dnl check for number of arguments to pcap_freecode. it might take
dnl either 1 or 2.
AC_MSG_CHECKING(if pcap_freecode takes 2 arguments)
AC_TRY_COMPILE([
#include <pcap.h>],[
struct bpf_program *program;
pcap_t *pcap;
pcap_freecode(pcap, program);],[
AC_MSG_RESULT(yes)
AC_DEFINE(HAVE_PCAP_FREECODE_2)
ac_cv_pcap_freecode_args=2],[
AC_MSG_RESULT(no)
AC_MSG_CHECKING(if pcap_freecode takes 1 argument)
AC_TRY_COMPILE([
#include <pcap.h>],[
struct bpf_program *program;
pcap_freecode(program);],[
AC_MSG_RESULT(yes)
AC_DEFINE(HAVE_PCAP_FREECODE_1)
ac_cv_pcap_freecode_args=1],[
AC_MSG_RESULT(no)
AC_MSG_ERROR([cannot discover number of arguments of pcap_freecode])
]
)]
)]
)
dnl
dnl Copied from cURL package ;
dnl Done by Jakub Skopal <[email protected]> on 2002-08-28.
dnl
AC_DEFUN(AC_NETTOP_CHECK_GETHOSTBYADDR_R,
[
AC_ARG_ENABLE(multithreaded-resolver, AC_HELP_STRING([--disable-multithreaded-resolver],[do not try to use multithreaded resolver !!FreeBSD!!]), disable_multithreaded_resolver=yes)
if test "x$disable_multithreaded_resolver" != "xyes"; then
if uname -a | grep "FreeBSD" > /dev/null 2>&1; then
echo "**********************************************************************"
echo "** configure script detected, that you're using FreeBSD. **"
echo "** 5.1-RELEASE and maybe others have been found to contain **"
echo "** bogus implementation of gethostbyaddr_r function. **"
echo "** **"
echo "** IN CASE YOU ENCOUNTER ANY Bus Error OR SegFault PROBLEMS WITH **"
echo "** jnettop, PLEASE SPECIFY --disable-multithreaded-resolver **"
echo "** OPTION TO CONFIGURE SCRIPT!! **"
echo "**********************************************************************"
fi
dnl check for number of arguments to gethostbyaddr_r. it might take
dnl either 5, 7, or 8 arguments.
AC_CHECK_FUNCS(gethostbyaddr_r,[
AC_MSG_CHECKING(if gethostbyaddr_r takes 5 arguments)
AC_TRY_COMPILE([
#include <sys/types.h>
#include <netdb.h>],[
char * address;
int length;
int type;
struct hostent h;
struct hostent_data hdata;
int rc;
rc = gethostbyaddr_r(address, length, type, &h, &hdata);],[
AC_MSG_RESULT(yes)
AC_DEFINE(HAVE_GETHOSTBYADDR_R_5)
ac_cv_gethostbyaddr_args=5],[
AC_MSG_RESULT(no)
AC_MSG_CHECKING(if gethostbyaddr_r with -D_REENTRANT takes 5 arguments)
AC_TRY_COMPILE([
#define _REENTRANT
#include <sys/types.h>
#include <netdb.h>],[
char * address;
int length;
int type;
struct hostent h;
struct hostent_data hdata;
int rc;
rc = gethostbyaddr_r(address, length, type, &h, &hdata);],[
AC_MSG_RESULT(yes)
AC_DEFINE(HAVE_GETHOSTBYADDR_R_5)
AC_DEFINE(NEED_REENTRANT)
ac_cv_gethostbyaddr_args=5],[
AC_MSG_RESULT(no)
AC_MSG_CHECKING(if gethostbyaddr_r takes 8 arguments)
AC_TRY_COMPILE([
#include <sys/types.h>
#include <netdb.h>],[
char * address;
int length;
int type;
struct hostent h;
char buffer[8192];
int h_errnop;
struct hostent * hp;
int rc;
rc = gethostbyaddr_r(address, length, type, &h,
buffer, 8192, &hp, &h_errnop);],[
AC_MSG_RESULT(yes)
AC_DEFINE(HAVE_GETHOSTBYADDR_R_8)
ac_cv_gethostbyaddr_args=8],[
AC_MSG_RESULT(no)
have_missing_r_funcs="$have_missing_r_funcs gethostbyaddr_r"])])])])
fi
])