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)
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)
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)
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)
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)
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)
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
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)
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)
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
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
SET(WITH_GPERF_TOOLS 1)
ENDIF(ENABLE_GPERF_TOOLS MATCHES "ON")
-
+# Find util library
FIND_LIBRARY(LIBUTIL_LIBRARY NAMES util PATHS /lib
/opt/lib
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)
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)
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)
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)
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)
SET(CONTRIBSRC "")
+# Optimization flags
IF(ENABLE_OPTIMIZATION MATCHES "ON")
SET(CMAKE_C_OPT_FLAGS "-O3")
ELSE(ENABLE_OPTIMIZATION MATCHES "ON")
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
<!-- Temporary directory -->
<tempdir>/tmp</tempdir>
<!-- Path to pid file -->
- <pidfile>/var/run/rspamd/rspamd.pid</pidfile>
+ <pidfile>@LOCALSTATES_PREFIX@/rspamd.pid</pidfile>
<!-- Turned on C filters -->
<filters>regexp,surbl,chartable,fuzzy_check,spf</filters>
<!-- Maximum size of statistics mapped in memory -->
<!-- DNS retransmits count -->
<dns_retransmits>5</dns_retransmits>
<!-- File for saving settings of symbols cache -->
- <cache_file>/var/run/rspamd/symbols.cache</cache_file>
+ <cache_file>@LOCALSTATES_PREFIX@/symbols.cache</cache_file>
</options>
<!-- End of options section -->
<count>1</count>
<maxfiles>2048</maxfiles>
<!-- Other params -->
- <hashfile>/var/run/rspamd/fuzzy.db</hashfile>
+ <hashfile>@LOCALSTATES_PREFIX@/fuzzy.db</hashfile>
<use_judy>yes</use_judy>
</worker>
<worker>
<!--
<module name="trie">
<rule>TRIE1:bad pattern</rule>
- <rule>TRIE2:file:///var/run/rspamd/bad_patterns.list</rule>
+ <rule>TRIE2:file://@LOCALSTATES_PREFIX@/bad_patterns.list</rule>
</module>
-->
<statfile>
<symbol>WINNOW_HAM</symbol>
<size>100M</size>
- <path>/var/run/rspamd/data.ham</path>
+ <path>@LOCALSTATES_PREFIX@/data.ham</path>
</statfile>
<statfile>
<symbol>WINNOW_SPAM</symbol>
<size>100M</size>
- <path>/var/run/rspamd/data.spam</path>
+ <path>@LOCALSTATES_PREFIX@/data.spam</path>
</statfile>
</classifier>
-->
<statfile>
<symbol>BAYES_HAM</symbol>
<size>10M</size>
- <path>/var/run/rspamd/bayes_slave.ham</path>
+ <path>@LOCALSTATES_PREFIX@/bayes_slave.ham</path>
<binlog_master>localhost:11334</binlog_master>
<binlog>slave</binlog>
</statfile>
<statfile>
<symbol>BAYES_SPAM</symbol>
<size>10M</size>
- <path>/var/run/rspamd/bayes_slave.spam</path>
+ <path>@LOCALSTATES_PREFIX@/bayes_slave.spam</path>
<binlog>slave</binlog>
<binlog_master>localhost:11334</binlog_master>
</statfile>
<statfile>
<symbol>BAYES_HAM_RU</symbol>
<size>50M</size>
- <path>/var/run/rspamd/bayes_ru.ham</path>
+ <path>@LOCALSTATES_PREFIX@/bayes_ru.ham</path>
<param name="language">ru</param>
</statfile>
<statfile>
<symbol>BAYES_SPAM_RU</symbol>
<size>50M</size>
- <path>/var/run/rspamd/bayes_ru.spam</path>
+ <path>@LOCALSTATES_PREFIX@/bayes_ru.spam</path>
<param name="language">ru</param>
</statfile>
<statfile>
<symbol>BAYES_HAM</symbol>
<size>50M</size>
- <path>/var/run/rspamd/bayes.ham</path>
+ <path>@LOCALSTATES_PREFIX@/bayes.ham</path>
</statfile>
<statfile>
<symbol>BAYES_SPAM</symbol>
<size>50M</size>
- <path>/var/run/rspamd/bayes.spam</path>
+ <path>@LOCALSTATES_PREFIX@/bayes.spam</path>
</statfile>
</classifier>
-->
<statfile>
<symbol>BAYES_HAM</symbol>
<size>10M</size>
- <path>/var/run/rspamd/bayes.ham</path>
+ <path>@LOCALSTATES_PREFIX@/bayes.ham</path>
</statfile>
<statfile>
<symbol>BAYES_SPAM</symbol>
<size>10M</size>
- <path>/var/run/rspamd/bayes.spam</path>
+ <path>@LOCALSTATES_PREFIX@/bayes.spam</path>
</statfile>
</classifier>