CMakeLists.txt 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. cmake_minimum_required(VERSION 2.6)
  2. PROJECT(procd C)
  3. INCLUDE(GNUInstallDirs)
  4. ADD_DEFINITIONS(-Os -ggdb -Wall -Werror --std=gnu99 -Wmissing-declarations)
  5. SET(CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "")
  6. IF(APPLE)
  7. INCLUDE_DIRECTORIES(/opt/local/include)
  8. LINK_DIRECTORIES(/opt/local/lib)
  9. ENDIF()
  10. ADD_LIBRARY(setlbf SHARED service/setlbf.c)
  11. INSTALL(TARGETS setlbf
  12. LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
  13. )
  14. SET(SOURCES procd.c signal.c state.c hotplug-dispatch.c inittab.c rcS.c ubus.c
  15. system.c sysupgrade.c service/service.c service/instance.c
  16. service/validate.c service/trigger.c service/watch.c utils/utils.c)
  17. IF(NOT DISABLE_INIT)
  18. SET(SOURCES ${SOURCES} watchdog.c plug/coldplug.c plug/hotplug.c)
  19. ENDIF()
  20. FIND_LIBRARY(ubox NAMES ubox)
  21. FIND_LIBRARY(ubus NAMES ubus)
  22. FIND_LIBRARY(uci NAMES uci)
  23. FIND_LIBRARY(blobmsg_json NAMES blobmsg_json)
  24. FIND_LIBRARY(json_script NAMES json_script)
  25. FIND_LIBRARY(json NAMES json-c json)
  26. FIND_LIBRARY(udebug NAMES udebug)
  27. SET(LIBS ${ubox} ${ubus} ${json} ${blobmsg_json} ${json_script} ${udebug})
  28. IF(DEBUG)
  29. ADD_DEFINITIONS(-DUDEV_DEBUG -g3)
  30. ENDIF()
  31. IF(EARLY_PATH)
  32. ADD_DEFINITIONS(-DEARLY_PATH="${EARLY_PATH}")
  33. ENDIF()
  34. IF(SELINUX)
  35. include(FindPkgConfig)
  36. pkg_search_module(SELINUX REQUIRED libselinux)
  37. add_compile_definitions(WITH_SELINUX)
  38. ENDIF()
  39. add_subdirectory(upgraded)
  40. ADD_EXECUTABLE(procd ${SOURCES})
  41. TARGET_LINK_LIBRARIES(procd ${LIBS})
  42. SET_TARGET_PROPERTIES(procd PROPERTIES COMPILE_DEFINITIONS "HAS_UDEBUG")
  43. INSTALL(TARGETS procd
  44. RUNTIME DESTINATION ${CMAKE_INSTALL_SBINDIR}
  45. )
  46. FIND_PATH(ubox_include_dir libubox/uloop.h)
  47. FIND_PATH(udebug_include_dir NAMES udebug.h)
  48. INCLUDE_DIRECTORIES(${ubox_include_dir} ${udebug_include_dir})
  49. IF(DISABLE_INIT)
  50. ADD_DEFINITIONS(-DDISABLE_INIT)
  51. ELSE()
  52. ADD_EXECUTABLE(init initd/init.c initd/early.c initd/preinit.c initd/mkdev.c sysupgrade.c watchdog.c
  53. utils/utils.c)
  54. TARGET_INCLUDE_DIRECTORIES(init PUBLIC ${SELINUX_INCLUDE_DIRS})
  55. TARGET_LINK_LIBRARIES(init ${LIBS} ${SELINUX_LIBRARIES})
  56. INSTALL(TARGETS init
  57. RUNTIME DESTINATION ${CMAKE_INSTALL_SBINDIR}
  58. )
  59. ADD_EXECUTABLE(udevtrigger plug/udevtrigger.c)
  60. INSTALL(TARGETS udevtrigger
  61. RUNTIME DESTINATION ${CMAKE_INSTALL_SBINDIR}
  62. )
  63. ENDIF()
  64. ADD_EXECUTABLE(askfirst utils/askfirst.c)
  65. INSTALL(TARGETS askfirst
  66. RUNTIME DESTINATION ${CMAKE_INSTALL_SBINDIR}
  67. )
  68. ADD_CUSTOM_COMMAND(
  69. OUTPUT syscall-names.h
  70. COMMAND ./make_syscall_h.sh ${CMAKE_C_COMPILER} > ./syscall-names.h
  71. DEPENDS ./make_syscall_h.sh
  72. )
  73. ADD_CUSTOM_TARGET(syscall-names-h DEPENDS syscall-names.h)
  74. ADD_CUSTOM_COMMAND(
  75. OUTPUT capabilities-names.h
  76. COMMAND ./make_capabilities_h.sh ${CMAKE_C_COMPILER} > ./capabilities-names.h
  77. DEPENDS ./make_capabilities_h.sh
  78. )
  79. ADD_CUSTOM_TARGET(capabilities-names-h DEPENDS capabilities-names.h)
  80. IF(SECCOMP_SUPPORT)
  81. ADD_DEFINITIONS(-DSECCOMP_SUPPORT)
  82. ADD_LIBRARY(preload-seccomp SHARED jail/preload.c jail/seccomp.c jail/seccomp-oci.c)
  83. TARGET_LINK_LIBRARIES(preload-seccomp dl ${ubox} ${blobmsg_json})
  84. INSTALL(TARGETS preload-seccomp
  85. LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
  86. )
  87. ADD_DEPENDENCIES(preload-seccomp syscall-names-h)
  88. SET(SOURCES_OCI_SECCOMP jail/seccomp-oci.c)
  89. ENDIF()
  90. IF(JAIL_SUPPORT)
  91. ADD_EXECUTABLE(ujail jail/jail.c jail/cgroups.c jail/cgroups-bpf.c jail/elf.c jail/fs.c jail/capabilities.c jail/netifd.c ${SOURCES_OCI_SECCOMP})
  92. TARGET_LINK_LIBRARIES(ujail ${ubox} ${ubus} ${uci} ${blobmsg_json})
  93. INSTALL(TARGETS ujail
  94. RUNTIME DESTINATION ${CMAKE_INSTALL_SBINDIR}
  95. )
  96. ADD_DEPENDENCIES(ujail capabilities-names-h)
  97. IF(SECCOMP_SUPPORT)
  98. ADD_DEPENDENCIES(ujail syscall-names-h)
  99. ENDIF()
  100. ADD_EXECUTABLE(uxc uxc.c)
  101. TARGET_LINK_LIBRARIES(uxc ${ubox} ${ubus} ${blobmsg_json})
  102. INSTALL(TARGETS uxc
  103. RUNTIME DESTINATION ${CMAKE_INSTALL_SBINDIR}
  104. )
  105. endif()
  106. IF(UTRACE_SUPPORT)
  107. ADD_EXECUTABLE(utrace trace/trace.c)
  108. TARGET_LINK_LIBRARIES(utrace ${ubox} ${json} ${blobmsg_json})
  109. INSTALL(TARGETS utrace
  110. RUNTIME DESTINATION ${CMAKE_INSTALL_SBINDIR}
  111. )
  112. ADD_DEPENDENCIES(utrace syscall-names-h)
  113. ADD_LIBRARY(preload-trace SHARED trace/preload.c)
  114. TARGET_LINK_LIBRARIES(preload-trace dl)
  115. INSTALL(TARGETS preload-trace
  116. LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
  117. )
  118. endif()