-
Notifications
You must be signed in to change notification settings - Fork 102
/
configure.in
235 lines (180 loc) · 4.71 KB
/
configure.in
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
dnl
dnl $Id$
dnl
dnl Copyright (c) 2001 Jordan Ritter <[email protected]>
dnl
dnl Please refer to the COPYRIGHT file for more information.
AC_INIT(ngrep.c)
AC_CANONICAL_SYSTEM
AC_PROG_CC
AC_PREFIX(gcc)
AC_HEADER_STDC
AC_C_CONST
AC_TYPE_SIZE_T
AC_TYPE_SIGNAL
AC_FUNC_ALLOCA
AC_CHECK_HEADER(strings.h,,echo need strings header; exit)
AC_CHECK_HEADER(netinet/if_ether.h,AC_DEFINE(HAVE_IF_ETHER_H,1),)
dnl
dnl Find ourselves some usable pcap headers.
dnl
AC_MSG_CHECKING(for a complete set of pcap headers)
possible_dirs="`eval echo -n ${includedir}` \
/usr/include /usr/include/pcap \
/usr/local/include /usr/local/include/pcap \
/usr/share/include /usr/share/include/pcap"
AC_ARG_WITH(pcap-includes,
[ --with-pcap-includes specify the pcap include directory],
[PCAP_DIR=$withval],
[PCAP_DIR=$possible_dirs])
pcap_dir=""
for dir in $PCAP_DIR ; do
if test -d $dir -a -r "$dir/pcap.h" -a \
-r "$dir/net/bpf.h" ; then
if test -n "$pcap_dir" -a "$pcap_dir" != "$dir"; then
echo
echo; echo more than one set found in:
echo $pcap_dir
echo $dir
echo; echo please wipe out all unused pcap installations
exit
else
pcap_dir="$dir"
fi
fi
done
if test -z "$pcap_dir" ; then
echo no; echo couldn\'t find a complete set of pcap headers
exit
else
echo found $pcap_dir
PCAP_INCLUDE="-I$pcap_dir"
PCAP_LINK="-L`dirname $pcap_dir`/lib"
AC_SUBST(PCAP_INCLUDE)
AC_SUBST(PCAP_LINK)
AC_MSG_CHECKING(for usable bpf.h)
if test -n "`grep DLT_RAW $pcap_dir/net/bpf.h`" ; then
echo yep
else
echo nope
echo '***************************************************************'
echo an important define is missing from the bpf.h I found. this
echo probably means that your installation of pcap is outdated and
echo needs upgrading. I\'ll go ahead and add the define for you but
echo understand that matching certain types of packets may not
echo function properly.
echo '***************************************************************'
sleep 3
AC_DEFINE(DLT_RAW, 12)
fi
fi
dnl
dnl pcre library compatibility stuff
dnl
AC_ARG_WITH(pcre,
[ --with-pcre use libnet build directory],
[
( cd pcre-3.4; ./configure && make libtool chartables.c )
AC_DEFINE(USE_PCRE)
REGEX_TARGET='pcre'
REGEX_OBJS='pcre.o study.o'
],
[
( cd regex-0.12; ./configure )
REGEX_TARGET='regex'
REGEX_OBJS='regex.o'
]
)
AC_SUBST(REGEX_TARGET)
AC_SUBST(REGEX_OBJS)
dnl
dnl OS-specific options
dnl
AC_DEFINE(_BSD_SOURCE)
AC_DEFINE(__FAVOR_BSD)
STRIPFLAG="-s"
case "$target_os" in
*linux*)
AC_DEFINE(LINUX)
AC_MSG_CHECKING(for a dumb udphdr declaration)
AC_TRY_COMPILE(,
#ifndef __FAVOR_BSD
#define __FAVOR_BSD
#endif
#ifndef _BSD_SOURCE
#define _BSD_SOURCE 1
#endif
#include <netinet/udp.h>
struct udphdr foo;
unsigned short bar = foo.uh_sport;
,
echo nope,
echo yep dumb; AC_DEFINE(HAVE_DUMB_UDPHDR))
;;
*bsd*)
AC_DEFINE(BSD)
;;
*solaris*)
AC_DEFINE(SOLARIS)
AC_CHECK_LIB(socket, socket,,
echo no socket in -lsocket\?; exit)
AC_CHECK_LIB(nsl, gethostbyname,,
echo no gethostbyname in -lnsl\?; exit)
LIBS="$LIBS -lnsl -lsocket"
AC_SUBST(EXTRA_LIBS)
EXTRA_LIBS='-lnsl -lsocket'
;;
*osf*)
AC_DEFINE(OSF1)
AC_DEFINE(__STDC__, 2)
;;
*hpux11*)
AC_DEFINE(BSD)
;;
*aix*)
AC_DEFINE(AIX)
;;
*darwin*)
AC_DEFINE(MACOSX)
STRIPFLAG=""
;;
*)
AC_MSG_WARN(Your OS ($target_os) is not supported yet. Try\
playing with the build host and target options.)
;;
esac
AC_SUBST(STRIPFLAG)
AC_CHECK_LIB(pcap, pcap_open_live,,echo need pcap lib; exit)
dnl
dnl Here's where we should check to see if we require the use of a
dnl PCAP_RESTART function. Should run a test program that calls
dnl pcap_compile() twice and checks the exit value, or something. For
dnl now, just let the user the flag itself, until I come up with a
dnl working methodology.
dnl
AC_ARG_WITH(restart,
[ --with-restart use libpcap restart func],
[
if test "$withval" = "yes"; then
AC_DEFINE(NEED_RESTART)
need_restart="yes"
else
need_restart="no"
fi
],
[
AC_DEFINE(NEED_RESTART)
need_restart="yes"
])
dnl
dnl Now find the function in the lib..
dnl
if test "$need_restart" = "yes" ; then
AC_CHECK_LIB(pcap, pcap_restart, AC_DEFINE(PCAP_RESTART,pcap_restart),
AC_CHECK_LIB(pcap, pcap_yyrestart, AC_DEFINE(PCAP_RESTART,pcap_yyrestart),
AC_CHECK_LIB(pcap, yyrestart, AC_DEFINE(PCAP_RESTART,yyrestart),
echo no yacc restart func found
echo perhaps libpcap wasn\'t compiled with bison/flex\?
exit)))
fi
AC_OUTPUT(Makefile)