diff --git a/Makefile.in b/Makefile.in index e2f1290e..30599345 100644 --- a/Makefile.in +++ b/Makefile.in @@ -16,9 +16,9 @@ localstatedir = @localstatedir@ CC = @CC@ CFLAGS = @CFLAGS@ @CPPFLAGS@ DEFS = @defs@ -INCDIR = -I. @INCDIR@ @mysql_includes@ +INCDIR = -I. @INCDIR@ @sql_includes@ LIBDIR = -L. @LIBDIR@ @LDFLAGS@ -LIBS = @LIBS@ @mysql_libs@ +LIBS = @LIBS@ @sql_libs@ RUNNING_USER = @RUNNING_USER@ RUNNING_GROUP = `@id_bin@ -gn $(RUNNING_USER)` diff --git a/configure b/configure index 07fb9ef2..4157c797 100755 --- a/configure +++ b/configure @@ -623,13 +623,14 @@ ac_subst_vars='LTLIBOBJS LIBOBJS DATADIR CFGDIR +PSQL_CONFIG MYSQL_CONFIG iv id_bin libclamav_extra_libs -mysql_obj -mysql_libs -mysql_includes +sql_obj +sql_libs +sql_includes MAKE SUBDIRS RUNNING_USER @@ -699,6 +700,7 @@ enable_starttls enable_tcpwrappers enable_multitenancy enable_tweak_sent_time +with_database with_piler_user ' ac_precious_vars='build_alias @@ -1328,6 +1330,7 @@ Optional Features: Optional Packages: --with-PACKAGE[=ARG] use PACKAGE [ARG=yes] --without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no) + --with-database[=mysql|psql] use either mysql or psql database for storing data (default: none) --with-piler-user=username what user the piler daemon shall be run as Some influential environment variables: @@ -3436,6 +3439,7 @@ have_clamd="no" have_antivirus="no" have_mysql="no" +have_psql="no" have_tre="no" have_zip="no" have_zlib="no" @@ -3458,7 +3462,7 @@ antispam_libs="-lz -lm -ldl -lcrypto -lssl" defs="" objs="" user_obj="" -mysql_obj="" +sql_obj="" os=`uname -s` id_bin="id" @@ -4247,7 +4251,18 @@ if test "$have_zlib" = "no"; then fi -# Extract the first word of "mysql_config", so it can be a program name with args. + +# Check whether --with-database was given. +if test "${with_database+set}" = set; then : + withval=$with_database; + if test "$withval" != "no" -a "$withval" != "yes"; then + DATABASE=$withval + fi + + + if test "$withval" = "mysql"; then + + # Extract the first word of "mysql_config", so it can be a program name with args. set dummy mysql_config; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } @@ -4285,16 +4300,17 @@ fi -if test x$MYSQL_CONFIG = xyes; then - have_mysql="yes" -fi + if test x$MYSQL_CONFIG = xyes; then + have_mysql="yes" + fi -if test "$have_mysql" = "yes"; then + if test "$have_mysql" = "yes"; then - mysql_includes=`mysql_config --cflags` - mysql_libs=`mysql_config --libs_r` + sql_includes=`mysql_config --cflags` + sql_libs=`mysql_config --libs_r` + sql_obj="mysql.o" - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for main in -lguide" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for main in -lguide" >&5 $as_echo_n "checking for main in -lguide... " >&6; } if ${ac_cv_lib_guide_main+:} false; then : $as_echo_n "(cached) " >&6 @@ -4370,10 +4386,72 @@ fi fi ac_cv_lib_guide=ac_cv_lib_guide_main + else + echo "MySQL support is not found" + exit 1; + fi + fi + + + if test "$withval" = "psql"; then + + # Extract the first word of "pg_config", so it can be a program name with args. +set dummy pg_config; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_PSQL_CONFIG+:} false; then : + $as_echo_n "(cached) " >&6 else - echo "MySQL support is not found" - exit 1; + if test -n "$PSQL_CONFIG"; then + ac_cv_prog_PSQL_CONFIG="$PSQL_CONFIG" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_PSQL_CONFIG="yes" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + fi +fi +PSQL_CONFIG=$ac_cv_prog_PSQL_CONFIG +if test -n "$PSQL_CONFIG"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $PSQL_CONFIG" >&5 +$as_echo "$PSQL_CONFIG" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + + + if test x$PSQL_CONFIG = xyes; then + have_psql="yes" + fi + + if test "$have_psql" = "yes"; then + + sql_includes="-I`pg_config --includedir`" + sql_libs="-L`pg_config --libdir`" + sql_obj="psql.o" + + else + echo "PSQL support is not found" + exit 1; + fi + fi + + +fi + @@ -4449,6 +4527,12 @@ _ACEOF +if test "$have_mysql" = "no" && test "$have_psql" = "no"; then + echo + echo "please specify the used database with --with-database=..." + echo + exit 1 +fi @@ -4498,6 +4582,15 @@ fi echo +if test "$have_mysql" = "yes"; then + echo "database: mysql" +fi + +if test "$have_psql" = "yes"; then + echo "database: psql" +fi + + if test "$have_tre" = "yes"; then echo "tre library: yes" defs="$defs -DHAVE_TRE" @@ -4555,7 +4648,7 @@ if test "$have_mysql" = "yes"; then fi if test "$have_icc_guide" = "yes" && test "$have_mysql" = "yes"; then - mysql_libs="$mysql_libs -lguide" + sql_libs="$sql_libs -lguide" fi if test "$have_multitenancy" = "yes"; then @@ -4653,7 +4746,7 @@ echo; echo CFLAGS="$static -O2 -Wall -g" LIBS="$antispam_libs $sunos_libs " -OBJS="dirs.o base64.o misc.o counters.o cfg.o sig.o decoder.o list.o parser.o parser_utils.o rules.o session.o message.o attachment.o digest.o store.o archive.o tai.o import.o imap.o pop3.o extract.o mydomains.o retr.o mysql.o $objs" +OBJS="dirs.o base64.o misc.o counters.o cfg.o sig.o decoder.o list.o parser.o parser_utils.o rules.o session.o message.o attachment.o digest.o store.o archive.o tai.o import.o imap.o pop3.o extract.o mydomains.o retr.o $objs" ac_config_files="$ac_config_files Makefile src/Makefile etc/Makefile util/Makefile init.d/Makefile test/Makefile contrib/imap/Makefile" diff --git a/configure.in b/configure.in index 70190644..20a41063 100644 --- a/configure.in +++ b/configure.in @@ -24,9 +24,9 @@ AC_SUBST(OBJS) AC_SUBST(RUNNING_USER) AC_SUBST(SUBDIRS) AC_SUBST(MAKE) -AC_SUBST(mysql_includes) -AC_SUBST(mysql_libs) -AC_SUBST(mysql_obj) +AC_SUBST(sql_includes) +AC_SUBST(sql_libs) +AC_SUBST(sql_obj) AC_SUBST(libclamav_extra_libs) AC_SUBST(id_bin) AC_SUBST(iv) @@ -37,6 +37,7 @@ have_clamd="no" have_antivirus="no" have_mysql="no" +have_psql="no" have_tre="no" have_zip="no" have_zlib="no" @@ -59,7 +60,7 @@ antispam_libs="-lz -lm -ldl -lcrypto -lssl" defs="" objs="" user_obj="" -mysql_obj="" +sql_obj="" os=`uname -s` id_bin="id" @@ -182,23 +183,57 @@ if test "$have_zlib" = "no"; then fi -AC_CHECK_PROG(MYSQL_CONFIG, mysql_config, yes) +AC_ARG_WITH(database, +[ --with-database[[=mysql|psql]] use either mysql or psql database for storing data (default: none)],[ + if test "$withval" != "no" -a "$withval" != "yes"; then + DATABASE=$withval + fi -if test x$MYSQL_CONFIG = xyes; then - have_mysql="yes" -fi -if test "$have_mysql" = "yes"; then + if test "$withval" = "mysql"; then - mysql_includes=`mysql_config --cflags` - mysql_libs=`mysql_config --libs_r` + AC_CHECK_PROG(MYSQL_CONFIG, mysql_config, yes) - AC_CHECK_LIB([guide],[main],[AC_CHECK_LIB(guide, _intel_fast_memset, have_icc_guide=yes, have_icc_guide=no)],[],[])ac_cv_lib_guide=ac_cv_lib_guide_main + if test x$MYSQL_CONFIG = xyes; then + have_mysql="yes" + fi -else - echo "MySQL support is not found" - exit 1; -fi + if test "$have_mysql" = "yes"; then + + sql_includes=`mysql_config --cflags` + sql_libs=`mysql_config --libs_r` + sql_obj="mysql.o" + + AC_CHECK_LIB([guide],[main],[AC_CHECK_LIB(guide, _intel_fast_memset, have_icc_guide=yes, have_icc_guide=no)],[],[])ac_cv_lib_guide=ac_cv_lib_guide_main + + else + echo "MySQL support is not found" + exit 1; + fi + fi + + + if test "$withval" = "psql"; then + + AC_CHECK_PROG(PSQL_CONFIG, pg_config, yes) + + if test x$PSQL_CONFIG = xyes; then + have_psql="yes" + fi + + if test "$have_psql" = "yes"; then + + sql_includes="-I`pg_config --includedir`" + sql_libs="-L`pg_config --libdir`" + sql_obj="psql.o" + + else + echo "PSQL support is not found" + exit 1; + fi + fi + +]) @@ -257,6 +292,12 @@ AC_DEFINE_UNQUOTED(VIRUS_TEMPLATE, "$my_prefix/share/clapf/template.virus", [whe AC_DEFINE_UNQUOTED(ZOMBIE_NET_REGEX, "$my_prefix/share/clapf/zombienets.regex", [where the virus template is]) +if test "$have_mysql" = "no" && test "$have_psql" = "no"; then + echo + echo "please specify the used database with --with-database=..." + echo + exit 1 +fi dnl let us know if we are building on FreeBSD @@ -302,6 +343,15 @@ fi echo +if test "$have_mysql" = "yes"; then + echo "database: mysql" +fi + +if test "$have_psql" = "yes"; then + echo "database: psql" +fi + + if test "$have_tre" = "yes"; then echo "tre library: yes" defs="$defs -DHAVE_TRE" @@ -347,7 +397,7 @@ if test "$have_mysql" = "yes"; then fi if test "$have_icc_guide" = "yes" && test "$have_mysql" = "yes"; then - mysql_libs="$mysql_libs -lguide" + sql_libs="$sql_libs -lguide" fi if test "$have_multitenancy" = "yes"; then @@ -417,7 +467,7 @@ echo; echo CFLAGS="$static -O2 -Wall -g" LIBS="$antispam_libs $sunos_libs " -OBJS="dirs.o base64.o misc.o counters.o cfg.o sig.o decoder.o list.o parser.o parser_utils.o rules.o session.o message.o attachment.o digest.o store.o archive.o tai.o import.o imap.o pop3.o extract.o mydomains.o retr.o mysql.o $objs" +OBJS="dirs.o base64.o misc.o counters.o cfg.o sig.o decoder.o list.o parser.o parser_utils.o rules.o session.o message.o attachment.o digest.o store.o archive.o tai.o import.o imap.o pop3.o extract.o mydomains.o retr.o $objs" AC_CONFIG_FILES([Makefile src/Makefile etc/Makefile util/Makefile init.d/Makefile test/Makefile contrib/imap/Makefile]) AC_OUTPUT diff --git a/etc/Makefile.in b/etc/Makefile.in index 1d70bc17..77b50862 100644 --- a/etc/Makefile.in +++ b/etc/Makefile.in @@ -16,9 +16,9 @@ localstatedir = @localstatedir@ CC = @CC@ CFLAGS = @CFLAGS@ @CPPFLAGS@ DEFS = @defs@ -INCDIR = -I. -I../.. -I../../src @INCDIR@ @mysql_includes@ +INCDIR = -I. -I../.. -I../../src @INCDIR@ @sql_includes@ LIBDIR = -L. @LIBDIR@ @LDFLAGS@ -L../../src -LIBS = @LIBS@ @mysql_libs@ +LIBS = @LIBS@ @sql_libs@ RUNNING_USER = @RUNNING_USER@ RUNNING_GROUP = `@id_bin@ -gn $(RUNNING_USER)` diff --git a/src/Makefile.in b/src/Makefile.in index df72f90f..23433df2 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -16,11 +16,11 @@ localstatedir = @localstatedir@ CC = @CC@ CFLAGS = @CFLAGS@ @CPPFLAGS@ DEFS = @defs@ -INCDIR = -I. -I.. @INCDIR@ @mysql_includes@ +INCDIR = -I. -I.. @INCDIR@ @sql_includes@ LIBDIR = -L. @LIBDIR@ @LDFLAGS@ -LIBS = @LIBS@ @mysql_libs@ +LIBS = @LIBS@ @sql_libs@ OBJS = @OBJS@ -MYSQL_OBJS = @mysql_obj@ +SQL_OBJS = @sql_obj@ RUNNING_USER = @RUNNING_USER@ RUNNING_GROUP = `@id_bin@ -gn $(RUNNING_USER)` @@ -43,10 +43,10 @@ piler: piler.c libpiler.a pilergetd: pilergetd.c libpiler.a $(CC) $(CFLAGS) $(INCDIR) $(DEFS) -o $@ $< -lpiler $(LIBS) $(LIBDIR) @LDFLAGS@ @libclamav_extra_libs@ -libpiler.a: $(OBJS) $(MYSQL_OBJS) - ar cr libpiler.a $(OBJS) $(MYSQL_OBJS) +libpiler.a: $(OBJS) $(SQL_OBJS) + ar cr libpiler.a $(OBJS) $(SQL_OBJS) ranlib libpiler.a - $(CC) -shared -o libpiler.so.$(LIBPILER_VERSION) $(OBJS) $(MYSQL_OBJS) + $(CC) -shared -o libpiler.so.$(LIBPILER_VERSION) $(OBJS) $(SQL_OBJS) ln -sf libpiler.so.$(LIBPILER_VERSION) libpiler.so ln -sf libpiler.so.$(LIBPILER_VERSION) libpiler.so.$(PILER_VERSION) diff --git a/test/Makefile.in b/test/Makefile.in index c571a813..207622c0 100644 --- a/test/Makefile.in +++ b/test/Makefile.in @@ -16,9 +16,9 @@ localstatedir = @localstatedir@ CC = @CC@ CFLAGS = @CFLAGS@ @CPPFLAGS@ DEFS = @defs@ -INCDIR = -I. -I.. -I../.. -I../../src -I../src @INCDIR@ @mysql_includes@ +INCDIR = -I. -I.. -I../.. -I../../src -I../src @INCDIR@ @sql_includes@ LIBDIR = -L. @LIBDIR@ @LDFLAGS@ -L../src -LIBS = @LIBS@ @mysql_libs@ +LIBS = @LIBS@ @sql_libs@ RUNNING_USER = @RUNNING_USER@ RUNNING_GROUP = `@id_bin@ -gn $(RUNNING_USER)` OBJS = import_helper.o diff --git a/util/Makefile.in b/util/Makefile.in index 88b4e7ae..d2d05c69 100644 --- a/util/Makefile.in +++ b/util/Makefile.in @@ -16,9 +16,9 @@ localstatedir = @localstatedir@ CC = @CC@ CFLAGS = @CFLAGS@ @CPPFLAGS@ DEFS = @defs@ -INCDIR = -I. -I../.. -I../../src @INCDIR@ @mysql_includes@ +INCDIR = -I. -I../.. -I../../src @INCDIR@ @sql_includes@ LIBDIR = -L. @LIBDIR@ @LDFLAGS@ -L../../src -LIBS = @LIBS@ @mysql_libs@ +LIBS = @LIBS@ @sql_libs@ RUNNING_USER = @RUNNING_USER@ RUNNING_GROUP = `@id_bin@ -gn $(RUNNING_USER)`