]> source.dussan.org Git - rspamd.git/commitdiff
Make hiredis optional dependency.
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Tue, 19 May 2015 12:43:26 +0000 (13:43 +0100)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Tue, 19 May 2015 12:43:26 +0000 (13:43 +0100)
CMakeLists.txt
config.h.in
src/libstat/CMakeLists.txt
src/lua/lua_redis.c

index 42b77e844f00bb96262b9acfe796d6f2c0958ef2..c9d8ae987a8c76af00dff28ae8abeafcf66c1a5e 100644 (file)
@@ -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)
index 211b4bba983646712fa10ca89f6eaa6c99aff89f..1ebac8fa00c631262c712618ee2ec95c9f734f67 100644 (file)
@@ -62,6 +62,8 @@
 
 #cmakedefine LIBEVENT_EVHTTP     1
 
+#cmakedefine WITH_HIREDIS        1
+
  #ifdef HAVE_ENDIAN_H
  #include <endian.h>
  #else 
index bf9aa94e40ca3e811460ed1f7766de427aeb4cef..f31cf4cf475eb35ce9b802c4e00469dd2b454d04 100644 (file)
@@ -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} 
index 275df0a35a64fa3e883f2501fa00ca44c788f9e3..9cf10bb10e4ca022829ed4606b1d432ac0ddaff6 100644 (file)
 #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)