1# -*- mode: m4; -*-
2# -*- Autoconf -*-
3# Process this file with autoconf to produce a configure script.
4# nepenthes meta-Makefile
5# Maximillian Dornseif 2005
6# $Id: configure.ac 1549 2008-02-14 11:45:25Z common $
7
8AC_PREREQ(2.59)
9AC_INIT([nepenthes], [0.2.2], [nepenthesdev@gmail.com])
10AM_INIT_AUTOMAKE([nepenthes], [0.2.2])
11AC_REVISION([$Id: configure.ac 1549 2008-02-14 11:45:25Z common $])
12
13AC_PREFIX_DEFAULT(/opt/nepenthes)
14AC_CONFIG_SRCDIR([nepenthes-core/include/Buffer.hpp])
15AM_CONFIG_HEADER([config.h])
16# AM_MAINTAINER_MODE
17
18AM_CONDITIONAL(NDEBUG, test "$disable_debug" = yes)
19AM_CONDITIONAL(PROFILE, test "$enable_profile" = yes)
20
21AC_CANONICAL_HOST
22AC_C_CONST
23AC_C_BIGENDIAN
24
25dnl Check for some target-specific stuff
26case "$host" in
27*-*-freebsd*)
28  # FreeBSD forgot to  install magic.h in a sane location. Bug or Feature?
29  CPPFLAGS="$CPPFLAGS -I/usr/local/include -I/usr/src/contrib/file/"
30  LDFLAGS="$LDFLAGS -L/usr/local/lib -R/usr/local/lib"
31  ;;
32*-*-linux*)
33  CPPFLAGS="$CPPFLAGS -D _GNU_SOURCE -I/usr/local/include"
34  LDFLAGS="$LDFLAGS -L/usr/local/lib -R/usr/local/lib"
35  ;;
36*-*-darwin*)
37  CPPFLAGS="$CPPFLAGS -I/opt/local/include"
38  LDFLAGS="$LDFLAGS -L/opt/local/lib"
39  if test "$GCC" = "yes"; then
40          CFLAGS="$CFLAGS -no-cpp-precomp"
41  fi
42  ;;
43esac
44
45# Checks for programs.
46AC_PROG_CXX
47AC_PROG_CC
48AC_PROG_MAKE_SET
49AC_PROG_LIBTOOL
50AC_PROG_YACC
51AC_PROG_LEX
52
53# Checks for header files.
54#AC_HEADER_DIRENT
55#AC_HEADER_STDC
56#AC_HEADER_SYS_WAIT
57#AC_HEADER_TIME
58#AC_HEADER_STDBOOL
59
60AC_CHECK_HEADERS([getopt.h arpa/inet.h fcntl.h memory.h netdb.h netinet/in.h stdlib.h string.h strings.h sys/ioctl.h sys/socket.h sys/time.h sys/timeb.h unistd.h])
61
62dnl   We ought not to have to worry about getopt.h, getopt{,1}.c,
63dnl   since they can always be unconditionally compiled and linked.  See
64dnl   http://mail.gnu.org/archive/html/autoconf/2000-12/msg00049.html
65dnl   and surrounding thread for discussion.  However that doesn't
66dnl   appear to work in fact, and the function in getopt_long.c has
67dnl   different magic to avoid getting horribly tangled up.
68AC_CHECK_FUNCS(getopt)
69AC_CHECK_DECLS([getopt,getsubopt,getopt_long,setenv,putenv])
70AC_REPLACE_FUNCS(getopt_long getsubopt)
71
72dnl   getopt_long.c uses (and provides a replacement for)
73dnl   this glibc utility function
74AC_CHECK_FUNCS(__strchrnul)
75
76
77# Checks for typedefs, structures, and compiler characteristics.
78AC_C_INLINE
79AC_TYPE_UID_T
80AC_STRUCT_TM
81AC_TYPE_SIZE_T
82AC_TYPE_SIGNAL
83
84
85AC_CHECK_SIZEOF(long)
86AC_CHECK_SIZEOF(off_t)
87
88AC_MSG_CHECKING([for SIGPOLL])
89AC_EGREP_CPP(we_have_sigpoll,
90[#include <signal.h>
91#ifdef SIGPOLL
92we_have_sigpoll
93#endif
94], AC_DEFINE([HAVE_SIGPOLL], [1], [Define to 1 if you have the sigpoll signal.]) haveSIGPOLL=yes, haveSIGPOLL=no)
95AC_MSG_RESULT([$haveSIGPOLL])
96
97AC_MSG_CHECKING([for SIGCLD])
98AC_EGREP_CPP(we_have_sigcld,
99[#include <signal.h>
100#ifdef SIGCLD
101we_have_sigcld
102#endif
103], AC_DEFINE([HAVE_SIGCLD], [1], [Define to 1 if you have the sigcld signal.]) haveSIGCLD=yes, haveSIGCLD=no)
104AC_MSG_RESULT([$haveSIGCLD])
105
106AC_MSG_CHECKING([for SIGPWR])
107AC_EGREP_CPP(we_have_sigpwr,
108[#include <signal.h>
109#ifdef SIGPWR
110we_have_sigpwr
111#endif
112], AC_DEFINE([HAVE_SIGPWR], [1], [Define to 1 if you have the sigpwr signal.]) haveSIGPWR=yes, haveSIGPWR=no)
113AC_MSG_RESULT([$haveSIGPWR])
114
115AC_MSG_CHECKING([for SIGSTKFLT])
116AC_EGREP_CPP(we_have_sigstkflt,
117[#include <signal.h>
118#ifdef SIGSTKFLT
119we_have_sigstkflt
120#endif
121], AC_DEFINE([HAVE_SIGSTKFLT], [1], [Define to 1 if you have the sigstkflt signal.]) haveSIGSTKFLT=yes, haveSIGSTKFLT=no)
122AC_MSG_RESULT([$haveSIGSTKFLT])
123
124AC_MSG_CHECKING([for SIGUNUSED])
125AC_EGREP_CPP(we_have_sigunused,
126[#include <signal.h>
127#ifdef SIGUNUSED
128we_have_sigunused
129#endif
130], AC_DEFINE([HAVE_SIGUNUSED], [1], [Define to 1 if you have the sigunused signal.]) haveSIGUNUSED=yes, haveSIGUNUSED=no)
131AC_MSG_RESULT([$haveSIGUNUSED])
132
133AC_MSG_CHECKING([for SIGINFO])
134AC_EGREP_CPP(we_have_siginfo,
135[#include <signal.h>
136#ifdef SIGINFO
137we_have_siginfo
138#endif
139], AC_DEFINE([HAVE_SIGINFO], [1], [Define to 1 if you have the siginfo signal.]) haveSIGINFO=yes, haveSIGINFO=no)
140AC_MSG_RESULT([$haveSIGINFO])
141
142AC_MSG_CHECKING([for SO_NOSIGPIPE])
143AC_EGREP_CPP(we_have_sonosigpipe,
144[#include <sys/socket.h>
145#ifdef SO_NOSIGPIPE
146we_have_sonosigpipe
147#endif
148], AC_DEFINE([HAVE_SO_NOSIGPIPE], [1], [Define to 1 if you have the SO_NOSIGPIPE socketoption.]) haveSO_NOSIGPIPE=yes, haveSO_NOSIGPIPE=no)
149AC_MSG_RESULT([$haveSO_NOSIGPIPE])
150
151AC_MSG_CHECKING(for MSG_NOSIGNAL)
152AC_EGREP_CPP(we_have_MSG_NOSIGNAL,
153[#include <linux/socket.h>
154#ifdef MSG_NOSIGNAL
155we_have_MSG_NOSIGNAL
156#endif
157], AC_DEFINE([HAVE_MSG_NOSIGNAL], [1], [Define to 1 if you have the MSG_NOSIGNAL socket flag.]) haveMSG_NOSIGNAL=yes, haveMSG_NOSIGNAL=no)
158AC_MSG_RESULT([$haveMSG_NOSIGNAL])
159
160# Checks for library functions.
161AC_FUNC_ERROR_AT_LINE
162AC_TYPE_SIGNAL
163AC_CHECK_FUNCS([strndup alarm bzero gethostbyname gethostname gettimeofday inet_ntoa localtime_r memmove memset munmap select socket strcasecmp strdup strerror strncasecmp strstr strtoul setresgid setresuid])
164
165
166# libadns
167AC_SUBST([LIB_ADNS])
168
169# libpcre
170AC_SUBST([LIB_PCRE])
171
172# libcurl
173AC_SUBST([LIB_CURL])
174
175# libcapabilities
176AC_SUBST([LIB_CAP])
177
178# libmagic
179AC_SUBST([LIB_MAGIC])
180
181# libpq
182AC_SUBST([LIB_POSTGRES])
183
184# libprelude
185AC_SUBST([LIB_PRELUDE])
186AC_SUBST([LDFLAG_PRELUDE])
187AC_SUBST([CPPFLAG_PRELUDE])
188
189# libipq
190AC_SUBST([LIB_IPQ])
191
192# libpcap
193AC_SUBST([LIB_PCAP])
194
195# libnet
196AC_SUBST([LIB_LIBNET])
197
198# liby
199AC_SUBST([LIB_LIBY])
200
201# libdl
202AC_SUBST([LIB_DL])
203
204# libssh
205AC_SUBST([LIB_SSH])
206
207# libemu
208AC_SUBST([LIB_EMU])
209
210
211dnl **************************************************
212dnl * libdl linking flag                             *
213dnl **************************************************
214
215enable_dl=no;
216AC_CHECK_FUNC([dlopen],enable_dl="yes", enable_dl="no")
217
218if test x$enable_dl = "xno" ; then
219	AC_CHECK_LIB([dl],[dlopen],enable_dl="yes", enable_dl="no")
220	if test x$enable_dl = "xyes" ; then
221		LIB_DL="-ldl"
222	fi
223fi
224
225if test x$enable_dl = "xno" ; then
226	AC_CHECK_LIB([ldld],[dlopen],enable_dl="yes", enable_dl="no")
227	if test x$enable_dl = "xyes" ; then
228		LIB_DL="-ldl"
229	fi
230fi
231
232
233
234dnl **************************************************
235dnl * libipq support                                 *
236dnl **************************************************
237
238enable_ipq="yes"
239
240AC_ARG_ENABLE(ipq, [  --enable-ipq	enable support for libipq],
241		    [enable_ipq="$enableval"],[enable_ipq="yes"])
242
243AC_ARG_WITH(ipq-include,
244                      [  --with-ipq-include=DIR  libipq include dir],
245                      [ipq_inc="$withval"],[ipq_inc=no])
246AC_ARG_WITH(ipq-lib,
247                      [  --with-ipq-lib=DIR  libipq library dir],
248                      [ipq_lib="$withval"],[ipq_lib=no])
249
250
251if test x$enable_ipq = "xyes" ; then
252        if test x$ipq_inc != "xno"; then
253		CPPFLAGS="${CPPFLAGS} -I${ipq_inc}"
254	fi
255
256	AC_CHECK_HEADER(libipq.h,[enable_ipq=yes],[enable_ipq=no])
257
258	if test x$enable_ipq = "xyes" ; then
259		if test x$ipq_lib != "xno"; then
260			LDFLAGS="${LDFLAGS}  -L${ipq_lib}"
261		fi
262
263		AC_CHECK_LIB([ipq],[ipq_set_mode],enable_ipq="yes", enable_ipq="no")
264
265		if test x$enable_ipq = "xyes" ; then
266			LIB_IPQ="-lipq"
267			AC_DEFINE([HAVE_IPQ], [1], [Define to 1 if you have ip queue on linux])
268		fi
269	fi
270fi
271
272
273dnl **************************************************
274dnl * pcap support                                   *
275dnl **************************************************
276
277AC_ARG_ENABLE(pcap, [  --enable-pcap	enable support for packet capture library],
278		    [enable_pcap="$enableval"],[enable_pcap="yes"])
279
280
281AC_ARG_WITH(pcap_include,
282	[  --with-pcap-include=DIR  pcap include directory],
283	[pcap_inc="$withval"],[pcap_inc=no])
284
285AC_ARG_WITH(pcap_lib,
286	[  --with-pcap-lib=DIR  pcap library directory],
287	[pcap_lib="$withval"],[pcap_lib=no])
288
289if test x$enable_pcap = xyes; then
290	if test "$pcap_inc" != "no"; then
291	   CPPFLAGS="${CPPFLAGS} -I${pcap_inc}"
292	fi
293
294	AC_CHECK_HEADER(pcap.h,[enable_pcap=yes],[enable_pcap=no])
295
296	if test x$enable_pcap != "xno"; then
297
298		if test "$pcap_lib" != "no"; then
299			LDFLAGS="${LDFLAGS}  -L${pcap_lib}"
300		fi
301
302		AC_CHECK_LIB([pcap],[pcap_open_live],enable_pcap="yes", enable_pcap="no")
303		if test x$enable_pcap = "xyes" ; then
304			LIB_PCAP="-lpcap"
305			AC_DEFINE([HAVE_PCAP], [1], [Define to 1 if you have packet capture library])
306		fi
307	fi
308
309fi
310
311
312
313dnl **************************************************
314dnl * ipfw support                                   *
315dnl **************************************************
316
317AC_ARG_ENABLE(ipfw,
318[  --enable-ipfw            enable support for ipfw Divert on FreeBSD],
319                enable_ipfw="$enableval", enable_ipfw=no)
320
321if test x$enable_ipfw = "xyes"; then
322	AC_DEFINE([HAVE_IPFW], [1], [Define to 1 if you want ipfw divert on FreeBSD])
323fi
324
325
326
327dnl **************************************************
328dnl * debug logging                                  *
329dnl **************************************************
330AC_ARG_ENABLE(debug-logging, [  --enable-debug-logging		spam the console and logfile with all debug information  [default=no]],
331		    enable_debug_logging="$enableval", enable_debug_logging="no")
332
333if test x$enable_debug_logging = "xyes"; then
334	AC_DEFINE([HAVE_DEBUG_LOGGING], [1], [Define to 1 if you need debug logging])
335fi
336
337
338# Checks for generic libraries.
339
340dnl **************************************************
341dnl * libcurl Support                                *
342dnl **************************************************
343AC_ARG_WITH(curl-include,
344    [  --with-curl-include=PATH	specify path to curl include files],
345    [curl_inc=$withval],
346    [curl_inc=no])
347
348AC_ARG_WITH(curl-lib,
349    [  --with-curl-lib=PATH	specify path to curl client library],
350    [curl_lib=$withval],
351    [curl_lib=no])
352
353if test xyes = "xyes"; then
354
355    AC_PATH_PROG(LIBCURL_CONFIG, curl-config, no)
356    if test "$LIBCURL_CONFIG" = "no" ; then
357	AC_MSG_ERROR([libcurl curl-config was not found in PATH])
358    fi
359
360
361    if test "x$curl_inc" != xno; then
362      CPPFLAGS="-I$curl_inc $CPPFLAGS"
363    fi
364
365    if test "x$curl_lib" != "xno"; then
366        LDFLAGS="-L$curl_lib $LDFLAGS"
367    fi
368
369    orig_cppflags=$CPPFLAGS
370    orig_libs=$LIBS
371
372    CPPFLAGS="$CPPFLAGS `curl-config --cflags`"
373    LIBS="$LIBS `curl-config --libs`"
374
375
376    AC_CHECK_LIB([curl], [curl_version],
377             [AC_DEFINE(HAVE_LIBCURL, 1,
378                       [Define if you want to use libcurl])
379             LIB_CURL="`curl-config --libs` -lcurl"],
380             [AC_MSG_ERROR([libcurl is missing - install it please])
381             ])
382
383    CPPFLAGS=$orig_cppflags
384    LIBS=$orig_libs
385fi
386
387
388dnl **************************************************
389dnl * libpcre Support                                *
390dnl **************************************************
391
392AC_ARG_WITH(pcre-include,
393    [  --with-pcre-include=PATH		specify path to pcre include files],
394    [pcre_inc=$withval],
395    [pcre_inc=no])
396
397AC_ARG_WITH(pcre-lib,
398    [  --with-pcre-lib=PATH	specify path to pcre client library],
399    [pcre_lib=$withval],
400    [pcre_lib=no])
401
402if test xyes = "xyes"; then
403    orig_cppflags=$CPPFLAGS
404
405    if test "x$pcre_inc" != xno; then
406      CPPFLAGS="-I$pcre_inc $CPPFLAGS"
407    fi
408
409    orig_ldflags=$LDFLAGS
410    if test "x$pcre_lib" != "xno"; then
411        LDFLAGS="-L$pcre_lib $LDFLAGS"
412    fi
413
414    AC_CHECK_LIB([pcre], [pcre_compile],
415             [AC_DEFINE(HAVE_LIBPCRE, 1,
416                        [Define if you want to use libpcre])
417              LIB_PCRE="-lpcre"],
418             [AC_MSG_ERROR([libpcre is missing - install it please])
419             ])
420fi
421
422dnl **************************************************
423dnl * libmagic Support                               *
424dnl **************************************************
425
426AC_ARG_WITH(magic-include,
427    [  --with-magic-include=PATH		specify path to magic include files],
428    [magic_inc=$withval],
429    [magic_inc=no])
430
431AC_ARG_WITH(magic-lib,
432    [  --with-magic-lib=PATH	specify path to magic client library],
433    [magic_lib=$withval],
434    [magic_lib=no])
435
436if test xyes = "xyes"; then
437    orig_cppflags=$CPPFLAGS
438
439    if test "x$magic_inc" != xno; then
440      CPPFLAGS="-I$magic_inc $CPPFLAGS"
441    fi
442
443    orig_ldflags=$LDFLAGS
444    if test "x$magic_lib" != "xno"; then
445        LDFLAGS="-L$magic_lib $LDFLAGS"
446    fi
447
448
449    orig_libs=$LIBS
450    LIBS="-lz $LIBS"
451
452    AC_CHECK_LIB([magic], [magic_open],
453             [AC_DEFINE(HAVE_LIBMAGIC, 1,
454                       [Define if you want to use libmagic])
455              LIB_MAGIC="-lmagic -lz"],
456             [AC_MSG_ERROR([libmagic is missing - install it please])
457             ])
458
459    LIBS=$orig_libs
460
461    AC_CHECK_HEADERS(magic.h)
462fi
463
464
465
466dnl **************************************************
467dnl * libssh Support                                 *
468dnl **************************************************
469
470AC_MSG_CHECKING(for libssh)
471
472AC_ARG_ENABLE(libssh, [  --enable-ssh	Enable Support for ssh[default=auto]],
473		    enable_ssh="$enableval", enable_ssh="yes")
474
475AC_ARG_WITH(ssh-lib,
476    [  --with-ssh-lib=PATH	specify path to ssh client library],
477    [ssh_lib=$withval],
478    [ssh_lib=no])
479AC_ARG_WITH(ssh-include,
480    [  --with-ssh-include=PATH	specify path to ssh include files],
481    [ssh_inc=$withval],
482    [ssh_inc=no])
483
484
485if test x$enable_ssh = xyes; then
486  dnl **************************************************
487  dnl * ssh headers                                  *
488  dnl **************************************************
489
490  orig_cppflags=$CPPFLAGS
491
492  if test "x$ssh_inc" != xno; then
493    CPPFLAGS="-I$ssh_inc $CPPFLAGS"
494  fi
495
496  AC_CHECK_HEADER(libssh.h, [found=yes], [found=no])
497
498
499  if test "x$found" != "xno"; then
500
501    dnl **************************************************
502    dnl * ssh lib                                      *
503    dnl **************************************************
504
505    orig_ldflags=$LDFLAGS
506    if test "x$ssh_lib" != "xno"; then
507        LDFLAGS="-L$ssh_lib $LDFLAGS"
508    fi
509    AC_CHECK_LIB([ssh], [ssh_bind_new],[found=yes], [found=no])
510
511    if test "x$found" != "xyes"; then
512        LDFLAGS=$orig_ldflags
513    fi
514  else
515     CPPFLAGS=$orig_cppflags
516
517  fi
518
519  if test "x$found" != "xyes"; then
520    enable_ssh=no
521  else
522    AC_DEFINE(HAVE_LIBSSH,1,[Define wether we have libssh])
523    LIB_SSH="-lssh"
524  fi
525
526fi
527
528
529dnl **************************************************
530dnl * mysql Support                                  *
531dnl **************************************************
532
533AC_ARG_WITH(mysql-lib,
534    [  --with-mysql-lib=PATH	specify path to MySQL client library],
535    [mysql_lib=$withval],
536    [mysql_lib=no])
537AC_ARG_WITH(mysql-include,
538    [  --with-mysql-include=PATH	specify path to MySQL include files],
539    [mysql_inc=$withval],
540    [mysql_inc=no])
541
542AC_ARG_ENABLE(mysql, [  --enable-mysql	Enable Support [default=auto]],
543		    enable_mysql="$enableval", enable_mysql="no")
544
545
546if test x$enable_mysql = xyes; then
547
548  AC_MSG_CHECKING(for mysql client library)
549
550
551
552  dnl **************************************************
553  dnl * mysql headers                                  *
554  dnl **************************************************
555
556  orig_cppflags=$CPPFLAGS
557
558  if test "x$mysql_inc" != xno; then
559    CPPFLAGS="-I$mysql_inc $CPPFLAGS"
560  fi
561
562  AC_CHECK_HEADER(mysql.h, [found=yes], [found=no])
563
564  if test "x$found" != "xno"; then
565
566
567    dnl **************************************************
568    dnl * mysql lib                                      *
569    dnl **************************************************
570
571    orig_ldflags=$LDFLAGS
572    if test "x$mysql_lib" != "xno"; then
573        LDFLAGS="-L$mysql_lib $LDFLAGS"
574    fi
575    AC_CHECK_LIB(mysqlclient, mysql_real_connect, [found=yes], [found=no])
576
577    if test "x$found" != "xyes"; then
578        LDFLAGS=$orig_ldflags
579    fi
580  else
581     CPPFLAGS=$orig_cppflags
582
583  fi
584
585  if test "x$found" != "xyes"; then
586    enable_mysql=no
587  else
588    AC_DEFINE(HAVE_MYSQL, 1 , [Define if we have mysql client library])
589    LIB_MYSQL="-lmysqlclient"
590  fi
591
592  AC_MSG_RESULT($enable_mysql)
593fi
594
595
596
597
598dnl **************************************************
599dnl * postgre Support                                  *
600dnl **************************************************
601
602AC_ARG_WITH(postgre-lib,
603    [  --with-postgre-lib=PATH	specify path to PostGRE client library],
604    [postgre_lib=$withval],
605    [postgre_lib=no])
606AC_ARG_WITH(postgre-include,
607    [  --with-postgre-include=PATH	specify path to PostGRE include files],
608    [postgre_inc=$withval],
609    [postgre_inc=no])
610
611AC_ARG_ENABLE(postgre, [  --enable-postgre	Enable Support [default=auto]],
612		    enable_postgre="$enableval", enable_postgre="no")
613
614
615if test x$enable_postgre = xyes; then
616
617  AC_MSG_CHECKING(for postgre client library)
618
619
620
621  dnl **************************************************
622  dnl * postgre headers                                  *
623  dnl **************************************************
624
625  orig_cppflags=$CPPFLAGS
626
627  if test "x$postgre_inc" != xno; then
628    CPPFLAGS="-I$postgre_inc $CPPFLAGS"
629  fi
630
631  AC_CHECK_HEADER(libpq-fe.h, [found=yes], [found=no])
632
633  if test "x$found" != "xno"; then
634
635
636    dnl **************************************************
637    dnl * postgre lib                                      *
638    dnl **************************************************
639
640    orig_ldflags=$LDFLAGS
641    if test "x$postgre_lib" != "xno"; then
642        LDFLAGS="-L$postgre_lib $LDFLAGS"
643    fi
644    AC_CHECK_LIB(pq, PQsetdbLogin, [found=yes], [found=no])
645
646    if test "x$found" != "xyes"; then
647        LDFLAGS=$orig_ldflags
648    fi
649  else
650     CPPFLAGS=$orig_cppflags
651
652  fi
653
654  if test "x$found" != "xyes"; then
655    enable_postgre=no
656  else
657    AC_DEFINE(HAVE_POSTGRES, 1 , [Define if we have postgre client library])
658    LIB_POSTGRES="-lpq"
659
660    have_pqserverversion=no
661    AC_CHECK_LIB(pq,PQserverVersion,[have_pqserverversion=yes],[have_pqserverversion=no])
662    if test "x$have_pqserverversion" != "xno"; then
663      AC_DEFINE(HAVE_PQSERVERVERSION, 1 , [Define if libpq supports PQserverVersion])
664    fi
665
666  fi
667
668fi
669
670
671
672dnl **************************************************
673dnl * libemu support                                  *
674dnl **************************************************
675
676AC_ARG_WITH(emu-lib,
677    [  --with-emu-lib=PATH	specify path to libemu library],
678    [emu_lib=$withval],
679    [emu_lib=no])
680AC_ARG_WITH(emu-include,
681    [  --with-emu-include=PATH	specify path to libemu include files],
682    [emu_inc=$withval],
683    [emu_inc=no])
684
685AC_ARG_ENABLE(emu, [  --enable-emu	Enable Support [default=auto]],
686		    enable_emu="$enableval", enable_emu="no")
687
688
689if test x$enable_emu = xyes; then
690
691  AC_MSG_CHECKING(for libemu - x86 emulation library)
692
693  dnl **************************************************
694  dnl * emu headers                                  *
695  dnl **************************************************
696
697  orig_cppflags=$CPPFLAGS
698
699  if test "x$emu_inc" != xno; then
700    CPPFLAGS="-I$emu_inc $CPPFLAGS"
701  fi
702
703  AC_CHECK_HEADER(emu/emu.h, [found=yes], [found=no])
704
705  if test "x$found" != "xno"; then
706
707
708    dnl **************************************************
709    dnl * emu lib                                      *
710    dnl **************************************************
711
712    orig_ldflags=$LDFLAGS
713    if test "x$emu_lib" != "xno"; then
714        LDFLAGS="-L$emu_lib $LDFLAGS"
715    fi
716    AC_CHECK_LIB(emu, emu_new, [found=yes], [found=no])
717
718    if test "x$found" != "xyes"; then
719        LDFLAGS=$orig_ldflags
720    fi
721  else
722     CPPFLAGS=$orig_cppflags
723
724  fi
725
726  if test "x$found" != "xyes"; then
727    enable_emu=no
728  else
729    AC_DEFINE(HAVE_EMU, 1 , [Define if we have emu client library])
730    LIB_EMU="-lemu"
731  fi
732fi
733
734
735
736
737dnl **************************************************
738dnl * large filesystem Support                       *
739dnl **************************************************
740
741AC_MSG_CHECKING(for Large File System support)
742AC_ARG_ENABLE(lfs,
743 AC_HELP_STRING([--enable-lfs],[Turn on Large File System (default)]),
744 [case "$host" in
745 *-*-linux*)
746 case "${enableval}" in
747    yes) CPPFLAGS="${CPPFLAGS} -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_LARGE_FILES" ;;
748     no) ;;
749      *) AC_MSG_ERROR(bad value ${enableval} for --enable-lfs) ;;
750   esac
751   ;;
752 esac],[
753 CPPFLAGS="${CPPFLAGS} -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_LARGE_FILES"
754 enable_lfs=yes]
755 ,enable_lfs=no,)
756AC_MSG_RESULT($enableval)
757
758
759
760dnl **************************************************
761dnl * dnsresolve Support                             *
762dnl **************************************************
763
764
765
766AC_ARG_ENABLE(dnsresolve_adns, [  --enable-dnsresolve-adns	Enable adns [default=yes]],
767		    enable_dnsresolve_adns="$enableval", enable_dnsresolve_adns="yes")
768
769dnl **************************************************
770dnl * libadns Support                                *
771dnl **************************************************
772AC_ARG_WITH(adns-include,
773    [  --with-adns-include=PATH	specify path to adns include files],
774    [adns_inc=$withval],
775    [adns_inc=no])
776
777AC_ARG_WITH(adns-lib,
778    [  --with-adns-lib=PATH	specify path to adns client library],
779    [adns_lib=$withval],
780    [adns_lib=no])
781
782if test x$enable_dnsresolve_adns = xyes; then
783    orig_cppflags=$CPPFLAGS
784
785    if test "x$adns_inc" != xno; then
786      CPPFLAGS="-I$adns_inc $CPPFLAGS"
787    fi
788
789    orig_ldflags=$LDFLAGS
790    if test "x$adns_lib" != "xno"; then
791        LDFLAGS="-L$adns_lib $LDFLAGS"
792    fi
793
794
795    AC_CHECK_LIB([adns], [adns_init],
796           [AC_DEFINE(HAVE_LIBADNS, 1,
797                      [Define if you want to use adns])
798            LIB_ADNS="-ladns"],
799     enable_dnsresolve_adns=no
800   )
801fi
802
803if test x$enable_dnsresolve_adns = xno; then
804  AC_MSG_ERROR([at least one dnsresolver has to work])
805fi
806
807
808
809#dnl **************************************************
810#dnl * ipv6 Support                                   *
811#dnl **************************************************
812#
813#AC_ARG_ENABLE(ipv6,
814#  [  --enable-ipv6          enable IPv6 support [default=auto].],
815#  [ if test "$enableval" = "no"; then
816#       enable_ipv6="no"
817#    fi ],
818#  [ enable_ipv6="yes" ] )
819#
820#
821#
822#if test x$enabled_ipv6 = xno ; then
823#    AC_MSG_RESULT([no -- disabled by user])
824#else
825#    enable_ipv6="no"
826#    AC_CHECK_FUNC(inet_pton,[enable_ipv6=yes])
827#    AC_CHECK_LIB(resolv,inet_pton,[enable_ipv6=yes])
828#    AC_MSG_CHECKING(for sockaddr_in6 in netinet/in.h)
829#    AC_EGREP_HEADER(sockaddr_in6,netinet/in.h,
830#    [AC_MSG_RESULT(yes)], [AC_MSG_RESULT(no); enable_ipv6="no"])
831#    if ${have_ipv6}; then
832#        AC_DEFINE(HAVE_IPV6, 1, Define if the system have IPv6 structures.)
833#    fi
834#fi
835
836
837
838
839dnl **************************************************
840dnl * libprelude Support                             *
841dnl **************************************************
842AC_MSG_CHECKING(whether to use prelude for logging)
843AC_ARG_ENABLE(prelude,
844  [  --enable-prelude          enable prelude support [default=no].],
845  [ if test "$enableval" = "yes"; then
846       enable_prelude="yes"
847    fi ],
848  [ enable_prelude="no" ] )
849
850if test x$enable_prelude = xno ; then
851    AC_MSG_RESULT([no -- disabled by user])
852else
853    AC_PATH_PROG(LIBPRELUDE_CONFIG, libprelude-config, no)
854    if test "$LIBPRELUDE_CONFIG" = "no" ; then
855	AC_MSG_ERROR([libpreludes libprelude-config was not found in PATH])
856	enable_prelude=no
857    else
858        AC_DEFINE(HAVE_LIBPRELUDE, 1,[Define if you want to use libprelude])
859	PRELUDE_LDFLAGS=`$LIBPRELUDE_CONFIG --ldflags`
860	PRELUDE_LIBS=`$LIBPRELUDE_CONFIG --libs`
861	PRELUDE_CPPFLAGS=`$LIBPRELUDE_CONFIG --pthread-cflags`
862
863	LIB_PRELUDE="$PRELUDE_LIBS"
864	LDFLAG_PRELUDE="$PRELUDE_LDFLAGS"
865	CPPFLAGS="$CPPFLAGS $PRELUDE_CPPFLAGS"
866    fi
867fi
868
869
870
871
872dnl **************************************************
873dnl * capabilities Support                           *
874dnl **************************************************
875
876AC_MSG_CHECKING(whether to use libcap to improve security)
877AC_ARG_ENABLE(capabilities, [  --enable-capabilities	Enable capabilities [default=auto]],
878		   [enable_capabilities="$enableval"],
879		   [enable_capabilities="yes"])
880
881if test x$enable_capabilities = xno ; then
882    AC_MSG_RESULT([no -- disabled by user])
883else
884    AC_ARG_WITH(cap-include,
885	[  --with-cap-include=PATH      use libcap],
886	[cap_inc=$withval],
887	[cap_inc=no])
888
889    AC_ARG_WITH(cap-lib,
890	[  --with-cap-lib=PATH       	use libcap],
891	[cap_lib=$withval],
892	[cap_lib=no])
893
894
895    orig_cppflags=$CPPFLAGS
896
897    if test "x$cap_inc" != xno; then
898      CPPFLAGS="-I$cap_inc $CPPFLAGS"
899    fi
900
901    orig_ldflags=$LDFLAGS
902    if test "x$cap_lib" != "xno"; then
903        LDFLAGS="-L$cap_lib $LDFLAGS"
904    fi
905
906    AC_CHECK_LIB(cap, cap_init,
907	[
908              AC_DEFINE(HAVE_LIBCAP, 1,[Define if libcap is available to restrict process capabilities])
909               LIB_CAP="-lcap"
910               enable_capabilities="yes"
911	],
912	[
913               AC_MSG_WARN([libcap check failed])
914               enable_capabilities="no (check failed)"
915	])
916
917fi
918
919dnl **************************************************
920dnl * liby existence                                 *
921dnl **************************************************
922
923AC_CHECK_LIB(y, yyerror,
924	[
925              LIB_LIBY="-ly"
926              enable_liby="yes"
927	],
928	[
929               enable_liby="no"
930	])
931
932
933
934
935AC_DEFUN([AC_DEFINE_DIR], [
936  prefix_NONE=
937  exec_prefix_NONE=
938  test "x$prefix" = xNONE && prefix_NONE=yes && prefix=$ac_default_prefix
939  test "x$exec_prefix" = xNONE && exec_prefix_NONE=yes && exec_prefix=$prefix
940dnl In Autoconf 2.60, ${datadir} refers to ${datarootdir}, which in turn
941dnl refers to ${prefix}.  Thus we have to use `eval' twice.
942  eval ac_define_dir="\"[$]$2\""
943  eval ac_define_dir="\"$ac_define_dir\""
944  AC_SUBST($1, "$ac_define_dir")
945  AC_DEFINE_UNQUOTED($1, "$ac_define_dir", [$3])
946  test "$prefix_NONE" && prefix=NONE
947  test "$exec_prefix_NONE" && exec_prefix=NONE
948])
949
950AC_DEFINE_DIR(PREFIX, prefix, [default working directory])
951AC_DEFINE_DIR(LOCALESTATEDIR, localstatedir, [where to put logs etc])
952AC_DEFINE_DIR(LIBDIR, libdir, [where to look for plugins])
953AC_DEFINE_DIR(SYSCONFDIR, [sysconfdir], [System configuration dir])
954
955AC_CONFIG_FILES([Makefile
956                 nepenthes-core/Makefile
957                 nepenthes-core/include/Makefile
958                 nepenthes-core/src/Makefile
959                 modules/Makefile
960                 modules/dnsresolve-adns/Makefile
961                 modules/download-creceive/Makefile
962                 modules/download-csend/Makefile
963                 modules/download-curl/Makefile
964                 modules/download-ftp/Makefile
965                 modules/download-http/Makefile
966                 modules/download-link/Makefile
967                 modules/download-rcp/Makefile
968                 modules/download-tftp/Makefile
969                 modules/log-download/Makefile
970                 modules/log-irc/Makefile
971                 modules/log-prelude/Makefile
972                 modules/log-surfnet/Makefile
973		 modules/module-bridge/Makefile
974                 modules/module-honeytrap/Makefile
975                 modules/module-portwatch/Makefile
976		 modules/module-peiros/Makefile
977                 modules/shellcode-generic/Makefile
978                 modules/shellcode-signatures/Makefile
979                 modules/shellemu-winnt/Makefile
980                 modules/sqlhandler-postgres/Makefile
981                 modules/submit-file/Makefile
982                 modules/submit-gotek/Makefile
983                 modules/submit-norman/Makefile
984                 modules/submit-postgres/Makefile
985                 modules/submit-http/Makefile
986                 modules/submit-mwserv/Makefile
987                 modules/vuln-asn1/Makefile
988                 modules/vuln-bagle/Makefile
989                 modules/vuln-dameware/Makefile
990                 modules/vuln-dcom/Makefile
991                 modules/vuln-ftpd/Makefile
992                 modules/vuln-iis/Makefile
993                 modules/vuln-kuang2/Makefile
994                 modules/vuln-lsass/Makefile
995                 modules/vuln-msdtc/Makefile
996                 modules/vuln-msmq/Makefile
997                 modules/vuln-mssql/Makefile
998                 modules/vuln-mydoom/Makefile
999                 modules/vuln-netbiosname/Makefile
1000                 modules/vuln-netdde/Makefile
1001                 modules/vuln-optix/Makefile
1002                 modules/vuln-pnp/Makefile
1003                 modules/vuln-realvnc/Makefile
1004                 modules/vuln-sasserftpd/Makefile
1005		 modules/vuln-sav/Makefile
1006                 modules/vuln-ssh/Makefile
1007                 modules/vuln-sub7/Makefile
1008                 modules/vuln-upnp/Makefile
1009                 modules/vuln-veritas/Makefile
1010                 modules/vuln-wins/Makefile
1011                 modules/x-1/Makefile
1012                 modules/x-2/Makefile
1013                 modules/x-3/Makefile
1014                 modules/x-4/Makefile
1015                 modules/x-5/Makefile
1016                 modules/x-6/Makefile
1017                 modules/x-9/Makefile
1018                 modules/log-hexdump/Makefile
1019		 ])
1020#		 modules/shellcode-emulation/Makefile
1021#		 modules/module-upnp/Makefile
1022#		 modules/log-prelude/Makefile
1023#                modules/module-drone/Makefile
1024#		 modules/log-surfnet/Makefile])
1025#                modules/vuln-netbios/Makefile
1026#                 modules/module-baitnswitch/Makefile
1027#		 modules/dnsresolve-udns/Makefile
1028
1029AC_OUTPUT
1030
1031echo
1032echo "*** Dumping Nepenthes Configuration ***"
1033echo "- Debug Logging               : $enable_debug_logging"
1034echo ""
1035echo "- link on liby                : $enable_liby"
1036echo ""
1037echo "- DNS Resolve                 "
1038echo "  - Support adns              : $enable_dnsresolve_adns"
1039echo ""
1040echo "- Support Large Filesystem    : $enable_lfs"
1041echo ""
1042echo "- Support MySQL               : $enable_mysql"
1043echo ""
1044echo "- Support PostgreSQL          : $enable_postgre"
1045echo ""
1046echo "- Support ssh                 : $enable_ssh"
1047echo ""
1048echo "- Support prelude             : $enable_prelude"
1049echo ""
1050echo "- Support capabilities        : $enable_capabilities"
1051echo ""
1052echo "- Packet Monitoring/Sniffing"
1053echo "  - linux ip_queue (ipq)      : $enable_ipq"
1054echo "  - FBSD ipfw Divert sockets  : $enable_ipfw"
1055echo "  - Packet Capture Lib (pcap) : $enable_pcap"
1056
1057# echo ""
1058# echo "- Support ipv6                : $enable_ipv6"
1059