IF(ENABLE_REDIRECTOR MATCHES "ON")
CONFIGURE_FILE(freebsd/redirector.sh.in freebsd/redirector.sh @ONLY)
ENDIF(ENABLE_REDIRECTOR MATCHES "ON")
- 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 PREFIX)
- SET(PREFIX /usr/local)
- ENDIF(NOT PREFIX)
+ IF(CMAKE_INSTALL_PREFIX)
+ SET(ETC_PREFIX "${CMAKE_INSTALL_PREFIX}/etc")
+ SET(MAN_PREFIX "${CMAKE_INSTALL_PREFIX}/etc")
+ 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 PREFIX)
+ SET(PREFIX /usr/local)
+ ENDIF(NOT PREFIX)
+ ENDIF(CMAKE_INSTALL_PREFIX)
FIND_LIBRARY(LIBINTL_LIBRARY NAMES intl PATHS /lib
/opt/lib
/usr/lib
IF(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_BSD_SOURCE -DDARWIN")
-
- 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 PREFIX)
- SET(PREFIX /usr/local)
- ENDIF(NOT PREFIX)
+
+ IF(CMAKE_INSTALL_PREFIX)
+ SET(ETC_PREFIX "${CMAKE_INSTALL_PREFIX}/etc")
+ SET(MAN_PREFIX "${CMAKE_INSTALL_PREFIX}/etc")
+ 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 PREFIX)
+ SET(PREFIX /usr/local)
+ ENDIF(NOT PREFIX)
+ ENDIF(CMAKE_INSTALL_PREFIX)
FIND_LIBRARY(LIBINTL_LIBRARY NAMES intl PATHS /lib
/opt/lib
IF(CMAKE_SYSTEM_NAME STREQUAL "Linux")
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_GNU_SOURCE -DLINUX")
- 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(CMAKE_INSTALL_PREFIX)
+ SET(ETC_PREFIX "${CMAKE_INSTALL_PREFIX}/etc")
+ SET(MAN_PREFIX "${CMAKE_INSTALL_PREFIX}/etc")
+ 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)
+ ENDIF(CMAKE_INSTALL_PREFIX)
+
LIST(APPEND CMAKE_REQUIRED_LIBRARIES rt)
LIST(APPEND CMAKE_REQUIRED_LIBRARIES dl)
MESSAGE(STATUS "Configuring for Linux")
IF(CMAKE_SYSTEM_NAME STREQUAL "SunOS")
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_GNU_SOURCE -DSOLARIS")
- IF(NOT ETC_PREFIX)
- SET(ETC_PREFIX /etc)
- ENDIF(NOT ETC_PREFIX)
- IF(NOT PREFIX)
- SET(PREFIX /opt/rspamd)
- ENDIF(NOT PREFIX)
- IF(NOT MAN_PREFIX)
- SET(MAN_PREFIX /usr/share/man)
- ENDIF(NOT MAN_PREFIX)
-
+ IF(CMAKE_INSTALL_PREFIX)
+ SET(ETC_PREFIX "${CMAKE_INSTALL_PREFIX}/etc")
+ SET(MAN_PREFIX "${CMAKE_INSTALL_PREFIX}/etc")
+ 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 /opt/rspamd)
+ ENDIF(NOT PREFIX)
+ IF(NOT MAN_PREFIX)
+ SET(MAN_PREFIX /usr/share/man)
+ ENDIF(NOT MAN_PREFIX)
+ ENDIF(CMAKE_INSTALL_PREFIX)
+
LIST(APPEND CMAKE_REQUIRED_LIBRARIES rt)
LIST(APPEND CMAKE_REQUIRED_LIBRARIES dl)
LIST(APPEND CMAKE_REQUIRED_LIBRARIES resolv)
WORKING_DIRECTORY src)
IF(PERL_EXECUTABLE)
- ADD_CUSTOM_COMMAND(OUTPUT perl/Makefile
- DEPENDS perl/Makefile.PL
+ ADD_CUSTOM_COMMAND(OUTPUT ${CMAKE_SOURCE_DIR}/perl/Makefile
+ DEPENDS ${CMAKE_SOURCE_DIR}/perl/Makefile.PL
COMMAND ${PERL_EXECUTABLE} ./Makefile.PL DESTDIR=${DESTDIR} PREFIX=${PREFIX} INSTALLMAN3DIR=${MAN_PREFIX}/man3
- WORKING_DIRECTORY perl)
+ WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/perl)
CONFIGURE_FILE(perl/Makefile.PL.in perl/Makefile.PL)
ADD_CUSTOM_TARGET(perlmodule
- COMMAND make
- DEPENDS perl/Makefile
- WORKING_DIRECTORY perl
+ COMMAND ${CMAKE_MAKE_PROGRAM} DESTDIR=${DESTDIR}
+ DEPENDS ${CMAKE_SOURCE_DIR}/perl/Makefile
+ WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/perl
VERBATIM)
ENDIF(PERL_EXECUTABLE)
INSTALL(CODE "EXECUTE_PROCESS(COMMAND ${CMAKE_COMMAND} -E make_directory ${DESTDIR}/${ETC_PREFIX}/rspamd)")
ENDIF(NOT EXISTS ${DESTDIR}/${ETC_PREFIX}/rspamd)
-INSTALL(FILES conf/2tld.inc RENAME 2tld.inc.orig DESTINATION ${ETC_PREFIX}/rspamd)
+INSTALL(FILES conf/2tld.inc RENAME 2tld.inc.orig DESTINATION etc/rspamd)
IF(NOT EXISTS ${ETC_PREFIX}/rspamd/2tld.inc)
- INSTALL(FILES conf/2tld.inc DESTINATION ${ETC_PREFIX}/rspamd)
+ INSTALL(FILES conf/2tld.inc DESTINATION etc/rspamd)
ENDIF(NOT EXISTS ${ETC_PREFIX}/rspamd/2tld.inc)
-INSTALL(FILES conf/rspamd.xml.sample DESTINATION ${ETC_PREFIX}/)
+INSTALL(FILES conf/rspamd.xml.sample DESTINATION etc/)
# Lua plugins
IF(NOT IS_DIRECTORY ${DESTDIR}/${ETC_PREFIX}/rspamd/plugins/lua)
INSTALL(CODE "EXECUTE_PROCESS(COMMAND ${CMAKE_COMMAND} -E make_directory ${DESTDIR}/${ETC_PREFIX}/rspamd/plugins/lua/${_rp})")
ENDIF(NOT IS_DIRECTORY ${DESTDIR}/${ETC_PREFIX}/rspamd/plugins/lua/${_rp})
IF(NOT EXISTS ${DESTDIR}/${ETC_PREFIX}/rspamd/plugins/${_rp}/${LUA_PLUGIN})
- INSTALL(FILES "src/plugins/lua/${LUA_PLUGIN}" DESTINATION ${ETC_PREFIX}/rspamd/plugins/lua/${_rp})
+ INSTALL(FILES "src/plugins/lua/${LUA_PLUGIN}" DESTINATION etc/rspamd/plugins/lua/${_rp})
ENDIF(NOT EXISTS ${DESTDIR}/${ETC_PREFIX}/rspamd/plugins/${_rp}/${LUA_PLUGIN})
ENDFOREACH(LUA_PLUGIN)
INSTALL(CODE "EXECUTE_PROCESS(COMMAND ${CMAKE_COMMAND} -E make_directory ${DESTDIR}/${ETC_PREFIX}/rspamd/lua/${_rp})")
ENDIF(NOT IS_DIRECTORY ${DESTDIR}/${ETC_PREFIX}/rspamd/lua/${_rp})
IF(NOT EXISTS ${DESTDIR}/${ETC_PREFIX}/rspamd/lua/${_rp}/${LUA_CONF})
- INSTALL(FILES "conf/lua/${LUA_CONF}" DESTINATION ${ETC_PREFIX}/rspamd/lua/${_rp})
+ INSTALL(FILES "conf/lua/${LUA_CONF}" DESTINATION etc/rspamd/lua/${_rp})
ENDIF(NOT EXISTS ${DESTDIR}/${ETC_PREFIX}/rspamd/lua/${_rp}/${LUA_CONF})
ENDFOREACH(LUA_CONF)
INSTALL(CODE "EXECUTE_PROCESS(COMMAND chown ${RSPAMD_USER}:${RSPAMD_GROUP} ${DESTDIR}/var/run/rspamd/)")
ENDIF(CMAKE_SYSTEM_NAME STREQUAL "FreeBSD" AND NOT BUILD_PORT)
IF(CMAKE_SYSTEM_NAME STREQUAL "Linux")
- INSTALL(PROGRAMS linux/rspamd DESTINATION ${ETC_PREFIX}/init.d)
+ INSTALL(PROGRAMS linux/rspamd DESTINATION etc/init.d)
INSTALL(CODE "EXECUTE_PROCESS(COMMAND ${CMAKE_COMMAND} -E make_directory ${DESTDIR}/var/run/rspamd/)")
INSTALL(CODE "EXECUTE_PROCESS(COMMAND chown ${RSPAMD_USER}:${RSPAMD_GROUP} ${DESTDIR}/var/run/rspamd/)")
ENDIF(CMAKE_SYSTEM_NAME STREQUAL "Linux")
INCLUDE("linux/cmake/UseRPMTools.cmake")
ENDIF(CMAKE_SYSTEM_NAME STREQUAL "Linux")
+IF(CMAKE_SYSTEM_NAME STREQUAL "FreeBSD")
+ INCLUDE("freebsd/cmake/PkgCreate.cmake")
+ENDIF(CMAKE_SYSTEM_NAME STREQUAL "FreeBSD")
+
SET(RPMNAME "rspamd")
SET(PACKAGE_NAME "rspamd")
SET(PACKAGE_RELEASE "1")
SET(PACKAGE_DEPENDS "libc6, libevent-1.4-2, libgmime-2.0-2, libxml-parser-perl, libterm-readkey-perl, libglib2.0-0")
ENDIF(GMIME24)
-SET(PACKAGE_VERSION "${RSPAMD_VERSION_MAJOR}.${RSPAMD_VERSION_MINOR}.${RSPAMD_VERSION_PATCH}")
+SET(PACKAGE_VERSION "${RSPAMD_VERSION_MAJOR}.${RSPAMD_VERSION_MINOR}.${RSPAMD_VERSION_PATCH}_${ID}")
IF(RPMTools_FOUND)
IF(DPKG_FOUND STREQUAL "YES")
ADD_DEBIAN_PACKAGE("rspamd")
-ENDIF(DPKG_FOUND STREQUAL "YES")
\ No newline at end of file
+ENDIF(DPKG_FOUND STREQUAL "YES")
+IF(PKGCREATE_FOUND STREQUAL "YES")
+ ADD_FREEBSD_PACKAGE("rspamd" "freebsd/rspamd.plist")
+ENDIF(PKGCREATE_FOUND STREQUAL "YES")
\ No newline at end of file
--- /dev/null
+# PkgCreate creates FreeBSD package for cmake
+# USAGE : ADD_FREEBSD_PACKAGE ( PKG_TARGET_NAME [DESCRIPTION] )
+
+FIND_PROGRAM(PKGCREATE
+ NAMES pkg_create
+ PATHS "/usr/sbin")
+
+IF ( PKGCREATE )
+ GET_FILENAME_COMPONENT(PKGCREATE_PATH ${PKGCREATE} ABSOLUTE)
+ MESSAGE(STATUS "Found pkg_create : ${PKGCREATE_PATH}")
+ SET(PKGCREATE_FOUND "YES")
+ELSE ( PKGCREATE )
+ MESSAGE(STATUS "pkg_create NOT found. package generation will not be available")
+ SET(PKGCREATE_FOUND "NO")
+ENDIF ( PKGCREATE )
+
+MACRO(ADD_FREEBSD_PACKAGE PKGNAME PLIST_FILE)
+ # let's create a directory to call 'make install DESTDIR=...' into:
+ SET ( FREEBSD_DIR ${CMAKE_BINARY_DIR}/${PACKAGE_NAME}_${PACKAGE_VERSION}-${PACKAGE_RELEASE} )
+ FILE ( REMOVE ${FREEBSD_DIR} )
+ FILE ( MAKE_DIRECTORY ${FREEBSD_DIR} )
+ FILE ( MAKE_DIRECTORY ${FREEBSD_DIR}/pkg )
+ # Calling "make install DESTDIR=${FREEBSD_DIR}"
+ ADD_CUSTOM_TARGET(pkg_destdir_install
+ COMMAND ${CMAKE_MAKE_PROGRAM} install CMAKE_INSTALL_PREFIX=/ DESTDIR=${FREEBSD_DIR}
+ DEPENDS ${CMAKE_BINARY_DIR}/cmake_install.cmake
+ COMMENT "Installing with DESTDIR = ${FREEBSD_DIR}"
+ )
+ ADD_DEPENDENCIES(pkg_destdir_install pkg_destdir_preinstall)
+ ADD_CUSTOM_TARGET(pkg_destdir_preinstall
+ COMMAND ${CMAKE_COMMAND} -DCMAKE_INSTALL_PREFIX=/ -DDESTDIR=${FREEBSD_DIR} .
+ DEPENDS ${CMAKE_BINARY_DIR}/cmake_install.cmake
+ COMMENT "Configuring with DESTDIR = ${FREEBSD_DIR}"
+ )
+ ADD_DEPENDENCIES(pkg_destdir_preinstall all preinstall)
+
+
+ ADD_CUSTOM_COMMAND(
+ OUTPUT ${CMAKE_BINARY_DIR}/${PACKAGE_NAME}_${PACKAGE_VERSION}-${PACKAGE_RELEASE}.tbz
+ COMMAND ${PKGCREATE_PATH} -c -"${PACKAGE_DESCRIPTION_SUMMARY}"
+ -d -"${PACKAGE_DESCRIPTION}"
+ -f ${PLIST_FILE}
+ -p ${FREEBSD_DIR}
+ ${CMAKE_BINARY_DIR}/${PACKAGE_NAME}_${PACKAGE_VERSION}-${PACKAGE_RELEASE}.tbz
+ # removing control, so its (re)generated each time we need to build the package
+ DEPENDS ${PLIST_FILE}
+ COMMENT "Generating freebsd package"
+ )
+
+ # the final target:
+ ADD_CUSTOM_TARGET(${PKGNAME}_pkg
+ DEPENDS ${CMAKE_BINARY_DIR}/${PACKAGE_NAME}_${PACKAGE_VERSION}-${PACKAGE_RELEASE}.tbz
+ )
+
+ ADD_DEPENDENCIES(${PKGNAME}_pkg pkg_destdir_install)
+ENDMACRO(ADD_FREEBSD_PACKAGE PKGNAME)
\ No newline at end of file