]> source.dussan.org Git - rspamd.git/commitdiff
Fix static build.
authorVsevolod Stakhov <vsevolod@rambler-co.ru>
Tue, 5 Jun 2012 15:22:57 +0000 (19:22 +0400)
committerVsevolod Stakhov <vsevolod@rambler-co.ru>
Tue, 5 Jun 2012 15:22:57 +0000 (19:22 +0400)
As there are too many changes from 0.4.7 mark this version as 0.5.0.

CMakeLists.txt
lib/CMakeLists.txt
src/cdb/CMakeLists.txt
src/client/CMakeLists.txt
src/json/CMakeLists.txt
src/logger.h
src/lua/CMakeLists.txt
src/printf.c
src/printf.h

index c1530e46803cdffb28f1f4ee3ade6fefb3ead2fe..07b8f228f007861d6705fa0435736c67cc3b31f3 100644 (file)
@@ -9,8 +9,8 @@
 PROJECT(rspamd C)
 
 SET(RSPAMD_VERSION_MAJOR 0)
-SET(RSPAMD_VERSION_MINOR 4)
-SET(RSPAMD_VERSION_PATCH 8)
+SET(RSPAMD_VERSION_MINOR 5)
+SET(RSPAMD_VERSION_PATCH 0)
 
 
 SET(RSPAMD_VERSION         "${RSPAMD_VERSION_MAJOR}.${RSPAMD_VERSION_MINOR}.${RSPAMD_VERSION_PATCH}")
@@ -414,11 +414,23 @@ IF(OPENSSL_FOUND)
 ENDIF(OPENSSL_FOUND)
 
 IF(ENABLE_STATIC MATCHES "ON")
-       pkg_check_modules(GLIB2 REQUIRED glib-2.0>=2.12)
+       pkg_check_modules(GLIB2 REQUIRED glib-2.0>=2.12 gmodule-2.0)
+       SET(LINK_TYPE "STATIC")
 ELSE(ENABLE_STATIC MATCHES "ON")
        pkg_check_modules(GLIB2 REQUIRED glib-2.0>=2.12 gmodule-2.0)
-       SET(GLIB2_VERSION "${GLIB2_glib-2.0_VERSION}")
+       SET(LINK_TYPE "SHARED")
 ENDIF(ENABLE_STATIC MATCHES "ON")
+SET(GLIB2_VERSION "${GLIB2_glib-2.0_VERSION}")
+
+IF(GLIB2_VERSION VERSION_GREATER "2.30.0")
+       pkg_check_modules(LIBFFI libffi)
+       IF(LIBFFI_FOUND)
+               SET(GLIB2_LDFLAGS "${GLIB2_LDFLAGS};${LIBFFI_LDFLAGS}")
+               SET(GLIB2_LIBRARIES "${GLIB2_LIBRARIES};${LIBFFI_LIBRARIES}")
+               SET(GLIB2_STATIC_LDFLAGS "${GLIB2_STATIC_LDFLAGS};${LIBFFI_STATIC_LDFLAGS}")
+               SET(GLIB2_CFLAGS "${GLIB2_CFLAGS};${LIBFFI_CFLAGS}")
+       ENDIF(LIBFFI_FOUND)
+ENDIF(GLIB2_VERSION VERSION_GREATER "2.30.0") 
 pkg_check_modules(GMIME2 gmime-2.0)
 
 # Try to find hiredis library
@@ -908,8 +920,8 @@ AddModules(MODULES_LIST WORKERS_LIST)
 
 ################################ SUBDIRS SECTION ###########################
 
-ADD_SUBDIRECTORY(contrib/lgpl)
 IF(GLIB_COMPAT)
+       ADD_SUBDIRECTORY(contrib/lgpl)
        INCLUDE_DIRECTORIES("${CMAKE_CURRENT_SOURCE_DIR}/contrib/lgpl")
 ENDIF(GLIB_COMPAT)
 
@@ -958,12 +970,28 @@ TARGET_LINK_LIBRARIES(rspamd event)
 IF(HAVE_LIBEVENT2)
        TARGET_LINK_LIBRARIES(rspamd event_pthreads)
 ENDIF(HAVE_LIBEVENT2)
