]>
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 | 87 | |
c91a4baa JI |
88 | #libyaml |
89 | AC_ARG_WITH(libyaml_includes, | |
90 | [ --with-libyaml-includes=DIR libyaml include directory], | |
91 | [with_libyaml_includes="$withval"],[with_libyaml_includes=no]) | |
92 | AC_ARG_WITH(libyaml_libraries, | |
93 | [ --with-libyaml-libraries=DIR libyaml library directory], | |
94 | [with_libyaml_libraries="$withval"],[with_libyaml_libraries="no"]) | |
95 | ||
96 | if test "$with_libyaml_includes" != "no"; then | |
97 | CPPFLAGS="${CPPFLAGS} -I${with_libyaml_includes}" | |
98 | fi | |
99 | ||
100 | AC_CHECK_HEADER(yaml.h,,LIBYAML="no") | |
101 | ||
102 | if test "$with_libyaml_libraries" != "no"; then | |
103 | LDFLAGS="${LDFLAGS} -L${with_libyaml_libraries}" | |
104 | fi | |
105 | ||
106 | LIBYAML="" | |
107 | AC_CHECK_LIB(yaml,yaml_parser_initialize,,LIBYAML="no") | |
108 | ||
109 | if test "$LIBYAML" = "no"; then | |
110 | echo | |
111 | echo " ERROR! libyaml library not found, go get it" | |
112 | echo " from http://pyyaml.org/wiki/LibYAML." | |
113 | echo " or check your package manager." | |
114 | echo | |
115 | exit 1 | |
116 | fi | |
117 | ||
6899b3da | 118 | #libpthread |
a3510f20 WM |
119 | AC_ARG_WITH(libpthread_includes, |
120 | [ --with-libpthread-includes=DIR libpthread include directory], | |
121 | [with_libpthread_includes="$withval"],[with_libpthread_includes=no]) | |
122 | AC_ARG_WITH(libpthread_libraries, | |
123 | [ --with-libpthread-libraries=DIR libpthread library directory], | |
124 | [with_libpthread_libraries="$withval"],[with_libpthread_libraries="no"]) | |
125 | ||
126 | if test "$with_libpthread_includes" != "no"; then | |
6899b3da | 127 | CPPFLAGS="${CPPFLAGS} -I${with_libpthread_includes}" |
a3510f20 | 128 | fi |
6899b3da | 129 | |
fa5939ca | 130 | dnl AC_CHECK_HEADER(pthread.h,,[AC_ERROR(pthread.h not found ...)]) |
6899b3da | 131 | |
a3510f20 | 132 | if test "$with_libpthread_libraries" != "no"; then |
6899b3da | 133 | LDFLAGS="${LDFLAGS} -L${with_libpthread_libraries}" |
a3510f20 | 134 | fi |
6899b3da | 135 | |
a3510f20 WM |
136 | PTHREAD="" |
137 | AC_CHECK_LIB(pthread, pthread_create,, PTHREAD="no") | |
6899b3da | 138 | |
a3510f20 | 139 | if test "$PTHREAD" = "no"; then |
6899b3da WM |
140 | echo |
141 | echo " ERROR! libpthread library not found, glibc problem?" | |
142 | echo | |
143 | exit 1 | |
a3510f20 WM |
144 | fi |
145 | ||
146 | #enable support for NFQUEUE | |
147 | AC_ARG_ENABLE(nfqueue, | |
148 | [ --enable-nfqueue Enable NFQUEUE support for inline IDP], | |
149 | [ enable_nfqueue=yes | |
150 | ]) | |
151 | if test "$enable_nfqueue" = "yes"; then | |
152 | CFLAGS="$CFLAGS -DNFQ" | |
6899b3da WM |
153 | |
154 | #libnfnetlink | |
a3510f20 WM |
155 | AC_ARG_WITH(libnfnetlink_includes, |
156 | [ --with-libnfnetlink-includes=DIR libnfnetlink include directory], | |
157 | [with_libnfnetlink_includes="$withval"],[with_libnfnetlink_includes=no]) | |
158 | AC_ARG_WITH(libnfnetlink_libraries, | |
159 | [ --with-libnfnetlink-libraries=DIR libnfnetlink library directory], | |
160 | [with_libnfnetlink_libraries="$withval"],[with_libnfnetlink_libraries="no"]) | |
161 | ||
162 | if test "$with_libnfnetlink_includes" != "no"; then | |
0ffa1c24 | 163 | CPPFLAGS="${CPPFLAGS} -I${with_libnfnetlink_includes}" |
a3510f20 | 164 | fi |
0ffa1c24 | 165 | |
a3510f20 | 166 | AC_CHECK_HEADER(libnfnetlink/libnfnetlink.h,,[AC_ERROR(libnfnetlink.h not found ...)]) |
0ffa1c24 | 167 | |
a3510f20 | 168 | if test "$with_libnfnetlink_libraries" != "no"; then |
0ffa1c24 | 169 | LDFLAGS="${LDFLAGS} -L${with_libnfnetlink_libraries}" |
a3510f20 | 170 | fi |
0ffa1c24 | 171 | |
a3510f20 WM |
172 | NFNL="" |
173 | AC_CHECK_LIB(nfnetlink, nfnl_fd,, NFNL="no") | |
0ffa1c24 | 174 | |
a3510f20 | 175 | if test "$NFNL" = "no"; then |
0ffa1c24 WM |
176 | echo |
177 | echo " ERROR! nfnetlink library not found, go get it" | |
178 | echo " from www.netfilter.org." | |
179 | echo " we automatically append libnetfilter_queue/ when searching" | |
180 | echo " for headers etc. when the --with-libnfnetlink-inlcudes directive" | |
181 | echo " is used" | |
182 | echo | |
183 | exit | |
a3510f20 | 184 | fi |
0ffa1c24 | 185 | |
6899b3da | 186 | #libnetfilter_queue |
a3510f20 WM |
187 | AC_ARG_WITH(libnetfilter_queue_includes, |
188 | [ --with-libnetfilter_queue-includes=DIR libnetfilter_queue include directory], | |
189 | [with_libnetfilter_queue_includes="$withval"],[with_libnetfilter_queue_includes=no]) | |
190 | AC_ARG_WITH(libnetfilter_queue_libraries, | |
191 | [ --with-libnetfilter_queue-libraries=DIR libnetfilter_queue library directory], | |
192 | [with_libnetfilter_queue_libraries="$withval"],[with_libnetfilter_queue_libraries="no"]) | |
193 | ||
194 | if test "$with_libnetfilter_queue_includes" != "no"; then | |
0ffa1c24 | 195 | CPPFLAGS="${CPPFLAGS} -I${with_libnetfilter_queue_includes}" |
a3510f20 | 196 | fi |
0ffa1c24 | 197 | |
a3510f20 | 198 | AC_CHECK_HEADER(libnetfilter_queue/libnetfilter_queue.h,,[AC_ERROR(libnetfilter_queue/libnetfilter_queue.h not found ...)]) |
0ffa1c24 | 199 | |
a3510f20 | 200 | if test "$with_libnetfilter_queue_libraries" != "no"; then |
0ffa1c24 | 201 | LDFLAGS="${LDFLAGS} -L${with_libnetfilter_queue_libraries}" |
a3510f20 | 202 | fi |
0ffa1c24 WM |
203 | |
204 | #LDFLAGS="${LDFLAGS} -lnetfilter_queue" | |
205 | ||
a3510f20 WM |
206 | NFQ="" |
207 | AC_CHECK_LIB(netfilter_queue, nfq_open,, NFQ="no",) | |
0ffa1c24 | 208 | |
a3510f20 | 209 | if test "$NFQ" = "no"; then |
0ffa1c24 WM |
210 | echo |
211 | echo " ERROR! libnetfilter_queue library not found, go get it" | |
212 | echo " from www.netfilter.org." | |
213 | echo " we automatically append libnetfilter_queue/ when searching" | |
214 | echo " for headers etc. when the --with-libnfq-inlcudes directive" | |
215 | echo " is used" | |
216 | echo | |
217 | exit 1 | |
a3510f20 WM |
218 | fi |
219 | fi | |
0ffa1c24 | 220 | |
6899b3da | 221 | #libnet |
a3510f20 WM |
222 | AC_ARG_WITH(libnet_includes, |
223 | [ --with-libnet-includes=DIR libnet include directory], | |
224 | [with_libnet_includes="$withval"],[with_libnet_includes="no"]) | |
225 | ||
226 | AC_ARG_WITH(libnet_libraries, | |
227 | [ --with-libnet-libraries=DIR libnet library directory], | |
228 | [with_libnet_libraries="$withval"],[with_libnet_libraries="no"]) | |
229 | ||
230 | if test "x$with_libnet_includes" != "xno"; then | |
0ffa1c24 | 231 | CPPFLAGS="${CPPFLAGS} -I${with_libnet_includes}" |
a3510f20 | 232 | fi |
0ffa1c24 | 233 | |
a3510f20 | 234 | if test "x$with_libnet_libraries" != "xno"; then |
0ffa1c24 | 235 | LDFLAGS="${LDFLAGS} -L${with_libnet_libraries}" |
a3510f20 WM |
236 | fi |
237 | ||
238 | LIBNET_INC_DIR="" | |
239 | AC_MSG_CHECKING("for libnet.h version 1.1.x") | |
240 | libnet_dir="/usr/include /usr/local/include" | |
241 | for i in $libnet_dir; do | |
242 | if test -r "$i/libnet.h"; then | |
243 | LIBNET_INC_DIR="$i" | |
244 | fi | |
245 | done | |
246 | ||
247 | if test "$LIBNET_INC_DIR" != ""; then | |
0ffa1c24 | 248 | if eval "grep LIBNET_VERSION $LIBNET_INC_DIR/libnet.h | grep -v 1.1 >/dev/null"; then |
a3510f20 | 249 | FAIL_MESSAGE("libnet 1.1.x (libnet.h)", $tmp) |
0ffa1c24 | 250 | fi |
6e8c75ff WM |
251 | |
252 | #CentOS, Fedora, Ubuntu-LTS, Ubuntu all set defines to the same values. libnet-config seems | |
253 | #to have been depreciated but all distro's seem to include it as part of the package. | |
254 | LLIBNET="" | |
255 | AC_CHECK_LIB(net, libnet_write,, LLIBNET="no") | |
256 | if test "$LLIBNET" != "no"; then | |
257 | CFLAGS="${CFLAGS} -D_BSD_SOURCE -D__BSD_SOURCE -D__FAVOR_BSD -DHAVE_NET_ETHERNET_H" | |
258 | fi | |
0ffa1c24 | 259 | AC_MSG_RESULT($i) |
a3510f20 | 260 | else |
0ffa1c24 | 261 | AC_MSG_RESULT(no) |
6e8c75ff | 262 | AC_MSG_ERROR("libnet 1.1.x could not be found. please download and install the library from http://sourceforge.net/projects/libnet-dev/") |
a3510f20 | 263 | fi |
0ffa1c24 WM |
264 | |
265 | # see if we have the patched libnet 1.1 | |
266 | # http://www.inliniac.net/blog/2007/10/16/libnet-11-ipv6-fixes-and-additions.html | |
a3510f20 | 267 | LLIBNET="" |
6e8c75ff WM |
268 | |
269 | #To prevent duping the lib link we reset LIBS after this check. Setting action-if-found to NULL doesn't seem to work | |
270 | #see: http://blog.flameeyes.eu/2008/04/29/i-consider-ac_check_lib-harmful | |
271 | TMPLIBS="${LIBS}" | |
a3510f20 | 272 | AC_CHECK_LIB(net, libnet_build_icmpv6_unreach,, LLIBNET="no") |
0ffa1c24 | 273 | if test "$LLIBNET" != "no"; then |
a3510f20 | 274 | CFLAGS="$CFLAGS -DHAVE_LIBNET_ICMPV6_UNREACH" |
0ffa1c24 | 275 | fi |
6e8c75ff | 276 | LIBS="${TMPLIBS}" |
0ffa1c24 | 277 | |
073d0421 WM |
278 | # libpfring (currently only supported for libpcap enabled pfring) |
279 | # Error on the side of caution. If libpfring enabled pcap is being used and we don't link against -lpfring compilation will fail. | |
280 | AC_ARG_WITH(libpfring_includes, | |
281 | [ --with-libpfring-includes=DIR libpfring include directory], | |
282 | [with_libpfring_includes="$withval"],[with_libpfring_includes=no]) | |
283 | AC_ARG_WITH(libpfring_libraries, | |
284 | [ --with-libpfring-libraries=DIR libpfring library directory], | |
285 | [with_libpfring_libraries="$withval"],[with_libpfring_libraries="no"]) | |
286 | ||
287 | if test "$with_libpfring_includes" != "no"; then | |
288 | CPPFLAGS="${CPPFLAGS} -I${with_libpfring_includes}" | |
289 | fi | |
290 | ||
291 | if test "$with_libpfring_libraries" != "no"; then | |
292 | LDFLAGS="${LDFLAGS} -L${with_libpfring_libraries}" | |
293 | fi | |
294 | ||
295 | LIBPFRING="" | |
296 | AC_CHECK_LIB(pfring, pfring_open,, LIBPFRING="no") | |
297 | ||
9c7f5afa | 298 | # libpcap |
a3510f20 WM |
299 | AC_ARG_WITH(libpcap_includes, |
300 | [ --with-libpcap-includes=DIR libpcap include directory], | |
301 | [with_libpcap_includes="$withval"],[with_libpcap_includes=no]) | |
302 | AC_ARG_WITH(libpcap_libraries, | |
303 | [ --with-libpcap-libraries=DIR libpcap library directory], | |
304 | [with_libpcap_libraries="$withval"],[with_libpcap_libraries="no"]) | |
305 | ||
306 | if test "$with_libpcap_includes" != "no"; then | |
6899b3da | 307 | CPPFLAGS="${CPPFLAGS} -I${with_libpcap_includes}" |
a3510f20 | 308 | fi |
6899b3da WM |
309 | |
310 | AC_CHECK_HEADER(pcap.h,,[AC_ERROR(pcap.h not found ...)]) | |
311 | ||
a3510f20 | 312 | if test "$with_libpcap_libraries" != "no"; then |
6899b3da | 313 | LDFLAGS="${LDFLAGS} -L${with_libpcap_libraries}" |
a3510f20 | 314 | fi |
6899b3da | 315 | |
a3510f20 WM |
316 | LIBPCAP="" |
317 | AC_CHECK_LIB(pcap, pcap_open_live,, LIBPCAP="no") | |
318 | if test "$LIBPCAP" = "no"; then | |
af992242 WM |
319 | echo |
320 | echo " ERROR! lipcap library not found, go get it" | |
321 | echo " from http://www.tcpdump.org." | |
322 | echo | |
323 | exit 1 | |
a3510f20 | 324 | fi |
af992242 WM |
325 | |
326 | # pcap_activate and pcap_create only exists in libpcap >= 1.0 | |
a3510f20 | 327 | LIBPCAPVTEST="" |
6e8c75ff WM |
328 | #To prevent duping the lib link we reset LIBS after this check. Setting action-if-found to NULL doesn't seem to work |
329 | #see: http://blog.flameeyes.eu/2008/04/29/i-consider-ac_check_lib-harmful | |
330 | TMPLIBS="${LIBS}" | |
a3510f20 | 331 | AC_CHECK_LIB(pcap, pcap_activate,, LPCAPVTEST="no") |
af992242 | 332 | if test "$LPCAPVTEST" != "no"; then |
a3510f20 | 333 | CFLAGS="${CFLAGS} `pcap-config --defines` `pcap-config --cflags` -DLIBPCAP_VERSION_MAJOR=1" |
af992242 | 334 | else |
a3510f20 WM |
335 | CFLAGS="${CFLAGS} -DLIBPCAP_VERSION_MAJOR=0" |
336 | fi | |
6e8c75ff | 337 | LIBS="${TMPLIBS}" |
a3510f20 WM |
338 | |
339 | # enable the running of unit tests | |
e6400bf4 VJ |
340 | AC_ARG_ENABLE(unittests, |
341 | [ --enable-unittests Enable compilation of the unit tests], | |
342 | [ enable_unittests=yes | |
a3510f20 | 343 | ]) |
e6400bf4 VJ |
344 | if test "$enable_unittests" = "yes"; then |
345 | CFLAGS="${CFLAGS} -DUNITTESTS" | |
a3510f20 WM |
346 | fi |
347 | ||
0ffa1c24 WM |
348 | AC_SUBST(CFLAGS) |
349 | AC_SUBST(LDFLAGS) | |
350 | AC_SUBST(CPPFLAGS) | |
351 | ||
bab4b623 | 352 | AC_OUTPUT(Makefile src/Makefile) |
0ffa1c24 | 353 |