aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2015-05-19 13:43:26 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2015-05-19 13:43:26 +0100
commitb4cfe06003e7bfb3e5c1e83058267f4224fe07d2 (patch)
tree313cc381538982d7aec1173a5f3a40c74e2b4540
parent90cc2d3b54b7cf6253d9cc467f4a540005a6fa5d (diff)
downloadrspamd-b4cfe06003e7bfb3e5c1e83058267f4224fe07d2.tar.gz
rspamd-b4cfe06003e7bfb3e5c1e83058267f4224fe07d2.zip
Make hiredis optional dependency.
-rw-r--r--CMakeLists.txt18
-rw-r--r--config.h.in2
-rw-r--r--src/libstat/CMakeLists.txt8
-rw-r--r--src/lua/lua_redis.c14
4 files changed, 33 insertions, 9 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 42b77e844..c9d8ae987 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -540,7 +540,6 @@ ENDIF(OPENSSL_FOUND)
ProcessPackage(GLIB2 glib-2.0>=2.28)
ProcessPackage(GTHREAD gthread-2.0)
-ProcessPackage(HIREDIS hiredis libhiredis)
ProcessPackage(PCRE pcre libpcre pcre3 libpcre3)
ProcessPackage(GMIME2 gmime-2.6 gmime-2.4 gmime-2.0)
ProcessPackage(LIBEVENT event libevent)
@@ -555,15 +554,20 @@ ELSE(PCRE_LIBRARY)
SET(CMAKE_REQUIRED_LIBRARIES "${CMAKE_REQUIRED_LIBRARIES};-lpcre")
ENDIF(PCRE_LIBRARY)
# Libhiredis pc file is so special
-FIND_PATH(LIBHIREDIS_INCLUDE hiredis.h
+IF(ENABLE_HIREDIS MATCHES "ON")
+ ProcessPackage(HIREDIS hiredis libhiredis)
+ SET(WITH_HIREDIS 1)
+ FIND_PATH(LIBHIREDIS_INCLUDE hiredis.h
HINTS "${RSPAMD_SEARCH_PATH}"
PATH_SUFFIXES "include" "include/hiredis"
PATHS ${RSPAMD_DEFAULT_INCLUDE_PATHS}
DOC "Path where the hiredis header files can be found")
-IF(LIBHIREDIS_INCLUDE)
- INCLUDE_DIRECTORIES("${LIBHIREDIS_INCLUDE}")
-ENDIF(LIBHIREDIS_INCLUDE)
+ IF(LIBHIREDIS_INCLUDE)
+ INCLUDE_DIRECTORIES("${LIBHIREDIS_INCLUDE}")
+ ENDIF(LIBHIREDIS_INCLUDE)
+ENDIF(ENABLE_HIREDIS MATCHES "ON")
+
# Google performance tools
@@ -1020,7 +1024,9 @@ IF(ENABLE_GPERF_TOOLS MATCHES "ON")
LIST(APPEND RSPAMD_REQUIRED_LIBRARIES profiler)
ENDIF(ENABLE_GPERF_TOOLS MATCHES "ON")
-LIST(APPEND RSPAMD_REQUIRED_LIBRARIES hiredis)
+IF(ENABLE_HIREDIS MATCHES "ON")
+ LIST(APPEND RSPAMD_REQUIRED_LIBRARIES hiredis)
+ENDIF(ENABLE_HIREDIS MATCHES "ON")
IF(GLIB_COMPAT)
LIST(APPEND RSPAMD_REQUIRED_LIBRARIES glibadditions)
ENDIF(GLIB_COMPAT)
diff --git a/config.h.in b/config.h.in
index 211b4bba9..1ebac8fa0 100644
--- a/config.h.in
+++ b/config.h.in
@@ -62,6 +62,8 @@
#cmakedefine LIBEVENT_EVHTTP 1
+#cmakedefine WITH_HIREDIS 1
+
#ifdef HAVE_ENDIAN_H
#include <endian.h>
#else
diff --git a/src/libstat/CMakeLists.txt b/src/libstat/CMakeLists.txt
index bf9aa94e4..f31cf4cf4 100644
--- a/src/libstat/CMakeLists.txt
+++ b/src/libstat/CMakeLists.txt
@@ -6,10 +6,12 @@ SET(TOKENIZERSSRC ${CMAKE_CURRENT_SOURCE_DIR}/tokenizers/tokenizers.c
${CMAKE_CURRENT_SOURCE_DIR}/tokenizers/osb.c)
SET(CLASSIFIERSSRC ${CMAKE_CURRENT_SOURCE_DIR}/classifiers/bayes.c)
-
-SET(BACKENDSSRC ${CMAKE_CURRENT_SOURCE_DIR}/backends/mmaped_file.c
- ${CMAKE_CURRENT_SOURCE_DIR}/backends/redis.c)
+SET(BACKENDSSRC ${CMAKE_CURRENT_SOURCE_DIR}/backends/mmaped_file.c)
+IF(ENABLE_HIREDIS MATCHES "ON")
+ SET(BACKENDSSRC ${BACKENDSSRC}
+ ${CMAKE_CURRENT_SOURCE_DIR}/backends/redis.c)
+ENDIF(ENABLE_HIREDIS MATCHES "ON")
SET(CACHESSRC ${CMAKE_CURRENT_SOURCE_DIR}/learn_cache/sqlite3_cache.c)
SET(RSPAMD_STAT ${LIBSTATSRC}
diff --git a/src/lua/lua_redis.c b/src/lua/lua_redis.c
index 275df0a35..9cf10bb10 100644
--- a/src/lua/lua_redis.c
+++ b/src/lua/lua_redis.c
@@ -24,9 +24,11 @@
#include "lua_common.h"
#include "dns.h"
+#ifdef WITH_HIREDIS
#include "hiredis.h"
#include "async.h"
#include "adapters/libevent.h"
+#endif
#define REDIS_DEFAULT_TIMEOUT 1.0
@@ -62,6 +64,7 @@ static const struct luaL_reg redislib_m[] = {
{NULL, NULL}
};
+#ifdef WITH_HIREDIS
/**
* Struct for userdata representation
*/
@@ -461,6 +464,17 @@ lua_redis_make_request (lua_State *L)
return 1;
}
+#else
+static int
+lua_redis_make_request (lua_State *L)
+{
+ msg_warn ("rspamd is compiled with no redis support");
+
+ lua_pushboolean (L, FALSE);
+
+ return 1;
+}
+#endif
static gint
lua_load_redis (lua_State * L)