]>
Commit | Line | Data |
---|---|---|
6899b3da | 1 | #TODO A better place for default CFLAGS? |
0ffa1c24 | 2 | |
bab4b623 VJ |
3 | AC_INIT(configure.in) |
4 | ||
a3510f20 WM |
5 | AM_CONFIG_HEADER(config.h) |
6 | AM_INIT_AUTOMAKE(eidps, 0.1) | |
7 | ||
8 | AC_LANG_C | |
ff6a2a01 | 9 | AC_PROG_CC_C99 |
a3510f20 WM |
10 | AM_PROG_LIBTOOL |
11 | ||
12 | AC_DEFUN([FAIL_MESSAGE],[ | |
13 | echo | |
14 | echo | |
15 | echo "**********************************************" | |
16 | echo " ERROR: unable to find" $1 | |
17 | echo " checked in the following places" | |
18 | for i in `echo $2`; do | |
19 | echo " $i" | |
20 | done | |
21 | echo "**********************************************" | |
22 | echo | |
23 | exit 1 | |
24 | ]) | |
25 | ||
26 | CFLAGS="$CFLAGS -Wall -fno-strict-aliasing" | |
0ffa1c24 | 27 | |
fa5939ca | 28 | # Checks for programs. |
fa5939ca BR |
29 | AC_PROG_AWK |
30 | AC_PROG_CC | |
31 | AC_PROG_CPP | |
32 | AC_PROG_INSTALL | |
33 | AC_PROG_LN_S | |
34 | AC_PROG_MAKE_SET | |
35 | AC_PROG_RANLIB | |
36 | ||
37 | # Checks for libraries. | |
38 | ||
39 | # Checks for header files. | |
40 | AC_CHECK_HEADERS([arpa/inet.h inttypes.h limits.h netinet/in.h stdint.h stdlib.h string.h sys/socket.h sys/time.h unistd.h]) | |
41 | ||
42 | # Checks for typedefs, structures, and compiler characteristics. | |
43 | AC_C_INLINE | |
44 | AC_TYPE_PID_T | |
45 | AC_TYPE_SIZE_T | |
46 | AC_TYPE_INT32_T | |
47 | AC_TYPE_UINT16_T | |
48 | AC_TYPE_UINT32_T | |
49 | AC_TYPE_UINT64_T | |
50 | AC_TYPE_UINT8_T | |
51 | AC_HEADER_STDBOOL | |
52 | ||
53 | # Checks for library functions. | |
54 | AC_FUNC_MALLOC | |
55 | AC_FUNC_REALLOC | |
56 | AC_CHECK_FUNCS([gettimeofday memset strcasecmp strchr strdup strerror strncasecmp strtol strtoul]) | |
57 | ||
58 | ||
6899b3da | 59 | #libpcre |
a3510f20 WM |
60 | AC_ARG_WITH(libpcre_includes, |
61 | [ --with-libpcre-includes=DIR libpcre include directory], | |
62 | [with_libpcre_includes="$withval"],[with_libpcre_includes=no]) | |
63 | AC_ARG_WITH(libpcre_libraries, | |
64 | [ --with-libpcre-libraries=DIR libpcre library directory], | |
65 | [with_libpcre_libraries="$withval"],[with_libpcre_libraries="no"]) | |
66 | ||
67 | if test "$with_libpcre_includes" != "no"; then | |
6899b3da | 68 | CPPFLAGS="${CPPFLAGS} -I${with_libpcre_includes}" |
a3510f20 | 69 | fi |
6899b3da | 70 | |
a3510f20 | 71 | AC_CHECK_HEADER(pcre.h,,[AC_ERROR(pcre.h not found ...)]) |
6899b3da | 72 | |
a3510f20 | 73 | if test "$with_libpcre_libraries" != "no"; then |
6899b3da | 74 | LDFLAGS="${LDFLAGS} -L${with_libpcre_libraries}" |
a3510f20 | 75 | fi |
6899b3da | 76 | |
a3510f20 WM |
77 | PCRE="" |
78 | AC_CHECK_LIB(pcre, pcre_get_substring,, PCRE="no") | |
6899b3da | 79 | |
a3510f20 | 80 | if test "$PCRE" = "no"; then |
6899b3da WM |
81 | echo |
82 | echo " ERROR! pcre library not found, go get it" | |
83 | echo " from www.pcre.org." | |
84 | echo | |
85 | exit 1 | |
a3510f20 | 86 | fi |
6899b3da WM |
87 | |
88 | #libpthread | |
a3510f20 WM |
89 | AC_ARG_WITH(libpthread_includes, |
90 | [ --with-libpthread-includes=DIR libpthread include directory], | |
91 | [with_libpthread_includes="$withval"],[with_libpthread_includes=no]) | |
92 | AC_ARG_WITH(libpthread_libraries, | |
93 | [ --with-libpthread-libraries=DIR libpthread library directory], | |
94 | [with_libpthread_libraries="$withval"],[with_libpthread_libraries="no"]) | |
95 | ||
96 | if test "$with_libpthread_includes" != "no"; then | |
6899b3da | 97 | CPPFLAGS="${CPPFLAGS} -I${with_libpthread_includes}" |
a3510f20 | 98 | fi |
6899b3da | 99 | |
fa5939ca | 100 | dnl AC_CHECK_HEADER(pthread.h,,[AC_ERROR(pthread.h not found ...)]) |
6899b3da | 101 | |
a3510f20 | 102 | if test "$with_libpthread_libraries" != "no"; then |
6899b3da | 103 | LDFLAGS="${LDFLAGS} -L${with_libpthread_libraries}" |
a3510f20 | 104 | fi |
6899b3da | 105 | |
a3510f20 WM |
106 | PTHREAD="" |
107 | AC_CHECK_LIB(pthread, pthread_create,, PTHREAD="no") | |
6899b3da | 108 | |
a3510f20 | 109 | if test "$PTHREAD" = "no"; then |
6899b3da WM |
110 | echo |
111 | echo " ERROR! libpthread library not found, glibc problem?" | |
112 | echo | |
113 | exit 1 | |
a3510f20 WM |
114 | fi |
115 | ||
116 | #enable support for NFQUEUE | |
117 | AC_ARG_ENABLE(nfqueue, | |
118 | [ --enable-nfqueue Enable NFQUEUE support for inline IDP], | |
119 | [ enable_nfqueue=yes | |
120 | ]) | |
121 | if test "$enable_nfqueue" = "yes"; then | |
122 | CFLAGS="$CFLAGS -DNFQ" | |
6899b3da WM |
123 | |
124 | #libnfnetlink | |
a3510f20 WM |
125 | AC_ARG_WITH(libnfnetlink_includes, |
126 | [ --with-libnfnetlink-includes=DIR libnfnetlink include directory], | |
127 | [with_libnfnetlink_includes="$withval"],[with_libnfnetlink_includes=no]) | |
128 | AC_ARG_WITH(libnfnetlink_libraries, | |
129 | [ --with-libnfnetlink-libraries=DIR libnfnetlink library directory], | |
130 | [with_libnfnetlink_libraries="$withval"],[with_libnfnetlink_libraries="no"]) | |
131 | ||
132 | if test "$with_libnfnetlink_includes" != "no"; then | |
0ffa1c24 | 133 | CPPFLAGS="${CPPFLAGS} -I${with_libnfnetlink_includes}" |
a3510f20 | 134 | fi |
0ffa1c24 | 135 | |
a3510f20 | 136 | AC_CHECK_HEADER(libnfnetlink/libnfnetlink.h,,[AC_ERROR(libnfnetlink.h not found ...)]) |
0ffa1c24 | 137 | |
a3510f20 | 138 | if test "$with_libnfnetlink_libraries" != "no"; then |
0ffa1c24 | 139 | LDFLAGS="${LDFLAGS} -L${with_libnfnetlink_libraries}" |
a3510f20 | 140 | fi |
0ffa1c24 | 141 | |
a3510f20 WM |
142 | NFNL="" |
143 | AC_CHECK_LIB(nfnetlink, nfnl_fd,, NFNL="no") | |
0ffa1c24 | 144 | |
a3510f20 | 145 | if test "$NFNL" = "no"; then |
0ffa1c24 WM |
146 | echo |
147 | echo " ERROR! nfnetlink library not found, go get it" | |
148 | echo " from www.netfilter.org." | |
149 | echo " we automatically append libnetfilter_queue/ when searching" | |
150 | echo " for headers etc. when the --with-libnfnetlink-inlcudes directive" | |
151 | echo " is used" | |
152 | echo | |
153 | exit | |
a3510f20 | 154 | fi |
0ffa1c24 | 155 | |
6899b3da | 156 | #libnetfilter_queue |
a3510f20 WM |
157 | AC_ARG_WITH(libnetfilter_queue_includes, |
158 | [ --with-libnetfilter_queue-includes=DIR libnetfilter_queue include directory], | |
159 | [with_libnetfilter_queue_includes="$withval"],[with_libnetfilter_queue_includes=no]) | |
160 | AC_ARG_WITH(libnetfilter_queue_libraries, | |
161 | [ --with-libnetfilter_queue-libraries=DIR libnetfilter_queue library directory], | |
162 | [with_libnetfilter_queue_libraries="$withval"],[with_libnetfilter_queue_libraries="no"]) | |
163 | ||
164 | if test "$with_libnetfilter_queue_includes" != "no"; then | |
0ffa1c24 | 165 | CPPFLAGS="${CPPFLAGS} -I${with_libnetfilter_queue_includes}" |
a3510f20 | 166 | fi |
0ffa1c24 | 167 | |
a3510f20 | 168 | AC_CHECK_HEADER(libnetfilter_queue/libnetfilter_queue.h,,[AC_ERROR(libnetfilter_queue/libnetfilter_queue.h not found ...)]) |
0ffa1c24 | 169 | |
a3510f20 | 170 | if test "$with_libnetfilter_queue_libraries" != "no"; then |
0ffa1c24 | 171 | LDFLAGS="${LDFLAGS} -L${with_libnetfilter_queue_libraries}" |
a3510f20 | 172 | fi |
0ffa1c24 WM |
173 | |
174 | #LDFLAGS="${LDFLAGS} -lnetfilter_queue" | |
175 | ||
a3510f20 WM |
176 | NFQ="" |
177 | AC_CHECK_LIB(netfilter_queue, nfq_open,, NFQ="no",) | |
0ffa1c24 | 178 | |
a3510f20 | 179 | if test "$NFQ" = "no"; then |
0ffa1c24 WM |
180 | echo |
181 | echo " ERROR! libnetfilter_queue library not found, go get it" | |
182 | echo " from www.netfilter.org." | |
183 | echo " we automatically append libnetfilter_queue/ when searching" | |
184 | echo " for headers etc. when the --with-libnfq-inlcudes directive" | |
185 | echo " is used" | |
186 | echo | |
187 | exit 1 | |
a3510f20 WM |
188 | fi |
189 | fi | |
0ffa1c24 | 190 | |
6899b3da | 191 | #libnet |
a3510f20 WM |
192 | AC_ARG_WITH(libnet_includes, |
193 | [ --with-libnet-includes=DIR libnet include directory], | |
194 | [with_libnet_includes="$withval"],[with_libnet_includes="no"]) | |
195 | ||
196 | AC_ARG_WITH(libnet_libraries, | |
197 | [ --with-libnet-libraries=DIR libnet library directory], | |
198 | [with_libnet_libraries="$withval"],[with_libnet_libraries="no"]) | |
199 | ||
200 | if test "x$with_libnet_includes" != "xno"; then | |
0ffa1c24 | 201 | CPPFLAGS="${CPPFLAGS} -I${with_libnet_includes}" |
a3510f20 | 202 | fi |
0ffa1c24 | 203 | |
a3510f20 | 204 | if test "x$with_libnet_libraries" != "xno"; then |
0ffa1c24 | 205 | LDFLAGS="${LDFLAGS} -L${with_libnet_libraries}" |
a3510f20 WM |
206 | fi |
207 | ||
208 | LIBNET_INC_DIR="" | |
209 | AC_MSG_CHECKING("for libnet.h version 1.1.x") | |
210 | libnet_dir="/usr/include /usr/local/include" | |
211 | for i in $libnet_dir; do | |
212 | if test -r "$i/libnet.h"; then | |
213 | LIBNET_INC_DIR="$i" | |
214 | fi | |
215 | done | |
216 | ||
217 | if test "$LIBNET_INC_DIR" != ""; then | |
0ffa1c24 | 218 | if eval "grep LIBNET_VERSION $LIBNET_INC_DIR/libnet.h | grep -v 1.1 >/dev/null"; then |
a3510f20 | 219 | FAIL_MESSAGE("libnet 1.1.x (libnet.h)", $tmp) |
0ffa1c24 WM |
220 | fi |
221 | CFLAGS="${CFLAGS} `libnet-config --defines` `libnet-config --cflags`" | |
222 | LIBS="${LIBS} `libnet-config --libs`" | |
223 | CPPFLAGS="${CPPFLAGS} -I${LIBNET_INC_DIR}" | |
224 | AC_MSG_RESULT($i) | |
a3510f20 | 225 | else |
0ffa1c24 WM |
226 | AC_MSG_RESULT(no) |
227 | AC_MSG_ERROR("libnet 1.1.x could not be found. please download and install the library from http://www.packetfactory.net/libnet/") | |
a3510f20 | 228 | fi |
0ffa1c24 WM |
229 | |
230 | # see if we have the patched libnet 1.1 | |
231 | # http://www.inliniac.net/blog/2007/10/16/libnet-11-ipv6-fixes-and-additions.html | |
a3510f20 WM |
232 | LLIBNET="" |
233 | AC_CHECK_LIB(net, libnet_build_icmpv6_unreach,, LLIBNET="no") | |
0ffa1c24 | 234 | if test "$LLIBNET" != "no"; then |
a3510f20 | 235 | CFLAGS="$CFLAGS -DHAVE_LIBNET_ICMPV6_UNREACH" |
0ffa1c24 WM |
236 | fi |
237 | ||
073d0421 WM |
238 | # libpfring (currently only supported for libpcap enabled pfring) |
239 | # Error on the side of caution. If libpfring enabled pcap is being used and we don't link against -lpfring compilation will fail. | |
240 | AC_ARG_WITH(libpfring_includes, | |
241 | [ --with-libpfring-includes=DIR libpfring include directory], | |
242 | [with_libpfring_includes="$withval"],[with_libpfring_includes=no]) | |
243 | AC_ARG_WITH(libpfring_libraries, | |
244 | [ --with-libpfring-libraries=DIR libpfring library directory], | |
245 | [with_libpfring_libraries="$withval"],[with_libpfring_libraries="no"]) | |
246 | ||
247 | if test "$with_libpfring_includes" != "no"; then | |
248 | CPPFLAGS="${CPPFLAGS} -I${with_libpfring_includes}" | |
249 | fi | |
250 | ||
251 | if test "$with_libpfring_libraries" != "no"; then | |
252 | LDFLAGS="${LDFLAGS} -L${with_libpfring_libraries}" | |
253 | fi | |
254 | ||
255 | LIBPFRING="" | |
256 | AC_CHECK_LIB(pfring, pfring_open,, LIBPFRING="no") | |
257 | ||
9c7f5afa | 258 | # libpcap |
a3510f20 WM |
259 | AC_ARG_WITH(libpcap_includes, |
260 | [ --with-libpcap-includes=DIR libpcap include directory], | |
261 | [with_libpcap_includes="$withval"],[with_libpcap_includes=no]) | |
262 | AC_ARG_WITH(libpcap_libraries, | |
263 | [ --with-libpcap-libraries=DIR libpcap library directory], | |
264 | [with_libpcap_libraries="$withval"],[with_libpcap_libraries="no"]) | |
265 | ||
266 | if test "$with_libpcap_includes" != "no"; then | |
6899b3da | 267 | CPPFLAGS="${CPPFLAGS} -I${with_libpcap_includes}" |
a3510f20 | 268 | fi |
6899b3da WM |
269 | |
270 | AC_CHECK_HEADER(pcap.h,,[AC_ERROR(pcap.h not found ...)]) | |
271 | ||
a3510f20 | 272 | if test "$with_libpcap_libraries" != "no"; then |
6899b3da | 273 | LDFLAGS="${LDFLAGS} -L${with_libpcap_libraries}" |
a3510f20 | 274 | fi |
6899b3da | 275 | |
a3510f20 WM |
276 | LIBPCAP="" |
277 | AC_CHECK_LIB(pcap, pcap_open_live,, LIBPCAP="no") | |
278 | if test "$LIBPCAP" = "no"; then | |
af992242 WM |
279 | echo |
280 | echo " ERROR! lipcap library not found, go get it" | |
281 | echo " from http://www.tcpdump.org." | |
282 | echo | |
283 | exit 1 | |
a3510f20 | 284 | fi |
af992242 WM |
285 | |
286 | # pcap_activate and pcap_create only exists in libpcap >= 1.0 | |
a3510f20 WM |
287 | LIBPCAPVTEST="" |
288 | AC_CHECK_LIB(pcap, pcap_activate,, LPCAPVTEST="no") | |
af992242 | 289 | if test "$LPCAPVTEST" != "no"; then |
a3510f20 | 290 | CFLAGS="${CFLAGS} `pcap-config --defines` `pcap-config --cflags` -DLIBPCAP_VERSION_MAJOR=1" |
af992242 | 291 | else |
a3510f20 WM |
292 | CFLAGS="${CFLAGS} -DLIBPCAP_VERSION_MAJOR=0" |
293 | fi | |
294 | ||
295 | # enable the running of unit tests | |
e6400bf4 VJ |
296 | AC_ARG_ENABLE(unittests, |
297 | [ --enable-unittests Enable compilation of the unit tests], | |
298 | [ enable_unittests=yes | |
a3510f20 | 299 | ]) |
e6400bf4 VJ |
300 | if test "$enable_unittests" = "yes"; then |
301 | CFLAGS="${CFLAGS} -DUNITTESTS" | |
a3510f20 WM |
302 | fi |
303 | ||
0ffa1c24 WM |
304 | AC_SUBST(CFLAGS) |
305 | AC_SUBST(LDFLAGS) | |
306 | AC_SUBST(CPPFLAGS) | |
307 | ||
bab4b623 | 308 | AC_OUTPUT(Makefile src/Makefile) |
0ffa1c24 | 309 |