forked from MITRECND/libnids
-
Notifications
You must be signed in to change notification settings - Fork 1
/
configure.ac
253 lines (234 loc) · 6.22 KB
/
configure.ac
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
dnl
dnl configure.in for libnids.
dnl
dnl Dug Song <[email protected]>
dnl ... mantained by Nergal
AC_INIT(src/libnids.c)
AC_CANONICAL_SYSTEM
AC_CONFIG_HEADER(src/config.h)
dnl Initialize prefix.
if test "$prefix" = "NONE" ; then
prefix="/usr/local"
fi
dnl Initialize exec_prefix.
if test "$exec_prefix" = "NONE" ; then
exec_prefix=$prefix
fi
dnl Checks for programs.
AC_PROG_CC
AC_PROG_RANLIB
AC_PROG_INSTALL
dnl Checks for header files.
AC_HEADER_STDC
AC_CHECK_HEADERS(sys/time.h syslog.h unistd.h)
dnl Checks for typedefs, structures, and compiler characteristics.
AC_C_CONST
AC_C_INLINE
AC_HEADER_TIME
AC_C_BIGENDIAN
dnl XXX - Linux sux.
CFLAGS="$CFLAGS -D_BSD_SOURCE"
dnl Checks for library functions.
AC_CHECK_FUNCS(gettimeofday)
dnl XXX - Solaris sux.
AC_CHECK_LIB(socket, socket)
AC_CHECK_LIB(nsl, gethostbyname)
case "$target_cpu" in
alpha*|arm*|hp*|mips*|sparc*)
ac_cv_lbl_unaligned_fail=yes
;;
*)
ac_cv_lbl_unaligned_fail=no
;;
esac
if test $ac_cv_lbl_unaligned_fail = yes ; then
AC_DEFINE(LBL_ALIGN,1,[if unaligned access fails])
fi
dnl Checks for libpcap
AC_MSG_CHECKING(for libpcap)
AC_ARG_WITH(libpcap,
[ --with-libpcap=DIR use libpcap build directory],
[ case "$withval" in
yes|no)
AC_MSG_RESULT(no)
;;
*)
AC_MSG_RESULT($withval)
if test -f $withval/pcap.h -a -f $withval/libpcap.a; then
owd=`pwd`
if cd $withval; then withval=`pwd`; cd $owd; fi
PCAP_CFLAGS="-I$withval -I$withval/bpf"
PCAPLIB="-L$withval -lpcap"
else
AC_ERROR(pcap.h or libpcap.a not found in $withval)
fi
;;
esac ],
[ if test -f ${prefix}/include/pcap.h; then
PCAP_CFLAGS="-I${prefix}/include"
PCAPLIB="-L${exec_prefix}/lib -lpcap"
elif test -f /usr/include/pcap/pcap.h; then
PCAP_CFLAGS="-I/usr/include/pcap"
PCAPLIB="-lpcap"
else
TMP=$LIBS
LIBS="-lpcap $LIBS"
AC_TRY_LINK([#include <pcap.h>], pcap_open_offline("",""),
LIBPCAP_FOUND=1,LIBPCAP_FOUND=0)
LIBS=$TMP
if test $LIBPCAP_FOUND = 1 ; then
PCAPLIB="-lpcap"
else
AC_ERROR(libpcap not found)
fi
fi
AC_MSG_RESULT(yes) ]
)
AC_SUBST(PCAP_CFLAGS)
AC_SUBST(PCAPLIB)
dnl Checks for libglib2.8
AC_ARG_ENABLE(libglib,
[ --disable-libglib use glib2 for multiprocessing support],
[
AC_MSG_RESULT(skipping glib2 support)
],
[
PKG_PROG_PKG_CONFIG
PKG_CHECK_MODULES(GLIB, glib-2.0 >= 2.2.0,[
PKG_CHECK_MODULES(GTHREAD, gthread-2.0 >= 2.2.0,,)
AC_CHECK_LIB(gthread-2.0,g_thread_init,,,$GTHREAD_LIBS)
],)
]
)
dnl Checks for libnet
AC_MSG_CHECKING(for libnet)
AC_ARG_ENABLE(libnet,
[ --disable-libnet whether to include code requiring libnet],
[ case "$enableval" in
yes)
AC_MSG_RESULT(yes)
;;
no)
AC_MSG_RESULT(no)
LIBNET_VER=-1
;;
*)
AC_ERROR(no arguments expected for --disable-libnet)
;;
esac ]
)
AC_ARG_WITH(libnet,
[ --with-libnet=DIR use libnet build directory],
[ case "$withval" in
yes)
;;
no)
LIBNET_VER=-1
AC_MSG_RESULT(no)
;;
*)
AC_MSG_RESULT($withval)
if test -f $withval/include/libnet.h -a -f $withval/lib/libnet.a -a -f $withval/libnet-config ; then
owd=`pwd`
if cd $withval; then withval=`pwd`; cd $owd; fi
LNET_CFLAGS="-I$withval/include `$withval/libnet-config --defines`"
LNETLIB="-L$withval/lib -lnet"
elif test -f $withval/include/libnet.h -a -f $withval/src/libnet.a; then
owd=`pwd`
if cd $withval; then withval=`pwd`; cd $owd; fi
LNET_CFLAGS="-I$withval/include"
LNETLIB="-L$withval/src -lnet"
else
echo "A working combination of libnet.h, libnet.a and libnet-config not found in $withval; get libnet from www.packetfactory.net/projects/libnet and reinstall"
AC_ERROR(libnet)
fi
;;
esac ],
[ if test "x"$LIBNET_VER = "x"-1 ; then
AC_MSG_RESULT(skipping libnet)
else
if test -f ${prefix}/include/libnet.h -a ${exec_prefix}/lib/libnet.a ; then
LNET_CFLAGS="-I${prefix}/include `${exec_prefix}/bin/libnet-config --defines 2>/dev/null`"
LNETLIB="-L${exec_prefix}/lib -lnet"
else
LNET_CFLAGS="`libnet-config --defines 2>/dev/null`"
LNETLIB="-lnet"
fi
fi ]
)
if test "x"$LIBNET_VER != "x"-1 ; then
TMPC="$CFLAGS"
TMPL="$LIBS"
CFLAGS="$CFLAGS $LNET_CFLAGS"
LIBS="$LNETLIB $LIBS"
AC_TRY_LINK([#include <libnet.h>], libnet_get_prand(0),
LIBNET_FOUND=1,LIBNET_FOUND=0)
CFLAGS="$TMPC"
LIBS="$TMPL"
if test $LIBNET_FOUND = 1 ; then
LNETLIB="-lnet"
AC_MSG_RESULT(yes)
else
echo "Working libnet not found; get it from www.packetfactory.net/projects/libnet and reinstall"
AC_ERROR(libnet)
fi
fi
AC_SUBST(LNET_CFLAGS)
AC_SUBST(LNETLIB)
BUILD_SHARED=
AC_MSG_CHECKING(whether to build shared library)
AC_ARG_ENABLE(shared,
[ --enable-shared enable building shared libraries],
[ case "$enableval" in
yes)
AC_MSG_RESULT(yes)
BUILD_SHARED=shared
;;
no)
AC_MSG_RESULT(no)
;;
*)
AC_ERROR(no arguments expected for --enable-shared)
;;
esac ],
[AC_MSG_RESULT(no)]
)
AC_SUBST(BUILD_SHARED)
AC_MSG_CHECKING(the name of struct icmp)
AC_TRY_COMPILE([#include <sys/types.h>
#include <netinet/in.h>
#include <netinet/ip.h>
#include <netinet/ip_icmp.h>], struct icmphdr h;int c=h.type, ICMPHEADER=1,ICMPHEADER=0)
AC_SUBST(ICMPHEADER)
if test $ICMPHEADER = 1 ; then
AC_MSG_RESULT(struct icmphdr) ; else AC_MSG_RESULT(struct icmp)
fi
AC_MSG_CHECKING(if tcp states are defined)
AC_TRY_COMPILE([#include <sys/types.h>
#include <netinet/in.h>
#include <netinet/tcp.h>], int c=TCP_ESTABLISHED,TCPSTATES=1,TCPSTATES=0)
AC_SUBST(TCPSTATES)
if test $TCPSTATES = 1 ; then
AC_MSG_RESULT(yes) ; else AC_MSG_RESULT(no)
fi
AC_MSG_CHECKING(for bsd-ish struct udphdr)
AC_TRY_COMPILE([#include <sys/types.h>
#include <netinet/in.h>
#include <netinet/udp.h>], struct udphdr h;int c=h.uh_ulen,HAVE_BSD_UDPHDR=1,HAVE_BSD_UDPHDR=0)
AC_SUBST(HAVE_BSD_UDPHDR)
if test $HAVE_BSD_UDPHDR = 1 ; then
AC_MSG_RESULT(yes) ; else AC_MSG_RESULT(no)
fi
if test "x"$LIBNET_VER != "x"-1 ; then
TMP=$CFLAGS
CFLAGS="$CFLAGS $LNET_CFLAGS"
AC_MSG_CHECKING(libnet version)
AC_TRY_COMPILE([#include <libnet.h>], int c=LIBNET_PTAG_INITIALIZER,
LIBNET_VER=1,LIBNET_VER=0)
CFLAGS=$TMP
if test $LIBNET_VER = 1 ; then
AC_MSG_RESULT(looks new) ; else AC_MSG_RESULT(looks old)
fi
fi
AC_SUBST(LIBNET_VER)
AC_OUTPUT(Makefile src/Makefile samples/Makefile)