dnl Process this file with autoconf to produce a configure script. AC_INIT(src) AC_PREREQ(2.53) AC_CANONICAL_SYSTEM AM_INIT_AUTOMAKE(prelude-manager, 0.8.10) AM_CONFIG_HEADER(config.h) AM_DISABLE_STATIC AM_MAINTAINER_MODE AM_PROG_LIBTOOL dnl Checks for programs. AC_PROG_CC AC_PROG_CPP AC_PROG_INSTALL AC_PROG_MAKE_SET AC_C_INLINE AC_C_BIGENDIAN AC_SUBST(CPPFLAGS) AC_SUBST(LDFLAGS) if test "x$prefix" = "xNONE"; then prefix="/usr/local" fi if test "x$localstatedir" = "x\${prefix}/var"; then localstatedir="$prefix/var" fi if test "x$sysconfdir" = "x\${prefix}/etc"; then sysconfdir="$prefix/etc" fi if test "x$datadir" = "x\${prefix}/share"; then datadir="$prefix/share" fi dnl ************************************************** dnl * Check for libprelude * dnl ************************************************** AC_PATH_GENERIC(libprelude, 0.8.9, , AC_MSG_ERROR(Cannot find libprelude: Is libprelude-config in the path?) ) pthread_cflags=`$LIBPRELUDE_CONFIG --pthread-cflags` defined="$defined $LIBPRELUDE_CFLAGS $pthread_cflags" dnl ************************************************** dnl * Check for OpenSSL. * dnl ************************************************** AC_ARG_ENABLE(openssl, [ --enable-openssl Enable OpenSSL support [default=auto]], enable_openssl="$enableval", enable_openssl=yes) if test x$enable_openssl = xyes; then AC_CHECK_HEADER(openssl/ssl.h, openssl_header=yes) if test x$openssl_header = xyes; then AC_DEFINE_UNQUOTED(HAVE_SSL, , Define wether OpenSSL is available on this system) enable_openssl=yes else enable_openssl=no fi fi dnl *************************************************** dnl * Check for the MySQL library (MySQL plugin * dnl *************************************************** # Check for mysql_config. If it is not found, look for mysql libraries # and headers in standard places AC_REAL_PATH_GENERIC(mysql, mysql_config, , cflags, libs, , mysql_use=true, mysql_use=false) if test x$mysql_use = xfalse; then for dir in /usr/lib /usr/lib/mysql /usr/local/lib \ /usr/local/lib/mysql; do AC_CHECK_FILE($dir/libmysqlclient.so, mysql_dir=$dir) done if test $mysql_dir ; then mysql_use=true; MYSQL_LIBS="-L$mysql_dir -lmysqlclient" fi for dir in /usr/include /usr/include/mysql /usr/local/include \ /usr/local/include/mysql; do AC_CHECK_HEADER($dir/mysql.h, mysql_inc=$dir) done if test $mysql_inc ; then MYSQL_CFLAGS=-I$mysql_inc else mysql_use=false; fi fi if test x$mysql_use = xtrue; then # mysql_config --libs outputs -L'directory' instead of -Ldirectory # and escaped version fools gcc in AC_CHECK_LIB so we must remove # apostrophes temp_mysql_flags=`echo $MYSQL_LIBS | sed -e s/\'//g` # this is needed for correct linking. If we don't add mysql library # flags to CFLAGS the test will always fail due to a linker error CFLAGS_bak=$CFLAGS CFLAGS="$CFLAGS $temp_mysql_flags" # restore the normal setting CFLAGS=$CFLAGS_bak fi AC_ARG_ENABLE(mysql, [ --enable-mysql Enable MySQL plugin [default=auto]], enable_mysql="$enableval", enable_mysql=yes) if test x$enable_mysql = xyes; then if test x$mysql_use = xtrue; then enable_mysql=yes; else enable_mysql=no; fi fi AM_CONDITIONAL(HAVE_MYSQL, test x$enable_mysql = xyes) AC_SUBST(HAVE_MYSQL) AC_SUBST(MYSQL_LIBS) AC_SUBST(MYSQL_CFLAGS) dnl ******************************************************** dnl * Check for the PostgreSQL library (PostgreSQL plugin) * dnl ******************************************************** AC_ARG_ENABLE(pgsql, [ --enable-pgsql Enable PostgreSQL plugin [default=auto]], enable_pgsql="$enableval", enable_pgsql=yes) if test x$enable_pgsql = xyes; then AC_REAL_PATH_GENERIC(pgsql, pg_config, , includedir, libdir, , have_pgsql=true, have_pgsql=false) if test x$have_pgsql = xtrue; then AC_CHECK_HEADER($PGSQL_CFLAGS/libpq-fe.h, pgsql_hdr=true) fi if test x$have_pgsql = xtrue && test x$pgsql_hdr = xtrue; then enable_pgsql=yes; else enable_pgsql=no; fi fi AM_CONDITIONAL(HAVE_PGSQL, test x$enable_pgsql = xyes) AC_SUBST(HAVE_PGSQL) dnl ******************************************************** dnl * Check for the Libxml2 * dnl ******************************************************** AC_PATH_GENERIC(xml2, , enable_xmlmod=yes, enable_xmlmod=no) AM_CONDITIONAL(HAVE_XML2, test x$enable_xmlmod = xyes) AC_SUBST(HAVE_XML2) dnl ************************************************** dnl * Do we need aligned access ? (from tcpdump) * dnl ************************************************** AC_MSG_CHECKING(if unaligned accesses fail) AC_CACHE_VAL(ac_cv_lbl_unaligned_fail, [case "$host_cpu" in # XXX: should also check that they don't do weird things (like on arm) alpha*|arm*|hp*|mips*|sparc*|ia64) ac_cv_lbl_unaligned_fail=yes ;; *) cat >conftest.c < # include # include unsigned char a[[5]] = { 1, 2, 3, 4, 5 }; main() { unsigned int i; pid_t pid; int status; /* avoid "core dumped" message */ pid = fork(); if (pid < 0) exit(2); if (pid > 0) { /* parent */ pid = waitpid(pid, &status, 0); if (pid < 0) exit(3); exit(!WIFEXITED(status)); } /* child */ i = *(unsigned int *)&a[[1]]; printf("%d\n", i); exit(0); } EOF ${CC-cc} -o conftest $CFLAGS $CPPFLAGS $LDFLAGS \ conftest.c $LIBS >/dev/null 2>&1 if test ! -x conftest ; then dnl failed to compile for some reason ac_cv_lbl_unaligned_fail=yes else ./conftest >conftest.out if test ! -s conftest.out ; then ac_cv_lbl_unaligned_fail=yes else ac_cv_lbl_unaligned_fail=no fi fi rm -f conftest* core core.conftest ;; esac]) AC_MSG_RESULT($ac_cv_lbl_unaligned_fail) if test $ac_cv_lbl_unaligned_fail = yes ; then AC_DEFINE_UNQUOTED(NEED_ALIGNED_ACCESS, , Define wether your system require memory aligned access) fi dnl ************************************************** dnl * Check for GTK-DOC * dnl ************************************************** AC_ARG_WITH(html-dir, [ --with-html-dir=PATH path to installed docs ]) if test "x$with_html_dir" = "x" ; then HTML_DIR='${datadir}/gtk-doc/html'; else HTML_DIR=$with_html_dir; fi AC_SUBST(HTML_DIR) AC_CHECK_PROG(GTKDOC, gtkdoc-mkdb, true, false) gtk_doc_min_version=0.6 if $GTKDOC; then gtk_doc_version=`gtkdoc-mkdb --version` AC_MSG_CHECKING([gtk-doc version ($gtk_doc_version) >= $gtk_doc_min_version]) if perl << EOF ; then exit (("$gtk_doc_version" =~ /^[[0-9]]+\.[[0-9]]+$/) && ("$gtk_doc_version" >= "$gtk_doc_min_version") ? 0 : 1); EOF AC_MSG_RESULT(yes); else AC_MSG_RESULT(no); GTKDOC=false; fi fi dnl Let people disable the gtk-doc stuff. AC_ARG_ENABLE(gtk-doc, [ --enable-gtk-doc Use gtk-doc to build documentation [default=no]], enable_gtk_doc="$enableval", enable_gtk_doc=no) AM_CONDITIONAL(ENABLE_GTK_DOC, test x$enable_gtk_doc = xyes) dnl ************************************************** dnl * Html dir ? * dnl ************************************************** if test "x$with_html_dir" = "x" ; then HTML_DIR='${datadir}/doc/prelude/html' else HTML_DIR=$with_html_dir fi AC_SUBST(HTML_DIR) dnl ************************************************** dnl * TCP WRAPPER CHECK * dnl ************************************************** AC_CHECK_HEADER(tcpd.h, have_tcpd_header=yes) if test x$have_tcpd_header = xyes; then AC_MSG_CHECKING(whether to use TCP wrappers) for tcpd_lib_path in /usr/lib /usr/local/lib; do if test -f $tcpd_lib_path/libwrap.a; then libwrap="$tcpd_lib_path/libwrap.a" break fi done if test -n "$libwrap"; then AC_MSG_RESULT(yes) else AC_MSG_RESULT(no) fi AC_CHECK_LIB(nsl, yp_get_default_domain, libnsl="-lnsl") AC_MSG_CHECKING(whether -lwrap require -lnsl) tcpd_ldflags="-L$tcpd_lib_path $libwrap" orig_libs=$LIBS LIBS="$LIBS $tcpd_ldflags" AC_TRY_LINK([extern int hosts_access; int allow_severity, deny_severity;], [return hosts_access;], [have_tcp_wrapper=yes libnsl=""], [LIBS="$LIBS $libnsl" AC_TRY_LINK([extern int hosts_access; int allow_severity, deny_severity;], [return hosts_access;], have_tcp_wrapper=yes) ]) if test -n "$libnsl"; then AC_MSG_RESULT(yes) else AC_MSG_RESULT(no) fi LIBWRAP_LIBS="$LIBS" LIBS=$orig_libs if test x$have_tcp_wrapper = xyes; then AC_DEFINE_UNQUOTED(HAVE_TCP_WRAPPERS, , Define wether you have TCP wrapper installed on your system) AC_SUBST(LIBWRAP_LIBS) fi fi dnl Add -no-cpp-precomp to avoid GNU macro extension parsing errors on OSX AC_MSG_CHECKING("whether we need to add -no-cpp-precomp") if test $host_cpu = "powerpc" && test $host_vendor = "apple"; then AC_MSG_RESULT(yes) CPPFLAGS="$CPPFLAGS -no-cpp-precomp" else AC_MSG_RESULT(no) fi dnl ************************************************** dnl * Check for socklen_t. * dnl ************************************************** AC_DATATYPE_GENERIC([ #include #include ], socklen_t, int size_t "unsigned long") dnl ************************************************** dnl * Check for Ipv6. * dnl ************************************************** AC_CHECK_TYPES([struct sockaddr_in], have_ipv6_type=yes,, [ #include #include #include ]) AC_CHECK_DECL(AF_INET6, have_ipv6_def=yes,, [ #include #include #include ]) if test x$have_ipv6_type = xyes && test x$have_ipv6_def = xyes; then AC_DEFINE_UNQUOTED(HAVE_IPV6, , Define wether Ipv6 is available on this system) fi dnl Checks for header files. AC_HEADER_DIRENT AC_HEADER_STDC dnl Checks for typedefs, structures, and compiler characteristics. AC_C_CONST AC_TYPE_PID_T AC_TYPE_SIZE_T AC_HEADER_TIME dnl Checks for library functions. AC_TYPE_SIGNAL AC_FUNC_VPRINTF AC_CHECK_FUNCS(gettimeofday select socket strdup strerror strstr) configdir=$sysconfdir/prelude-manager prelude_manager_conf=$configdir/prelude-manager.conf plugindir=$libdir/prelude-manager report_plugin_dir=$plugindir/reports decode_plugin_dir=$plugindir/decodes filter_plugin_dir=$plugindir/filters db_plugin_dir=$plugindir/db manager_fifo_dir=$localstatedir/spool/prelude-manager manager_data_dir=$datadir/prelude-manager AC_DEFINE_UNQUOTED(PRELUDE_MANAGER_CONFDIR, "$configdir", Define the Prelude Manager configuration directory) AC_DEFINE_UNQUOTED(PRELUDE_MANAGER_CONF, "$prelude_manager_conf", Define the Prelude Manager configuration file path) AC_SUBST(manager_data_dir) AC_SUBST(defined) AC_SUBST(configdir) AC_SUBST(localstatedir) AC_SUBST(prelude_manager_conf) AC_SUBST(report_plugin_dir) AC_SUBST(decode_plugin_dir) AC_SUBST(filter_plugin_dir) AC_SUBST(db_plugin_dir) AC_SUBST(LIBWRAP_LIBS) AC_SUBST(manager_fifo_dir) CFLAGS="$CFLAGS -Wall -Wmissing-prototypes -Wmissing-declarations \ -Wbad-function-cast -Wcast-qual -Wcast-align -Wnested-externs -Wunused" AC_SUBST(CFLAGS) AC_OUTPUT([ Makefile docs/Makefile docs/api/Makefile prelude-manager.conf prelude-manager-db-create.sh manager-adduser/Makefile src/Makefile src/include/Makefile plugins/Makefile plugins/db/Makefile plugins/db/mysql/Makefile plugins/db/pgsql/Makefile plugins/decodes/Makefile plugins/decodes/prelude-nids/Makefile plugins/filters/Makefile plugins/reports/Makefile plugins/reports/debug/Makefile plugins/reports/textmod/Makefile plugins/reports/xmlmod/Makefile ]) AC_CONFIG_COMMANDS([default],[[ chmod +x prelude-manager-db-create.sh ]],[[]]) dnl **** TODO add the following lines in above section **** dnl docs/Makefile dnl docs/api/Makefile dnl plugins/execmod/Makefile dnl plugins/filemod/Makefile dnl plugins/htmlmod/Makefile dnl plugins/xmlmod/Makefile echo echo "*** Dumping configuration ***" echo " - Enable OpenSSL : $enable_openssl" echo " - Generate documentation : $enable_gtk_doc" echo " - Enable MySQL plugin : $enable_mysql" echo " - Enable PostgreSQL plugin : $enable_pgsql"; echo " - Enable Xml plugin : $enable_xmlmod";