1 # SPDX-License-Identifier: LGPL-2.1-or-later
13 meson_version : '>= 0.45',
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()
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))
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'))
36 datadir = join_paths(prefixdir, get_option('datadir'))
38 conf.set_quoted('BINDIR', bindir)
39 conf.set_quoted('LIBDIR', libdir)
40 conf.set_quoted('LOCALSTATEDIR', localstatedir)
41 conf.set_quoted('RUNTIME_PATH', runtimepath)
42 conf.set_quoted('SYSCONFDIR', sysconfdir)
44 conf.set_quoted('LXCFS_BUILD_ROOT', project_build_root)
45 conf.set_quoted('LXCFS_SOURCE_ROOT', project_source_root)
47 lxcfssharedir = join_paths(datadir, 'lxcfs')
48 conf.set_quoted('LXCFSSHAREDIR', lxcfssharedir)
50 lxcconfdir = join_paths(datadir, 'lxc/config/common.conf.d')
51 conf.set_quoted('LXCCONFDIR', lxcconfdir)
53 init_script = get_option('init-script')
55 cc = meson.get_compiler('c')
56 meson_build_sh = find_program('tools/meson-build.sh')
58 want_tests = get_option('tests')
62 '-Wimplicit-fallthrough=5',
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',
72 '-Wmissing-include-dirs',
73 '-Wold-style-definition',
75 '-Wunused-but-set-variable',
76 '-Wno-unused-parameter',
78 '-Wsuggest-attribute=noreturn',
79 '-Werror=return-type',
80 '-Werror=incompatible-pointer-types',
85 '-fdiagnostics-show-option',
86 '-Werror=shift-count-overflow',
87 '-Werror=shift-overflow=2',
90 '-fasynchronous-unwind-tables',
94 '-Wreturn-local-addr',
96 '-Wstringop-overflow',
99 possible_link_flags = [
106 if meson.version().version_compare('>=0.46')
107 add_project_link_arguments(cc.get_supported_link_arguments(possible_link_flags), language : 'c')
109 add_project_link_arguments(possible_link_flags, language : 'c')
112 add_project_arguments(cc.get_supported_arguments(possible_cc_flags), language : 'c')
115 ['strlcpy', '''#include <string.h>'''],
116 ['strlcat', '''#include <string.h>'''],
117 ['pidfd_send_signal', '''#include <stdlib.h>
120 #include <sys/wait.h>'''],
121 ['pidfd_open', '''#include <stdlib.h>
124 #include <sys/wait.h>'''],
127 have = cc.has_function(ident[0], prefix : ident[1], args : '-D_GNU_SOURCE')
128 conf.set10('HAVE_' + ident[0].to_upper(), have)
131 conf.set('_FILE_OFFSET_BITS', 64)
133 libfuse = dependency('fuse3', required : false)
135 conf.set10('HAVE_FUSE3', true)
136 conf.set('FUSE_USE_VERSION', 30)
138 if dependency('fuse').found()
139 conf.set10('HAVE_FUSE', true)
140 conf.set('FUSE_USE_VERSION', 26)
144 libdl = cc.find_library('dl')
145 threads = dependency('threads')
147 config_h = configure_file(
149 configuration : conf)
150 config_include = include_directories('.')
152 add_project_arguments('-include', 'config.h', language : 'c')
158 lxcfs_sources = files('src/lxcfs.c')
160 public_programs += executable(
163 dependencies : [threads,
167 install_dir : bindir)
169 liblxcfs_sources = files(
170 'src/api_extensions.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',
182 'src/cpuset_parse.c',
183 'src/cpuset_parse.h',
185 'src/lxcfs_fuse_compat.h',
187 'src/memory_utils.h',
188 'src/proc_cpuview.c',
189 'src/proc_cpuview.h',
192 'src/proc_loadavg.c',
193 'src/proc_loadavg.h',
194 'src/syscall_numbers.h',
200 liblxcfs = shared_library(
203 link_args : ['-shared'],
204 dependencies : [threads,
208 install_dir : lxcfsdir)
210 if want_tests == true
211 liblxcfs_test = shared_library(
214 link_args : ['-shared'],
215 dependencies : [threads,
219 install_dir : lxcfsdir,
220 c_args : '-DRELOADTEST -DDEBUG')
223 if init_script == 'systemd'
224 systemd_service_data = configuration_data()
225 systemd_service_data.set_quoted('LXCFSTARGETDIR', join_paths(localstatedir, 'lib/lxcfs'))
226 systemd_service = configure_file(
227 configuration : systemd_service_data,
228 input : 'config/init/systemd/lxcfs.service.in',
229 output : 'lxcfs.service')
230 install_data(join_paths(project_build_root, 'lxcfs.service'), install_dir : '/lib/systemd/system')
231 elif init_script == 'upstart'
232 install_data('config/init/upstart/lxcfs.conf', install_dir : join_paths(sysconfdir, 'init'))
233 elif init_script == 'openrc'
234 install_data('config/init/sysvinit/lxcfs', install_dir : join_paths(sysconfdir, 'rc.d/init.d/lxcfs'))
235 elif init_script == 'sysvinit'
236 install_data('config/init/sysvinit/lxcfs', install_dir : join_paths(sysconfdir, 'rc.d/init.d/lxcfs'))
240 '@0@ @1@'.format(meson.project_name(), meson.project_version()),
242 'FUSE version: @0@'.format(libfuse.version()),
243 'bin directory: @0@'.format(bindir),
244 'lib directory: @0@'.format(libdir),
245 'data directory: @0@'.format(datadir),
246 'local state directory: @0@'.format(localstatedir),
247 'prefix directory: @0@'.format(prefixdir),
248 'runtime directory: @0@'.format(runtimepath),
249 'sysconf directory: @0@'.format(sysconfdir),
250 'lxc conf directory: @0@'.format(lxcconfdir),
251 'lxcfs directory: @0@'.format(lxcfsdir),
252 'lxcfs shared directory: @0@'.format(lxcfssharedir),
253 'lxcfs build root directory: @0@'.format(project_build_root),
254 'lxcfs source root directory: @0@'.format(project_source_root),
255 'init system: @0@'.format(init_script),
256 'tests: @0@'.format(want_tests)]
258 message('\n '.join(status))