diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2013-11-19 16:17:13 +0000 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2013-11-19 16:17:13 +0000 |
commit | 4abb85d399ff5d9ae83dc76a9cfdb416ec13137a (patch) | |
tree | ba4f28252e9bd539bc0e963f44235276c170fb8b /CMakeLists.txt | |
parent | c87580806c6e941fe34be0751f928325271ee7eb (diff) | |
download | rspamd-4abb85d399ff5d9ae83dc76a9cfdb416ec13137a.tar.gz rspamd-4abb85d399ff5d9ae83dc76a9cfdb416ec13137a.zip |
Rework build and install paths.
Diffstat (limited to 'CMakeLists.txt')
-rw-r--r-- | CMakeLists.txt | 221 |
1 files changed, 52 insertions, 169 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index e558c93e5..fda25e115 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -43,6 +43,42 @@ OPTION(FORCE_GMIME24 "Link with gmime2.4 [default: OFF]" # Build optimized code for following CPU (default i386) #SET(CPU_TUNE "i686") +# Now CMAKE_INSTALL_PREFIX is a base prefix for everything +# CONFDIR - for configuration +# MANDIR - for manual pages +# RUNDIR - for runtime files +# DBDIR - for static files +# LOGDIR - for log files +# EXAMPLESDIR - for examples files + +IF(NOT CONFDIR) + SET(CONFDIR "${CMAKE_INSTALL_PREFIX}/etc/rspamd") +ENDIF(NOT CONFDIR) + +IF(NOT MANDIR) + SET(MANDIR "${CMAKE_INSTALL_PREFIX}/share/man") +ENDIF(NOT MANDIR) + +IF(NOT RUNDIR) + SET(RUNDIR "${CMAKE_INSTALL_PREFIX}/var/run/rspamd") +ENDIF(NOT RUNDIR) + +IF(NOT DBDIR) + SET(DBDIR "${CMAKE_INSTALL_PREFIX}/var/lib/rspamd") +ENDIF(NOT DBDIR) + +IF(NOT LOGDIR) + SET(LOGDIR "${CMAKE_INSTALL_PREFIX}/var/log/rspamd") +ENDIF(NOT LOGDIR) + +IF(NOT EXAMPLESDIR) + SET(EXAMPLESDIR "${CMAKE_INSTALL_PREFIX}/share/examples/rspamd") +ENDIF(NOT EXAMPLESDIR) + +IF(NOT PLUGINSDIR) + SET(PLUGINSDIR "${CMAKE_INSTALL_PREFIX}/share/rspamd") +ENDIF(NOT PLUGINSDIR) + ############################# INCLUDE SECTION ############################################# INCLUDE(CheckIncludeFiles) @@ -217,31 +253,6 @@ IF(CMAKE_SYSTEM_NAME STREQUAL "FreeBSD") IF(ENABLE_REDIRECTOR MATCHES "ON") CONFIGURE_FILE(freebsd/redirector.sh.in freebsd/redirector @ONLY) ENDIF(ENABLE_REDIRECTOR MATCHES "ON") - IF(CMAKE_INSTALL_PREFIX) - 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 "${CMAKE_INSTALL_PREFIX}/var/run/rspamd") - ENDIF(NOT LOCALSTATES_PREFIX) - SET(PREFIX "${CMAKE_INSTALL_PREFIX}") - ELSE(CMAKE_INSTALL_PREFIX) - IF(NOT ETC_PREFIX) - SET(ETC_PREFIX /usr/local/etc) - ENDIF(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) - ENDIF(CMAKE_INSTALL_PREFIX) FIND_LIBRARY(LIBINTL_LIBRARY NAMES intl PATHS /lib /opt/lib /usr/lib @@ -254,32 +265,6 @@ ENDIF(CMAKE_SYSTEM_NAME STREQUAL "FreeBSD") IF(CMAKE_SYSTEM_NAME STREQUAL "Darwin") SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_BSD_SOURCE -DDARWIN") - - IF(CMAKE_INSTALL_PREFIX) - 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 "${CMAKE_INSTALL_PREFIX}/var/run/rspamd") - ENDIF(NOT LOCALSTATES_PREFIX) - SET(PREFIX "${CMAKE_INSTALL_PREFIX}") - ELSE(CMAKE_INSTALL_PREFIX) - IF(NOT ETC_PREFIX) - SET(ETC_PREFIX /usr/local/etc) - ENDIF(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) - ENDIF(CMAKE_INSTALL_PREFIX) FIND_LIBRARY(LIBINTL_LIBRARY NAMES intl PATHS /lib /opt/lib @@ -293,33 +278,6 @@ ENDIF(CMAKE_SYSTEM_NAME STREQUAL "Darwin") IF(CMAKE_SYSTEM_NAME STREQUAL "Linux") SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_GNU_SOURCE -DLINUX") - IF(CMAKE_INSTALL_PREFIX) - 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}/share/man") - ENDIF(NOT MAN_PREFIX) - IF(NOT LOCALSTATES_PREFIX) - SET(LOCALSTATES_PREFIX "${CMAKE_INSTALL_PREFIX}/var/run/rspamd") - ENDIF(NOT LOCALSTATES_PREFIX) - - SET(PREFIX "${CMAKE_INSTALL_PREFIX}") - ELSE(CMAKE_INSTALL_PREFIX) - IF(NOT ETC_PREFIX) - SET(ETC_PREFIX /etc) - ENDIF(NOT ETC_PREFIX) - IF(NOT PREFIX) - SET(PREFIX /usr) - ENDIF(NOT 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) IF(BUILD_CPU_MODE STREQUAL "32") SET(CMAKE_C_FLAGS "-D_FILE_OFFSET_BITS=64 -D_LARGEFILE64_SOURCE ${CMAKE_C_FLAGS}") ENDIF(BUILD_CPU_MODE STREQUAL "32") @@ -371,32 +329,6 @@ IF(CMAKE_SYSTEM_NAME STREQUAL "SunOS") ENDIF (BUILD_CPU_MODE STREQUAL "32") SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D__EXTENSIONS__ -DSOLARIS -D_POSIX_SOURCE -D_POSIX_C_SOURCE=200112L") - - IF(CMAKE_INSTALL_PREFIX) - 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) - SET(ETC_PREFIX /etc) - ENDIF(NOT ETC_PREFIX) - IF(NOT PREFIX) - SET(PREFIX /usr) - ENDIF(NOT 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) LIST(APPEND CMAKE_REQUIRED_LIBRARIES dl) @@ -424,32 +356,6 @@ IF(NOT INCLUDEDIR) SET(INCLUDEDIR include/rspamd) ENDIF(NOT INCLUDEDIR) -# 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") - 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 "${CMAKE_INSTALL_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 # Find lua libraries @@ -1091,7 +997,6 @@ LIST(LENGTH PLUGINSSRC RSPAMD_MODULES_NUM) CONFIGURE_FILE(config.h.in src/config.h) CONFIGURE_FILE(contrib/exim/local_scan.c.in contrib/exim/local_scan_rspamd.c @ONLY) -CONFIGURE_FILE(conf/rspamd-basic.xml.in conf/rspamd.xml.sample @ONLY) ######################### LINK SECTION ############################### @@ -1166,56 +1071,34 @@ ENDIF(GLIB_COMPAT) INSTALL(TARGETS rspamd RUNTIME DESTINATION bin) # Configs -INSTALL(CODE "FILE(MAKE_DIRECTORY \$ENV{DESTDIR}${ETC_PREFIX}/rspamd)") - -INSTALL(FILES conf/2tld.inc RENAME 2tld.inc DESTINATION ${ETC_PREFIX}/rspamd) -IF(NOT EXISTS ${ETC_PREFIX}/rspamd/2tld.inc OR BUILD_PORT) - INSTALL(FILES conf/2tld.inc DESTINATION ${ETC_PREFIX}/rspamd) -ENDIF(NOT EXISTS ${ETC_PREFIX}/rspamd/2tld.inc OR BUILD_PORT) +INSTALL(CODE "FILE(MAKE_DIRECTORY \$ENV{DESTDIR}${CONFDIR})") +INSTALL(CODE "FILE(MAKE_DIRECTORY \$ENV{DESTDIR}${EXAMPLESDIR})") +INSTALL(CODE "FILE(MAKE_DIRECTORY \$ENV{DESTDIR}${PLUGINSDIR}/lua)") -INSTALL(FILES conf/surbl-whitelist.inc RENAME surbl-whitelist.inc DESTINATION ${ETC_PREFIX}/rspamd) -IF(NOT EXISTS ${ETC_PREFIX}/rspamd/surbl-whitelist.inc OR BUILD_PORT) - INSTALL(FILES conf/surbl-whitelist.inc DESTINATION ${ETC_PREFIX}/rspamd) -ENDIF(NOT EXISTS ${ETC_PREFIX}/rspamd/surbl-whitelist.inc OR BUILD_PORT) +INSTALL(FILES conf/2tld.inc RENAME 2tld.inc DESTINATION ${CONFDIR}) -IF(NOT DEBIAN_BUILD) - INSTALL(FILES ${CMAKE_BINARY_DIR}/conf/rspamd.xml.sample DESTINATION ${ETC_PREFIX}) -ENDIF(NOT DEBIAN_BUILD) +INSTALL(FILES conf/surbl-whitelist.inc RENAME surbl-whitelist.inc DESTINATION ${CONFDIR}) # Lua plugins -INSTALL(CODE "FILE(MAKE_DIRECTORY \$ENV{DESTDIR}${ETC_PREFIX}/rspamd/plugins/lua)") -FILE(GLOB LUA_PLUGINS RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}/src/plugins/lua" "${CMAKE_CURRENT_SOURCE_DIR}/src/plugins/lua/*.lua" ) +FILE(GLOB LUA_PLUGINS RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}/src/plugins/lua" + "${CMAKE_CURRENT_SOURCE_DIR}/src/plugins/lua/*.lua" ) FOREACH(LUA_PLUGIN ${LUA_PLUGINS}) GET_FILENAME_COMPONENT(_rp ${LUA_PLUGIN} PATH) - INSTALL(CODE "FILE(MAKE_DIRECTORY \$ENV{DESTDIR}${ETC_PREFIX}/rspamd/plugins/lua/${_rp})") - INSTALL(FILES "src/plugins/lua/${LUA_PLUGIN}" DESTINATION ${ETC_PREFIX}/rspamd/plugins/lua/${_rp}) + INSTALL(CODE "FILE(MAKE_DIRECTORY \$ENV{DESTDIR}${PLUGINSDIR}/lua/${_rp})") + INSTALL(FILES "src/plugins/lua/${LUA_PLUGIN}" DESTINATION ${PLUGINSDIR}/lua/${_rp}) ENDFOREACH(LUA_PLUGIN) # Lua config -INSTALL(CODE "FILE(MAKE_DIRECTORY \$ENV{DESTDIR}${ETC_PREFIX}/rspamd/lua)") -FILE(GLOB_RECURSE LUA_CONFIGS RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}/conf/lua" "${CMAKE_CURRENT_SOURCE_DIR}/conf/lua/*.lua") +INSTALL(CODE "FILE(MAKE_DIRECTORY \$ENV{DESTDIR}${CONFDIR}/lua)") +FILE(GLOB_RECURSE LUA_CONFIGS RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}/conf/lua" + "${CMAKE_CURRENT_SOURCE_DIR}/conf/lua/*.lua") FOREACH(LUA_CONF ${LUA_CONFIGS}) GET_FILENAME_COMPONENT(_rp ${LUA_CONF} PATH) - INSTALL(CODE "FILE(MAKE_DIRECTORY \$ENV{DESTDIR}${ETC_PREFIX}/rspamd/lua/${_rp})") - INSTALL(FILES "conf/lua/${LUA_CONF}" DESTINATION ${ETC_PREFIX}/rspamd/lua/${_rp}) + INSTALL(CODE "FILE(MAKE_DIRECTORY \$ENV{DESTDIR}${CONFDIR}/lua/${_rp})") + INSTALL(FILES "conf/lua/${LUA_CONF}" DESTINATION ${CONFDIR}/lua/${_rp}) ENDFOREACH(LUA_CONF) # Manual pages -INSTALL(FILES "doc/rspamd.8" DESTINATION ${MAN_PREFIX}/man8) -INSTALL(FILES "doc/rspamc.1" DESTINATION ${MAN_PREFIX}/man1) - -# Start scripts -IF(CMAKE_SYSTEM_NAME STREQUAL "FreeBSD" AND NOT BUILD_PORT) - INSTALL(PROGRAMS ${CMAKE_BINARY_DIR}/freebsd/rspamd DESTINATION ${ETC_PREFIX}/rc.d) - 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}/${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" AND NOT DEBIAN_BUILD) - INSTALL(PROGRAMS "linux/${LINUX_START_SCRIPT}" DESTINATION ${ETC_PREFIX}/init.d RENAME 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" AND NOT DEBIAN_BUILD) +INSTALL(FILES "doc/rspamd.8" DESTINATION ${MANDIR}/man8) +INSTALL(FILES "doc/rspamc.1" DESTINATION ${MANDIR}/man1)
\ No newline at end of file |