Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

CMakeLists.txt 5.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  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. option(USE_SELINUX "Enable SELinux policy module" OFF)
  7. set(CHROOT_DIR "${CMAKE_INSTALL_PREFIX}/lib/${PROJECT_NAME}" CACHE PATH "Chroot jail for daemon")
  8. set(SYSCONF_DIR "/etc" CACHE PATH "Global system configuration folder")
  9. set(SYSD_UNIT_DIR "${SYSCONF_DIR}/systemd/system" CACHE PATH "Systemd unit file folder")
  10. set(CONFIG_DIR "${SYSCONF_DIR}/default" CACHE PATH "Location of startup configuration file")
  11. set(DOC_DIR "share/doc/${PROJECT_NAME}" CACHE PATH "Path for documentation files")
  12. mark_as_advanced(CHROOT_DIR SYSCONF_DIR SYSD_UNIT_DIR CONFIG_DIR DOC_DIR)
  13. find_program(HELP2MAN help2man DOC "path to help2man executable")
  14. find_program(DD dd DOC "path to dd executable")
  15. find_program(BASE64 base64 DOC "path to base64 executable")
  16. find_program(OPENSSL openssl DOC "path to OpenSSL executable")
  17. find_program(INSSERV insserv DOC "path to insserv executable")
  18. find_program(CHKCONFIG chkconfig DOC "path to chkconfig executable")
  19. find_library(LIBSOCKET socket)
  20. find_library(LIBNSL nsl)
  21. if(BASE64)
  22. set(BASE64_ENCODE "${BASE64}")
  23. elseif(OPENSSL)
  24. set(BASE64_ENCODE "${OPENSSL} base64 -e")
  25. else()
  26. set(BASE64_ENCODE "")
  27. endif()
  28. check_include_file(sys/wait.h HAVE_SYS_WAIT_H)
  29. if(HAVE_SYS_WAIT_H)
  30. add_definitions(-DHAVE_SYS_WAIT_H)
  31. endif()
  32. check_include_file(wait.h HAVE_WAIT_H)
  33. if(HAVE_WAIT_H)
  34. add_definitions(-DHAVE_WAIT_H)
  35. endif()
  36. check_include_file(sys/time.h HAVE_SYS_TIME_H)
  37. if(HAVE_SYS_TIME_H)
  38. add_definitions(-DHAVE_SYS_TIME_H)
  39. endif()
  40. check_include_file(time.h HAVE_TIME_H)
  41. if(HAVE_TIME_H)
  42. add_definitions(-DHAVE_TIME_H)
  43. endif()
  44. check_include_file(alloca.h HAVE_ALLOCA_H)
  45. if(HAVE_ALLOCA_H)
  46. add_definitions(-DHAVE_ALLOCA_H)
  47. endif()
  48. check_include_file(sys/types.h HAVE_SYS_TYPES_H)
  49. if(HAVE_SYS_TYPES_H)
  50. add_definitions(-DHAVE_SYS_TYPES_H)
  51. endif()
  52. if(NOT DEFINED INIT_FLAVOR)
  53. if(IS_DIRECTORY "${SYSD_UNIT_DIR}" AND EXISTS "/usr/lib/systemd/systemd")
  54. message(STATUS "Detected init flavor: systemd")
  55. set(INIT_FLAVOR "systemd" CACHE STRING "Init daemon of this system")
  56. elseif(IS_DIRECTORY "${SYSCONF_DIR}/init" AND EXISTS "/lib/init/upstart-job")
  57. message(STATUS "Detected init flavor: upstart")
  58. set(INIT_FLAVOR "upstart" CACHE STRING "Init daemon of this system")
  59. elseif(IS_DIRECTORY "${SYSCONF_DIR}/init.d" AND EXISTS "${SYSCONF_DIR}/init.d/functions")
  60. message(STATUS "Detected init flavor: sysv-redhat")
  61. set(INIT_FLAVOR "sysv-redhat" CACHE STRING "Init daemon of this system")
  62. elseif(IS_DIRECTORY "${SYSCONF_DIR}/init.d" AND EXISTS "/lib/lsb/init-functions")
  63. message(STATUS "Detected init flavor: sysv-lsb")
  64. set(INIT_FLAVOR "sysv-lsb" CACHE STRING "Init daemon of this system")
  65. else()
  66. message(STATUS "Detected init flavor: none")
  67. message(STATUS "System startup files will not be installed")
  68. set(INIT_FLAVOR "" CACHE STRING "Init daemon of this system")
  69. endif()
  70. endif()
  71. add_executable(${PROJECT_NAME} postsrsd.c sha1.c srs2.c)
  72. if(${CMAKE_SYSTEM_NAME} MATCHES "SunOS")
  73. target_link_libraries(${PROJECT_NAME} ${LIBSOCKET} ${LIBNSL})
  74. endif()
  75. get_target_property(POSTSRSD ${PROJECT_NAME} LOCATION)
  76. get_filename_component(POSTSRSD ${POSTSRSD} NAME_WE)
  77. set(APPARMOR_PROFILE "${CMAKE_INSTALL_PREFIX}/sbin/${POSTSRSD}")
  78. string(REGEX REPLACE "^/+" "" APPARMOR_PROFILE "${APPARMOR_PROFILE}")
  79. string(REPLACE "/" "." APPARMOR_PROFILE "${APPARMOR_PROFILE}")
  80. configure_file(init/${PROJECT_NAME}.sysv-lsb.in ${PROJECT_NAME}.sysv-lsb @ONLY)
  81. configure_file(init/${PROJECT_NAME}.sysv-redhat.in ${PROJECT_NAME}.sysv-redhat @ONLY)
  82. configure_file(init/${PROJECT_NAME}.upstart.in ${PROJECT_NAME}.upstart @ONLY)
  83. configure_file(init/${PROJECT_NAME}.apparmor.in ${PROJECT_NAME}.apparmor @ONLY)
  84. configure_file(init/${PROJECT_NAME}.systemd.in ${PROJECT_NAME}.systemd @ONLY)
  85. configure_file(init/${PROJECT_NAME}.default.in ${PROJECT_NAME}.default @ONLY)
  86. configure_file(postinstall.cmake.in postinstall.cmake @ONLY)
  87. if(HELP2MAN)
  88. add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD
  89. COMMAND ${HELP2MAN} ARGS -s8 -o${PROJECT_NAME}.8 -n "Postfix Sender Rewriting Scheme daemon" -N -h-h -v-v ${CMAKE_CURRENT_BINARY_DIR}/${POSTSRSD}
  90. VERBATIM
  91. )
  92. install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.8 DESTINATION "share/man/man8")
  93. endif()
  94. if(USE_APPARMOR)
  95. install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.apparmor DESTINATION "${SYSCONF_DIR}/apparmor.d" RENAME "${APPARMOR_PROFILE}")
  96. endif()
  97. if(USE_SELINUX)
  98. file(COPY selinux/${PROJECT_NAME}.te selinux/${PROJECT_NAME}.fc DESTINATION selinux)
  99. add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD
  100. WORKING_DIRECTORY selinux
  101. COMMAND make -f /usr/share/selinux/devel/Makefile)
  102. install(FILES ${CMAKE_CURRENT_BINARY_DIR}/selinux/${PROJECT_NAME}.pp
  103. DESTINATION /usr/share/selinux/packages/${PROJECT_NAME})
  104. endif()
  105. install(TARGETS ${PROJECT_NAME} DESTINATION "sbin")
  106. install(FILES README.md README_UPGRADE.md main.cf.ex DESTINATION "${DOC_DIR}")
  107. install(SCRIPT "${CMAKE_CURRENT_BINARY_DIR}/postinstall.cmake")