CMakeLists.txt 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  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 inittab.c rcS.c ubus.c system.c sysupgrade.c
  15. service/service.c service/instance.c service/validate.c service/trigger.c service/watch.c
  16. 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(blobmsg_json NAMES blobmsg_json)
  23. FIND_LIBRARY(json_script NAMES json_script)
  24. FIND_LIBRARY(json NAMES json-c json)
  25. SET(LIBS ${ubox} ${ubus} ${json} ${blobmsg_json} ${json_script})
  26. IF(DEBUG)
  27. ADD_DEFINITIONS(-DUDEV_DEBUG -g3)
  28. ENDIF()
  29. IF(EARLY_PATH)
  30. ADD_DEFINITIONS(-DEARLY_PATH="${EARLY_PATH}")
  31. ENDIF()
  32. IF(ZRAM_TMPFS)
  33. ADD_DEFINITIONS(-DZRAM_TMPFS)
  34. SET(SOURCES_ZRAM initd/zram.c)
  35. ENDIF()
  36. add_subdirectory(upgraded)
  37. ADD_EXECUTABLE(procd ${SOURCES})
  38. TARGET_LINK_LIBRARIES(procd ${LIBS})
  39. INSTALL(TARGETS procd
  40. RUNTIME DESTINATION ${CMAKE_INSTALL_SBINDIR}
  41. )
  42. FIND_PATH(ubox_include_dir libubox/uloop.h)
  43. INCLUDE_DIRECTORIES(${ubox_include_dir})
  44. IF(DISABLE_INIT)
  45. ADD_DEFINITIONS(-DDISABLE_INIT)
  46. ELSE()
  47. ADD_EXECUTABLE(init initd/init.c initd/early.c initd/preinit.c initd/mkdev.c sysupgrade.c watchdog.c
  48. utils/utils.c ${SOURCES_ZRAM})
  49. TARGET_LINK_LIBRARIES(init ${LIBS})
  50. INSTALL(TARGETS init
  51. RUNTIME DESTINATION ${CMAKE_INSTALL_SBINDIR}
  52. )
  53. ADD_EXECUTABLE(udevtrigger plug/udevtrigger.c)
  54. INSTALL(TARGETS udevtrigger
  55. RUNTIME DESTINATION ${CMAKE_INSTALL_SBINDIR}
  56. )
  57. ENDIF()
  58. ADD_EXECUTABLE(askfirst utils/askfirst.c)
  59. INSTALL(TARGETS askfirst
  60. RUNTIME DESTINATION ${CMAKE_INSTALL_SBINDIR}
  61. )
  62. ADD_CUSTOM_COMMAND(
  63. OUTPUT syscall-names.h
  64. COMMAND ./make_syscall_h.sh ${CMAKE_C_COMPILER} > ./syscall-names.h
  65. DEPENDS ./make_syscall_h.sh
  66. )
  67. ADD_CUSTOM_TARGET(syscall-names-h DEPENDS syscall-names.h)
  68. ADD_CUSTOM_COMMAND(
  69. OUTPUT capabilities-names.h
  70. COMMAND ./make_capabilities_h.sh ${CMAKE_C_COMPILER} > ./capabilities-names.h
  71. DEPENDS ./make_capabilities_h.sh
  72. )
  73. ADD_CUSTOM_TARGET(capabilities-names-h DEPENDS capabilities-names.h)
  74. IF(SECCOMP_SUPPORT)
  75. ADD_DEFINITIONS(-DSECCOMP_SUPPORT)
  76. ADD_LIBRARY(preload-seccomp SHARED jail/preload.c jail/seccomp.c)
  77. TARGET_LINK_LIBRARIES(preload-seccomp dl ${ubox} ${blobmsg_json})
  78. INSTALL(TARGETS preload-seccomp
  79. LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
  80. )
  81. ADD_DEPENDENCIES(preload-seccomp syscall-names-h)
  82. endif()
  83. IF(SECCOMP_SUPPORT)
  84. SET(SOURCES_OCI_SECCOMP jail/seccomp-oci.c)
  85. ENDIF()
  86. IF(JAIL_SUPPORT)
  87. ADD_EXECUTABLE(ujail jail/jail.c jail/elf.c jail/fs.c jail/capabilities.c ${SOURCES_OCI_SECCOMP})
  88. TARGET_LINK_LIBRARIES(ujail ${ubox} ${ubus} ${blobmsg_json})
  89. INSTALL(TARGETS ujail
  90. RUNTIME DESTINATION ${CMAKE_INSTALL_SBINDIR}
  91. )
  92. ADD_DEPENDENCIES(ujail capabilities-names-h)
  93. IF(SECCOMP_SUPPORT)
  94. ADD_DEPENDENCIES(ujail syscall-names-h)
  95. ENDIF()
  96. ADD_EXECUTABLE(ujail-console jail/console.c)
  97. TARGET_LINK_LIBRARIES(ujail-console ${ubox} ${ubus} ${blobmsg_json})
  98. INSTALL(TARGETS ujail-console
  99. RUNTIME DESTINATION ${CMAKE_INSTALL_SBINDIR}
  100. )
  101. ADD_EXECUTABLE(uxc uxc.c)
  102. TARGET_LINK_LIBRARIES(uxc ${ubox} ${ubus} ${blobmsg_json})
  103. INSTALL(TARGETS uxc
  104. RUNTIME DESTINATION ${CMAKE_INSTALL_SBINDIR}
  105. )
  106. endif()
  107. IF(UTRACE_SUPPORT)
  108. ADD_EXECUTABLE(utrace trace/trace.c)
  109. TARGET_LINK_LIBRARIES(utrace ${ubox} ${json} ${blobmsg_json})
  110. INSTALL(TARGETS utrace
  111. RUNTIME DESTINATION ${CMAKE_INSTALL_SBINDIR}
  112. )
  113. ADD_DEPENDENCIES(utrace syscall-names-h)
  114. ADD_LIBRARY(preload-trace SHARED trace/preload.c)
  115. TARGET_LINK_LIBRARIES(preload-trace dl)
  116. INSTALL(TARGETS preload-trace
  117. LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
  118. )
  119. endif()