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