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