Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

CMakeLists.txt 3.5KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. cmake_minimum_required(VERSION 2.4)
  2. project(postsrsd C)
  3. include(CheckIncludeFile)
  4. option(GENERATE_SRS_SECRET "Generate a random SRS secret if none exists during install" ON)
  5. option(USE_APPARMOR "Enable AppArmor profile" OFF)
  6. set(CHROOT_DIR "${CMAKE_INSTALL_PREFIX}/lib/${PROJECT_NAME}" CACHE PATH "Chroot jail for daemon")
  7. set(SYSCONF_DIR "/etc" CACHE PATH "Global system configuration folder")
  8. set(CONFIG_DIR "${SYSCONF_DIR}/default" CACHE PATH "Location of startup configuration file")
  9. set(DOC_DIR "share/doc/${PROJECT_NAME}" CACHE PATH "Path for documentation files")
  10. find_program(HELP2MAN help2man DOC "path to help2man executable")
  11. find_program(DD dd DOC "path to dd executable")
  12. find_program(BASE64 base64 DOC "path to base64 executable")
  13. find_program(INSSERV insserv DOC "path to insserv executable")
  14. find_program(CHKCONFIG chkconfig DOC "path to chkconfig executable")
  15. check_include_file(sys/wait.h HAVE_SYS_WAIT_H)
  16. if(HAVE_SYS_WAIT_H)
  17. add_definitions(-DHAVE_SYS_WAIT_H)
  18. endif()
  19. check_include_file(wait.h HAVE_WAIT_H)
  20. if(HAVE_WAIT_H)
  21. add_definitions(-DHAVE_WAIT_H)
  22. endif()
  23. check_include_file(sys/time.h HAVE_SYS_TIME_H)
  24. if(HAVE_SYS_TIME_H)
  25. add_definitions(-DHAVE_SYS_TIME_H)
  26. endif()
  27. check_include_file(time.h HAVE_TIME_H)
  28. if(HAVE_TIME_H)
  29. add_definitions(-DHAVE_TIME_H)
  30. endif()
  31. if(NOT DEFINED INIT_FLAVOR)
  32. if(IS_DIRECTORY "${SYSCONF_DIR}/init" AND EXISTS "/lib/init/upstart-job")
  33. message(STATUS "Detected init flavor: upstart")
  34. set(INIT_FLAVOR "upstart" CACHE STRING "Init daemon of this system")
  35. elseif(IS_DIRECTORY "${SYSCONF_DIR}/init.d" AND EXISTS "${SYSCONF_DIR}/init.d/functions")
  36. message(STATUS "Detected init flavor: sysv-redhat")
  37. set(INIT_FLAVOR "sysv-redhat" CACHE STRING "Init daemon of this system")
  38. elseif(IS_DIRECTORY "${SYSCONF_DIR}/init.d" AND EXISTS "/lib/lsb/init-functions")
  39. message(STATUS "Detected init flavor: sysv-lsb")
  40. set(INIT_FLAVOR "sysv-lsb" CACHE STRING "Init daemon of this system")
  41. else()
  42. message(STATUS "Detected init flavor: none")
  43. message(STATUS "System startup files will not be installed")
  44. set(INIT_FLAVOR "" CACHE STRING "Init daemon of this system")
  45. endif()
  46. endif()
  47. add_executable(${PROJECT_NAME} postsrsd.c sha1.c srs2.c)
  48. get_target_property(POSTSRSD ${PROJECT_NAME} LOCATION)
  49. get_filename_component(POSTSRSD ${POSTSRSD} NAME_WE)
  50. set(APPARMOR_PROFILE "${CMAKE_INSTALL_PREFIX}/sbin/${POSTSRSD}")
  51. string(REGEX REPLACE "^/+" "" APPARMOR_PROFILE "${APPARMOR_PROFILE}")
  52. string(REPLACE "/" "." APPARMOR_PROFILE "${APPARMOR_PROFILE}")
  53. configure_file(${PROJECT_NAME}.lsb_init.in ${PROJECT_NAME}.lsb_init @ONLY)
  54. configure_file(${PROJECT_NAME}.rh_init.in ${PROJECT_NAME}.rh_init @ONLY)
  55. configure_file(${PROJECT_NAME}.upstart.in ${PROJECT_NAME}.upstart @ONLY)
  56. configure_file(${PROJECT_NAME}.apparmor.in ${PROJECT_NAME}.apparmor @ONLY)
  57. configure_file(postinstall.cmake.in postinstall.cmake @ONLY)
  58. if(HELP2MAN)
  59. add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD
  60. COMMAND ${HELP2MAN} ARGS -s8 -o${PROJECT_NAME}.8 -n "Postfix Sender Rewriting Scheme daemon" -N -h-h -v-v ${CMAKE_CURRENT_BINARY_DIR}/${POSTSRSD}
  61. VERBATIM
  62. )
  63. install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.8 DESTINATION "share/man/man8")
  64. endif()
  65. if(USE_APPARMOR)
  66. install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.apparmor DESTINATION "${SYSCONF_DIR}/apparmor.d" RENAME "${APPARMOR_PROFILE}")
  67. endif()
  68. install(TARGETS ${PROJECT_NAME} DESTINATION "sbin")
  69. install(FILES README.md main.cf.ex DESTINATION "${DOC_DIR}")
  70. install(SCRIPT "${CMAKE_CURRENT_BINARY_DIR}/postinstall.cmake")