-TARGET_LINK_LIBRARIES(rspamd ${PCRE_LIBRARIES})
+IF(WITH_DB)
+       TARGET_LINK_LIBRARIES(rspamd db)
+ENDIF(WITH_DB)
+IF(SQLITE_LIBRARIES)
+       TARGET_LINK_LIBRARIES(rspamd ${SQLITE_LIBRARIES})
+ENDIF(SQLITE_LIBRARIES)
 
+IF(OPENSSL_FOUND)
+       TARGET_LINK_LIBRARIES(rspamd ${OPENSSL_LIBRARIES})
+ENDIF(OPENSSL_FOUND)
+TARGET_LINK_LIBRARIES(rspamd ${PCRE_LIBRARIES})
+IF(GMIME24)
+       TARGET_LINK_LIBRARIES(rspamd ${GMIME24_LIBRARIES})
+ELSE(GMIME24)
+       TARGET_LINK_LIBRARIES(rspamd ${GMIME2_LIBRARIES})
+ENDIF(GMIME24)
+TARGET_LINK_LIBRARIES(rspamd ${GLIB2_LIBRARIES})
 TARGET_LINK_LIBRARIES(rspamd ${CMAKE_REQUIRED_LIBRARIES})
 
 IF(ENABLE_STATIC MATCHES "ON")
        TARGET_LINK_LIBRARIES(rspamd ${PCRE_LIBRARIES})
+       TARGET_LINK_LIBRARIES(rspamd "z")
 ENDIF(ENABLE_STATIC MATCHES "ON")
 
 IF(ENABLE_LUAJIT MATCHES "ON")
