aboutsummaryrefslogtreecommitdiffstats
path: root/CMakeLists.txt
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@rambler-co.ru>2011-08-08 17:20:34 +0400
committerVsevolod Stakhov <vsevolod@rambler-co.ru>2011-08-08 17:20:34 +0400
commitf5949d261a1d4e76fa6dbd7c502ea54cfc3491a4 (patch)
treee5fc4189b8a369a629b7a2b5cead65302cc5db89 /CMakeLists.txt
parentce7d7a2d8e0a9523d965018bfc103fb052520d7f (diff)
downloadrspamd-f5949d261a1d4e76fa6dbd7c502ea54cfc3491a4.tar.gz
rspamd-f5949d261a1d4e76fa6dbd7c502ea54cfc3491a4.zip
Add LOCALSTATES_PREFIX variable for setting where should be runtime files for rspamd.
Suggested by: Vasiliy G. Tolstov
Diffstat (limited to 'CMakeLists.txt')
-rw-r--r--CMakeLists.txt83
1 files changed, 72 insertions, 11 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 3ed111e59..924ee20d8 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -48,7 +48,7 @@ IF(CMAKE_INSTALL_PREFIX)
SET(PREFIX ${CMAKE_INSTALL_PREFIX})
ENDIF(CMAKE_INSTALL_PREFIX)
-# Platform specific routines
+# Platform specific configuration
IF(CMAKE_SYSTEM_NAME STREQUAL "FreeBSD")
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_BSD_SOURCE -DFREEBSD")
CONFIGURE_FILE(freebsd/rspamd.sh.in freebsd/rspamd @ONLY)
@@ -63,6 +63,9 @@ IF(CMAKE_SYSTEM_NAME STREQUAL "FreeBSD")
IF(NOT MAN_PREFIX)
SET(MAN_PREFIX "${CMAKE_INSTALL_PREFIX}/man")
ENDIF(NOT MAN_PREFIX)
+ IF(NOT LOCALSTATES_PREFIX)
+ SET(LOCALSTATES_PREFIX "/var/run/rspamd")
+ ENDIF(NOT LOCALSTATES_PREFIX)
SET(PREFIX "${CMAKE_INSTALL_PREFIX}")
ELSE(CMAKE_INSTALL_PREFIX)
IF(NOT ETC_PREFIX)
@@ -71,6 +74,9 @@ IF(CMAKE_SYSTEM_NAME STREQUAL "FreeBSD")
IF(NOT MAN_PREFIX)
SET(MAN_PREFIX /usr/local/man)
ENDIF(NOT MAN_PREFIX)
+ IF(NOT LOCALSTATES_PREFIX)
+ SET(LOCALSTATES_PREFIX "/var/run/rspamd")
+ ENDIF(NOT LOCALSTATES_PREFIX)
IF(NOT PREFIX)
SET(PREFIX /usr/local)
ENDIF(NOT PREFIX)
@@ -89,8 +95,15 @@ IF(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_BSD_SOURCE -DDARWIN")
IF(CMAKE_INSTALL_PREFIX)
- SET(ETC_PREFIX "${CMAKE_INSTALL_PREFIX}/etc")
- SET(MAN_PREFIX "${CMAKE_INSTALL_PREFIX}/etc")
+ IF(NOT ETC_PREFIX)
+ SET(ETC_PREFIX "${CMAKE_INSTALL_PREFIX}/etc")
+ ENDIF(NOT ETC_PREFIX)
+ IF(NOT MAN_PREFIX)
+ SET(MAN_PREFIX "${CMAKE_INSTALL_PREFIX}/man")
+ ENDIF(NOT MAN_PREFIX)
+ IF(NOT LOCALSTATES_PREFIX)
+ SET(LOCALSTATES_PREFIX "/var/run/rspamd")
+ ENDIF(NOT LOCALSTATES_PREFIX)
SET(PREFIX "${CMAKE_INSTALL_PREFIX}")
ELSE(CMAKE_INSTALL_PREFIX)
IF(NOT ETC_PREFIX)
@@ -99,6 +112,9 @@ IF(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
IF(NOT MAN_PREFIX)
SET(MAN_PREFIX /usr/local/man)
ENDIF(NOT MAN_PREFIX)
+ IF(NOT LOCALSTATES_PREFIX)
+ SET(LOCALSTATES_PREFIX "/var/run/rspamd")
+ ENDIF(NOT LOCALSTATES_PREFIX)
IF(NOT PREFIX)
SET(PREFIX /usr/local)
ENDIF(NOT PREFIX)
@@ -124,6 +140,9 @@ IF(CMAKE_SYSTEM_NAME STREQUAL "Linux")
IF(NOT MAN_PREFIX)
SET(MAN_PREFIX "${CMAKE_INSTALL_PREFIX}/share/man")
ENDIF(NOT MAN_PREFIX)
+ IF(NOT LOCALSTATES_PREFIX)
+ SET(LOCALSTATES_PREFIX "/var/run/rspamd")
+ ENDIF(NOT LOCALSTATES_PREFIX)
SET(PREFIX "${CMAKE_INSTALL_PREFIX}")
ELSE(CMAKE_INSTALL_PREFIX)
@@ -136,6 +155,9 @@ IF(CMAKE_SYSTEM_NAME STREQUAL "Linux")
IF(NOT MAN_PREFIX)
SET(MAN_PREFIX /usr/share/man)
ENDIF(NOT MAN_PREFIX)
+ IF(NOT LOCALSTATES_PREFIX)
+ SET(LOCALSTATES_PREFIX "/var/run/rspamd")
+ ENDIF(NOT LOCALSTATES_PREFIX)
ENDIF(CMAKE_INSTALL_PREFIX)
# Workaround with architecture specific includes
@@ -157,8 +179,15 @@ ENDIF(CMAKE_SYSTEM_NAME STREQUAL "Linux")
IF(CMAKE_SYSTEM_NAME STREQUAL "SunOS")
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_GNU_SOURCE -DSOLARIS")
IF(CMAKE_INSTALL_PREFIX)
- SET(ETC_PREFIX "${CMAKE_INSTALL_PREFIX}/etc")
- SET(MAN_PREFIX "${CMAKE_INSTALL_PREFIX}/etc")
+ IF(NOT ETC_PREFIX)
+ SET(ETC_PREFIX "${CMAKE_INSTALL_PREFIX}/etc")
+ ENDIF(NOT ETC_PREFIX)
+ IF(NOT MAN_PREFIX)
+ SET(MAN_PREFIX "${CMAKE_INSTALL_PREFIX}/man")
+ ENDIF(NOT MAN_PREFIX)
+ IF(NOT LOCALSTATES_PREFIX)
+ SET(LOCALSTATES_PREFIX "/var/run/rspamd")
+ ENDIF(NOT LOCALSTATES_PREFIX)
SET(PREFIX "${CMAKE_INSTALL_PREFIX}")
ELSE(CMAKE_INSTALL_PREFIX)
IF(NOT ETC_PREFIX)
@@ -170,6 +199,9 @@ IF(CMAKE_SYSTEM_NAME STREQUAL "SunOS")
IF(NOT MAN_PREFIX)
SET(MAN_PREFIX /usr/share/man)
ENDIF(NOT MAN_PREFIX)
+ IF(NOT LOCALSTATES_PREFIX)
+ SET(LOCALSTATES_PREFIX "/var/run/rspamd")
+ ENDIF(NOT LOCALSTATES_PREFIX)
ENDIF(CMAKE_INSTALL_PREFIX)
LIST(APPEND CMAKE_REQUIRED_LIBRARIES rt)
@@ -179,16 +211,33 @@ IF(CMAKE_SYSTEM_NAME STREQUAL "SunOS")
MESSAGE(STATUS "Configuring for Solaris")
ENDIF(CMAKE_SYSTEM_NAME STREQUAL "SunOS")
+# Check prefixes
IF(NOT ETC_PREFIX)
IF(CMAKE_INSTALL_PREFIX)
MESSAGE(WARNING "Your system is unknown for rspamd, assume defining ETC_PREFIX and MAN_PREFIX by -D option, now ETC_PREFIX and MAN_PREFIX are relative to ${CMAKE_INSTALL_PREFIX}")
SET(ETC_PREFIX "${CMAKE_INSTALL_PREFIX}/etc")
- SET(MAN_PREFIX "${CMAKE_INSTALL_PREFIX}/man")
ELSE(CMAKE_INSTALL_PREFIX)
MESSAGE(FATAL_ERROR "Your system is unknown for rspamd and no CMAKE_INSTALL_PREFIX specified, assume defining CMAKE_INSTALL_PREFIX")
ENDIF(CMAKE_INSTALL_PREFIX)
MESSAGE(STATUS "Configuring for ${CMAKE_SYSTEM_NAME}")
ENDIF(NOT ETC_PREFIX)
+IF(NOT MAN_PREFIX)
+ IF(CMAKE_INSTALL_PREFIX)
+ SET(MAN_PREFIX "${CMAKE_INSTALL_PREFIX}/man")
+ ENDIF(CMAKE_INSTALL_PREFIX)
+ENDIF(NOT MAN_PREFIX)
+IF(NOT LOCALSTATES_PREFIX)
+ IF(CMAKE_INSTALL_PREFIX)
+ SET(LOCALSTATES_PREFIX "/var/run/rspamd")
+ ENDIF(CMAKE_INSTALL_PREFIX)
+ENDIF(NOT LOCALSTATES_PREFIX)
+
+# Now CMAKE_INSTALL_PREFIX is a base prefix for everything
+# ETC_PREFIX - for configuration
+# MAN_PREFIX - for manual pages
+# LOCALSTATES_PREFIX - for runtime files
+
+# Now find libraries and headers
INCLUDE(FindLua51)
# Check for luajit
@@ -354,12 +403,16 @@ IF(ENABLE_PROFILING MATCHES "ON")
SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -pg")
ENDIF(ENABLE_PROFILING MATCHES "ON")
+# Static build
+
IF(ENABLE_STATIC MATCHES "ON")
SET(BUILD_STATIC 1)
SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static")
MESSAGE(STATUS "Static build of rspamd, no custom plugins support")
ENDIF(ENABLE_STATIC MATCHES "ON")
+# Google performance tools
+
IF(ENABLE_GPERF_TOOLS MATCHES "ON")
FIND_PATH(GPERF_INCLUDE google/profiler.h PATHS /opt/include
/usr/include
@@ -380,7 +433,7 @@ IF(ENABLE_GPERF_TOOLS MATCHES "ON")
SET(WITH_GPERF_TOOLS 1)
ENDIF(ENABLE_GPERF_TOOLS MATCHES "ON")
-
+# Find util library
FIND_LIBRARY(LIBUTIL_LIBRARY NAMES util PATHS /lib
/opt/lib
@@ -397,6 +450,8 @@ IF(LIBUTIL_LIBRARY)
DOC "Path to libutil header")
ENDIF(LIBUTIL_LIBRARY)
+
+# Check platform specific includes
CHECK_INCLUDE_FILES(sys/types.h HAVE_SYS_TYPES_H)
CHECK_INCLUDE_FILES(sys/time.h HAVE_SYS_TIME_H)
CHECK_INCLUDE_FILES(sys/uio.h HAVE_SYS_UIO_H)
@@ -439,6 +494,7 @@ CHECK_INCLUDE_FILES(glob.h HAVE_GLOB_H)
CHECK_INCLUDE_FILES(poll.h HAVE_POLL_H)
CHECK_INCLUDE_FILES(sys/sendfile.h HAVE_SYS_SENDFILE_H)
+# Some dependencies
IF(HAVE_SYS_WAIT_H)
LIST(APPEND CMAKE_REQUIRED_INCLUDES sys/wait.h)
ENDIF(HAVE_SYS_WAIT_H)
@@ -449,6 +505,7 @@ IF(HAVE_SYS_TIME_H)
LIST(APPEND CMAKE_REQUIRED_INCLUDES sys/time.h)
ENDIF(HAVE_SYS_TIME_H)
+# Check platform API
CHECK_FUNCTION_EXISTS(setproctitle HAVE_SETPROCTITLE)
CHECK_FUNCTION_EXISTS(getpagesize HAVE_GETPAGESIZE)
CHECK_FUNCTION_EXISTS(nanosleep HAVE_NANOSLEEP)
@@ -462,6 +519,7 @@ CHECK_FUNCTION_EXISTS(mkstemp HAVE_MKSTEMP)
CHECK_FUNCTION_EXISTS(setitimer HAVE_SETITIMER)
CHECK_FUNCTION_EXISTS(clock_gettime HAVE_CLOCK_GETTIME)
+# Check macros
CHECK_SYMBOL_EXISTS(PATH_MAX limits.h HAVE_PATH_MAX)
CHECK_SYMBOL_EXISTS(MAXPATHLEN sys/param.h HAVE_MAXPATHLEN)
CHECK_SYMBOL_EXISTS(MAP_SHARED sys/mman.h HAVE_MMAP_SHARED)
@@ -477,12 +535,14 @@ ELSE(HAVE_CLOCK_GETTIME)
CHECK_INCLUDE_FILES(sys/timeb.h HAVE_SYS_TIMEB_H)
ENDIF(HAVE_CLOCK_GETTIME)
+# Check asm pause instruction
CHECK_C_SOURCE_COMPILES ("#include <sys/types.h>
int main (int argc, char **argv) {
__asm __volatile(\"pause\");
return 0;
}" HAVE_ASM_PAUSE)
+# Check queue.h compatibility
IF(NOT HAVE_COMPATIBLE_QUEUE_H)
INCLUDE_DIRECTORIES(compat)
ENDIF(NOT HAVE_COMPATIBLE_QUEUE_H)
@@ -490,6 +550,7 @@ ENDIF(NOT HAVE_COMPATIBLE_QUEUE_H)
SET(CONTRIBSRC "")
+# Optimization flags
IF(ENABLE_OPTIMIZATION MATCHES "ON")
SET(CMAKE_C_OPT_FLAGS "-O3")
ELSE(ENABLE_OPTIMIZATION MATCHES "ON")
@@ -725,13 +786,13 @@ IF(CMAKE_SYSTEM_NAME STREQUAL "FreeBSD" AND NOT BUILD_PORT)
IF(ENABLE_REDIRECTOR MATCHES "ON")
INSTALL(PROGRAMS ${CMAKE_BINARY_DIR}/freebsd/redirector DESTINATION ${ETC_PREFIX}/rc.d)
ENDIF(ENABLE_REDIRECTOR MATCHES "ON")
- INSTALL(CODE "FILE(MAKE_DIRECTORY \$ENV{DESTDIR}/var/run/rspamd)")
- INSTALL(CODE "EXECUTE_PROCESS(COMMAND chown ${RSPAMD_USER}:${RSPAMD_GROUP} \$ENV{DESTDIR}/var/run/rspamd/)")
+ INSTALL(CODE "FILE(MAKE_DIRECTORY \$ENV{DESTDIR}/${LOCALSTATES_PREFIX})")
+ INSTALL(CODE "EXECUTE_PROCESS(COMMAND chown ${RSPAMD_USER}:${RSPAMD_GROUP} \$ENV{DESTDIR}/${LOCALSTATES_PREFIX})")
ENDIF(CMAKE_SYSTEM_NAME STREQUAL "FreeBSD" AND NOT BUILD_PORT)
IF(CMAKE_SYSTEM_NAME STREQUAL "Linux")
INSTALL(PROGRAMS "linux/${LINUX_START_SCRIPT}" DESTINATION ${ETC_PREFIX}/init.d RENAME rspamd)
- INSTALL(CODE "FILE(MAKE_DIRECTORY \$ENV{DESTDIR}/var/run/rspamd)")
- INSTALL(CODE "EXECUTE_PROCESS(COMMAND chown ${RSPAMD_USER}:${RSPAMD_GROUP} \$ENV{DESTDIR}/var/run/rspamd/)")
+ INSTALL(CODE "FILE(MAKE_DIRECTORY \$ENV{DESTDIR}/${LOCALSTATES_PREFIX})")
+ INSTALL(CODE "EXECUTE_PROCESS(COMMAND chown ${RSPAMD_USER}:${RSPAMD_GROUP} \$ENV{DESTDIR}/${LOCALSTATES_PREFIX})")
ENDIF(CMAKE_SYSTEM_NAME STREQUAL "Linux")
# CPack section