diff options
author | Vsevolod Stakhov <vsevolod@rambler-co.ru> | 2012-06-05 19:22:57 +0400 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@rambler-co.ru> | 2012-06-05 19:22:57 +0400 |
commit | 20c329815f2855d7c1356c3bbe26bddca20ac281 (patch) | |
tree | 9eede9a52174f7ab6dc4911cd7f86afffb37156f | |
parent | 35cb2b6e2f17a518d0c940985e6e19b41fdedf19 (diff) | |
download | rspamd-20c329815f2855d7c1356c3bbe26bddca20ac281.tar.gz rspamd-20c329815f2855d7c1356c3bbe26bddca20ac281.zip |
Fix static build.
As there are too many changes from 0.4.7 mark this version as 0.5.0.
-rw-r--r-- | CMakeLists.txt | 40 | ||||
-rw-r--r-- | lib/CMakeLists.txt | 17 | ||||
-rw-r--r-- | src/cdb/CMakeLists.txt | 2 | ||||
-rw-r--r-- | src/client/CMakeLists.txt | 8 | ||||
-rw-r--r-- | src/json/CMakeLists.txt | 2 | ||||
-rw-r--r-- | src/logger.h | 10 | ||||
-rw-r--r-- | src/lua/CMakeLists.txt | 2 | ||||
-rw-r--r-- | src/printf.c | 17 | ||||
-rw-r--r-- | src/printf.h | 1 |
9 files changed, 70 insertions, 29 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index c1530e468..07b8f228f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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") diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt index 2ef90dec2..09b3dcdd2 100644 --- a/lib/CMakeLists.txt +++ b/lib/CMakeLists.txt @@ -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") diff --git a/src/cdb/CMakeLists.txt b/src/cdb/CMakeLists.txt index ab7b8b57a..122ac4540 100644 --- a/src/cdb/CMakeLists.txt +++ b/src/cdb/CMakeLists.txt @@ -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} diff --git a/src/client/CMakeLists.txt b/src/client/CMakeLists.txt index fe02d5e1b..0950fb49d 100644 --- a/src/client/CMakeLists.txt +++ b/src/client/CMakeLists.txt @@ -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) diff --git a/src/json/CMakeLists.txt b/src/json/CMakeLists.txt index ad8059269..fb3d88785 100644 --- a/src/json/CMakeLists.txt +++ b/src/json/CMakeLists.txt @@ -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} diff --git a/src/logger.h b/src/logger.h index ec7a23af5..81dd9c1c4 100644 --- a/src/logger.h +++ b/src/logger.h @@ -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 diff --git a/src/lua/CMakeLists.txt b/src/lua/CMakeLists.txt index bdba01c27..a37731973 100644 --- a/src/lua/CMakeLists.txt +++ b/src/lua/CMakeLists.txt @@ -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 diff --git a/src/printf.c b/src/printf.c index 3ab5be3df..07cf4367c 100644 --- a/src/printf.c +++ b/src/printf.c @@ -186,6 +186,23 @@ rspamd_fprintf (FILE *f, const gchar *fmt, ...) } 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, ...) { gchar *p; diff --git a/src/printf.h b/src/printf.h index 436ec3059..ff0422d17 100644 --- a/src/printf.h +++ b/src/printf.h @@ -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); |