1 # SPDX-License-Identifier: LGPL-2.1-or-later
13 meson_version : '>= 0.50',
16 conf = configuration_data()
17 conf.set_quoted('PROJECT', meson.project_name())
18 conf.set_quoted('PROJECT_URL', 'https://linuxcontainers.org/lxcfs/introduction/')
19 conf.set_quoted('PROJECT_VERSION', meson.project_version(),
20 description : 'Numerical project version (used where a simple number is expected)')
21 project_source_root = meson.current_source_dir()
22 project_build_root = meson.current_build_dir()
24 # join_paths ignores the preceding arguments if an absolute component is
25 # encountered, so this should canonicalize various paths when they are
26 # absolute or relative.
27 prefixdir = get_option('prefix')
28 bindir = join_paths(prefixdir, get_option('bindir'))
29 libdir = join_paths(prefixdir, get_option('libdir'))
30 lxcfsdir = join_paths(libdir, 'lxcfs')
31 sysconfdir = join_paths(prefixdir, get_option('sysconfdir'))
32 runtimepath = join_paths(prefixdir, get_option('runtime-path'))
33 localstatedir = join_paths('/', get_option('localstatedir'))
34 datadir = join_paths(prefixdir, get_option('datadir'))
36 conf.set_quoted('BINDIR', bindir)
37 conf.set_quoted('LIBDIR', libdir)
38 conf.set_quoted('LOCALSTATEDIR', localstatedir)
39 conf.set_quoted('RUNTIME_PATH', runtimepath)
40 conf.set_quoted('SYSCONFDIR', sysconfdir)
41 conf.set_quoted('LXCFSTARGETDIR', join_paths(localstatedir, 'lib/lxcfs'))
43 conf.set_quoted('LXCFS_BUILD_ROOT', project_build_root)
44 conf.set_quoted('LXCFS_SOURCE_ROOT', project_source_root)
46 lxcfssharedir = join_paths(datadir, 'lxcfs')
47 conf.set_quoted('LXCFSSHAREDIR', lxcfssharedir)
49 lxcconfdir = join_paths(datadir, 'lxc/config/common.conf.d')
50 conf.set_quoted('LXCCONFDIR', lxcconfdir)
52 init_script = get_option('init-script')
54 cc = meson.get_compiler('c')
55 meson_build_sh = find_program('tools/meson-build.sh')
57 if run_command('python3', '-c', 'import jinja2').returncode() != 0
58 error('python3 jinja2 missing')
61 meson_render_jinja2 = find_program('tools/meson-render-jinja2.py')
63 want_tests = get_option('tests')
67 '-Wimplicit-fallthrough=5',
69 '-Wstrict-prototypes',
70 '-fno-strict-aliasing',
71 '-fstack-clash-protection',
72 '-fstack-protector-strong',
73 '--param=ssp-buffer-size=4',
74 '--mcet -fcf-protection',
75 '-Werror=implicit-function-declaration',
77 '-Wmissing-include-dirs',
78 '-Wold-style-definition',
80 '-Wunused-but-set-variable',
81 '-Wno-unused-parameter',
83 '-Wsuggest-attribute=noreturn',
84 '-Werror=return-type',
85 '-Werror=incompatible-pointer-types',
90 '-fdiagnostics-show-option',
91 '-Werror=shift-count-overflow',
92 '-Werror=shift-overflow=2',
95 '-fasynchronous-unwind-tables',
99 '-Wreturn-local-addr',
101 '-Wstringop-overflow',
104 possible_link_flags = [
111 if meson.version().version_compare('>=0.46')
112 add_project_link_arguments(cc.get_supported_link_arguments(possible_link_flags), language : 'c')
114 add_project_link_arguments(possible_link_flags, language : 'c')
117 add_project_arguments(cc.get_supported_arguments(possible_cc_flags), language : 'c')
120 ['strlcpy', '''#include <string.h>'''],
121 ['strlcat', '''#include <string.h>'''],
122 ['pidfd_send_signal', '''#include <stdlib.h>
125 #include <sys/wait.h>'''],
126 ['pidfd_open', '''#include <stdlib.h>
129 #include <sys/wait.h>'''],
132 have = cc.has_function(ident[0], prefix : ident[1], args : '-D_GNU_SOURCE')
133 conf.set10('HAVE_' + ident[0].to_upper(), have)
136 conf.set('_GNU_SOURCE', true)
137 conf.set('_FILE_OFFSET_BITS', 64)
138 conf.set('__STDC_FORMAT_MACROS', true)
140 libfuse = dependency('fuse3', required : false)
142 conf.set10('HAVE_FUSE3', true)
143 conf.set('FUSE_USE_VERSION', 30)
145 libfuse = dependency('fuse', version: '>= 2.6')
147 conf.set10('HAVE_FUSE', true)
148 conf.set('FUSE_USE_VERSION', 26)
152 libdl = cc.find_library('dl')
153 threads = dependency('threads')
155 config_h = configure_file(
157 configuration : conf)
158 config_include = include_directories('.')
160 add_project_arguments('-include', 'config.h', language : 'c')
167 lxcfs_sources = files('src/lxcfs.c')
169 public_programs += executable(
172 dependencies : [threads,
176 install_dir : bindir)
178 liblxcfs_sources = files(
179 'src/api_extensions.h',
182 'src/cgroups/cgfsng.c',
183 'src/cgroups/cgroup.c',
184 'src/cgroups/cgroup.h',
185 'src/cgroups/cgroup2_devices.c',
186 'src/cgroups/cgroup2_devices.h',
187 'src/cgroups/cgroup_utils.c',
188 'src/cgroups/cgroup_utils.h',
191 'src/cpuset_parse.c',
192 'src/cpuset_parse.h',
195 'src/lxcfs_fuse_compat.h',
197 'src/memory_utils.h',
198 'src/proc_cpuview.c',
199 'src/proc_cpuview.h',
202 'src/proc_loadavg.c',
203 'src/proc_loadavg.h',
204 'src/syscall_numbers.h',
210 liblxcfs_common_dependencies = declare_dependency(
211 sources: liblxcfs_sources,
212 dependencies: [threads, libfuse])
214 liblxcfs = shared_module(
217 dependencies : liblxcfs_common_dependencies,
219 install_dir : lxcfsdir)
221 if want_tests == true
222 liblxcfs_test = shared_module(
225 dependencies : liblxcfs_common_dependencies,
227 install_dir : lxcfsdir,
228 c_args : '-DRELOADTEST -DDEBUG')
231 lxcfs_spec = custom_target(
233 build_by_default : true,
234 input : 'lxcfs.spec.in',
235 output : 'lxcfs.spec',
236 command : [meson_render_jinja2, config_h, '@INPUT@', '@OUTPUT@'])
239 subdir('config/init')
242 '@0@ @1@'.format(meson.project_name(), meson.project_version()),
244 'FUSE version: @0@'.format(libfuse.version()),
245 'bin directory: @0@'.format(bindir),
246 'lib directory: @0@'.format(libdir),
247 'data directory: @0@'.format(datadir),
248 'local state directory: @0@'.format(localstatedir),
249 'prefix directory: @0@'.format(prefixdir),
250 'runtime directory: @0@'.format(runtimepath),
251 'sysconf directory: @0@'.format(sysconfdir),
252 'lxc conf directory: @0@'.format(lxcconfdir),
253 'lxcfs directory: @0@'.format(lxcfsdir),
254 'lxcfs shared directory: @0@'.format(lxcfssharedir),
255 'lxcfs build root directory: @0@'.format(project_build_root),
256 'lxcfs source root directory: @0@'.format(project_source_root),
257 'init system: @0@'.format(init_script),
258 'tests: @0@'.format(want_tests)]
260 message('\n '.join(status))