index 2ef90dec206aadd97a70ed905202261bac19288a..09b3dcdd2b674d8eca1f62a1b85f51f17b66f59d 100644 (file)
@@ -57,7 +57,7 @@ SET(LIBRSPAMDMIMESRC
 # Add targets
 
 # Rspamdutil
-ADD_LIBRARY(rspamd-util SHARED ${LIBRSPAMDUTILSRC})
+ADD_LIBRARY(rspamd-util ${LINK_TYPE} ${LIBRSPAMDUTILSRC})
 IF(CMAKE_COMPILER_IS_GNUCC)
 SET_TARGET_PROPERTIES(rspamd-util PROPERTIES COMPILE_FLAGS "-fno-strict-aliasing")
 ENDIF(CMAKE_COMPILER_IS_GNUCC)
@@ -80,7 +80,7 @@ INSTALL(TARGETS rspamd-util
     ARCHIVE DESTINATION ${LIBDIR})
 
 # Rspamd client
-ADD_LIBRARY(rspamdclient SHARED ${LIBRSPAMDCLIENTSRC})
+ADD_LIBRARY(rspamdclient ${LINK_TYPE} ${LIBRSPAMDCLIENTSRC})
 ADD_LIBRARY(rspamdclient_static STATIC ${LIBRSPAMDCLIENTSRC})
 SET_TARGET_PROPERTIES(rspamdclient PROPERTIES PUBLIC_HEADER "client/librspamdclient.h")
 
@@ -117,15 +117,14 @@ IF(WITH_SQLITE)
        LIST(APPEND LIBRSPAMDSERVERSRC ../src/kvstorage_sqlite.c)
 ENDIF(WITH_SQLITE)
                                
-ADD_LIBRARY(rspamd-server SHARED ${LIBRSPAMDSERVERSRC})
-SET_TARGET_PROPERTIES(rspamd-server PROPERTIES LINKER_LANGUAGE C)
-SET_TARGET_PROPERTIES(rspamd-server PROPERTIES COMPILE_FLAGS "-DRSPAMD_LIB")
+ADD_LIBRARY(rspamd-server ${LINK_TYPE} ${LIBRSPAMDSERVERSRC})
+SET_TARGET_PROPERTIES(rspamd-server PROPERTIES LINKER_LANGUAGE C COMPILE_FLAGS "-DRSPAMD_LIB")
 TARGET_LINK_LIBRARIES(rspamd-server rspamd-lua)
 TARGET_LINK_LIBRARIES(rspamd-server rspamd-json)
 TARGET_LINK_LIBRARIES(rspamd-server rspamd-cdb)
 TARGET_LINK_LIBRARIES(rspamd-server rspamd-util)      
 IF(CMAKE_COMPILER_IS_GNUCC)
-SET_TARGET_PROPERTIES(rspamd-server PROPERTIES COMPILE_FLAGS "-fno-strict-aliasing")
+SET_TARGET_PROPERTIES(rspamd-server PROPERTIES COMPILE_FLAGS "-DRSPAMD_LIB -fno-strict-aliasing")
 ENDIF(CMAKE_COMPILER_IS_GNUCC)
 
 IF(WITH_DB)
@@ -144,13 +143,13 @@ INSTALL(TARGETS rspamd-server
     ARCHIVE DESTINATION ${LIBDIR})
     
 # Librspamdmime
-ADD_LIBRARY(rspamd-mime SHARED ${LIBRSPAMDMIMESRC})
+ADD_LIBRARY(rspamd-mime ${LINK_TYPE} ${LIBRSPAMDMIMESRC})
 SET_TARGET_PROPERTIES(rspamd-mime PROPERTIES LINKER_LANGUAGE C)
 SET_TARGET_PROPERTIES(rspamd-mime PROPERTIES COMPILE_FLAGS "-DRSPAMD_LIB")
 TARGET_LINK_LIBRARIES(rspamd-mime rspamd-server)
 TARGET_LINK_LIBRARIES(rspamd-mime rspamd-util)      
 IF(CMAKE_COMPILER_IS_GNUCC)
-SET_TARGET_PROPERTIES(rspamd-mime PROPERTIES COMPILE_FLAGS "-fno-strict-aliasing")
+SET_TARGET_PROPERTIES(rspamd-mime PROPERTIES COMPILE_FLAGS "-DRSPAMD_LIB -fno-strict-aliasing")
 ENDIF(CMAKE_COMPILER_IS_GNUCC)
 
 IF(GMIME24)
@@ -166,7 +165,7 @@ INSTALL(TARGETS rspamd-mime
 
 # Libkvstorageclient
 
-ADD_LIBRARY(kvstorageclient SHARED ${LIBRKVSTORAGESRC})
+ADD_LIBRARY(kvstorageclient ${LINK_TYPE} ${LIBRKVSTORAGESRC})
 ADD_LIBRARY(kvstorageclient_static STATIC ${LIBRKVSTORAGESRC})
 SET_TARGET_PROPERTIES(kvstorageclient PROPERTIES PUBLIC_HEADER "kvstorage/libkvstorageclient.h")
 
index ab7b8b57ad8175d4246d40cef6b5b04d5c76f5d4..122ac45409d2ea7f39c96a5a6ac26339aec1743e 100644 (file)
@@ -3,7 +3,7 @@ SET(CDBSRC                              cdb_init.c
                                                cdb_find.c
                                                cdb_make.c)
 
-ADD_LIBRARY(rspamd-cdb SHARED ${CDBSRC})
+ADD_LIBRARY(rspamd-cdb ${LINK_TYPE} ${CDBSRC})
 SET_TARGET_PROPERTIES(rspamd-cdb PROPERTIES COMPILE_FLAGS "-DRSPAMD_LIB")
 INSTALL(TARGETS rspamd-cdb 
     LIBRARY DESTINATION ${LIBDIR} 
index fe02d5e1bd2a159d38370809e284641b83cafa9f..0950fb49d4c29d6790f22806ffb943cdfa73b8a9 100644 (file)
@@ -3,12 +3,8 @@ SET(RSPAMCSRC                    rspamc.c)
 
 ADD_EXECUTABLE(rspamc ${RSPAMCSRC})
 SET_TARGET_PROPERTIES(rspamc PROPERTIES COMPILE_FLAGS "-I${CMAKE_SOURCE_DIR}/lib")
-TARGET_LINK_LIBRARIES(rspamc rspamd-util)
-IF(ENABLE_STATIC MATCHES "ON")
-       TARGET_LINK_LIBRARIES(rspamc rspamdclient_static)
-ELSE(ENABLE_STATIC MATCHES "ON")
-       TARGET_LINK_LIBRARIES(rspamc rspamdclient)
-ENDIF(ENABLE_STATIC MATCHES "ON")
+TARGET_LINK_LIBRARIES(rspamc rspamd-server)
+TARGET_LINK_LIBRARIES(rspamc rspamdclient)
 TARGET_LINK_LIBRARIES(rspamc pcre)
 IF(GLIB_COMPAT)
        TARGET_LINK_LIBRARIES(rspamc glibadditions)
index ad8059269601d27741b60316224f6f27563cf1b8..fb3d88785eed64adb51d40515e65a5f7eca5ce31 100644 (file)
@@ -6,7 +6,7 @@ SET(JSONSRC                             dump.c
                                                utf.c
                                                value.c)
 
-ADD_LIBRARY(rspamd-json SHARED ${JSONSRC})
+ADD_LIBRARY(rspamd-json ${LINK_TYPE} ${JSONSRC})
 SET_TARGET_PROPERTIES(rspamd-json PROPERTIES COMPILE_FLAGS "-DRSPAMD_LIB")
 INSTALL(TARGETS rspamd-json 
     LIBRARY DESTINATION ${LIBDIR} 
index ec7a23af5fc9f13501cee2fc88e58c665f2eda5c..81dd9c1c40829dfaefbece3c2354e5d821449b95 100644 (file)
@@ -90,11 +90,11 @@ void rspamd_log_nodebug (rspamd_logger_t *logger);
 # define debug_task(...) rspamd_conditional_debug(rspamd_main->logger, task->from_addr.s_addr, __FUNCTION__, __VA_ARGS__)
 #endif
 #else
-#define msg_err(...)   rspamd_fprintf(stderr, __VA_ARGS__)
-#define msg_warn(...)  rspamd_fprintf(stderr, __VA_ARGS__)
-#define msg_info(...)  rspamd_fprintf(stderr, __VA_ARGS__)
-#define msg_debug(...) rspamd_fprintf(stderr, __VA_ARGS__)
-#define debug_task(...) rspamd_fprintf(stderr, __VA_ARGS__)
+#define msg_err(...)   rspamd_log_fprintf(stderr, __VA_ARGS__)
+#define msg_warn(...)  rspamd_log_fprintf(stderr, __VA_ARGS__)
+#define msg_info(...)  rspamd_log_fprintf(stderr, __VA_ARGS__)
+#define msg_debug(...) rspamd_log_fprintf(stderr, __VA_ARGS__)
+#define debug_task(...) rspamd_log_fprintf(stderr, __VA_ARGS__)
 #endif
 
 #endif
index bdba01c27669f120b3238103a295caeb8a6d3538..a37731973805cd3be4f1729fe682d46a1aee15ce 100644 (file)
@@ -12,7 +12,7 @@ SET(LUASRC                      lua_common.c
                                          lua_redis.c
                                          lua_upstream.c)
 
-ADD_LIBRARY(rspamd-lua SHARED ${LUASRC})
+ADD_LIBRARY(rspamd-lua ${LINK_TYPE} ${LUASRC})
 TARGET_LINK_LIBRARIES(rspamd-lua ${LUALIB})
 SET_TARGET_PROPERTIES(rspamd-lua PROPERTIES COMPILE_FLAGS "-DRSPAMD_LIB")
 INSTALL(TARGETS rspamd-lua 
index 3ab5be3dfc458c11902cc966c9f0713ebb66ef32..07cf4367c9b144923c5e01aad7dc7b1860fc00ce 100644 (file)
@@ -185,6 +185,23 @@ rspamd_fprintf (FILE *f, const gchar *fmt, ...)
     return r;
 }
 
+gint
+rspamd_log_fprintf (FILE *f, const gchar *fmt, ...)
+{
+       va_list   args;
+    gchar buf[BUFSIZ];
+    gint r;
+
+       va_start (args, fmt);
+       rspamd_vsnprintf (buf, sizeof (buf), fmt, args);
+       va_end (args);
+
+    r = fprintf (f, "%s\n", buf);
+    fflush (f);
+
+    return r;
+}
+
 gint
 rspamd_sprintf (gchar *buf, const gchar *fmt, ...)
 {
index 436ec305966a1ab716fa4d9bf4cb53a40466a24f..ff0422d1702c55ea20ed89d763a7e872e8bc2108 100644 (file)
@@ -56,6 +56,7 @@
  */
 gint rspamd_sprintf (gchar *buf, const gchar *fmt, ...);
 gint rspamd_fprintf (FILE *f, const gchar *fmt, ...);
+gint rspamd_log_fprintf (FILE *f, const gchar *fmt, ...);
 gint rspamd_snprintf (gchar *buf, glong max, const gchar *fmt, ...);
 gchar *rspamd_vsnprintf (gchar *buf, glong max, const gchar *fmt, va_list args);