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