]>
Commit | Line | Data |
---|---|---|
1fbf5591 CB |
1 | # SPDX-License-Identifier: LGPL-2.1-or-later |
2 | ||
3 | project('lxcfs', 'c', | |
4 | version : '4.0.0', | |
5 | license : 'LGPLv2+', | |
6 | default_options: [ | |
ff6b89e2 CB |
7 | 'b_colorout=always', |
8 | 'b_asneeded=true', | |
9 | 'b_pie=true', | |
1fbf5591 CB |
10 | 'c_std=gnu11', |
11 | 'warning_level=2', | |
12 | ], | |
13 | meson_version : '>= 0.45', | |
14 | ) | |
15 | ||
16 | conf = configuration_data() | |
17 | conf.set_quoted('PROJECT_URL', 'https://linuxcontainers.org/lxcfs/introduction/') | |
18 | conf.set('PROJECT_VERSION', meson.project_version(), | |
19 | description : 'Numerical project version (used where a simple number is expected)') | |
20 | project_source_root = meson.current_source_dir() | |
21 | project_build_root = meson.current_build_dir() | |
22 | ||
23 | # join_paths ignores the preceding arguments if an absolute component is | |
24 | # encountered, so this should canonicalize various paths when they are | |
25 | # absolute or relative. | |
26 | prefixdir = get_option('prefix') | |
27 | if not prefixdir.startswith('/') | |
28 | error('Prefix is not absolute: "@0@"'.format(prefixdir)) | |
29 | endif | |
30 | bindir = join_paths(prefixdir, get_option('bindir')) | |
31 | libdir = join_paths(prefixdir, get_option('libdir')) | |
32 | lxcfsdir = join_paths(libdir, 'lxcfs') | |
33 | sysconfdir = join_paths(prefixdir, get_option('sysconfdir')) | |
34 | runtimepath = join_paths(prefixdir, get_option('runtime-path')) | |
35 | localstatedir = join_paths('/', get_option('localstatedir')) | |
0d2038cd | 36 | datadir = join_paths(prefixdir, get_option('datadir')) |
1fbf5591 | 37 | |
1fbf5591 CB |
38 | conf.set_quoted('BINDIR', bindir) |
39 | conf.set_quoted('LIBDIR', libdir) | |
40 | conf.set_quoted('LOCALSTATEDIR', localstatedir) | |
1fbf5591 CB |
41 | conf.set_quoted('RUNTIME_PATH', runtimepath) |
42 | conf.set_quoted('SYSCONFDIR', sysconfdir) | |
43 | ||
0d2038cd CB |
44 | conf.set_quoted('LXCFS_BUILD_ROOT', project_build_root) |
45 | conf.set_quoted('LXCFS_SOURCE_ROOT', project_source_root) | |
46 | ||
47 | lxcfssharedir = join_paths(datadir, 'lxcfs') | |
48 | conf.set_quoted('LXCFSSHAREDIR', lxcfssharedir) | |
49 | ||
50 | lxcconfdir = join_paths(datadir, 'lxc/config/common.conf.d') | |
51 | conf.set_quoted('LXCCONFDIR', lxcconfdir) | |
52 | ||
1fbf5591 CB |
53 | init_script = get_option('init-script') |
54 | ||
55 | cc = meson.get_compiler('c') | |
56 | meson_build_sh = find_program('tools/meson-build.sh') | |
57 | ||
58 | want_tests = get_option('tests') | |
59 | ||
60 | possible_cc_flags = [ | |
1fbf5591 | 61 | '-Wvla', |
1fbf5591 CB |
62 | '-Wimplicit-fallthrough=5', |
63 | '-Wcast-align', | |
64 | '-Wstrict-prototypes', | |
65 | '-fno-strict-aliasing', | |
66 | '-fstack-clash-protection', | |
67 | '-fstack-protector-strong', | |
68 | '--param=ssp-buffer-size=4', | |
69 | '--mcet -fcf-protection', | |
70 | '-Werror=implicit-function-declaration', | |
71 | '-Wlogical-op', | |
72 | '-Wmissing-include-dirs', | |
73 | '-Wold-style-definition', | |
74 | '-Winit-self', | |
75 | '-Wunused-but-set-variable', | |
76 | '-Wno-unused-parameter', | |
77 | '-Wfloat-equal', | |
78 | '-Wsuggest-attribute=noreturn', | |
79 | '-Werror=return-type', | |
80 | '-Werror=incompatible-pointer-types', | |
81 | '-Wformat=2', | |
82 | '-Wshadow', | |
83 | '-Wendif-labels', | |
84 | '-Werror=overflow', | |
85 | '-fdiagnostics-show-option', | |
86 | '-Werror=shift-count-overflow', | |
87 | '-Werror=shift-overflow=2', | |
88 | '-Wdate-time', | |
89 | '-Wnested-externs', | |
90 | '-fasynchronous-unwind-tables', | |
91 | '-fexceptions', | |
92 | '-Warray-bounds', | |
93 | '-Wrestrict', | |
94 | '-Wreturn-local-addr', | |
95 | '-fsanitize=cfi', | |
96 | '-Wstringop-overflow', | |
97 | ] | |
98 | ||
99 | possible_link_flags = [ | |
1fbf5591 CB |
100 | '-Wl,--gc-sections', |
101 | '-Wl,-z,relro', | |
102 | '-Wl,-z,now', | |
1fbf5591 CB |
103 | '-Wl,-fuse-ld=gold', |
104 | ] | |
105 | ||
106 | if meson.version().version_compare('>=0.46') | |
107 | add_project_link_arguments(cc.get_supported_link_arguments(possible_link_flags), language : 'c') | |
108 | else | |
109 | add_project_link_arguments(possible_link_flags, language : 'c') | |
110 | endif | |
111 | ||
112 | add_project_arguments(cc.get_supported_arguments(possible_cc_flags), language : 'c') | |
113 | ||
114 | foreach ident : [ | |
115 | ['strlcpy', '''#include <string.h>'''], | |
116 | ['strlcat', '''#include <string.h>'''], | |
117 | ['pidfd_send_signal', '''#include <stdlib.h> | |
118 | #include <unistd.h> | |
119 | #include <signal.h> | |
120 | #include <sys/wait.h>'''], | |
121 | ['pidfd_open', '''#include <stdlib.h> | |
122 | #include <unistd.h> | |
123 | #include <signal.h> | |
124 | #include <sys/wait.h>'''], | |
125 | ] | |
126 | ||
127 | have = cc.has_function(ident[0], prefix : ident[1], args : '-D_GNU_SOURCE') | |
128 | conf.set10('HAVE_' + ident[0].to_upper(), have) | |
129 | endforeach | |
130 | ||
131 | conf.set('_FILE_OFFSET_BITS', 64) | |
132 | ||
5f275367 | 133 | libfuse = dependency('fuse3', required : false) |
1fbf5591 | 134 | if libfuse.found() |
5f275367 | 135 | conf.set10('HAVE_FUSE3', true) |
1fbf5591 CB |
136 | conf.set('FUSE_USE_VERSION', 30) |
137 | else | |
5f275367 CB |
138 | if dependency('fuse').found() |
139 | conf.set10('HAVE_FUSE', true) | |
140 | conf.set('FUSE_USE_VERSION', 26) | |
141 | endif | |
1fbf5591 CB |
142 | endif |
143 | ||
144 | libdl = cc.find_library('dl') | |
145 | threads = dependency('threads') | |
146 | ||
147 | config_h = configure_file( | |
148 | output : 'config.h', | |
149 | configuration : conf) | |
150 | config_include = include_directories('.') | |
151 | ||
152 | add_project_arguments('-include', 'config.h', language : 'c') | |
153 | ||
154 | subdir('tests') | |
155 | ||
156 | public_programs = [] | |
157 | ||
158 | lxcfs_sources = files('src/lxcfs.c') | |
159 | ||
160 | public_programs += executable( | |
161 | 'lxcfs', | |
162 | lxcfs_sources, | |
163 | dependencies : [threads, | |
164 | libdl, | |
165 | libfuse], | |
166 | install : true, | |
167 | install_dir : bindir) | |
168 | ||
169 | liblxcfs_sources = files( | |
170 | 'src/api_extensions.h', | |
171 | 'src/bindings.c', | |
172 | 'src/bindings.h', | |
173 | 'src/cgroups/cgfsng.c', | |
174 | 'src/cgroups/cgroup.c', | |
175 | 'src/cgroups/cgroup.h', | |
176 | 'src/cgroups/cgroup2_devices.c', | |
177 | 'src/cgroups/cgroup2_devices.h', | |
178 | 'src/cgroups/cgroup_utils.c', | |
179 | 'src/cgroups/cgroup_utils.h', | |
180 | 'src/cgroup_fuse.c', | |
181 | 'src/cgroup_fuse.h', | |
182 | 'src/cpuset_parse.c', | |
183 | 'src/cpuset_parse.h', | |
184 | 'src/lxcfs.c', | |
185 | 'src/lxcfs_fuse_compat.h', | |
186 | 'src/macro.h', | |
187 | 'src/memory_utils.h', | |
188 | 'src/proc_cpuview.c', | |
189 | 'src/proc_cpuview.h', | |
190 | 'src/proc_fuse.c', | |
191 | 'src/proc_fuse.h', | |
192 | 'src/proc_loadavg.c', | |
193 | 'src/proc_loadavg.h', | |
194 | 'src/syscall_numbers.h', | |
195 | 'src/sysfs_fuse.c', | |
196 | 'src/sysfs_fuse.h', | |
197 | 'src/utils.c', | |
198 | 'src/utils.h') | |
199 | ||
200 | liblxcfs = shared_library( | |
201 | 'lxcfs', | |
202 | liblxcfs_sources, | |
1fbf5591 CB |
203 | dependencies : [threads, |
204 | libdl, | |
205 | libfuse], | |
206 | install : true, | |
207 | install_dir : lxcfsdir) | |
208 | ||
209 | if want_tests == true | |
210 | liblxcfs_test = shared_library( | |
211 | 'lxcfstest', | |
212 | liblxcfs_sources, | |
1fbf5591 CB |
213 | dependencies : [threads, |
214 | libdl, | |
215 | libfuse], | |
216 | install : false, | |
217 | install_dir : lxcfsdir, | |
218 | c_args : '-DRELOADTEST -DDEBUG') | |
219 | endif | |
220 | ||
221 | if init_script == 'systemd' | |
222 | systemd_service_data = configuration_data() | |
223 | systemd_service_data.set_quoted('LXCFSTARGETDIR', join_paths(localstatedir, 'lib/lxcfs')) | |
224 | systemd_service = configure_file( | |
225 | configuration : systemd_service_data, | |
226 | input : 'config/init/systemd/lxcfs.service.in', | |
227 | output : 'lxcfs.service') | |
228 | install_data(join_paths(project_build_root, 'lxcfs.service'), install_dir : '/lib/systemd/system') | |
229 | elif init_script == 'upstart' | |
230 | install_data('config/init/upstart/lxcfs.conf', install_dir : join_paths(sysconfdir, 'init')) | |
231 | elif init_script == 'openrc' | |
232 | install_data('config/init/sysvinit/lxcfs', install_dir : join_paths(sysconfdir, 'rc.d/init.d/lxcfs')) | |
233 | elif init_script == 'sysvinit' | |
234 | install_data('config/init/sysvinit/lxcfs', install_dir : join_paths(sysconfdir, 'rc.d/init.d/lxcfs')) | |
235 | endif | |
236 | ||
237 | status = [ | |
238 | '@0@ @1@'.format(meson.project_name(), meson.project_version()), | |
239 | ||
5f275367 | 240 | 'FUSE version: @0@'.format(libfuse.version()), |
0d2038cd CB |
241 | 'bin directory: @0@'.format(bindir), |
242 | 'lib directory: @0@'.format(libdir), | |
243 | 'data directory: @0@'.format(datadir), | |
244 | 'local state directory: @0@'.format(localstatedir), | |
1fbf5591 | 245 | 'prefix directory: @0@'.format(prefixdir), |
0d2038cd | 246 | 'runtime directory: @0@'.format(runtimepath), |
1fbf5591 | 247 | 'sysconf directory: @0@'.format(sysconfdir), |
0d2038cd | 248 | 'lxc conf directory: @0@'.format(lxcconfdir), |
1fbf5591 | 249 | 'lxcfs directory: @0@'.format(lxcfsdir), |
0d2038cd | 250 | 'lxcfs shared directory: @0@'.format(lxcfssharedir), |
1fbf5591 CB |
251 | 'lxcfs build root directory: @0@'.format(project_build_root), |
252 | 'lxcfs source root directory: @0@'.format(project_source_root), | |
253 | 'init system: @0@'.format(init_script), | |
254 | 'tests: @0@'.format(want_tests)] | |
255 | ||
256 | message('\n '.join(status)) |