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