diff options
-rw-r--r-- | acinclude.m4 | 353 | ||||
-rw-r--r-- | configure.in | 194 | ||||
-rw-r--r-- | output/mysql/Makefile.am | 4 | ||||
-rw-r--r-- | output/pcap/Makefile.am | 4 | ||||
-rw-r--r-- | output/pgsql/Makefile.am | 4 | ||||
-rw-r--r-- | output/sqlite3/Makefile.am | 9 |
6 files changed, 382 insertions, 186 deletions
diff --git a/acinclude.m4 b/acinclude.m4 new file mode 100644 index 0000000..c371558 --- /dev/null +++ b/acinclude.m4 @@ -0,0 +1,353 @@ +dnl @synopsis CT_CHECK_POSTGRES_DB +dnl +dnl This macro tries to find the headers and libraries for the +dnl PostgreSQL database to build client applications. +dnl +dnl If includes are found, the variable PQINCPATH will be set. If +dnl libraries are found, the variable PQLIBPATH will be set. if no check +dnl was successful, the script exits with a error message. +dnl +dnl @category InstalledPackages +dnl @author Christian Toepp <c.toepp@gmail.com> +dnl @version 2005-12-30 +dnl @license AllPermissive + +AC_DEFUN([CT_CHECK_POSTGRES_DB], [ + +AC_ARG_WITH(pgsql, + [ --with-pgsql=PREFIX Prefix of your PostgreSQL installation], + [pg_prefix=$withval], [pg_prefix=]) +AC_ARG_WITH(pgsql-inc, + [ --with-pgsql-inc=PATH Path to the include directory of PostgreSQL], + [pg_inc=$withval], [pg_inc=]) +AC_ARG_WITH(pgsql-lib, + [ --with-pgsql-lib=PATH Path to the libraries of PostgreSQL], + [pg_lib=$withval], [pg_lib=]) + + +AC_SUBST(PQINCPATH) +AC_SUBST(PQLIBPATH) +AC_SUBST(PQLIBS) +PQLIBS=-lpq + +AC_MSG_CHECKING([for PostgreSQL pg_config program]) +for d in $pg_prefix/bin /usr/bin /usr/local/bin /usr/local/pgsql/bin /opt/pgsql/bin /opt/packages/pgsql/bin +do + if test -x $d/pg_config + then + AC_MSG_RESULT(found pg_config in $d) + PQINCPATH=`$d/pg_config --includedir` + PQLIBPATH=`$d/pg_config --libdir` + break + fi +done + +if test "$PQINCPATH" = ""; then + +if test "$pg_prefix" != ""; then + AC_MSG_CHECKING([for PostgreSQL includes in $pg_prefix/include]) + if test -f "$pg_prefix/include/libpq-fe.h" ; then + PQINCPATH="-I$pg_prefix/include" + AC_MSG_RESULT([yes]) + else + AC_MSG_ERROR(libpq-fe.h not found) + fi + AC_MSG_CHECKING([for PostgreSQL libraries in $pg_prefix/lib]) + if test -f "$pg_prefix/lib/libpq.so" ; then + PQLIBPATH="-L$pg_prefix/lib" + AC_MSG_RESULT([yes]) + else + AC_MSG_ERROR(libpq.so not found) + fi +else + if test "$pg_inc" != ""; then + AC_MSG_CHECKING([for PostgreSQL includes in $pg_inc]) + if test -f "$pg_inc/libpq-fe.h" ; then + PQINCPATH="-I$pg_inc" + AC_MSG_RESULT([yes]) + else + AC_MSG_ERROR(libpq-fe.h not found) + fi + fi + if test "$pg_lib" != ""; then + AC_MSG_CHECKING([for PostgreSQL libraries in $pg_lib]) + if test -f "$pg_lib/libpq.so" ; then + PQLIBPATH="-L$pg_lib" + AC_MSG_RESULT([yes]) + else + AC_MSG_ERROR(libpq.so not found) + fi + fi +fi + +fi + +if test "$PQINCPATH" = "" ; then + AC_CHECK_HEADER([libpq-fe.h], [], AC_MSG_ERROR(libpq-fe.h not found)) +fi +if test "$PQLIBPATH" = "" ; then + AC_CHECK_LIB(pq, PQconnectdb, [], AC_MSG_ERROR(libpq.so not found)) +fi + +]) + +dnl @synopsis CT_CHECK_MYSQL_DB +dnl +dnl This macro tries to find the headers and librariess for the +dnl MySQL database to build client applications. +dnl +dnl If includes are found, the variable MYSQL_INC will be set. If +dnl libraries are found, the variable MYSQL_LIB will be set. if no check +dnl was successful, the script exits with a error message. +dnl +dnl @category InstalledPackages +dnl @author Harald Welte <laforge@gnumonks.org> +dnl @version 2006-01-07 +dnl @license AllPermissive + +AC_DEFUN([CT_CHECK_MYSQL_DB], [ + +AC_ARG_WITH(mysql, + [ --with-mysql=PREFIX Prefix of your MySQL installation], + [my_prefix=$withval], [my_prefix=]) +AC_ARG_WITH(mysql-inc, + [ --with-mysql-inc=PATH Path to the include directory of MySQL], + [my_inc=$withval], [my_inc=]) +AC_ARG_WITH(mysql-lib, + [ --with-mysql-lib=PATH Path to the libraries of MySQL], + [my_lib=$withval], [my_lib=]) + + +AC_SUBST(MYSQL_INC) +AC_SUBST(MYSQL_LIB) + +AC_MSG_CHECKING([for MySQL mysql_config program]) +for d in $my_prefix/bin /usr/bin /usr/local/bin /usr/local/mysql/bin /opt/mysql/bin /opt/packages/mysql/bin +do + if test -x $d/mysql_config + then + AC_MSG_RESULT(found mysql_config in $d) + MYSQL_INC=`$d/mysql_config --include` + MYSQL_LIB=`$d/mysql_config --libs` + break + fi +done + +if test "$MYSQL_INC" = ""; then + +if test "$my_prefix" != ""; then + AC_MSG_CHECKING([for MySQL includes in $my_prefix/include]) + if test -f "$my_prefix/include/mysql.h" ; then + MYSQL_INC="-I$my_prefix/include" + AC_MSG_RESULT([yes]) + else + AC_MSG_ERROR(mysql.h not found) + fi + AC_MSG_CHECKING([for MySQL libraries in $my_prefix/lib]) + if test -f "$my_prefix/lib/libmysql.so" ; then + MYSQL_LIB="-L$my_prefix/lib -lmysqlclient" + AC_MSG_RESULT([yes]) + else + AC_MSG_ERROR(libmysqlclient.so not found) + fi +else + if test "$my_inc" != ""; then + AC_MSG_CHECKING([for MySQL includes in $my_inc]) + if test -f "$my_inc/mysql.h" ; then + MYSQL_INC="-I$my_inc" + AC_MSG_RESULT([yes]) + else + AC_MSG_ERROR(mysql.h not found) + fi + fi + if test "$my_lib" != ""; then + AC_MSG_CHECKING([for MySQL libraries in $my_lib]) + if test -f "$my_lib/libmysqlclient.so" ; then + MYSQL_LIB="-L$my_lib -lmysqlclient" + AC_MSG_RESULT([yes]) + else + AC_MSG_ERROR(libmysqlclient.so not found) + fi + fi +fi + +fi + +if test "$MYSQL_INC" = "" ; then + AC_CHECK_HEADER([mysql.h], [], AC_MSG_ERROR(mysql.h not found)) +fi +if test "$MYSQL_LIB" = "" ; then + AC_CHECK_LIB(mysqlclient, mysql_close, [], AC_MSG_ERROR(libmysqlclient.so not found)) +fi + +]) + +dnl @synopsis CT_CHECK_PCAP +dnl +dnl This macro tries to find the headers and libraries for libpcap. +dnl +dnl If includes are found, the variable PCAP_INC will be set. If +dnl libraries are found, the variable PCAP_LIB will be set. if no check +dnl was successful, the script exits with a error message. +dnl +dnl @category InstalledPackages +dnl @author Harald Welte <laforge@gnumonks.org> +dnl @version 2006-01-07 +dnl @license AllPermissive + +AC_DEFUN([CT_CHECK_PCAP], [ + +AC_ARG_WITH(pcap, + [ --with-pcap=PREFIX Prefix of your libpcap installation], + [pcap_prefix=$withval], [pcap_prefix=]) +AC_ARG_WITH(pcap-inc, + [ --with-pcap-inc=PATH Path to the include directory of pcap], + [pcap_inc=$withval], [pcap_inc=/usr/include]) +AC_ARG_WITH(pcap-lib, + [ --with-pcap-lib=PATH Path to the libraries of pcap], + [pcap_lib=$withval], [pcap_lib=/usr/lib]) + + +AC_SUBST(PCAP_INC) +AC_SUBST(PCAP_LIB) + +if test "$pcap_prefix" != ""; then + AC_MSG_CHECKING([for libpcap includes in $pcap_prefix/include]) + if test -f "$pcap_prefix/include/pcap.h" ; then + PCAP_INC="-I$pcap_prefix/include" + AC_MSG_RESULT([yes]) + else + AC_MSG_ERROR(pcap.h not found) + fi + AC_MSG_CHECKING([for libpcap in $pcap_prefix/lib]) + if test -f "$pcap_prefix/lib/libpcap.so" ; then + PCAP_LIB="-L$pcap_prefix/lib -lpcap"; + AC_MSG_RESULT([yes]) + else + AC_MSG_ERROR(libpcap.so not found) + fi +else + if test "$pcap_inc" != ""; then + AC_MSG_CHECKING([for libpcap includes in $pcap_inc]) + if test -f "$pcap_inc/pcap.h" ; then + PCAP_INC="-I$pcap_inc" + AC_MSG_RESULT([yes]) + else + AC_MSG_ERROR(pcap.h not found) + fi + fi + if test "$pcap_lib" != ""; then + AC_MSG_CHECKING([for libpcap in $pcap_lib]) + if test -f "$pcap_lib/libpcap.so" ; then + PCAP_LIB="-L$pcap_lib -lpcap"; + AC_MSG_RESULT([yes]) + else + AC_MSG_ERROR(libpcap.so not found) + fi + fi +fi + +if test "$PCAP_INC" = "" ; then + AC_CHECK_HEADER([pcap.h], [], AC_MSG_ERROR(pcap.h not found)) +fi +if test "$PCAP_LIB" = "" ; then + AC_CHECK_LIB(pcap, pcap_close, [], AC_MSG_ERROR(libpcap.so not found)) +fi + +]) + +dnl @synopsis CT_CHECK_SQLITE3_DB +dnl +dnl This macro tries to find the headers and libraries for the +dnl SQLITE3 database to build client applications. +dnl +dnl If includes are found, the variable SQLITE3_INC will be set. If +dnl libraries are found, the variable SQLITE3_LIB will be set. if no check +dnl was successful, the script exits with a error message. +dnl +dnl @category InstalledPackages +dnl @author Harald Welte <laforge@gnumonks.org> +dnl @version 2006-01-07 +dnl @license AllPermissive + +AC_DEFUN([CT_CHECK_SQLITE3_DB], [ + +AC_ARG_WITH(sqlite3, + [ --with-sqlitee=PREFIX Prefix of your SQLITE3 installation], + [sqlite3_prefix=$withval], [sqlite3_prefix=]) +AC_ARG_WITH(sqlite3-inc, + [ --with-sqlite3-inc=PATH Path to the include directory of MySQL], + [sqlite3_inc=$withval], [sqlite3_inc=]) +AC_ARG_WITH(sqlite3-lib, + [ --with-sqlite3-lib=PATH Path to the libraries of MySQL], + [sqlite3_lib=$withval], [sqlite3_lib=]) + + +AC_SUBST(SQLITE3_INC) +AC_SUBST(SQLITE3_LIB) + +AC_MSG_CHECKING([for MySQL sqlite3_config program]) +for d in $sqlite3_prefix/bin /usr/bin /usr/local/bin /usr/local/sqlite3/bin /opt/sqlite3/bin /opt/packages/sqlite3/bin +do + if test -x $d/pkg-config + then + AC_MSG_RESULT(found pkg-config in $d) + $d/pkg-config --exists sqlite3 + if test "$?" != "0"; then + AC_MSG_RESULT(pkg-config doesn't know sqlite3) + break + fi + SQLITE3_INC=`$d/pkg-config --cflags sqlite3` + SQLITE3_LIB=`$d/pkg-config --libs sqlite3` + break + fi +done + +if test "$SQLITE3_INC" = ""; then + +if test "$sqlite3_prefix" != ""; then + AC_MSG_CHECKING([for SQLITE3 includes in $sqlite3_prefix/include]) + if test -f "$sqlite3_prefix/include/sqlite3.h" ; then + SQLITE3_INC="-I$sqlite3_prefix/include" + AC_MSG_RESULT([yes]) + else + AC_MSG_ERROR(sqlite3.h not found) + fi + AC_MSG_CHECKING([for SQLITE3 libraries in $sqlite3_prefix/lib]) + if test -f "$sqlite3_prefix/lib/libsqlite3.so" ; then + SQLITE3_LIB="-L$sqlite3_prefix/lib -lsqlite3" + AC_MSG_RESULT([yes]) + else + AC_MSG_ERROR(libsqlite3.so not found) + fi +else + if test "$sqlite3_inc" != ""; then + AC_MSG_CHECKING([for SQLITE3 includes in $sqlite3_inc]) + if test -f "$sqlite3_inc/sqlite3.h" ; then + SQLITE3_INC="-I$sqlite3_inc" + AC_MSG_RESULT([yes]) + else + AC_MSG_ERROR(sqlite3.h not found) + fi + fi + if test "$sqlite3_lib" != ""; then + AC_MSG_CHECKING([for SQLITE3 libraries in $sqlite3_lib]) + if test -f "$sqlite3_lib/libsqlite3.so" ; then + SQLITE3_LIB="-L$sqlite3_lib -lsqlite3" + AC_MSG_RESULT([yes]) + else + AC_MSG_ERROR(libsqlite3.so not found) + fi + fi +fi + +fi + +if test "$SQLITE3_INC" = "" ; then + AC_CHECK_HEADER([sqlite3.h], [], AC_MSG_ERROR(sqlite3.h not found)) +fi +if test "$SQLITE3_LIB" = "" ; then + AC_CHECK_LIB(sqlite3, sqlite3_close, [], AC_MSG_ERROR(libsqlite3.so not found)) +fi + +]) diff --git a/configure.in b/configure.in index fc758e2..55e877c 100644 --- a/configure.in +++ b/configure.in @@ -34,189 +34,23 @@ AC_CHECK_HEADER([libnetfilter_log/linux_nfnetlink_log.h], [AC_MSG_RESULT([found] AC_CHECK_HEADER([libnetfilter_conntrack/libnetfilter_conntrack.h], [AC_MSG_RESULT([found])], [AC_MSG_ERROR([libnetfilter_conntrack Version 0.0.11 or later needed])]) -DATABASE_DIR="" -DATABASE_LIB="" -DATABASE_LIB_DIR="" -DATABASE_DRIVERS="" +CT_CHECK_POSTGRES_DB() +CT_CHECK_MYSQL_DB() +CT_CHECK_SQLITE3_DB() +CT_CHECK_PCAP() -dnl -dnl test for MySQL -dnl -AC_ARG_WITH(mysql, - --with-mysql=<directory> mysql installed in <directoty>,[ -if test $withval != yes -then - dir=$withval -else - dir="/usr/local" -fi -mysqldir="" -AC_MSG_CHECKING(for MySQL files) -for d in $dir /usr /usr/local /usr/local/mysql /opt/mysql /opt/packages/mysql -do - if test -f $d/lib/mysql/libmysqlclient.so - then - AC_MSG_RESULT(found mysql in $d) - mysqldir=$d - mysqldir_suffix=/mysql - break - elif test -f $d/lib/libmysqlclient.so - then - AC_MSG_RESULT(found mysql in $d) - mysqldir=$d - mysqldir_suffix= - break - fi -done +dnl AC_SUBST(DATABASE_DIR) +dnl AC_SUBST(DATABASE_LIB) +dnl AC_SUBST(DATABASE_LIB_DIR) +dnl AC_SUBST(DB_DEF) +dnl AC_SUBST(EXTRA_MYSQL_DEF) +dnl AC_SUBST(EXTRA_PGSQL_DEF) -if test x$mysqldir = x -then - AC_MSG_WARN(MySQL backend not used) -else - AC_DEFINE([HAVE_MYSQL], [], [Description]) - MYSQLINCLUDES=${mysqldir}/include${mysqldir_suffix} - MYSQLLIBS=${mysqldir}/lib${mysqldir_suffix} +dnl AC_SUBST(DATABASE_DRIVERS) +dnl AC_SUBST(HAVE_PCAP_H) - DATABASE_DIR="${DATABASE_DIR} mysql" - - MYSQL_LIB="${DATABASE_LIB} -lmysqlclient " - DATABASE_LIB_DIR="${DATABASE_LIB_DIR} -L${MYSQLLIBS} " - - DATABASE_DRIVERS="${DATABASE_DRIVERS} ../mysql/mysql_driver.o " - - DB_DEF="${DB_DEF} -DHAVE_MYSQL " - - - AC_SUBST(MYSQLINCLUDES) - AC_SUBST(MYSQL_LIB) - - if test -f $MYSQLLIBS/libmystrings.so - then - DATABASE_LIB="${DATABASE_LIB} -lmystrings " - else - MYSQLEXTRALIBS= - fi - - dnl Here we check whether we have an old MySQL client library - dnl installed, which does not support the mysql_real_escape_string(), - dnl but the real_escape_string() function. - dnl Having a look in the libary itself should be more reliable than - dnl parsing the output of mysql --version. - - AC_MSG_CHECKING(for mysql_real_escape_string support) - - MYSQL_FUNCTION_TEST=`strings ${MYSQLLIBS}/libmysqlclient.so | grep mysql_real_escape_string` - - if test "x$MYSQL_FUNCTION_TEST" = x - then - EXTRA_MYSQL_DEF="OLD_MYSQL=1 " - AC_MSG_RESULT(found old MySQL) - else - AC_MSG_RESULT(found new MySQL) - fi - -fi -]) - - -dnl -dnl Check whether the user wants log IP-addresses as strings rather -dnl than as unsigned long-integers to his MySQL-database. Since this -dnl feature is only used in ulogd_MYSQL.c, there are no checks in any -dnl way. -dnl - -AC_ARG_WITH(mysql-log-ip-as-string, - --with-mysql-log-ip-as-string log IPs as string rather than as - unsigned long-integer. -,[ - EXTRA_MYSQL_DEF="-D${EXTRA_MYSQL_DEF} -DIP_AS_STRING=1" - AC_MSG_WARN(the use of --with-mysql-log-ip-as-string is discouraged) -]) - - -dnl -dnl test for PostgreSQL -dnl -AC_ARG_WITH(pgsql, - --with-pgsql=<directory> pgsql installed in <directoty>,[ -if test $withval != yes -then - dir=$withval -else - dir="/usr/local" -fi -pgsqldir="" -AC_MSG_CHECKING(for PGSQL files) -for d in $dir /usr /usr/local /usr/local/pgsql /opt/pgsql /opt/packages/pgsql -do - if test -f $d/lib/pgsql/libpq.so - then - AC_MSG_RESULT(found pgsql in $d) - pgsqldir=$d - break - elif test -f $d/lib/libpq.so - then - AC_MSG_RESULT(found pgsql in $d) - pgsqldir=$d - break - fi -done - -if test x$pgsqldir = x -then - AC_MSG_WARN(PGSQL backend not used) -else - AC_DEFINE([HAVE_PGSQL], [], [Description]) - for i in include include/postgresql include/pgsql - do - if test -f ${pgsqldir}/$i/libpq-fe.h - then - PGSQLINCLUDES=${pgsqldir}/$i - break - fi - done - PGSQLLIBS=${pgsqldir}/lib - - DATABASE_DIR="${DATABASE_DIR} pgsql" - - PGSQL_LIB="${DATABASE_LIB} -lpq " - DATABASE_LIB_DIR="${DATABASE_LIB_DIR} -L${PGSQLLIBS} " - - DB_DEF="${DB_DEF} -DHAVE_PGSQL " - - AC_SUBST(PGSQLINCLUDES) - AC_SUBST(PGSQL_LIB) - -fi -]) - -dnl -dnl Check whether the user wants to log IP-addresses as strings rather -dnl than integers to his pgsql-database. -dnl - -AC_ARG_WITH(pgsql-log-ip-as-string, - --with-pgsql-log-ip-as-string log IPs as string rather than as interger -,[ - EXTRA_PGSQL_DEF="-DIP_AS_STRING=1" -]) - - - - -AC_SUBST(DATABASE_DIR) -AC_SUBST(DATABASE_LIB) -AC_SUBST(DATABASE_LIB_DIR) -AC_SUBST(DB_DEF) -AC_SUBST(EXTRA_MYSQL_DEF) -AC_SUBST(EXTRA_PGSQL_DEF) - -AC_SUBST(DATABASE_DRIVERS) -AC_SUBST(HAVE_PCAP_H) - -AM_CONDITIONAL(HAVE_MYSQL, test x$mysqldir != x) -AM_CONDITIONAL(HAVE_PGSQL, test x$pgsqldir != x) +dnl AM_CONDITIONAL(HAVE_MYSQL, test x$mysqldir != x) +dnl AM_CONDITIONAL(HAVE_PGSQL, test x$pgsqldir != x) AC_OUTPUT(doc/Makefile libipulog/Makefile input/Makefile input/packet/Makefile input/flow/Makefile filter/Makefile filter/raw2packet/Makefile filter/packet2flow/Makefile output/Makefile output/pcap/Makefile output/mysql/Makefile output/pgsql/Makefile src/Makefile Makefile Rules.make) diff --git a/output/mysql/Makefile.am b/output/mysql/Makefile.am index b6730c0..3684ec3 100644 --- a/output/mysql/Makefile.am +++ b/output/mysql/Makefile.am @@ -1,6 +1,6 @@ -INCLUDES = $(all_includes) -I$(top_srcdir)/include -LIBS=-lmysqlclient_r +INCLUDES = $(all_includes) $(MYSQL_INC) +LIBS=$(MYSQL_LIB) pkglib_LTLIBRARIES = ulogd_output_MYSQL.la diff --git a/output/pcap/Makefile.am b/output/pcap/Makefile.am index b4bdb99..f2d9a67 100644 --- a/output/pcap/Makefile.am +++ b/output/pcap/Makefile.am @@ -1,6 +1,6 @@ -INCLUDES = $(all_includes) -I$(top_srcdir)/include -LIBS=-lpcap +INCLUDES = $(all_includes) $(PCAP_INC) +LIBS=$(PCAP_LIB) pkglib_LTLIBRARIES = ulogd_output_PCAP.la diff --git a/output/pgsql/Makefile.am b/output/pgsql/Makefile.am index 3de6b2c..6e2a6a4 100644 --- a/output/pgsql/Makefile.am +++ b/output/pgsql/Makefile.am @@ -1,6 +1,6 @@ -INCLUDES = $(all_includes) -I$(top_srcdir)/include -I$(PGSQLINCLUDES) -LIBS=$(PGSQL_LIB) +INCLUDES = $(all_includes) -I$(top_srcdir)/include -I$(PQINCPATH) +LIBS=$(PQLIBS) pkglib_LTLIBRARIES = ulogd_output_PGSQL.la diff --git a/output/sqlite3/Makefile.am b/output/sqlite3/Makefile.am new file mode 100644 index 0000000..0760814 --- /dev/null +++ b/output/sqlite3/Makefile.am @@ -0,0 +1,9 @@ + +INCLUDES = $(all_includes) $(SQLITE3_INC) +LIBS=$(SQLITE3_LIB) + +pkglib_LTLIBRARIES = ulogd_output_SQLITE3.la + +ulogd_output_SQLITE3_la_SOURCES = ulogd_output_SQLITE3.c ../../util/db.c +ulogd_output_SQLITE3_la_LDFLAGS = -module + |