]>
Commit | Line | Data |
---|---|---|
db9ecf05 | 1 | # SPDX-License-Identifier: LGPL-2.1-or-later |
3a726fcd | 2 | |
5c23128d | 3 | project('systemd', 'c', |
eed3d044 | 4 | version : '254', |
5c23128d ZJS |
5 | license : 'LGPLv2+', |
6 | default_options: [ | |
2b2dbcbb | 7 | 'c_std=gnu11', |
37efbbd8 ZJS |
8 | 'prefix=/usr', |
9 | 'sysconfdir=/etc', | |
10 | 'localstatedir=/var', | |
827ca909 | 11 | 'warning_level=2', |
5c23128d | 12 | ], |
35c035a1 | 13 | meson_version : '>= 0.60.0', |
5c23128d ZJS |
14 | ) |
15 | ||
eed3d044 LB |
16 | libsystemd_version = '0.37.0' |
17 | libudev_version = '1.7.7' | |
56d50ab1 | 18 | |
5c23128d | 19 | conf = configuration_data() |
a8c03388 | 20 | conf.set_quoted('PROJECT_URL', 'https://systemd.io/') |
d1b0d841 | 21 | conf.set('PROJECT_VERSION', meson.project_version(), |
6ffeca8c | 22 | description : 'Numerical project version (used where a simple number is expected)') |
5c23128d | 23 | |
1485aacb DC |
24 | # This is to be used instead of meson.source_root(), as the latter will return |
25 | # the wrong result when systemd is being built as a meson subproject | |
26 | project_source_root = meson.current_source_dir() | |
81e06775 | 27 | project_build_root = meson.current_build_dir() |
a0b15b41 | 28 | relative_source_path = run_command('realpath', |
81e06775 | 29 | '--relative-to=@0@'.format(project_build_root), |
e92777d2 ZJS |
30 | project_source_root, |
31 | check : true).stdout().strip() | |
a0b15b41 | 32 | conf.set_quoted('RELATIVE_SOURCE_PATH', relative_source_path) |
1485aacb | 33 | |
47350c5f ZJS |
34 | conf.set10('BUILD_MODE_DEVELOPER', get_option('mode') == 'developer', |
35 | description : 'tailor build to development or release builds') | |
011a03a3 ZJS |
36 | verification = get_option('log-message-verification') |
37 | if verification == 'auto' | |
38 | verification = conf.get('BUILD_MODE_DEVELOPER') == 1 | |
39 | else | |
40 | verification = verification == 'true' | |
41 | endif | |
42 | conf.set10('LOG_MESSAGE_VERIFICATION', verification) | |
839bdf25 | 43 | |
c09edc79 ZJS |
44 | want_ossfuzz = get_option('oss-fuzz') |
45 | want_libfuzzer = get_option('llvm-fuzz') | |
c29537f3 | 46 | if want_ossfuzz and want_libfuzzer |
6b8d32ea | 47 | error('only one of oss-fuzz or llvm-fuzz can be specified') |
c09edc79 | 48 | endif |
87ac55a1 | 49 | |
678ba020 | 50 | skip_deps = want_ossfuzz or get_option('skip-deps') |
6b8d32ea | 51 | fuzzer_build = want_ossfuzz or want_libfuzzer |
c09edc79 | 52 | |
c4f883b7 ZJS |
53 | # If we're building *not* for actual fuzzing, allow input samples of any size |
54 | # (for testing and for reproduction of issues discovered with previously-higher | |
55 | # limits). | |
56 | conf.set10('FUZZ_USE_SIZE_LIMIT', fuzzer_build) | |
57 | ||
493cd503 ZJS |
58 | # We'll set this to '1' for EFI builds in a different place. |
59 | conf.set10('SD_BOOT', false) | |
60 | ||
3f871f12 ZJS |
61 | # Create a title-less summary section early, so it ends up first in the output. |
62 | # More items are added later after they have been detected. | |
63 | summary({'build mode' : get_option('mode')}) | |
64 | ||
5c23128d ZJS |
65 | ##################################################################### |
66 | ||
003c8879 | 67 | # Try to install the git pre-commit hook |
e2d612a8 ZJS |
68 | add_git_hook_sh = find_program('tools/add-git-hook.sh', required : false) |
69 | if add_git_hook_sh.found() | |
e92777d2 | 70 | git_hook = run_command(add_git_hook_sh, check : false) |
e2d612a8 ZJS |
71 | if git_hook.returncode() == 0 |
72 | message(git_hook.stdout().strip()) | |
73 | endif | |
003c8879 ZJS |
74 | endif |
75 | ||
76 | ##################################################################### | |
77 | ||
4cf8a609 | 78 | fs = import('fs') |
157baa87 | 79 | if get_option('split-bin') == 'auto' |
4cf8a609 | 80 | split_bin = not fs.is_symlink('/usr/sbin') |
157baa87 ZJS |
81 | else |
82 | split_bin = get_option('split-bin') == 'true' | |
83 | endif | |
671f0f8d ZJS |
84 | conf.set10('HAVE_SPLIT_BIN', split_bin, |
85 | description : 'bin and sbin directories are separate') | |
157baa87 | 86 | |
8ef8f3d5 FB |
87 | have_standalone_binaries = get_option('standalone-binaries') |
88 | ||
5c23128d ZJS |
89 | sysvinit_path = get_option('sysvinit-path') |
90 | sysvrcnd_path = get_option('sysvrcnd-path') | |
348b4437 | 91 | conf.set10('HAVE_SYSV_COMPAT', sysvinit_path != '' and sysvrcnd_path != '', |
349cc4a5 | 92 | description : 'SysV init scripts and rcN.d links are supported') |
6fe23ff3 | 93 | conf.set10('CREATE_LOG_DIRS', get_option('create-log-dirs')) |
5c23128d | 94 | |
cdf7ad38 NL |
95 | if get_option('hibernate') and not get_option('initrd') |
96 | error('hibernate depends on initrd') | |
97 | endif | |
98 | ||
a8b627aa LP |
99 | conf.set10('BUMP_PROC_SYS_FS_FILE_MAX', get_option('bump-proc-sys-fs-file-max')) |
100 | conf.set10('BUMP_PROC_SYS_FS_NR_OPEN', get_option('bump-proc-sys-fs-nr-open')) | |
09dad04c | 101 | conf.set('HIGH_RLIMIT_NOFILE', 512*1024) |
a8b627aa | 102 | |
fce9abb2 ZJS |
103 | # Meson ignores the preceding arguments when joining paths if an absolute |
104 | # component is encountered, so this should canonicalize various paths when they | |
105 | # are absolute or relative. | |
5c23128d ZJS |
106 | prefixdir = get_option('prefix') |
107 | if not prefixdir.startswith('/') | |
37efbbd8 | 108 | error('Prefix is not absolute: "@0@"'.format(prefixdir)) |
5c23128d | 109 | endif |
d895e10a | 110 | |
b0d3095f | 111 | prefixdir_noslash = '/' + prefixdir.strip('/') |
fce9abb2 | 112 | bindir = prefixdir / get_option('bindir') |
b0d3095f | 113 | sbindir = prefixdir / (split_bin ? 'sbin' : 'bin') |
fce9abb2 ZJS |
114 | libdir = prefixdir / get_option('libdir') |
115 | sysconfdir = prefixdir / get_option('sysconfdir') | |
116 | includedir = prefixdir / get_option('includedir') | |
117 | datadir = prefixdir / get_option('datadir') | |
118 | localstatedir = '/' / get_option('localstatedir') | |
5c23128d | 119 | |
b0d3095f LB |
120 | libexecdir = prefixdir / 'lib/systemd' |
121 | pkglibdir = libdir / 'systemd' | |
5c23128d | 122 | |
225d08b8 JT |
123 | install_sysconfdir = get_option('install-sysconfdir') != 'false' |
124 | install_sysconfdir_samples = get_option('install-sysconfdir') == 'true' | |
5c23128d | 125 | # Dirs of external packages |
fce9abb2 ZJS |
126 | pkgconfigdatadir = get_option('pkgconfigdatadir') != '' ? get_option('pkgconfigdatadir') : datadir / 'pkgconfig' |
127 | pkgconfiglibdir = get_option('pkgconfiglibdir') != '' ? get_option('pkgconfiglibdir') : libdir / 'pkgconfig' | |
128 | polkitpolicydir = datadir / 'polkit-1/actions' | |
129 | polkitrulesdir = datadir / 'polkit-1/rules.d' | |
130 | polkitpkladir = localstatedir / 'lib/polkit-1/localauthority/10-vendor.d' | |
131 | xinitrcdir = get_option('xinitrcdir') != '' ? get_option('xinitrcdir') : sysconfdir / 'X11/xinit/xinitrc.d' | |
8a38aac3 YW |
132 | rpmmacrosdir = get_option('rpmmacrosdir') |
133 | if rpmmacrosdir != 'no' | |
fce9abb2 | 134 | rpmmacrosdir = prefixdir / rpmmacrosdir |
8a38aac3 | 135 | endif |
b0d3095f | 136 | modprobedir = prefixdir / 'lib/modprobe.d' |
5c23128d ZJS |
137 | |
138 | # Our own paths | |
fce9abb2 ZJS |
139 | pkgdatadir = datadir / 'systemd' |
140 | environmentdir = prefixdir / 'lib/environment.d' | |
141 | pkgsysconfdir = sysconfdir / 'systemd' | |
142 | userunitdir = prefixdir / 'lib/systemd/user' | |
143 | userpresetdir = prefixdir / 'lib/systemd/user-preset' | |
144 | tmpfilesdir = prefixdir / 'lib/tmpfiles.d' | |
107795a7 | 145 | usertmpfilesdir = prefixdir / 'share/user-tmpfiles.d' |
fce9abb2 ZJS |
146 | sysusersdir = prefixdir / 'lib/sysusers.d' |
147 | sysctldir = prefixdir / 'lib/sysctl.d' | |
148 | binfmtdir = prefixdir / 'lib/binfmt.d' | |
149 | modulesloaddir = prefixdir / 'lib/modules-load.d' | |
b0d3095f LB |
150 | networkdir = prefixdir / 'lib/systemd/network' |
151 | systemgeneratordir = libexecdir / 'system-generators' | |
fce9abb2 ZJS |
152 | usergeneratordir = prefixdir / 'lib/systemd/user-generators' |
153 | systemenvgeneratordir = prefixdir / 'lib/systemd/system-environment-generators' | |
154 | userenvgeneratordir = prefixdir / 'lib/systemd/user-environment-generators' | |
b0d3095f LB |
155 | systemshutdowndir = libexecdir / 'system-shutdown' |
156 | systemsleepdir = libexecdir / 'system-sleep' | |
157 | systemunitdir = prefixdir / 'lib/systemd/system' | |
158 | systempresetdir = prefixdir / 'lib/systemd/system-preset' | |
159 | udevlibexecdir = prefixdir / 'lib/udev' | |
fce9abb2 ZJS |
160 | udevrulesdir = udevlibexecdir / 'rules.d' |
161 | udevhwdbdir = udevlibexecdir / 'hwdb.d' | |
162 | catalogdir = prefixdir / 'lib/systemd/catalog' | |
641e2124 | 163 | kerneldir = prefixdir / 'lib/kernel' |
164 | kernelinstalldir = kerneldir / 'install.d' | |
fce9abb2 ZJS |
165 | factorydir = datadir / 'factory' |
166 | bootlibdir = prefixdir / 'lib/systemd/boot/efi' | |
167 | testsdir = prefixdir / 'lib/systemd/tests' | |
26c2b302 | 168 | unittestsdir = testsdir / 'unit-tests' |
539ee7ab | 169 | testdata_dir = testsdir / 'testdata' |
fce9abb2 ZJS |
170 | systemdstatedir = localstatedir / 'lib/systemd' |
171 | catalogstatedir = systemdstatedir / 'catalog' | |
172 | randomseeddir = localstatedir / 'lib/systemd' | |
b0d3095f LB |
173 | profiledir = libexecdir / 'portable' / 'profile' |
174 | ntpservicelistdir = prefixdir / 'lib/systemd/ntp-units.d' | |
24039e12 | 175 | credstoredir = prefixdir / 'lib/credstore' |
5c23128d | 176 | |
75aaade1 TB |
177 | docdir = get_option('docdir') |
178 | if docdir == '' | |
fce9abb2 | 179 | docdir = datadir / 'doc/systemd' |
75aaade1 TB |
180 | endif |
181 | ||
5c23128d ZJS |
182 | pamlibdir = get_option('pamlibdir') |
183 | if pamlibdir == '' | |
b0d3095f | 184 | pamlibdir = libdir / 'security' |
5c23128d ZJS |
185 | endif |
186 | ||
187 | pamconfdir = get_option('pamconfdir') | |
188 | if pamconfdir == '' | |
fce9abb2 | 189 | pamconfdir = prefixdir / 'lib/pam.d' |
5c23128d ZJS |
190 | endif |
191 | ||
d1ae38d8 OK |
192 | libcryptsetup_plugins_dir = get_option('libcryptsetup-plugins-dir') |
193 | if libcryptsetup_plugins_dir == '' | |
b0d3095f | 194 | libcryptsetup_plugins_dir = libdir / 'cryptsetup' |
d1ae38d8 OK |
195 | endif |
196 | ||
444d5863 | 197 | memory_accounting_default = get_option('memory-accounting-default') |
36cf4507 | 198 | status_unit_format_default = get_option('status-unit-format-default') |
819c0dcb ZJS |
199 | if status_unit_format_default == 'auto' |
200 | status_unit_format_default = conf.get('BUILD_MODE_DEVELOPER') == 1 ? 'name' : 'description' | |
201 | endif | |
444d5863 | 202 | |
b0d3095f | 203 | conf.set_quoted('BINDIR', bindir) |
491bf10c ZJS |
204 | conf.set_quoted('BINFMT_DIR', binfmtdir) |
205 | conf.set_quoted('BOOTLIBDIR', bootlibdir) | |
fce9abb2 | 206 | conf.set_quoted('CATALOG_DATABASE', catalogstatedir / 'database') |
491bf10c | 207 | conf.set_quoted('CERTIFICATE_ROOT', get_option('certificate-root')) |
6fe23ff3 | 208 | conf.set_quoted('DOC_DIR', docdir) |
fce9abb2 | 209 | conf.set_quoted('DOCUMENT_ROOT', pkgdatadir / 'gatewayd') |
491bf10c ZJS |
210 | conf.set_quoted('ENVIRONMENT_DIR', environmentdir) |
211 | conf.set_quoted('INCLUDE_DIR', includedir) | |
212 | conf.set_quoted('LIBDIR', libdir) | |
b0d3095f | 213 | conf.set_quoted('LIBEXECDIR', libexecdir) |
491bf10c ZJS |
214 | conf.set_quoted('MODPROBE_DIR', modprobedir) |
215 | conf.set_quoted('MODULESLOAD_DIR', modulesloaddir) | |
5c23128d | 216 | conf.set_quoted('PKGSYSCONFDIR', pkgsysconfdir) |
fce9abb2 | 217 | conf.set_quoted('POLKIT_AGENT_BINARY_PATH', bindir / 'pkttyagent') |
491bf10c | 218 | conf.set_quoted('PREFIX', prefixdir) |
b0d3095f | 219 | conf.set_quoted('PREFIX_NOSLASH', prefixdir_noslash) |
fce9abb2 | 220 | conf.set_quoted('RANDOM_SEED', randomseeddir / 'random-seed') |
491bf10c | 221 | conf.set_quoted('RANDOM_SEED_DIR', randomseeddir) |
452d2dfd | 222 | conf.set_quoted('RC_LOCAL_PATH', get_option('rc-local')) |
491bf10c ZJS |
223 | conf.set_quoted('SYSCONF_DIR', sysconfdir) |
224 | conf.set_quoted('SYSCTL_DIR', sysctldir) | |
b0d3095f LB |
225 | conf.set_quoted('SYSTEMCTL_BINARY_PATH', bindir / 'systemctl') |
226 | conf.set_quoted('SYSTEMD_BINARY_PATH', libexecdir / 'systemd') | |
491bf10c | 227 | conf.set_quoted('SYSTEMD_CATALOG_DIR', catalogdir) |
b0d3095f LB |
228 | conf.set_quoted('SYSTEMD_CGROUPS_AGENT_PATH', libexecdir / 'systemd-cgroups-agent') |
229 | conf.set_quoted('SYSTEMD_CRYPTSETUP_PATH', libexecdir / 'systemd-cryptsetup') | |
230 | conf.set_quoted('SYSTEMD_EXPORT_PATH', libexecdir / 'systemd-export') | |
231 | conf.set_quoted('SYSTEMD_FSCK_PATH', libexecdir / 'systemd-fsck') | |
232 | conf.set_quoted('SYSTEMD_GROWFS_PATH', libexecdir / 'systemd-growfs') | |
233 | conf.set_quoted('SYSTEMD_HOMEWORK_PATH', libexecdir / 'systemd-homework') | |
234 | conf.set_quoted('SYSTEMD_IMPORT_FS_PATH', libexecdir / 'systemd-import-fs') | |
235 | conf.set_quoted('SYSTEMD_IMPORT_PATH', libexecdir / 'systemd-import') | |
236 | conf.set_quoted('SYSTEMD_INTEGRITYSETUP_PATH', libexecdir / 'systemd-integritysetup') | |
fce9abb2 ZJS |
237 | conf.set_quoted('SYSTEMD_KBD_MODEL_MAP', pkgdatadir / 'kbd-model-map') |
238 | conf.set_quoted('SYSTEMD_LANGUAGE_FALLBACK_MAP', pkgdatadir / 'language-fallback-map') | |
b0d3095f LB |
239 | conf.set_quoted('SYSTEMD_MAKEFS_PATH', libexecdir / 'systemd-makefs') |
240 | conf.set_quoted('SYSTEMD_PULL_PATH', libexecdir / 'systemd-pull') | |
241 | conf.set_quoted('SYSTEMD_SHUTDOWN_BINARY_PATH', libexecdir / 'systemd-shutdown') | |
539ee7ab | 242 | conf.set_quoted('SYSTEMD_TEST_DATA', testdata_dir) |
b0d3095f LB |
243 | conf.set_quoted('SYSTEMD_TTY_ASK_PASSWORD_AGENT_BINARY_PATH', bindir / 'systemd-tty-ask-password-agent') |
244 | conf.set_quoted('SYSTEMD_UPDATE_HELPER_PATH', libexecdir / 'systemd-update-helper') | |
245 | conf.set_quoted('SYSTEMD_USERWORK_PATH', libexecdir / 'systemd-userwork') | |
246 | conf.set_quoted('SYSTEMD_VERITYSETUP_PATH', libexecdir / 'systemd-veritysetup') | |
fce9abb2 | 247 | conf.set_quoted('SYSTEM_CONFIG_UNIT_DIR', pkgsysconfdir / 'system') |
491bf10c | 248 | conf.set_quoted('SYSTEM_DATA_UNIT_DIR', systemunitdir) |
96d33e4a | 249 | conf.set_quoted('SYSTEM_ENV_GENERATOR_DIR', systemenvgeneratordir) |
491bf10c ZJS |
250 | conf.set_quoted('SYSTEM_GENERATOR_DIR', systemgeneratordir) |
251 | conf.set_quoted('SYSTEM_PRESET_DIR', systempresetdir) | |
5c23128d ZJS |
252 | conf.set_quoted('SYSTEM_SHUTDOWN_PATH', systemshutdowndir) |
253 | conf.set_quoted('SYSTEM_SLEEP_PATH', systemsleepdir) | |
491bf10c ZJS |
254 | conf.set_quoted('SYSTEM_SYSVINIT_PATH', sysvinit_path) |
255 | conf.set_quoted('SYSTEM_SYSVRCND_PATH', sysvrcnd_path) | |
835cf75a ZJS |
256 | conf.set_quoted('SYSUSERS_DIR', sysusersdir) |
257 | conf.set_quoted('TMPFILES_DIR', tmpfilesdir) | |
107795a7 | 258 | conf.set_quoted('USER_TMPFILES_DIR', usertmpfilesdir) |
5c23128d | 259 | conf.set_quoted('UDEVLIBEXECDIR', udevlibexecdir) |
491bf10c ZJS |
260 | conf.set_quoted('UDEV_HWDB_DIR', udevhwdbdir) |
261 | conf.set_quoted('UDEV_RULES_DIR', udevrulesdir) | |
fce9abb2 | 262 | conf.set_quoted('USER_CONFIG_UNIT_DIR', pkgsysconfdir / 'user') |
491bf10c ZJS |
263 | conf.set_quoted('USER_DATA_UNIT_DIR', userunitdir) |
264 | conf.set_quoted('USER_ENV_GENERATOR_DIR', userenvgeneratordir) | |
265 | conf.set_quoted('USER_GENERATOR_DIR', usergeneratordir) | |
fce9abb2 | 266 | conf.set_quoted('USER_KEYRING_PATH', pkgsysconfdir / 'import-pubring.gpg') |
491bf10c | 267 | conf.set_quoted('USER_PRESET_DIR', userpresetdir) |
b0d3095f | 268 | conf.set_quoted('VENDOR_KEYRING_PATH', libexecdir / 'import-pubring.gpg') |
491bf10c ZJS |
269 | |
270 | conf.set('ANSI_OK_COLOR', 'ANSI_' + get_option('ok-color').underscorify().to_upper()) | |
e5d86ebe | 271 | conf.set10('ENABLE_URLIFY', get_option('urlify')) |
491bf10c | 272 | conf.set10('ENABLE_FEXECVE', get_option('fexecve')) |
30538ff1 | 273 | conf.set10('MEMORY_ACCOUNTING_DEFAULT', memory_accounting_default) |
36cf4507 | 274 | conf.set('STATUS_UNIT_FORMAT_DEFAULT', 'STATUS_UNIT_FORMAT_' + status_unit_format_default.to_upper()) |
e11a25ca | 275 | conf.set_quoted('STATUS_UNIT_FORMAT_DEFAULT_STR', status_unit_format_default) |
5c23128d | 276 | |
e4c7b5f5 ZJS |
277 | conf.set('DEFAULT_TIMEOUT_SEC', get_option('default-timeout-sec')) |
278 | conf.set('DEFAULT_USER_TIMEOUT_SEC', get_option('default-user-timeout-sec')) | |
279 | conf.set('UPDATE_HELPER_USER_TIMEOUT_SEC', get_option('update-helper-user-timeout-sec')) | |
280 | ||
93651582 JL |
281 | conf.set10('FIRST_BOOT_FULL_PRESET', get_option('first-boot-full-preset')) |
282 | ||
5c23128d ZJS |
283 | ##################################################################### |
284 | ||
285 | cc = meson.get_compiler('c') | |
92148283 JJ |
286 | userspace_c_args = [] |
287 | userspace_c_ld_args = [] | |
b68dfb9e | 288 | meson_build_sh = find_program('tools/meson-build.sh') |
5c23128d | 289 | |
d3da291e ZJS |
290 | want_tests = get_option('tests') |
291 | slow_tests = want_tests != 'false' and get_option('slow-tests') | |
c56463fd | 292 | fuzz_tests = want_tests != 'false' and get_option('fuzz-tests') |
d3da291e ZJS |
293 | install_tests = get_option('install-tests') |
294 | ||
daf4e78e | 295 | if add_languages('cpp', native : false, required : fuzzer_build) |
3b2bdd62 | 296 | # Used only for tests |
e9f4f566 ZJS |
297 | cxx = meson.get_compiler('cpp') |
298 | cxx_cmd = ' '.join(cxx.cmd_array()) | |
1b2acaa7 | 299 | else |
9b0ca019 | 300 | cxx_cmd = '' |
94e2523b ZJS |
301 | endif |
302 | ||
31e57a35 | 303 | if want_libfuzzer |
9c5c4677 EV |
304 | fuzzing_engine = meson.get_compiler('cpp').find_library('Fuzzer', required : false) |
305 | if fuzzing_engine.found() | |
92148283 | 306 | userspace_c_args += '-fsanitize-coverage=trace-pc-guard,trace-cmp' |
9c5c4677 | 307 | elif cc.has_argument('-fsanitize=fuzzer-no-link') |
92148283 | 308 | userspace_c_args += '-fsanitize=fuzzer-no-link' |
9c5c4677 EV |
309 | else |
310 | error('Looks like neither libFuzzer nor -fsanitize=fuzzer-no-link is supported') | |
311 | endif | |
c09edc79 | 312 | elif want_ossfuzz |
7db7d5b7 JR |
313 | fuzzing_engine = meson.get_compiler('cpp').find_library('FuzzingEngine') |
314 | endif | |
315 | ||
e9f4f566 ZJS |
316 | # Those generate many false positives, and we do not want to change the code to |
317 | # avoid them. | |
318 | basic_disabled_warnings = [ | |
e9f4f566 | 319 | '-Wno-missing-field-initializers', |
505ab9dd | 320 | '-Wno-unused-parameter', |
e9f4f566 | 321 | ] |
e9f4f566 | 322 | |
65267363 | 323 | possible_common_cc_flags = [ |
fc568837 ZJS |
324 | '-Warray-bounds', # clang |
325 | '-Warray-bounds=2', | |
505ab9dd YW |
326 | '-Wdate-time', |
327 | '-Wendif-labels', | |
328 | '-Werror=format=2', | |
a4ea5d19 | 329 | '-Werror=format-signedness', |
505ab9dd | 330 | '-Werror=implicit-function-declaration', |
a0d613ec | 331 | '-Werror=implicit-int', |
505ab9dd | 332 | '-Werror=incompatible-pointer-types', |
ebbb1e36 | 333 | '-Werror=int-conversion', |
0b482b37 JJ |
334 | '-Werror=missing-declarations', |
335 | '-Werror=missing-prototypes', | |
505ab9dd | 336 | '-Werror=overflow', |
48c67fdf | 337 | '-Werror=override-init', |
505ab9dd YW |
338 | '-Werror=return-type', |
339 | '-Werror=shift-count-overflow', | |
340 | '-Werror=shift-overflow=2', | |
6405afda | 341 | '-Werror=strict-flex-arrays', |
30a4ddff | 342 | '-Werror=undef', |
505ab9dd | 343 | '-Wfloat-equal', |
c0f5d58c JJ |
344 | # gperf prevents us from enabling this because it does not emit fallthrough |
345 | # attribute with clang. | |
346 | #'-Wimplicit-fallthrough', | |
505ab9dd YW |
347 | '-Wimplicit-fallthrough=5', |
348 | '-Winit-self', | |
30a4ddff YW |
349 | '-Wlogical-op', |
350 | '-Wmissing-include-dirs', | |
505ab9dd YW |
351 | '-Wmissing-noreturn', |
352 | '-Wnested-externs', | |
30a4ddff YW |
353 | '-Wold-style-definition', |
354 | '-Wpointer-arith', | |
30a4ddff | 355 | '-Wredundant-decls', |
30a4ddff | 356 | '-Wshadow', |
30a4ddff | 357 | '-Wstrict-aliasing=2', |
505ab9dd YW |
358 | '-Wstrict-prototypes', |
359 | '-Wsuggest-attribute=noreturn', | |
054ed430 | 360 | '-Wunused-function', |
30a4ddff | 361 | '-Wwrite-strings', |
31560245 | 362 | '-Wzero-length-bounds', |
bf7efeb1 FB |
363 | |
364 | # negative arguments are correctly detected starting with meson 0.46. | |
eed33623 ZJS |
365 | '-Wno-error=#warnings', # clang |
366 | '-Wno-string-plus-int', # clang | |
fc568837 | 367 | |
0b482b37 JJ |
368 | '-fdiagnostics-show-option', |
369 | '-fno-common', | |
48e1b2c2 JJ |
370 | '-fstack-protector', |
371 | '-fstack-protector-strong', | |
fc568837 | 372 | '-fstrict-flex-arrays', |
48e1b2c2 JJ |
373 | '--param=ssp-buffer-size=4', |
374 | ] | |
375 | ||
376 | possible_common_link_flags = [ | |
377 | '-fstack-protector', | |
30a4ddff YW |
378 | ] |
379 | ||
b528a628 ZJS |
380 | c_args = get_option('c_args') |
381 | ||
60f97fee | 382 | # Our json library does not support -ffinite-math-only, which is enabled by -Ofast or -ffast-math. |
53403091 | 383 | if (('-Ofast' in c_args or '-ffast-math' in c_args or '-ffinite-math-only' in c_args) and '-fno-finite-math-only' not in c_args) |
60f97fee YW |
384 | error('-Ofast, -ffast-math, or -ffinite-math-only is specified in c_args.') |
385 | endif | |
386 | ||
a17e5478 | 387 | # Disable -Wmaybe-uninitialized when compiling with -Os/-O1/-O3/etc. There are |
68c98a41 ZJS |
388 | # too many false positives with gcc >= 8. Effectively, we only test with -O0 |
389 | # and -O2; this should be enough to catch most important cases without too much | |
390 | # busywork. See https://github.com/systemd/systemd/pull/19226. | |
391 | if cc.get_id() == 'gcc' and (not '02'.contains(get_option('optimization')) or | |
b528a628 ZJS |
392 | cc.version().version_compare('<10') or |
393 | '-Os' in c_args or | |
394 | '-O1' in c_args or | |
395 | '-O3' in c_args or | |
396 | '-Og' in c_args) | |
65267363 | 397 | possible_common_cc_flags += '-Wno-maybe-uninitialized' |
68c98a41 ZJS |
398 | endif |
399 | ||
bc2a4af2 ZJS |
400 | # Disable -Wno-unused-result with gcc, see |
401 | # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66425. | |
402 | if cc.get_id() == 'gcc' | |
403 | possible_common_cc_flags += '-Wno-unused-result' | |
404 | endif | |
405 | ||
30a4ddff | 406 | # --as-needed and --no-undefined are provided by meson by default, |
9247df5a | 407 | # run 'meson configure' to see what is enabled |
30a4ddff | 408 | possible_link_flags = [ |
42e3bb35 | 409 | '-Wl,--fatal-warnings', |
30a4ddff | 410 | '-Wl,-z,now', |
42e3bb35 | 411 | '-Wl,-z,relro', |
30a4ddff | 412 | ] |
5c23128d | 413 | |
42e3bb35 JJ |
414 | if get_option('b_sanitize') == 'none' |
415 | possible_link_flags += '-Wl,--warn-common' | |
416 | endif | |
417 | ||
30a4ddff | 418 | if cc.get_id() == 'clang' |
65267363 | 419 | possible_common_cc_flags += [ |
30a4ddff YW |
420 | '-Wno-typedef-redefinition', |
421 | '-Wno-gnu-variable-sized-type-not-at-end', | |
422 | ] | |
423 | endif | |
424 | ||
1a4e3927 JJ |
425 | if get_option('mode') == 'release' |
426 | # We could enable 'pattern' for developer mode, but that can interfere with | |
427 | # valgrind and sanitizer builds. Also, clang does not zero-initialize unions, | |
428 | # breaking some of our code (https://reviews.llvm.org/D68115). | |
429 | possible_common_cc_flags += '-ftrivial-auto-var-init=zero' | |
430 | endif | |
431 | ||
92148283 | 432 | possible_cc_flags = [ |
16e09d51 | 433 | '-fno-strict-aliasing', |
afd8e1d9 | 434 | '-fstrict-flex-arrays=1', |
16e09d51 | 435 | '-fvisibility=hidden', |
16e09d51 YW |
436 | ] |
437 | ||
30a4ddff | 438 | if get_option('buildtype') != 'debug' |
16e09d51 | 439 | possible_cc_flags += [ |
30a4ddff YW |
440 | '-ffunction-sections', |
441 | '-fdata-sections', | |
442 | ] | |
443 | ||
444 | possible_link_flags += '-Wl,--gc-sections' | |
445 | endif | |
446 | ||
82390022 DDM |
447 | if get_option('mode') == 'developer' |
448 | possible_cc_flags += '-fno-omit-frame-pointer' | |
449 | endif | |
450 | ||
92148283 JJ |
451 | add_project_arguments( |
452 | cc.get_supported_arguments( | |
453 | basic_disabled_warnings, | |
454 | possible_common_cc_flags | |
455 | ), | |
456 | language : 'c') | |
457 | ||
48e1b2c2 JJ |
458 | add_project_link_arguments( |
459 | cc.get_supported_link_arguments(possible_common_link_flags), | |
460 | language : 'c') | |
461 | ||
92148283 JJ |
462 | userspace_c_args += cc.get_supported_arguments(possible_cc_flags) |
463 | userspace_c_ld_args += cc.get_supported_link_arguments(possible_link_flags) | |
30a4ddff | 464 | |
94c0c5b7 ZJS |
465 | have = cc.has_argument('-Wzero-length-bounds') |
466 | conf.set10('HAVE_ZERO_LENGTH_BOUNDS', have) | |
467 | ||
9e70f2f8 | 468 | if cc.compiles(''' |
5c23128d ZJS |
469 | #include <time.h> |
470 | #include <inttypes.h> | |
471 | typedef uint64_t usec_t; | |
472 | usec_t now(clockid_t clock); | |
473 | int main(void) { | |
474 | struct timespec now; | |
475 | return 0; | |
476 | } | |
38c1c96d | 477 | ''', args: '-Werror=shadow', name : '-Werror=shadow with local shadowing') |
37efbbd8 | 478 | add_project_arguments('-Werror=shadow', language : 'c') |
5c23128d ZJS |
479 | endif |
480 | ||
e9f4f566 ZJS |
481 | if cxx_cmd != '' |
482 | add_project_arguments(cxx.get_supported_arguments(basic_disabled_warnings), language : 'cpp') | |
483 | endif | |
484 | ||
0e3cc902 | 485 | cpp = ' '.join(cc.cmd_array()) + ' -E' |
9cc0e6e9 | 486 | |
6695c200 ZJS |
487 | has_wstringop_truncation = cc.has_argument('-Wstringop-truncation') |
488 | ||
5c23128d ZJS |
489 | ##################################################################### |
490 | # compilation result tests | |
491 | ||
78103450 | 492 | conf.set('_GNU_SOURCE', 1) |
2c201c21 | 493 | conf.set('__SANE_USERSPACE_TYPES__', true) |
6695c200 | 494 | conf.set10('HAVE_WSTRINGOP_TRUNCATION', has_wstringop_truncation) |
5c23128d | 495 | |
5c23128d ZJS |
496 | conf.set('SIZEOF_DEV_T', cc.sizeof('dev_t', prefix : '#include <sys/types.h>')) |
497 | conf.set('SIZEOF_INO_T', cc.sizeof('ino_t', prefix : '#include <sys/types.h>')) | |
5c23128d | 498 | conf.set('SIZEOF_RLIM_T', cc.sizeof('rlim_t', prefix : '#include <sys/resource.h>')) |
84d953e8 | 499 | conf.set('SIZEOF_TIME_T', cc.sizeof('time_t', prefix : '#include <sys/time.h>')) |
3112d756 | 500 | conf.set('SIZEOF_TIMEX_MEMBER', cc.sizeof('typeof(((struct timex *)0)->freq)', prefix : '#include <sys/timex.h>')) |
5c23128d | 501 | |
2736a0c6 | 502 | long_max = cc.compute_int( |
503 | 'LONG_MAX', | |
504 | prefix : '#include <limits.h>', | |
505 | guess : 0x7FFFFFFFFFFFFFFF, | |
506 | high : 0x7FFFFFFFFFFFFFFF) | |
a5fac1df ZJS |
507 | assert(long_max > 100000) |
508 | conf.set_quoted('LONG_MAX_STR', '@0@'.format(long_max)) | |
509 | ||
5c23128d | 510 | decl_headers = ''' |
eb292969 | 511 | #include <dirent.h> |
5c23128d | 512 | #include <uchar.h> |
84e8edec | 513 | #include <sys/mount.h> |
4c2e1b39 | 514 | #include <sys/stat.h> |
5c23128d | 515 | ''' |
5c23128d ZJS |
516 | |
517 | foreach decl : ['char16_t', | |
518 | 'char32_t', | |
84e8edec | 519 | 'struct mount_attr', |
4c2e1b39 | 520 | 'struct statx', |
eb292969 | 521 | 'struct dirent64', |
5c23128d | 522 | ] |
2c201c21 ZJS |
523 | |
524 | # We get -1 if the size cannot be determined | |
9c869d08 ZJS |
525 | have = cc.sizeof(decl, prefix : decl_headers, args : '-D_GNU_SOURCE') > 0 |
526 | ||
3657d3a0 RH |
527 | if decl == 'struct mount_attr' |
528 | if have | |
529 | want_linux_fs_h = false | |
530 | else | |
531 | have = cc.sizeof(decl, | |
532 | prefix : decl_headers + '#include <linux/fs.h>', | |
533 | args : '-D_GNU_SOURCE') > 0 | |
534 | want_linux_fs_h = have | |
535 | endif | |
536 | endif | |
537 | ||
9c869d08 ZJS |
538 | if decl == 'struct statx' |
539 | if have | |
540 | want_linux_stat_h = false | |
541 | else | |
542 | have = cc.sizeof(decl, | |
543 | prefix : decl_headers + '#include <linux/stat.h>', | |
544 | args : '-D_GNU_SOURCE') > 0 | |
545 | want_linux_stat_h = have | |
546 | endif | |
547 | endif | |
548 | ||
349cc4a5 | 549 | conf.set10('HAVE_' + decl.underscorify().to_upper(), have) |
5c23128d ZJS |
550 | endforeach |
551 | ||
9c869d08 | 552 | conf.set10('WANT_LINUX_STAT_H', want_linux_stat_h) |
3657d3a0 | 553 | conf.set10('WANT_LINUX_FS_H', want_linux_fs_h) |
75720bff | 554 | |
5c23128d | 555 | foreach ident : ['secure_getenv', '__secure_getenv'] |
349cc4a5 | 556 | conf.set10('HAVE_' + ident.to_upper(), cc.has_function(ident)) |
5c23128d ZJS |
557 | endforeach |
558 | ||
559 | foreach ident : [ | |
85db59b7 | 560 | ['memfd_create', '''#include <sys/mman.h>'''], |
7b961e40 LP |
561 | ['gettid', '''#include <sys/types.h> |
562 | #include <unistd.h>'''], | |
3c042add LP |
563 | ['pivot_root', '''#include <stdlib.h> |
564 | #include <unistd.h>'''], # no known header declares pivot_root | |
51fe206f ZJS |
565 | ['ioprio_get', '''#include <sched.h>'''], # no known header declares ioprio_get |
566 | ['ioprio_set', '''#include <sched.h>'''], # no known header declares ioprio_set | |
85db59b7 | 567 | ['name_to_handle_at', '''#include <sys/types.h> |
37efbbd8 ZJS |
568 | #include <sys/stat.h> |
569 | #include <fcntl.h>'''], | |
85db59b7 | 570 | ['setns', '''#include <sched.h>'''], |
2acfd0ff LP |
571 | ['renameat2', '''#include <stdio.h> |
572 | #include <fcntl.h>'''], | |
37efbbd8 ZJS |
573 | ['kcmp', '''#include <linux/kcmp.h>'''], |
574 | ['keyctl', '''#include <sys/types.h> | |
575 | #include <keyutils.h>'''], | |
85db59b7 | 576 | ['copy_file_range', '''#include <sys/syscall.h> |
37efbbd8 | 577 | #include <unistd.h>'''], |
71e5200f DM |
578 | ['bpf', '''#include <sys/syscall.h> |
579 | #include <unistd.h>'''], | |
4c2e1b39 LP |
580 | ['statx', '''#include <sys/types.h> |
581 | #include <sys/stat.h> | |
582 | #include <unistd.h>'''], | |
aa484f35 | 583 | ['explicit_bzero' , '''#include <string.h>'''], |
5bb20fd3 | 584 | ['reallocarray', '''#include <stdlib.h>'''], |
b070c7c0 MS |
585 | ['set_mempolicy', '''#include <stdlib.h> |
586 | #include <unistd.h>'''], | |
587 | ['get_mempolicy', '''#include <stdlib.h> | |
588 | #include <unistd.h>'''], | |
5f152f43 LP |
589 | ['pidfd_send_signal', '''#include <stdlib.h> |
590 | #include <unistd.h> | |
591 | #include <signal.h> | |
592 | #include <sys/wait.h>'''], | |
593 | ['pidfd_open', '''#include <stdlib.h> | |
594 | #include <unistd.h> | |
595 | #include <signal.h> | |
596 | #include <sys/wait.h>'''], | |
5ead4e85 LP |
597 | ['rt_sigqueueinfo', '''#include <stdlib.h> |
598 | #include <unistd.h> | |
599 | #include <signal.h> | |
600 | #include <sys/wait.h>'''], | |
a5421953 DDM |
601 | ['rt_tgsigqueueinfo', '''#include <stdlib.h> |
602 | #include <unistd.h> | |
603 | #include <signal.h> | |
604 | #include <sys/wait.h>'''], | |
4b6f74f5 | 605 | ['mallinfo', '''#include <malloc.h>'''], |
1885169c | 606 | ['mallinfo2', '''#include <malloc.h>'''], |
8939eeae | 607 | ['execveat', '''#include <unistd.h>'''], |
441e0fdb | 608 | ['close_range', '''#include <unistd.h>'''], |
420297c9 | 609 | ['epoll_pwait2', '''#include <sys/epoll.h>'''], |
84e8edec LP |
610 | ['mount_setattr', '''#include <sys/mount.h>'''], |
611 | ['move_mount', '''#include <sys/mount.h>'''], | |
612 | ['open_tree', '''#include <sys/mount.h>'''], | |
1c265fcd DDM |
613 | ['fsopen', '''#include <sys/mount.h>'''], |
614 | ['fsconfig', '''#include <sys/mount.h>'''], | |
34a9da0d | 615 | ['fsmount', '''#include <sys/mount.h>'''], |
aab35b1e | 616 | ['getdents64', '''#include <dirent.h>'''], |
37efbbd8 ZJS |
617 | ] |
618 | ||
85db59b7 | 619 | have = cc.has_function(ident[0], prefix : ident[1], args : '-D_GNU_SOURCE') |
4b9545f1 | 620 | conf.set10('HAVE_' + ident[0].to_upper(), have) |
5c23128d ZJS |
621 | endforeach |
622 | ||
85db59b7 | 623 | if cc.has_function('getrandom', prefix : '''#include <sys/random.h>''', args : '-D_GNU_SOURCE') |
349cc4a5 | 624 | conf.set10('USE_SYS_RANDOM_H', true) |
4b9545f1 | 625 | conf.set10('HAVE_GETRANDOM', true) |
4984c8be ZJS |
626 | else |
627 | have = cc.has_function('getrandom', prefix : '''#include <linux/random.h>''') | |
349cc4a5 | 628 | conf.set10('USE_SYS_RANDOM_H', false) |
4b9545f1 | 629 | conf.set10('HAVE_GETRANDOM', have) |
4984c8be ZJS |
630 | endif |
631 | ||
5c23128d ZJS |
632 | ##################################################################### |
633 | ||
0f4c4f38 ZJS |
634 | sh = find_program('sh') |
635 | echo = find_program('echo') | |
5c23128d | 636 | sed = find_program('sed') |
5c23128d | 637 | awk = find_program('awk') |
5c23128d | 638 | stat = find_program('stat') |
0f4c4f38 | 639 | ln = find_program('ln') |
d68b342b | 640 | git = find_program('git', required : false) |
b68dfb9e | 641 | env = find_program('env') |
0f4c4f38 | 642 | rsync = find_program('rsync', required : false) |
4d56d084 | 643 | diff = find_program('diff') |
d9081eb0 | 644 | find = find_program('find') |
7c22f07c | 645 | meson_make_symlink = project_source_root + '/tools/meson-make-symlink.sh' |
5c23128d | 646 | |
94e75a54 | 647 | mkdir_p = 'mkdir -p $DESTDIR/@0@' |
24039e12 | 648 | mkdir_p_mode = 'mkdir -p $DESTDIR/@0@ -m @1@' |
94e75a54 | 649 | |
9247df5a | 650 | # If -Dxxx-path option is found, use that. Otherwise, check in $PATH, |
5c23128d | 651 | # /usr/sbin, /sbin, and fall back to the default from middle column. |
2fa645f1 | 652 | progs = [['quotaon', '/usr/sbin/quotaon' ], |
5c23128d | 653 | ['quotacheck', '/usr/sbin/quotacheck' ], |
5c23128d ZJS |
654 | ['kmod', '/usr/bin/kmod' ], |
655 | ['kexec', '/usr/sbin/kexec' ], | |
656 | ['sulogin', '/usr/sbin/sulogin' ], | |
657 | ['mount', '/usr/bin/mount', 'MOUNT_PATH'], | |
658 | ['umount', '/usr/bin/umount', 'UMOUNT_PATH'], | |
659 | ['loadkeys', '/usr/bin/loadkeys', 'KBD_LOADKEYS'], | |
660 | ['setfont', '/usr/bin/setfont', 'KBD_SETFONT'], | |
6db90462 | 661 | ['nologin', '/usr/sbin/nologin', ], |
5c23128d ZJS |
662 | ] |
663 | foreach prog : progs | |
37efbbd8 ZJS |
664 | path = get_option(prog[0] + '-path') |
665 | if path != '' | |
666 | message('Using @1@ for @0@'.format(prog[0], path)) | |
667 | else | |
668 | exe = find_program(prog[0], | |
669 | '/usr/sbin/' + prog[0], | |
670 | '/sbin/' + prog[0], | |
671 | required: false) | |
573c0dc1 | 672 | path = exe.found() ? exe.full_path() : prog[1] |
37efbbd8 ZJS |
673 | endif |
674 | name = prog.length() > 2 ? prog[2] : prog[0].to_upper() | |
675 | conf.set_quoted(name, path) | |
5c23128d ZJS |
676 | endforeach |
677 | ||
2fa645f1 MG |
678 | conf.set_quoted('TELINIT', get_option('telinit-path')) |
679 | ||
e92777d2 | 680 | if run_command(ln, '--relative', '--help', check : false).returncode() != 0 |
cd001016 | 681 | error('ln does not support --relative (added in coreutils 8.16)') |
1276a9f6 | 682 | endif |
5c23128d ZJS |
683 | |
684 | ############################################################ | |
685 | ||
686 | gperf = find_program('gperf') | |
687 | ||
688 | gperf_test_format = ''' | |
689 | #include <string.h> | |
690 | const char * in_word_set(const char *, @0@); | |
691 | @1@ | |
692 | ''' | |
ac3eda34 | 693 | gperf_snippet = run_command(sh, '-c', 'echo foo,bar | "$1" -L ANSI-C', '_', gperf, |
e92777d2 | 694 | check : true) |
5c23128d ZJS |
695 | gperf_test = gperf_test_format.format('size_t', gperf_snippet.stdout()) |
696 | if cc.compiles(gperf_test) | |
37efbbd8 | 697 | gperf_len_type = 'size_t' |
5c23128d | 698 | else |
37efbbd8 ZJS |
699 | gperf_test = gperf_test_format.format('unsigned', gperf_snippet.stdout()) |
700 | if cc.compiles(gperf_test) | |
701 | gperf_len_type = 'unsigned' | |
702 | else | |
703 | error('unable to determine gperf len type') | |
704 | endif | |
5c23128d ZJS |
705 | endif |
706 | message('gperf len type is @0@'.format(gperf_len_type)) | |
37efbbd8 ZJS |
707 | conf.set('GPERF_LEN_TYPE', gperf_len_type, |
708 | description : 'The type of gperf "len" parameter') | |
5c23128d ZJS |
709 | |
710 | ############################################################ | |
711 | ||
712 | if not cc.has_header('sys/capability.h') | |
37efbbd8 | 713 | error('POSIX caps headers not found') |
5c23128d | 714 | endif |
9f555bba | 715 | foreach header : ['crypt.h', |
5c23128d ZJS |
716 | 'linux/memfd.h', |
717 | 'linux/vm_sockets.h', | |
af8786b1 | 718 | 'sys/auxv.h', |
5545f336 | 719 | 'threads.h', |
5c23128d ZJS |
720 | 'valgrind/memcheck.h', |
721 | 'valgrind/valgrind.h', | |
420297c9 | 722 | 'linux/time_types.h', |
b428efa5 | 723 | 'sys/sdt.h', |
5c23128d | 724 | ] |
2c201c21 | 725 | |
349cc4a5 ZJS |
726 | conf.set10('HAVE_' + header.underscorify().to_upper(), |
727 | cc.has_header(header)) | |
5c23128d ZJS |
728 | endforeach |
729 | ||
730 | ############################################################ | |
731 | ||
eef4b800 ZJS |
732 | fallback_hostname = get_option('fallback-hostname') |
733 | if fallback_hostname == '' or fallback_hostname[0] == '.' or fallback_hostname[0] == '-' | |
734 | error('Invalid fallback-hostname configuration') | |
735 | # A more extensive test is done in test-hostname-util. Let's catch | |
736 | # the most obvious errors here so we don't fail with an assert later. | |
737 | endif | |
738 | conf.set_quoted('FALLBACK_HOSTNAME', fallback_hostname) | |
739 | ||
5c23128d ZJS |
740 | default_hierarchy = get_option('default-hierarchy') |
741 | conf.set_quoted('DEFAULT_HIERARCHY_NAME', default_hierarchy, | |
742 | description : 'default cgroup hierarchy as string') | |
743 | if default_hierarchy == 'legacy' | |
37efbbd8 | 744 | conf.set('DEFAULT_HIERARCHY', 'CGROUP_UNIFIED_NONE') |
5c23128d | 745 | elif default_hierarchy == 'hybrid' |
37efbbd8 | 746 | conf.set('DEFAULT_HIERARCHY', 'CGROUP_UNIFIED_SYSTEMD') |
5c23128d | 747 | else |
37efbbd8 | 748 | conf.set('DEFAULT_HIERARCHY', 'CGROUP_UNIFIED_ALL') |
5c23128d ZJS |
749 | endif |
750 | ||
681cb84a ZJS |
751 | extra_net_naming_schemes = [] |
752 | extra_net_naming_map = [] | |
753 | foreach scheme: get_option('extra-net-naming-schemes').split(',') | |
754 | if scheme != '' | |
755 | name = scheme.split('=')[0] | |
756 | value = scheme.split('=')[1] | |
757 | NAME = name.underscorify().to_upper() | |
758 | VALUE = [] | |
759 | foreach field: value.split('+') | |
760 | VALUE += 'NAMING_' + field.underscorify().to_upper() | |
761 | endforeach | |
762 | extra_net_naming_schemes += 'NAMING_@0@ = @1@,'.format(NAME, '|'.join(VALUE)) | |
763 | extra_net_naming_map += '{ "@0@", NAMING_@1@ },'.format(name, NAME) | |
764 | endif | |
765 | endforeach | |
766 | conf.set('EXTRA_NET_NAMING_SCHEMES', ' '.join(extra_net_naming_schemes)) | |
767 | conf.set('EXTRA_NET_NAMING_MAP', ' '.join(extra_net_naming_map)) | |
768 | ||
06da5c63 ZJS |
769 | default_net_naming_scheme = get_option('default-net-naming-scheme') |
770 | conf.set_quoted('DEFAULT_NET_NAMING_SCHEME', default_net_naming_scheme) | |
77faadfd ZJS |
771 | if default_net_naming_scheme != 'latest' |
772 | conf.set('_DEFAULT_NET_NAMING_SCHEME_TEST', | |
773 | 'NAMING_' + default_net_naming_scheme.underscorify().to_upper()) | |
774 | endif | |
06da5c63 | 775 | |
5c23128d | 776 | time_epoch = get_option('time-epoch') |
a36be3e5 | 777 | if time_epoch <= 0 |
e92777d2 | 778 | time_epoch = run_command(sh, '-c', 'echo "$SOURCE_DATE_EPOCH"', check : true).stdout().strip() |
edd84b8e | 779 | if time_epoch == '' and git.found() and fs.is_dir('.git') |
bd190899 | 780 | # If we're in a git repository, use the creation time of the latest git tag. |
e92777d2 ZJS |
781 | latest_tag = run_command(git, 'describe', '--abbrev=0', '--tags', |
782 | check : false) | |
783 | if latest_tag.returncode() == 0 | |
784 | time_epoch = run_command( | |
785 | git, 'log', '--no-show-signature', '-1', '--format=%at', | |
786 | latest_tag.stdout().strip(), | |
787 | check : false).stdout() | |
788 | endif | |
0390b094 ZJS |
789 | endif |
790 | if time_epoch == '' | |
6dbf352c | 791 | NEWS = files('NEWS') |
e92777d2 ZJS |
792 | time_epoch = run_command(stat, '-c', '%Y', NEWS, |
793 | check : true).stdout() | |
6dbf352c | 794 | endif |
89cdbe1f | 795 | time_epoch = time_epoch.strip().to_int() |
5c23128d | 796 | endif |
5c23128d ZJS |
797 | conf.set('TIME_EPOCH', time_epoch) |
798 | ||
b10abe4b EI |
799 | conf.set('CLOCK_VALID_RANGE_USEC_MAX', get_option('clock-valid-range-usec-max')) |
800 | ||
53350c7b | 801 | default_user_shell = get_option('default-user-shell') |
802 | conf.set_quoted('DEFAULT_USER_SHELL', default_user_shell) | |
803 | conf.set_quoted('DEFAULT_USER_SHELL_NAME', fs.name(default_user_shell)) | |
804 | ||
fc1a5d1a ZJS |
805 | foreach tuple : [['system-alloc-uid-min', 'SYS_UID_MIN', 1], # Also see login.defs(5). |
806 | ['system-uid-max', 'SYS_UID_MAX', 999], | |
807 | ['system-alloc-gid-min', 'SYS_GID_MIN', 1], | |
808 | ['system-gid-max', 'SYS_GID_MAX', 999]] | |
809 | v = get_option(tuple[0]) | |
a36be3e5 | 810 | if v <= 0 |
fc1a5d1a ZJS |
811 | v = run_command( |
812 | awk, | |
813 | '/^\s*@0@\s+/ { uid=$2 } END { print uid }'.format(tuple[1]), | |
e92777d2 ZJS |
814 | '/etc/login.defs', |
815 | check : false).stdout().strip() | |
fc1a5d1a ZJS |
816 | if v == '' |
817 | v = tuple[2] | |
818 | else | |
819 | v = v.to_int() | |
820 | endif | |
2f62cf35 | 821 | endif |
fc1a5d1a | 822 | conf.set(tuple[0].underscorify().to_upper(), v) |
fc1a5d1a ZJS |
823 | endforeach |
824 | if conf.get('SYSTEM_ALLOC_UID_MIN') >= conf.get('SYSTEM_UID_MAX') | |
825 | error('Invalid uid allocation range') | |
5c23128d | 826 | endif |
fc1a5d1a ZJS |
827 | if conf.get('SYSTEM_ALLOC_GID_MIN') >= conf.get('SYSTEM_GID_MAX') |
828 | error('Invalid gid allocation range') | |
5c23128d | 829 | endif |
5c23128d | 830 | |
ac09340e YW |
831 | dynamic_uid_min = get_option('dynamic-uid-min') |
832 | dynamic_uid_max = get_option('dynamic-uid-max') | |
87d5e4f2 LP |
833 | conf.set('DYNAMIC_UID_MIN', dynamic_uid_min) |
834 | conf.set('DYNAMIC_UID_MAX', dynamic_uid_max) | |
87d5e4f2 | 835 | |
ac09340e YW |
836 | container_uid_base_min = get_option('container-uid-base-min') |
837 | container_uid_base_max = get_option('container-uid-base-max') | |
87d5e4f2 LP |
838 | conf.set('CONTAINER_UID_BASE_MIN', container_uid_base_min) |
839 | conf.set('CONTAINER_UID_BASE_MAX', container_uid_base_max) | |
87d5e4f2 | 840 | |
afde4574 LP |
841 | nobody_user = get_option('nobody-user') |
842 | nobody_group = get_option('nobody-group') | |
843 | ||
2484bff3 | 844 | if not meson.is_cross_build() |
e92777d2 | 845 | getent_result = run_command('getent', 'passwd', '65534', check : false) |
2484bff3 CQ |
846 | if getent_result.returncode() == 0 |
847 | name = getent_result.stdout().split(':')[0] | |
848 | if name != nobody_user | |
849 | warning('\n' + | |
850 | 'The local user with the UID 65534 does not match the configured user name "@0@" of the nobody user (its name is @1@).\n'.format(nobody_user, name) + | |
851 | 'Your build will result in an user table setup that is incompatible with the local system.') | |
852 | endif | |
afde4574 | 853 | endif |
e92777d2 | 854 | id_result = run_command('id', '-u', nobody_user, check : false) |
2484bff3 | 855 | if id_result.returncode() == 0 |
89cdbe1f | 856 | id = id_result.stdout().strip().to_int() |
2484bff3 CQ |
857 | if id != 65534 |
858 | warning('\n' + | |
859 | 'The local user with the configured user name "@0@" of the nobody user does not have UID 65534 (it has @1@).\n'.format(nobody_user, id) + | |
860 | 'Your build will result in an user table setup that is incompatible with the local system.') | |
861 | endif | |
afde4574 | 862 | endif |
afde4574 | 863 | |
e92777d2 | 864 | getent_result = run_command('getent', 'group', '65534', check : false) |
2484bff3 CQ |
865 | if getent_result.returncode() == 0 |
866 | name = getent_result.stdout().split(':')[0] | |
867 | if name != nobody_group | |
868 | warning('\n' + | |
869 | 'The local group with the GID 65534 does not match the configured group name "@0@" of the nobody group (its name is @1@).\n'.format(nobody_group, name) + | |
870 | 'Your build will result in an group table setup that is incompatible with the local system.') | |
871 | endif | |
afde4574 | 872 | endif |
e92777d2 | 873 | id_result = run_command('id', '-g', nobody_group, check : false) |
2484bff3 | 874 | if id_result.returncode() == 0 |
89cdbe1f | 875 | id = id_result.stdout().strip().to_int() |
2484bff3 CQ |
876 | if id != 65534 |
877 | warning('\n' + | |
d5b3e510 | 878 | 'The local group with the configured group name "@0@" of the nobody group does not have GID 65534 (it has @1@).\n'.format(nobody_group, id) + |
2484bff3 CQ |
879 | 'Your build will result in an group table setup that is incompatible with the local system.') |
880 | endif | |
afde4574 LP |
881 | endif |
882 | endif | |
8374cc62 | 883 | if nobody_user != nobody_group and not (nobody_user == 'nobody' and nobody_group == 'nogroup') |
8ea9fad7 YW |
884 | warning('\n' + |
885 | 'The configured user name "@0@" and group name "@0@" of the nobody user/group are not equivalent.\n'.format(nobody_user, nobody_group) + | |
886 | 'Please re-check that both "nobody-user" and "nobody-group" options are correctly set.') | |
8374cc62 | 887 | endif |
afde4574 LP |
888 | |
889 | conf.set_quoted('NOBODY_USER_NAME', nobody_user) | |
890 | conf.set_quoted('NOBODY_GROUP_NAME', nobody_group) | |
87d5e4f2 | 891 | |
9a797ddc ZJS |
892 | static_ugids = [] |
893 | foreach option : ['adm-gid', | |
894 | 'audio-gid', | |
895 | 'cdrom-gid', | |
896 | 'dialout-gid', | |
897 | 'disk-gid', | |
898 | 'input-gid', | |
899 | 'kmem-gid', | |
900 | 'kvm-gid', | |
901 | 'lp-gid', | |
902 | 'render-gid', | |
903 | 'sgx-gid', | |
904 | 'tape-gid', | |
905 | 'tty-gid', | |
906 | 'users-gid', | |
907 | 'utmp-gid', | |
908 | 'video-gid', | |
909 | 'wheel-gid', | |
910 | 'systemd-journal-gid', | |
911 | 'systemd-network-uid', | |
912 | 'systemd-resolve-uid', | |
913 | 'systemd-timesync-uid'] | |
914 | name = option.underscorify().to_upper() | |
915 | val = get_option(option) | |
916 | ||
917 | # Ensure provided GID argument is numeric, otherwise fall back to default assignment | |
a36be3e5 YW |
918 | conf.set(name, val > 0 ? val : '-') |
919 | if val > 0 | |
9a797ddc ZJS |
920 | static_ugids += '@0@:@1@'.format(option, val) |
921 | endif | |
922 | endforeach | |
84786b8e | 923 | |
348b4437 YW |
924 | conf.set10('ENABLE_ADM_GROUP', get_option('adm-group')) |
925 | conf.set10('ENABLE_WHEEL_GROUP', get_option('wheel-group')) | |
5c23128d | 926 | |
ace5e311 | 927 | dev_kvm_mode = get_option('dev-kvm-mode') |
d924a938 | 928 | conf.set_quoted('DEV_KVM_MODE', dev_kvm_mode) # FIXME: convert to 0o… notation |
ace5e311 | 929 | conf.set10('DEV_KVM_UACCESS', dev_kvm_mode != '0666') |
055a083a | 930 | group_render_mode = get_option('group-render-mode') |
8feaea5e | 931 | conf.set_quoted('GROUP_RENDER_MODE', group_render_mode) |
055a083a | 932 | conf.set10('GROUP_RENDER_UACCESS', group_render_mode != '0666') |
5c23128d | 933 | |
2a4c156d ZJS |
934 | kill_user_processes = get_option('default-kill-user-processes') |
935 | conf.set10('KILL_USER_PROCESSES', kill_user_processes) | |
5c23128d | 936 | |
829257d1 ZJS |
937 | dns_servers = get_option('dns-servers') |
938 | conf.set_quoted('DNS_SERVERS', dns_servers) | |
5c23128d | 939 | |
829257d1 ZJS |
940 | ntp_servers = get_option('ntp-servers') |
941 | conf.set_quoted('NTP_SERVERS', ntp_servers) | |
5c23128d | 942 | |
8ca9e92c DR |
943 | default_locale = get_option('default-locale') |
944 | conf.set_quoted('SYSTEMD_DEFAULT_LOCALE', default_locale) | |
945 | ||
a22f5186 DDM |
946 | nspawn_locale = get_option('nspawn-locale') |
947 | conf.set_quoted('SYSTEMD_NSPAWN_LOCALE', nspawn_locale) | |
948 | ||
f129d0e7 MY |
949 | default_keymap = get_option('default-keymap') |
950 | conf.set_quoted('SYSTEMD_DEFAULT_KEYMAP', default_keymap) | |
951 | ||
8f20232f | 952 | localegen_path = get_option('localegen-path') |
8f20232f MK |
953 | if localegen_path != '' |
954 | conf.set_quoted('LOCALEGEN_PATH', localegen_path) | |
8f20232f | 955 | endif |
71ae5ce5 | 956 | conf.set10('HAVE_LOCALEGEN', localegen_path != '') |
8f20232f | 957 | |
5c23128d ZJS |
958 | conf.set_quoted('GETTEXT_PACKAGE', meson.project_name()) |
959 | ||
21d0dd5a | 960 | service_watchdog = get_option('service-watchdog') |
7bc9ea51 | 961 | watchdog_value = service_watchdog == '' ? '' : 'WatchdogSec=' + service_watchdog |
059cc610 | 962 | conf.set_quoted('SERVICE_WATCHDOG', watchdog_value) |
21d0dd5a | 963 | |
059cc610 | 964 | conf.set_quoted('SUSHELL', get_option('debug-shell')) |
93912e87 | 965 | conf.set_quoted('DEBUGTTY', get_option('debug-tty')) |
3131bfe3 | 966 | |
349cc4a5 ZJS |
967 | enable_debug_hashmap = false |
968 | enable_debug_mmap_cache = false | |
d6601495 | 969 | enable_debug_siphash = false |
8f6b442a | 970 | foreach name : get_option('debug-extra') |
ad7aa760 YW |
971 | if name == 'hashmap' |
972 | enable_debug_hashmap = true | |
973 | elif name == 'mmap-cache' | |
974 | enable_debug_mmap_cache = true | |
d6601495 YW |
975 | elif name == 'siphash' |
976 | enable_debug_siphash = true | |
ad7aa760 YW |
977 | else |
978 | message('unknown debug option "@0@", ignoring'.format(name)) | |
979 | endif | |
980 | endforeach | |
349cc4a5 ZJS |
981 | conf.set10('ENABLE_DEBUG_HASHMAP', enable_debug_hashmap) |
982 | conf.set10('ENABLE_DEBUG_MMAP_CACHE', enable_debug_mmap_cache) | |
d6601495 | 983 | conf.set10('ENABLE_DEBUG_SIPHASH', enable_debug_siphash) |
fd5dec9a | 984 | conf.set10('LOG_TRACE', get_option('log-trace')) |
d18cb393 | 985 | |
3602ca6f ZJS |
986 | default_user_path = get_option('user-path') |
987 | if default_user_path != '' | |
988 | conf.set_quoted('DEFAULT_USER_PATH', default_user_path) | |
989 | endif | |
990 | ||
5c23128d ZJS |
991 | ##################################################################### |
992 | ||
993 | threads = dependency('threads') | |
994 | librt = cc.find_library('rt') | |
995 | libm = cc.find_library('m') | |
996 | libdl = cc.find_library('dl') | |
55573787 YW |
997 | libcrypt = dependency('libcrypt', 'libxcrypt', required : false) |
998 | if not libcrypt.found() | |
999 | # fallback to use find_library() if libcrypt is provided by glibc, e.g. for LibreELEC. | |
1000 | libcrypt = cc.find_library('crypt') | |
1001 | endif | |
d625f717 | 1002 | libcap = dependency('libcap') |
5c23128d | 1003 | |
96f8c636 ZJS |
1004 | # On some architectures, libatomic is required. But on some installations, |
1005 | # it is found, but actual linking fails. So let's try to use it opportunistically. | |
1006 | # If it is installed, but not needed, it will be dropped because of --as-needed. | |
1007 | if cc.links('''int main(int argc, char **argv) { return 0; }''', | |
1008 | args : '-latomic', | |
1009 | name : 'libatomic') | |
1010 | libatomic = declare_dependency(link_args : '-latomic') | |
1011 | else | |
1012 | libatomic = [] | |
1013 | endif | |
1014 | ||
06ca077b | 1015 | crypt_header = conf.get('HAVE_CRYPT_H') == 1 ? '''#include <crypt.h>''' : '''#include <unistd.h>''' |
e8644a41 | 1016 | foreach ident : [ |
feee7f62 LB |
1017 | ['crypt_ra', crypt_header], |
1018 | ['crypt_preferred_method', crypt_header], | |
1019 | ['crypt_gensalt_ra', crypt_header]] | |
e8644a41 ZJS |
1020 | |
1021 | have = cc.has_function(ident[0], prefix : ident[1], args : '-D_GNU_SOURCE', | |
1022 | dependencies : libcrypt) | |
1023 | conf.set10('HAVE_' + ident[0].to_upper(), have) | |
1024 | endforeach | |
1025 | ||
7d861e12 | 1026 | want_bpf_framework = get_option('bpf-framework') |
b88323e4 | 1027 | bpf_compiler = get_option('bpf-compiler') |
7d861e12 JK |
1028 | bpf_framework_required = want_bpf_framework == 'true' |
1029 | ||
87e462f7 | 1030 | libbpf_version_requirement = '>= 0.1.0' |
b88323e4 JH |
1031 | if bpf_compiler == 'gcc' |
1032 | libbpf_version_requirement = '>= 1.0.0' | |
1033 | endif | |
1034 | libbpf = dependency('libbpf', required : bpf_framework_required, version : libbpf_version_requirement) | |
7d861e12 JK |
1035 | conf.set10('HAVE_LIBBPF', libbpf.found()) |
1036 | ||
b88323e4 JH |
1037 | bpftool_strip_version_requirement = '>= 5.13.0' |
1038 | if bpf_compiler == 'gcc' | |
1039 | bpftool_strip_version_requirement = '>= 7.0.0' | |
1040 | endif | |
1041 | ||
3d954ef1 | 1042 | if want_bpf_framework == 'false' or not libbpf.found() or skip_deps |
cf2dc690 | 1043 | conf.set10('BPF_FRAMEWORK', false) |
7d861e12 | 1044 | else |
76abad4d JH |
1045 | clang_found = false |
1046 | clang_supports_bpf = false | |
1047 | bpf_gcc_found = false | |
b88323e4 | 1048 | bpftool_strip = false |
76abad4d JH |
1049 | deps_found = false |
1050 | ||
1051 | if bpf_compiler == 'clang' | |
1052 | # Support 'versioned' clang/llvm-strip binaries, as seen on Debian/Ubuntu | |
1053 | # (like clang-10/llvm-strip-10) | |
1054 | if meson.is_cross_build() or cc.get_id() != 'clang' or cc.cmd_array()[0].contains('afl-clang') or cc.cmd_array()[0].contains('hfuzz-clang') | |
1055 | r = find_program('clang', required : bpf_framework_required, version : '>= 10.0.0') | |
1056 | clang_found = r.found() | |
1057 | if clang_found | |
573c0dc1 | 1058 | clang = r.full_path() |
76abad4d | 1059 | endif |
76abad4d JH |
1060 | else |
1061 | clang_found = true | |
1062 | clang = cc.cmd_array() | |
dc7e9c1b | 1063 | endif |
a6ac8b5a | 1064 | |
76abad4d JH |
1065 | if clang_found |
1066 | # Check if 'clang -target bpf' is supported. | |
1067 | clang_supports_bpf = run_command(clang, '-target', 'bpf', '--print-supported-cpus', check : false).returncode() == 0 | |
1068 | endif | |
1069 | elif bpf_compiler == 'gcc' | |
76abad4d | 1070 | bpf_gcc = find_program('bpf-gcc', |
e4086f7d | 1071 | 'bpf-none-gcc', |
76abad4d | 1072 | required : true, |
4a7a13b5 | 1073 | version : '>= 13.1.0') |
76abad4d | 1074 | bpf_gcc_found = bpf_gcc.found() |
a6ac8b5a YW |
1075 | endif |
1076 | ||
76abad4d JH |
1077 | if clang_supports_bpf or bpf_gcc_found |
1078 | # Debian installs this in /usr/sbin/ which is not in $PATH. | |
1079 | # We check for 'bpftool' first, honouring $PATH, and in /usr/sbin/ for Debian. | |
1080 | # We use 'bpftool gen object' subcommand for bpftool strip, it was added by d80b2fcbe0a023619e0fc73112f2a02c2662f6ab (v5.13). | |
b88323e4 | 1081 | bpftool_strip_required = bpf_framework_required and bpf_compiler == 'gcc' |
e3759ac4 JH |
1082 | bpftool = find_program('bpftool', |
1083 | '/usr/sbin/bpftool', | |
b88323e4 JH |
1084 | required : bpftool_strip_required, |
1085 | version : bpftool_strip_version_requirement) | |
e3759ac4 | 1086 | |
76abad4d JH |
1087 | if bpftool.found() |
1088 | bpftool_strip = true | |
1089 | deps_found = true | |
b88323e4 | 1090 | elif bpf_compiler == 'clang' |
76abad4d JH |
1091 | # We require the 'bpftool gen skeleton' subcommand, it was added by 985ead416df39d6fe8e89580cc1db6aa273e0175 (v5.6). |
1092 | bpftool = find_program('bpftool', | |
1093 | '/usr/sbin/bpftool', | |
1094 | required : bpf_framework_required, | |
1095 | version : '>= 5.6.0') | |
e3759ac4 | 1096 | endif |
68e101da | 1097 | |
76abad4d JH |
1098 | # We use `llvm-strip` as a fallback if `bpftool gen object` strip support is not available. |
1099 | if not bpftool_strip and bpftool.found() and clang_supports_bpf | |
1100 | if not meson.is_cross_build() | |
1101 | llvm_strip_bin = run_command(clang, '--print-prog-name', 'llvm-strip', | |
1102 | check : true).stdout().strip() | |
1103 | else | |
1104 | llvm_strip_bin = 'llvm-strip' | |
1105 | endif | |
1106 | llvm_strip = find_program(llvm_strip_bin, required : bpf_framework_required, version : '>= 10.0.0') | |
1107 | deps_found = llvm_strip.found() | |
1108 | endif | |
1109 | endif | |
68e101da | 1110 | |
7d861e12 | 1111 | # Can build BPF program from source code in restricted C |
d40ce018 | 1112 | conf.set10('BPF_FRAMEWORK', deps_found) |
7d861e12 JK |
1113 | endif |
1114 | ||
5c23128d | 1115 | libmount = dependency('mount', |
c0b4b0f8 | 1116 | version : fuzzer_build ? '>= 0' : '>= 2.30') |
5c23128d | 1117 | |
e594a3b1 LP |
1118 | want_libfdisk = get_option('fdisk') |
1119 | if want_libfdisk != 'false' and not skip_deps | |
1120 | libfdisk = dependency('fdisk', | |
baec7d78 | 1121 | version : '>= 2.32', |
e594a3b1 LP |
1122 | required : want_libfdisk == 'true') |
1123 | have = libfdisk.found() | |
1124 | else | |
1125 | have = false | |
1126 | libfdisk = [] | |
1127 | endif | |
1128 | conf.set10('HAVE_LIBFDISK', have) | |
1129 | ||
1d8aae43 | 1130 | want_passwdqc = get_option('passwdqc') |
70a5db58 | 1131 | want_pwquality = get_option('pwquality') |
1d8aae43 EI |
1132 | if want_passwdqc == 'true' and want_pwquality == 'true' |
1133 | error('passwdqc and pwquality cannot be requested simultaneously') | |
1134 | endif | |
1135 | ||
1136 | if want_pwquality != 'false' and want_passwdqc != 'true' and not skip_deps | |
51c425dc DL |
1137 | libpwquality = dependency('pwquality', |
1138 | version : '>= 1.4.1', | |
1139 | required : want_pwquality == 'true') | |
70a5db58 LP |
1140 | have = libpwquality.found() |
1141 | else | |
1142 | have = false | |
1143 | libpwquality = [] | |
1144 | endif | |
1145 | conf.set10('HAVE_PWQUALITY', have) | |
1146 | ||
1d8aae43 EI |
1147 | if not have and want_passwdqc != 'false' and not skip_deps |
1148 | libpasswdqc = dependency('passwdqc', | |
1149 | required : want_passwdqc == 'true') | |
1150 | have = libpasswdqc.found() | |
1151 | else | |
1152 | have = false | |
1153 | libpasswdqc = [] | |
1154 | endif | |
1155 | conf.set10('HAVE_PASSWDQC', have) | |
1156 | ||
5c23128d | 1157 | want_seccomp = get_option('seccomp') |
87ac55a1 | 1158 | if want_seccomp != 'false' and not skip_deps |
37efbbd8 | 1159 | libseccomp = dependency('libseccomp', |
9f0e9c01 | 1160 | version : '>= 2.3.1', |
37efbbd8 | 1161 | required : want_seccomp == 'true') |
349cc4a5 | 1162 | have = libseccomp.found() |
5c23128d | 1163 | else |
349cc4a5 | 1164 | have = false |
37efbbd8 | 1165 | libseccomp = [] |
5c23128d | 1166 | endif |
349cc4a5 | 1167 | conf.set10('HAVE_SECCOMP', have) |
5c23128d ZJS |
1168 | |
1169 | want_selinux = get_option('selinux') | |
87ac55a1 | 1170 | if want_selinux != 'false' and not skip_deps |
37efbbd8 ZJS |
1171 | libselinux = dependency('libselinux', |
1172 | version : '>= 2.1.9', | |
1173 | required : want_selinux == 'true') | |
349cc4a5 | 1174 | have = libselinux.found() |
5c23128d | 1175 | else |
349cc4a5 | 1176 | have = false |
37efbbd8 | 1177 | libselinux = [] |
5c23128d | 1178 | endif |
349cc4a5 | 1179 | conf.set10('HAVE_SELINUX', have) |
5c23128d ZJS |
1180 | |
1181 | want_apparmor = get_option('apparmor') | |
87ac55a1 | 1182 | if want_apparmor != 'false' and not skip_deps |
37efbbd8 | 1183 | libapparmor = dependency('libapparmor', |
2ffadd3c | 1184 | version : '>= 2.13', |
37efbbd8 | 1185 | required : want_apparmor == 'true') |
349cc4a5 | 1186 | have = libapparmor.found() |
5c23128d | 1187 | else |
349cc4a5 | 1188 | have = false |
37efbbd8 | 1189 | libapparmor = [] |
5c23128d | 1190 | endif |
349cc4a5 | 1191 | conf.set10('HAVE_APPARMOR', have) |
5c23128d | 1192 | |
07b382cc ZJS |
1193 | have = get_option('smack') and get_option('smack-run-label') != '' |
1194 | conf.set10('HAVE_SMACK_RUN_LABEL', have) | |
1195 | if have | |
1196 | conf.set_quoted('SMACK_RUN_LABEL', get_option('smack-run-label')) | |
1197 | endif | |
5c23128d | 1198 | |
aa5ae971 ŁS |
1199 | have = get_option('smack') and get_option('smack-default-process-label') != '' |
1200 | if have | |
1201 | conf.set_quoted('SMACK_DEFAULT_PROCESS_LABEL', get_option('smack-default-process-label')) | |
1202 | endif | |
1203 | ||
3ca0cb73 ZJS |
1204 | want_polkit = get_option('polkit') |
1205 | install_polkit = false | |
1206 | install_polkit_pkla = false | |
87ac55a1 | 1207 | if want_polkit != 'false' and not skip_deps |
37efbbd8 | 1208 | install_polkit = true |
3ca0cb73 | 1209 | |
37efbbd8 ZJS |
1210 | libpolkit = dependency('polkit-gobject-1', |
1211 | required : false) | |
1212 | if libpolkit.found() and libpolkit.version().version_compare('< 0.106') | |
1213 | message('Old polkit detected, will install pkla files') | |
1214 | install_polkit_pkla = true | |
1215 | endif | |
3ca0cb73 | 1216 | endif |
349cc4a5 | 1217 | conf.set10('ENABLE_POLKIT', install_polkit) |
3ca0cb73 | 1218 | |
36f0387e | 1219 | want_acl = get_option('acl') |
87ac55a1 | 1220 | if want_acl != 'false' and not skip_deps |
d625f717 | 1221 | libacl = dependency('libacl', required : want_acl == 'true') |
349cc4a5 | 1222 | have = libacl.found() |
36f0387e | 1223 | else |
349cc4a5 | 1224 | have = false |
36f0387e ZJS |
1225 | libacl = [] |
1226 | endif | |
349cc4a5 | 1227 | conf.set10('HAVE_ACL', have) |
36f0387e | 1228 | |
5c23128d | 1229 | want_audit = get_option('audit') |
87ac55a1 | 1230 | if want_audit != 'false' and not skip_deps |
37efbbd8 | 1231 | libaudit = dependency('audit', required : want_audit == 'true') |
349cc4a5 | 1232 | have = libaudit.found() |
5c23128d | 1233 | else |
349cc4a5 | 1234 | have = false |
37efbbd8 | 1235 | libaudit = [] |
5c23128d | 1236 | endif |
349cc4a5 | 1237 | conf.set10('HAVE_AUDIT', have) |
5c23128d ZJS |
1238 | |
1239 | want_blkid = get_option('blkid') | |
87ac55a1 | 1240 | if want_blkid != 'false' and not skip_deps |
37efbbd8 | 1241 | libblkid = dependency('blkid', required : want_blkid == 'true') |
349cc4a5 | 1242 | have = libblkid.found() |
4fcc033b KZ |
1243 | |
1244 | conf.set10('HAVE_BLKID_PROBE_SET_HINT', | |
1245 | have and cc.has_function('blkid_probe_set_hint', dependencies : libblkid)) | |
5c23128d | 1246 | else |
349cc4a5 | 1247 | have = false |
37efbbd8 | 1248 | libblkid = [] |
5c23128d | 1249 | endif |
349cc4a5 | 1250 | conf.set10('HAVE_BLKID', have) |
5c23128d ZJS |
1251 | |
1252 | want_kmod = get_option('kmod') | |
87ac55a1 | 1253 | if want_kmod != 'false' and not skip_deps |
37efbbd8 ZJS |
1254 | libkmod = dependency('libkmod', |
1255 | version : '>= 15', | |
1256 | required : want_kmod == 'true') | |
349cc4a5 | 1257 | have = libkmod.found() |
5c23128d | 1258 | else |
349cc4a5 | 1259 | have = false |
37efbbd8 | 1260 | libkmod = [] |
5c23128d | 1261 | endif |
349cc4a5 | 1262 | conf.set10('HAVE_KMOD', have) |
5c23128d | 1263 | |
ede5a78f ST |
1264 | want_xenctrl = get_option('xenctrl') |
1265 | if want_xenctrl != 'false' and not skip_deps | |
1266 | libxenctrl = dependency('xencontrol', | |
1267 | version : '>= 4.9', | |
1268 | required : want_xenctrl == 'true') | |
1269 | have = libxenctrl.found() | |
1270 | else | |
1271 | have = false | |
1272 | libxenctrl = [] | |
1273 | endif | |
1274 | conf.set10('HAVE_XENCTRL', have) | |
1275 | ||
5c23128d | 1276 | want_pam = get_option('pam') |
87ac55a1 | 1277 | if want_pam != 'false' and not skip_deps |
d625f717 YW |
1278 | libpam = dependency('pam', required : false) |
1279 | if not libpam.found() | |
1280 | # Debian older than bookworm and Ubuntu older than 22.10 do not provide the .pc file. | |
1281 | libpam = cc.find_library('pam', required : want_pam == 'true') | |
1282 | endif | |
1283 | libpam_misc = dependency('pam_misc', required : false) | |
1284 | if not libpam_misc.found() | |
1285 | libpam_misc = cc.find_library('pam_misc', required : want_pam == 'true') | |
1286 | endif | |
349cc4a5 | 1287 | have = libpam.found() and libpam_misc.found() |
5c23128d | 1288 | else |
349cc4a5 | 1289 | have = false |
37efbbd8 ZJS |
1290 | libpam = [] |
1291 | libpam_misc = [] | |
5c23128d | 1292 | endif |
349cc4a5 | 1293 | conf.set10('HAVE_PAM', have) |
5c23128d ZJS |
1294 | |
1295 | want_microhttpd = get_option('microhttpd') | |
87ac55a1 | 1296 | if want_microhttpd != 'false' and not skip_deps |
37efbbd8 ZJS |
1297 | libmicrohttpd = dependency('libmicrohttpd', |
1298 | version : '>= 0.9.33', | |
1299 | required : want_microhttpd == 'true') | |
349cc4a5 | 1300 | have = libmicrohttpd.found() |
5c23128d | 1301 | else |
349cc4a5 | 1302 | have = false |
37efbbd8 | 1303 | libmicrohttpd = [] |
5c23128d | 1304 | endif |
349cc4a5 | 1305 | conf.set10('HAVE_MICROHTTPD', have) |
5c23128d ZJS |
1306 | |
1307 | want_libcryptsetup = get_option('libcryptsetup') | |
d1ae38d8 OK |
1308 | want_libcryptsetup_plugins = get_option('libcryptsetup-plugins') |
1309 | ||
1310 | if want_libcryptsetup_plugins == 'true' and want_libcryptsetup == 'false' | |
1311 | error('libcryptsetup-plugins can not be requested without libcryptsetup') | |
1312 | endif | |
1313 | ||
87ac55a1 | 1314 | if want_libcryptsetup != 'false' and not skip_deps |
37efbbd8 | 1315 | libcryptsetup = dependency('libcryptsetup', |
d1ae38d8 OK |
1316 | version : want_libcryptsetup_plugins == 'true' ? '>= 2.4.0' : '>= 2.0.1', |
1317 | required : want_libcryptsetup == 'true' or want_libcryptsetup_plugins == 'true') | |
349cc4a5 | 1318 | have = libcryptsetup.found() |
70a5db58 | 1319 | |
aac80717 ZJS |
1320 | foreach ident : ['crypt_set_metadata_size', |
1321 | 'crypt_activate_by_signed_key', | |
48a09a8f DDM |
1322 | 'crypt_token_max', |
1323 | 'crypt_reencrypt_init_by_passphrase', | |
1324 | 'crypt_reencrypt', | |
1325 | 'crypt_set_data_offset'] | |
aac80717 ZJS |
1326 | have_ident = have and cc.has_function( |
1327 | ident, | |
1328 | prefix : '#include <libcryptsetup.h>', | |
1329 | dependencies : libcryptsetup) | |
1330 | conf.set10('HAVE_' + ident.to_upper(), have_ident) | |
1331 | endforeach | |
5c23128d | 1332 | else |
349cc4a5 | 1333 | have = false |
37efbbd8 | 1334 | libcryptsetup = [] |
5c23128d | 1335 | endif |
349cc4a5 | 1336 | conf.set10('HAVE_LIBCRYPTSETUP', have) |
5c23128d | 1337 | |
d1ae38d8 | 1338 | if want_libcryptsetup_plugins != 'false' and not skip_deps |
aac80717 ZJS |
1339 | have = (cc.has_function( |
1340 | 'crypt_activate_by_token_pin', | |
1341 | prefix : '#include <libcryptsetup.h>', | |
1342 | dependencies : libcryptsetup) and | |
1343 | cc.has_function( | |
1344 | 'crypt_token_external_path', | |
1345 | prefix : '#include <libcryptsetup.h>', | |
1346 | dependencies : libcryptsetup)) | |
d1ae38d8 OK |
1347 | else |
1348 | have = false | |
1349 | endif | |
1350 | conf.set10('HAVE_LIBCRYPTSETUP_PLUGINS', have) | |
1351 | ||
5c23128d | 1352 | want_libcurl = get_option('libcurl') |
87ac55a1 | 1353 | if want_libcurl != 'false' and not skip_deps |
37efbbd8 ZJS |
1354 | libcurl = dependency('libcurl', |
1355 | version : '>= 7.32.0', | |
1356 | required : want_libcurl == 'true') | |
349cc4a5 | 1357 | have = libcurl.found() |
5c23128d | 1358 | else |
349cc4a5 | 1359 | have = false |
37efbbd8 | 1360 | libcurl = [] |
5c23128d | 1361 | endif |
349cc4a5 | 1362 | conf.set10('HAVE_LIBCURL', have) |
47350c5f | 1363 | conf.set10('CURL_NO_OLDIES', conf.get('BUILD_MODE_DEVELOPER') == 1) |
5c23128d ZJS |
1364 | |
1365 | want_libidn = get_option('libidn') | |
87057e24 ZJS |
1366 | want_libidn2 = get_option('libidn2') |
1367 | if want_libidn == 'true' and want_libidn2 == 'true' | |
1368 | error('libidn and libidn2 cannot be requested simultaneously') | |
1369 | endif | |
1370 | ||
1b931399 YW |
1371 | if want_libidn2 != 'false' and want_libidn != 'true' and not skip_deps |
1372 | libidn = dependency('libidn2', | |
1373 | required : want_libidn2 == 'true') | |
349cc4a5 | 1374 | have = libidn.found() |
87057e24 | 1375 | else |
349cc4a5 | 1376 | have = false |
87057e24 ZJS |
1377 | libidn = [] |
1378 | endif | |
1b931399 YW |
1379 | conf.set10('HAVE_LIBIDN2', have) |
1380 | if not have and want_libidn != 'false' and not skip_deps | |
7f7ab228 | 1381 | # libidn is used for both libidn and libidn2 objects |
1b931399 YW |
1382 | libidn = dependency('libidn', |
1383 | required : want_libidn == 'true') | |
349cc4a5 ZJS |
1384 | have = libidn.found() |
1385 | else | |
1386 | have = false | |
5c23128d | 1387 | endif |
1b931399 | 1388 | conf.set10('HAVE_LIBIDN', have) |
5c23128d ZJS |
1389 | |
1390 | want_libiptc = get_option('libiptc') | |
87ac55a1 | 1391 | if want_libiptc != 'false' and not skip_deps |
37efbbd8 ZJS |
1392 | libiptc = dependency('libiptc', |
1393 | required : want_libiptc == 'true') | |
349cc4a5 | 1394 | have = libiptc.found() |
5c23128d | 1395 | else |
349cc4a5 | 1396 | have = false |
37efbbd8 | 1397 | libiptc = [] |
5c23128d | 1398 | endif |
349cc4a5 | 1399 | conf.set10('HAVE_LIBIPTC', have) |
5c23128d ZJS |
1400 | |
1401 | want_qrencode = get_option('qrencode') | |
87ac55a1 | 1402 | if want_qrencode != 'false' and not skip_deps |
37efbbd8 | 1403 | libqrencode = dependency('libqrencode', |
3f5225d7 | 1404 | version : '>= 3', |
37efbbd8 | 1405 | required : want_qrencode == 'true') |
349cc4a5 | 1406 | have = libqrencode.found() |
5c23128d | 1407 | else |
349cc4a5 | 1408 | have = false |
37efbbd8 | 1409 | libqrencode = [] |
5c23128d | 1410 | endif |
349cc4a5 | 1411 | conf.set10('HAVE_QRENCODE', have) |
5c23128d | 1412 | |
a44fb601 | 1413 | want_gcrypt = get_option('gcrypt') |
87ac55a1 | 1414 | if want_gcrypt != 'false' and not skip_deps |
d625f717 YW |
1415 | libgcrypt = dependency('libgcrypt', required : want_gcrypt == 'true') |
1416 | libgpg_error = dependency('gpg-error', required : false) | |
1417 | if not libgpg_error.found() | |
1418 | # CentOS 8 does not provide the .pc file. | |
1419 | libgpg_error = cc.find_library('gpg-error', required : want_gcrypt == 'true') | |
1420 | endif | |
349cc4a5 | 1421 | have = libgcrypt.found() and libgpg_error.found() |
a44fb601 | 1422 | else |
349cc4a5 ZJS |
1423 | have = false |
1424 | endif | |
1425 | if not have | |
1426 | # link to neither of the libs if one is not found | |
a44fb601 ZJS |
1427 | libgcrypt = [] |
1428 | libgpg_error = [] | |
1429 | endif | |
349cc4a5 | 1430 | conf.set10('HAVE_GCRYPT', have) |
a44fb601 | 1431 | |
5c23128d | 1432 | want_gnutls = get_option('gnutls') |
87ac55a1 | 1433 | if want_gnutls != 'false' and not skip_deps |
37efbbd8 ZJS |
1434 | libgnutls = dependency('gnutls', |
1435 | version : '>= 3.1.4', | |
1436 | required : want_gnutls == 'true') | |
349cc4a5 | 1437 | have = libgnutls.found() |
5c23128d | 1438 | else |
349cc4a5 | 1439 | have = false |
37efbbd8 | 1440 | libgnutls = [] |
5c23128d | 1441 | endif |
349cc4a5 | 1442 | conf.set10('HAVE_GNUTLS', have) |
5c23128d | 1443 | |
096cbdce | 1444 | want_openssl = get_option('openssl') |
87ac55a1 | 1445 | if want_openssl != 'false' and not skip_deps |
096cbdce IT |
1446 | libopenssl = dependency('openssl', |
1447 | version : '>= 1.1.0', | |
1448 | required : want_openssl == 'true') | |
1449 | have = libopenssl.found() | |
1450 | else | |
1451 | have = false | |
1452 | libopenssl = [] | |
1453 | endif | |
1454 | conf.set10('HAVE_OPENSSL', have) | |
1455 | ||
839fddbe LP |
1456 | want_p11kit = get_option('p11kit') |
1457 | if want_p11kit != 'false' and not skip_deps | |
1458 | libp11kit = dependency('p11-kit-1', | |
6164ec4c ZJS |
1459 | version : '>= 0.23.3', |
1460 | required : want_p11kit == 'true') | |
839fddbe | 1461 | have = libp11kit.found() |
da035a3a | 1462 | libp11kit_cflags = libp11kit.partial_dependency(includes: true, compile_args: true) |
839fddbe LP |
1463 | else |
1464 | have = false | |
da035a3a | 1465 | libp11kit_cflags = [] |
839fddbe LP |
1466 | libp11kit = [] |
1467 | endif | |
1468 | conf.set10('HAVE_P11KIT', have) | |
1469 | ||
af4fbd46 LP |
1470 | want_libfido2 = get_option('libfido2') |
1471 | if want_libfido2 != 'false' and not skip_deps | |
e0f435f9 YW |
1472 | if conf.get('HAVE_OPENSSL') == 1 |
1473 | libfido2 = dependency('libfido2', | |
1474 | required : want_libfido2 == 'true') | |
1475 | have = libfido2.found() | |
1476 | elif want_libfido2 == 'true' | |
1477 | error('libfido2=true requires openssl') | |
1478 | else | |
1479 | have = false | |
1480 | libfido2 = [] | |
1481 | endif | |
af4fbd46 LP |
1482 | else |
1483 | have = false | |
1484 | libfido2 = [] | |
1485 | endif | |
1486 | conf.set10('HAVE_LIBFIDO2', have) | |
1487 | ||
5e521624 LP |
1488 | want_tpm2 = get_option('tpm2') |
1489 | if want_tpm2 != 'false' and not skip_deps | |
d7a57308 | 1490 | tpm2 = dependency('tss2-esys tss2-rc tss2-mu tss2-tcti-device', |
ba081955 | 1491 | required : want_tpm2 == 'true') |
5e521624 | 1492 | have = tpm2.found() |
155c5129 | 1493 | have_esys3 = tpm2.version().version_compare('>= 3.0.0') |
5e521624 LP |
1494 | else |
1495 | have = false | |
155c5129 | 1496 | have_esys3 = false |
5e521624 LP |
1497 | tpm2 = [] |
1498 | endif | |
1499 | conf.set10('HAVE_TPM2', have) | |
155c5129 | 1500 | conf.set10('HAVE_TSS2_ESYS3', have_esys3) |
5e521624 | 1501 | |
5c23128d | 1502 | want_elfutils = get_option('elfutils') |
87ac55a1 | 1503 | if want_elfutils != 'false' and not skip_deps |
37efbbd8 ZJS |
1504 | libdw = dependency('libdw', |
1505 | required : want_elfutils == 'true') | |
349cc4a5 | 1506 | have = libdw.found() |
d48c2721 LB |
1507 | |
1508 | # New in elfutils 0.177 | |
1509 | conf.set10('HAVE_DWELF_ELF_E_MACHINE_STRING', | |
1510 | have and cc.has_function('dwelf_elf_e_machine_string', dependencies : libdw)) | |
5c23128d | 1511 | else |
349cc4a5 | 1512 | have = false |
37efbbd8 | 1513 | libdw = [] |
5c23128d | 1514 | endif |
349cc4a5 | 1515 | conf.set10('HAVE_ELFUTILS', have) |
5c23128d ZJS |
1516 | |
1517 | want_zlib = get_option('zlib') | |
87ac55a1 | 1518 | if want_zlib != 'false' and not skip_deps |
37efbbd8 ZJS |
1519 | libz = dependency('zlib', |
1520 | required : want_zlib == 'true') | |
349cc4a5 | 1521 | have = libz.found() |
5c23128d | 1522 | else |
349cc4a5 | 1523 | have = false |
37efbbd8 | 1524 | libz = [] |
5c23128d | 1525 | endif |
349cc4a5 | 1526 | conf.set10('HAVE_ZLIB', have) |
5c23128d ZJS |
1527 | |
1528 | want_bzip2 = get_option('bzip2') | |
87ac55a1 | 1529 | if want_bzip2 != 'false' and not skip_deps |
d625f717 YW |
1530 | libbzip2 = dependency('bzip2', required : false) |
1531 | if not libbzip2.found() | |
1532 | # Debian and Ubuntu do not provide the .pc file. | |
1533 | libbzip2 = cc.find_library('bz2', required : want_bzip2 == 'true') | |
1534 | endif | |
349cc4a5 | 1535 | have = libbzip2.found() |
5c23128d | 1536 | else |
349cc4a5 | 1537 | have = false |
37efbbd8 | 1538 | libbzip2 = [] |
5c23128d | 1539 | endif |
349cc4a5 | 1540 | conf.set10('HAVE_BZIP2', have) |
5c23128d ZJS |
1541 | |
1542 | want_xz = get_option('xz') | |
87ac55a1 | 1543 | if want_xz != 'false' and not skip_deps |
37efbbd8 ZJS |
1544 | libxz = dependency('liblzma', |
1545 | required : want_xz == 'true') | |
d80b051c | 1546 | have_xz = libxz.found() |
5c23128d | 1547 | else |
d80b051c | 1548 | have_xz = false |
37efbbd8 | 1549 | libxz = [] |
5c23128d | 1550 | endif |
d80b051c | 1551 | conf.set10('HAVE_XZ', have_xz) |
5c23128d ZJS |
1552 | |
1553 | want_lz4 = get_option('lz4') | |
87ac55a1 | 1554 | if want_lz4 != 'false' and not skip_deps |
37efbbd8 | 1555 | liblz4 = dependency('liblz4', |
e0a1d4b0 | 1556 | version : '>= 1.3.0', |
37efbbd8 | 1557 | required : want_lz4 == 'true') |
d80b051c | 1558 | have_lz4 = liblz4.found() |
5c23128d | 1559 | else |
d80b051c | 1560 | have_lz4 = false |
37efbbd8 | 1561 | liblz4 = [] |
5c23128d | 1562 | endif |
d80b051c | 1563 | conf.set10('HAVE_LZ4', have_lz4) |
5c23128d | 1564 | |
ef5924aa NL |
1565 | want_zstd = get_option('zstd') |
1566 | if want_zstd != 'false' and not skip_deps | |
1567 | libzstd = dependency('libzstd', | |
1568 | required : want_zstd == 'true', | |
1569 | version : '>= 1.4.0') | |
d80b051c | 1570 | have_zstd = libzstd.found() |
ef5924aa | 1571 | else |
d80b051c | 1572 | have_zstd = false |
ef5924aa NL |
1573 | libzstd = [] |
1574 | endif | |
d80b051c LP |
1575 | conf.set10('HAVE_ZSTD', have_zstd) |
1576 | ||
1577 | conf.set10('HAVE_COMPRESSION', have_xz or have_lz4 or have_zstd) | |
ef5924aa | 1578 | |
cd3c6322 LB |
1579 | compression = get_option('default-compression') |
1580 | if compression == 'auto' | |
1581 | if have_zstd | |
1582 | compression = 'zstd' | |
1583 | elif have_lz4 | |
1584 | compression = 'lz4' | |
1585 | elif have_xz | |
1586 | compression = 'xz' | |
1587 | else | |
1588 | compression = 'none' | |
1589 | endif | |
1590 | elif compression == 'zstd' and not have_zstd | |
1591 | error('default-compression=zstd requires zstd') | |
1592 | elif compression == 'lz4' and not have_lz4 | |
1593 | error('default-compression=lz4 requires lz4') | |
1594 | elif compression == 'xz' and not have_xz | |
1595 | error('default-compression=xz requires xz') | |
1596 | endif | |
1788c6f3 | 1597 | conf.set('DEFAULT_COMPRESSION', 'COMPRESSION_@0@'.format(compression.to_upper())) |
cd3c6322 | 1598 | |
a44fb601 | 1599 | want_xkbcommon = get_option('xkbcommon') |
87ac55a1 | 1600 | if want_xkbcommon != 'false' and not skip_deps |
a44fb601 ZJS |
1601 | libxkbcommon = dependency('xkbcommon', |
1602 | version : '>= 0.3.0', | |
1603 | required : want_xkbcommon == 'true') | |
349cc4a5 | 1604 | have = libxkbcommon.found() |
a44fb601 | 1605 | else |
349cc4a5 | 1606 | have = false |
a44fb601 ZJS |
1607 | libxkbcommon = [] |
1608 | endif | |
349cc4a5 | 1609 | conf.set10('HAVE_XKBCOMMON', have) |
a44fb601 | 1610 | |
c4c978a0 | 1611 | want_pcre2 = get_option('pcre2') |
8739f309 | 1612 | if want_pcre2 != 'false' and not skip_deps |
c4c978a0 ZJS |
1613 | libpcre2 = dependency('libpcre2-8', |
1614 | required : want_pcre2 == 'true') | |
1615 | have = libpcre2.found() | |
1616 | else | |
1617 | have = false | |
1618 | libpcre2 = [] | |
1619 | endif | |
1620 | conf.set10('HAVE_PCRE2', have) | |
1621 | ||
69e96427 | 1622 | want_glib = get_option('glib') |
87ac55a1 | 1623 | if want_glib != 'false' and not skip_deps |
37efbbd8 ZJS |
1624 | libglib = dependency('glib-2.0', |
1625 | version : '>= 2.22.0', | |
1626 | required : want_glib == 'true') | |
1627 | libgobject = dependency('gobject-2.0', | |
1628 | version : '>= 2.22.0', | |
1629 | required : want_glib == 'true') | |
1630 | libgio = dependency('gio-2.0', | |
1631 | required : want_glib == 'true') | |
2c201c21 | 1632 | have = libglib.found() and libgobject.found() and libgio.found() |
69e96427 | 1633 | else |
349cc4a5 | 1634 | have = false |
37efbbd8 ZJS |
1635 | libglib = [] |
1636 | libgobject = [] | |
1637 | libgio = [] | |
69e96427 | 1638 | endif |
349cc4a5 | 1639 | conf.set10('HAVE_GLIB', have) |
69e96427 ZJS |
1640 | |
1641 | want_dbus = get_option('dbus') | |
87ac55a1 | 1642 | if want_dbus != 'false' and not skip_deps |
37efbbd8 ZJS |
1643 | libdbus = dependency('dbus-1', |
1644 | version : '>= 1.3.2', | |
1645 | required : want_dbus == 'true') | |
349cc4a5 | 1646 | have = libdbus.found() |
69e96427 | 1647 | else |
349cc4a5 | 1648 | have = false |
37efbbd8 | 1649 | libdbus = [] |
69e96427 | 1650 | endif |
349cc4a5 | 1651 | conf.set10('HAVE_DBUS', have) |
69e96427 | 1652 | |
1bd0cc45 YW |
1653 | dbusdatadir = datadir / 'dbus-1' |
1654 | if conf.get('HAVE_DBUS') == 1 | |
1655 | dbusdatadir = libdbus.get_variable(pkgconfig: 'datadir', default_value: datadir) / 'dbus-1' | |
1656 | endif | |
1657 | ||
1658 | dbuspolicydir = get_option('dbuspolicydir') | |
1659 | if dbuspolicydir == '' | |
1660 | dbuspolicydir = dbusdatadir / 'system.d' | |
1661 | endif | |
1662 | ||
1663 | dbussessionservicedir = get_option('dbussessionservicedir') | |
1664 | if dbussessionservicedir == '' | |
1665 | dbussessionservicedir = dbusdatadir / 'services' | |
1666 | if conf.get('HAVE_DBUS') == 1 | |
1667 | dbussessionservicedir = libdbus.get_variable(pkgconfig: 'session_bus_services_dir', default_value: dbussessionservicedir) | |
1668 | endif | |
1669 | endif | |
1670 | ||
1671 | dbussystemservicedir = get_option('dbussystemservicedir') | |
1672 | if dbussystemservicedir == '' | |
1673 | dbussystemservicedir = dbusdatadir / 'system-services' | |
1674 | if conf.get('HAVE_DBUS') == 1 | |
1675 | dbussystemservicedir = libdbus.get_variable(pkgconfig: 'system_bus_services_dir', default_value: dbussystemservicedir) | |
1676 | endif | |
1677 | endif | |
1678 | ||
1679 | dbus_interfaces_dir = get_option('dbus-interfaces-dir') | |
1680 | if dbus_interfaces_dir == '' or dbus_interfaces_dir == 'yes' | |
1681 | if meson.is_cross_build() and dbus_interfaces_dir != 'yes' | |
1682 | dbus_interfaces_dir = 'no' | |
1683 | warning('Exporting D-Bus interface XML files is disabled during cross build. Pass path or "yes" to force enable.') | |
1684 | else | |
1685 | dbus_interfaces_dir = dbusdatadir / 'interfaces' | |
1686 | if conf.get('HAVE_DBUS') == 1 | |
1687 | dbus_interfaces_dir = libdbus.get_variable(pkgconfig: 'interfaces_dir', default_value: dbus_interfaces_dir) | |
1688 | endif | |
1689 | endif | |
1690 | endif | |
1bd0cc45 | 1691 | |
e37ad765 ZJS |
1692 | # We support one or the other. If gcrypt is available, we assume it's there to |
1693 | # be used, and use it in preference. | |
1694 | opt = get_option('cryptolib') | |
1695 | if opt == 'openssl' and conf.get('HAVE_OPENSSL') == 0 | |
1696 | error('openssl requested as the default cryptolib, but not available') | |
1697 | endif | |
1698 | conf.set10('PREFER_OPENSSL', | |
1699 | opt == 'openssl' or (opt == 'auto' and conf.get('HAVE_OPENSSL') == 1 and conf.get('HAVE_GCRYPT') == 0)) | |
1700 | conf.set10('HAVE_OPENSSL_OR_GCRYPT', | |
1701 | conf.get('HAVE_OPENSSL') == 1 or conf.get('HAVE_GCRYPT') == 1) | |
9bcf483b | 1702 | lib_openssl_or_gcrypt = conf.get('PREFER_OPENSSL') == 1 ? [libopenssl] : [libgcrypt, libgpg_error] |
42303dcb | 1703 | |
56ddbf10 YW |
1704 | dns_over_tls = get_option('dns-over-tls') |
1705 | if dns_over_tls != 'false' | |
e37ad765 ZJS |
1706 | if dns_over_tls == 'gnutls' and conf.get('PREFER_OPENSSL') == 1 |
1707 | error('Sorry, -Ddns-over-tls=gnutls is not supported when openssl is used as the cryptolib') | |
1708 | endif | |
1709 | ||
1f9aa3d2 LB |
1710 | if dns_over_tls == 'gnutls' |
1711 | have_openssl = false | |
096cbdce | 1712 | else |
1f9aa3d2 LB |
1713 | have_openssl = conf.get('HAVE_OPENSSL') == 1 |
1714 | if dns_over_tls == 'openssl' and not have_openssl | |
1715 | error('DNS-over-TLS support was requested with openssl, but dependencies are not available') | |
096cbdce | 1716 | endif |
56ddbf10 | 1717 | endif |
1f9aa3d2 LB |
1718 | if dns_over_tls == 'openssl' or have_openssl |
1719 | have_gnutls = false | |
096cbdce | 1720 | else |
1f9aa3d2 LB |
1721 | have_gnutls = conf.get('HAVE_GNUTLS') == 1 and libgnutls.version().version_compare('>= 3.6.0') |
1722 | if dns_over_tls != 'auto' and not have_gnutls | |
1723 | str = dns_over_tls == 'gnutls' ? ' with gnutls' : '' | |
b349bc59 | 1724 | error('DNS-over-TLS support was requested@0@, but dependencies are not available'.format(str)) |
096cbdce IT |
1725 | endif |
1726 | endif | |
1727 | have = have_gnutls or have_openssl | |
56ddbf10 | 1728 | else |
be5536a6 MO |
1729 | have = false |
1730 | have_gnutls = false | |
1731 | have_openssl = false | |
56ddbf10 YW |
1732 | endif |
1733 | conf.set10('ENABLE_DNS_OVER_TLS', have) | |
096cbdce IT |
1734 | conf.set10('DNS_OVER_TLS_USE_GNUTLS', have_gnutls) |
1735 | conf.set10('DNS_OVER_TLS_USE_OPENSSL', have_openssl) | |
56ddbf10 | 1736 | |
c9299be2 | 1737 | default_dns_over_tls = get_option('default-dns-over-tls') |
87ac55a1 | 1738 | if skip_deps |
c9299be2 | 1739 | default_dns_over_tls = 'no' |
5d67a7ae | 1740 | endif |
56ddbf10 | 1741 | if default_dns_over_tls != 'no' and conf.get('ENABLE_DNS_OVER_TLS') == 0 |
4310bfc2 | 1742 | message('default-dns-over-tls cannot be enabled or set to opportunistic when DNS-over-TLS support is disabled. Setting default-dns-over-tls to no.') |
c9299be2 | 1743 | default_dns_over_tls = 'no' |
5d67a7ae | 1744 | endif |
c9299be2 IT |
1745 | conf.set('DEFAULT_DNS_OVER_TLS_MODE', |
1746 | 'DNS_OVER_TLS_' + default_dns_over_tls.underscorify().to_upper()) | |
411d1f4c | 1747 | conf.set_quoted('DEFAULT_DNS_OVER_TLS_MODE_STR', default_dns_over_tls) |
5d67a7ae | 1748 | |
3614df05 ZJS |
1749 | default_mdns = get_option('default-mdns') |
1750 | conf.set('DEFAULT_MDNS_MODE', | |
1751 | 'RESOLVE_SUPPORT_' + default_mdns.to_upper()) | |
411d1f4c | 1752 | conf.set_quoted('DEFAULT_MDNS_MODE_STR', default_mdns) |
3614df05 ZJS |
1753 | |
1754 | default_llmnr = get_option('default-llmnr') | |
1755 | conf.set('DEFAULT_LLMNR_MODE', | |
1756 | 'RESOLVE_SUPPORT_' + default_llmnr.to_upper()) | |
411d1f4c | 1757 | conf.set_quoted('DEFAULT_LLMNR_MODE_STR', default_llmnr) |
3614df05 | 1758 | |
e594a3b1 LP |
1759 | want_repart = get_option('repart') |
1760 | if want_repart != 'false' | |
6b12086e | 1761 | have = conf.get('HAVE_LIBFDISK') == 1 |
e594a3b1 LP |
1762 | if want_repart == 'true' and not have |
1763 | error('repart support was requested, but dependencies are not available') | |
1764 | endif | |
1765 | else | |
1766 | have = false | |
1767 | endif | |
1768 | conf.set10('ENABLE_REPART', have) | |
1769 | ||
7e8facb3 ZJS |
1770 | default_dnssec = get_option('default-dnssec') |
1771 | if skip_deps | |
1772 | default_dnssec = 'no' | |
1773 | endif | |
1774 | if default_dnssec != 'no' and conf.get('HAVE_OPENSSL_OR_GCRYPT') == 0 | |
1775 | message('default-dnssec cannot be set to yes or allow-downgrade openssl and gcrypt are disabled. Setting default-dnssec to no.') | |
1776 | default_dnssec = 'no' | |
1777 | endif | |
1778 | conf.set('DEFAULT_DNSSEC_MODE', | |
1779 | 'DNSSEC_' + default_dnssec.underscorify().to_upper()) | |
1780 | conf.set_quoted('DEFAULT_DNSSEC_MODE_STR', default_dnssec) | |
1781 | ||
43cc7a3e LP |
1782 | want_sysupdate = get_option('sysupdate') |
1783 | if want_sysupdate != 'false' | |
1784 | have = (conf.get('HAVE_OPENSSL') == 1 and | |
1785 | conf.get('HAVE_LIBFDISK') == 1) | |
1786 | if want_sysupdate == 'true' and not have | |
1787 | error('sysupdate support was requested, but dependencies are not available') | |
1788 | endif | |
1789 | else | |
1790 | have = false | |
1791 | endif | |
1792 | conf.set10('ENABLE_SYSUPDATE', have) | |
1793 | ||
5c23128d | 1794 | want_importd = get_option('importd') |
4390be30 | 1795 | if want_importd != 'false' |
349cc4a5 | 1796 | have = (conf.get('HAVE_LIBCURL') == 1 and |
6214d42b | 1797 | conf.get('HAVE_OPENSSL_OR_GCRYPT') == 1 and |
349cc4a5 | 1798 | conf.get('HAVE_ZLIB') == 1 and |
6214d42b | 1799 | conf.get('HAVE_XZ') == 1) |
349cc4a5 | 1800 | if want_importd == 'true' and not have |
37efbbd8 ZJS |
1801 | error('importd support was requested, but dependencies are not available') |
1802 | endif | |
349cc4a5 ZJS |
1803 | else |
1804 | have = false | |
5c23128d | 1805 | endif |
349cc4a5 | 1806 | conf.set10('ENABLE_IMPORTD', have) |
5c23128d | 1807 | |
70a5db58 LP |
1808 | want_homed = get_option('homed') |
1809 | if want_homed != 'false' | |
1810 | have = (conf.get('HAVE_OPENSSL') == 1 and | |
1811 | conf.get('HAVE_LIBFDISK') == 1 and | |
1812 | conf.get('HAVE_LIBCRYPTSETUP') == 1) | |
1813 | if want_homed == 'true' and not have | |
1814 | error('homed support was requested, but dependencies are not available') | |
1815 | endif | |
1816 | else | |
1817 | have = false | |
1818 | endif | |
1819 | conf.set10('ENABLE_HOMED', have) | |
1820 | ||
af06ddf5 YW |
1821 | have = have and conf.get('HAVE_PAM') == 1 |
1822 | conf.set10('ENABLE_PAM_HOME', have) | |
1823 | ||
5c23128d | 1824 | want_remote = get_option('remote') |
4390be30 | 1825 | if want_remote != 'false' |
349cc4a5 ZJS |
1826 | have_deps = [conf.get('HAVE_MICROHTTPD') == 1, |
1827 | conf.get('HAVE_LIBCURL') == 1] | |
37efbbd8 ZJS |
1828 | # sd-j-remote requires µhttpd, and sd-j-upload requires libcurl, so |
1829 | # it's possible to build one without the other. Complain only if | |
5238e957 | 1830 | # support was explicitly requested. The auxiliary files like sysusers |
37efbbd8 ZJS |
1831 | # config should be installed when any of the programs are built. |
1832 | if want_remote == 'true' and not (have_deps[0] and have_deps[1]) | |
1833 | error('remote support was requested, but dependencies are not available') | |
1834 | endif | |
349cc4a5 ZJS |
1835 | have = have_deps[0] or have_deps[1] |
1836 | else | |
1837 | have = false | |
5c23128d | 1838 | endif |
349cc4a5 | 1839 | conf.set10('ENABLE_REMOTE', have) |
5c23128d | 1840 | |
b3259a6e ZJS |
1841 | foreach term : ['analyze', |
1842 | 'backlight', | |
a9149d87 | 1843 | 'binfmt', |
dfca5587 | 1844 | 'compat-mutable-uid-boundaries', |
a9149d87 | 1845 | 'coredump', |
b3259a6e ZJS |
1846 | 'efi', |
1847 | 'environment-d', | |
1848 | 'firstboot', | |
1849 | 'gshadow', | |
1850 | 'hibernate', | |
a9149d87 | 1851 | 'hostnamed', |
b3259a6e ZJS |
1852 | 'hwdb', |
1853 | 'idn', | |
1854 | 'ima', | |
1855 | 'initrd', | |
1782534b | 1856 | 'kernel-install', |
b3259a6e | 1857 | 'ldconfig', |
a9149d87 | 1858 | 'localed', |
b3259a6e | 1859 | 'logind', |
a9149d87 ZJS |
1860 | 'machined', |
1861 | 'networkd', | |
dfca5587 | 1862 | 'nscd', |
b3259a6e ZJS |
1863 | 'nss-myhostname', |
1864 | 'nss-systemd', | |
1782534b | 1865 | 'oomd', |
b3259a6e ZJS |
1866 | 'portabled', |
1867 | 'pstore', | |
a9149d87 | 1868 | 'quotacheck', |
b3259a6e ZJS |
1869 | 'randomseed', |
1870 | 'resolve', | |
1871 | 'rfkill', | |
1872 | 'smack', | |
dfca5587 | 1873 | 'sysext', |
a9149d87 | 1874 | 'sysusers', |
b3259a6e ZJS |
1875 | 'timedated', |
1876 | 'timesyncd', | |
a9149d87 | 1877 | 'tmpfiles', |
a9149d87 | 1878 | 'tpm', |
b3259a6e ZJS |
1879 | 'userdb', |
1880 | 'utmp', | |
1881 | 'vconsole', | |
1882 | 'xdg-autostart'] | |
a9149d87 ZJS |
1883 | have = get_option(term) |
1884 | name = 'ENABLE_' + term.underscorify().to_upper() | |
1885 | conf.set10(name, have) | |
5c23128d ZJS |
1886 | endforeach |
1887 | ||
bd7e6aa7 ZJS |
1888 | enable_sysusers = conf.get('ENABLE_SYSUSERS') == 1 |
1889 | ||
08540a95 YW |
1890 | foreach tuple : [['nss-mymachines', 'machined'], |
1891 | ['nss-resolve', 'resolve']] | |
1892 | want = get_option(tuple[0]) | |
1893 | if want != 'false' | |
1894 | have = get_option(tuple[1]) | |
1895 | if want == 'true' and not have | |
1896 | error('@0@ is requested but @1@ is disabled'.format(tuple[0], tuple[1])) | |
1897 | endif | |
1898 | else | |
1899 | have = false | |
1900 | endif | |
1901 | name = 'ENABLE_' + tuple[0].underscorify().to_upper() | |
1902 | conf.set10(name, have) | |
1903 | endforeach | |
1904 | ||
1905 | enable_nss = false | |
1906 | foreach term : ['ENABLE_NSS_MYHOSTNAME', | |
1907 | 'ENABLE_NSS_MYMACHINES', | |
1908 | 'ENABLE_NSS_RESOLVE', | |
1909 | 'ENABLE_NSS_SYSTEMD'] | |
1910 | if conf.get(term) == 1 | |
1911 | enable_nss = true | |
1912 | endif | |
1913 | endforeach | |
1914 | conf.set10('ENABLE_NSS', enable_nss) | |
1915 | ||
348b4437 | 1916 | conf.set10('ENABLE_TIMEDATECTL', get_option('timedated') or get_option('timesyncd')) |
6129ec85 | 1917 | |
b68dfb9e | 1918 | conf.set10('SYSTEMD_SLOW_TESTS_DEFAULT', slow_tests) |
00d82c81 | 1919 | |
db7f5ab6 JJ |
1920 | ############################################################ |
1921 | ||
9c45bfb2 FS |
1922 | pymod = import('python') |
1923 | python = pymod.find_installation('python3', required : true, modules : ['jinja2']) | |
1924 | python_39 = python.language_version().version_compare('>=3.9') | |
1925 | ||
4d3ef2d1 LP |
1926 | ############################################################ |
1927 | ||
1928 | if conf.get('BPF_FRAMEWORK') == 1 | |
1929 | bpf_clang_flags = [ | |
1930 | '-std=gnu11', | |
1931 | '-Wno-compare-distinct-pointer-types', | |
1932 | '-fno-stack-protector', | |
1933 | '-O2', | |
1934 | '-target', | |
1935 | 'bpf', | |
1936 | '-g', | |
1937 | '-c', | |
1938 | ] | |
1939 | ||
1940 | bpf_gcc_flags = [ | |
1941 | '-std=gnu11', | |
1942 | '-fno-stack-protector', | |
1943 | '-O2', | |
1944 | '-mkernel=5.2', | |
1945 | '-mcpu=v3', | |
1946 | '-mco-re', | |
1947 | '-gbtf', | |
1948 | '-c', | |
1949 | ] | |
1950 | ||
1951 | # Generate defines that are appropriate to tell the compiler what architecture | |
1952 | # we're compiling for. By default we just map meson's cpu_family to __<cpu_family>__. | |
1953 | # This dictionary contains the exceptions where this doesn't work. | |
1954 | # | |
1955 | # C.f. https://mesonbuild.com/Reference-tables.html#cpu-families | |
1956 | # and src/basic/missing_syscall_def.h. | |
1957 | cpu_arch_defines = { | |
1958 | 'ppc' : ['-D__powerpc__'], | |
1959 | 'ppc64' : ['-D__powerpc64__', '-D_CALL_ELF=2'], | |
1960 | 'riscv32' : ['-D__riscv', '-D__riscv_xlen=32'], | |
1961 | 'riscv64' : ['-D__riscv', '-D__riscv_xlen=64'], | |
1962 | 'x86' : ['-D__i386__'], | |
1963 | ||
1964 | # For arm, assume hardware fp is available. | |
1965 | 'arm' : ['-D__arm__', '-D__ARM_PCS_VFP'], | |
1966 | } | |
1967 | ||
1968 | bpf_arch_flags = cpu_arch_defines.get(host_machine.cpu_family(), | |
1969 | ['-D__@0@__'.format(host_machine.cpu_family())]) | |
1970 | if bpf_compiler == 'gcc' | |
1971 | bpf_arch_flags += ['-m' + host_machine.endian() + '-endian'] | |
1972 | endif | |
1973 | ||
1974 | libbpf_include_dir = libbpf.get_variable(pkgconfig : 'includedir') | |
1975 | ||
1976 | bpf_o_unstripped_cmd = [] | |
1977 | if bpf_compiler == 'clang' | |
1978 | bpf_o_unstripped_cmd += [ | |
1979 | clang, | |
1980 | bpf_clang_flags, | |
1981 | bpf_arch_flags, | |
1982 | ] | |
1983 | elif bpf_compiler == 'gcc' | |
1984 | bpf_o_unstripped_cmd += [ | |
1985 | bpf_gcc, | |
1986 | bpf_gcc_flags, | |
1987 | bpf_arch_flags, | |
1988 | ] | |
1989 | endif | |
1990 | ||
1991 | bpf_o_unstripped_cmd += ['-I.'] | |
1992 | ||
1993 | if not meson.is_cross_build() and bpf_compiler == 'clang' | |
1994 | target_triplet_cmd = run_command('gcc', '-dumpmachine', check: false) | |
1995 | if target_triplet_cmd.returncode() == 0 | |
1996 | target_triplet = target_triplet_cmd.stdout().strip() | |
1997 | bpf_o_unstripped_cmd += [ | |
1998 | '-isystem', | |
1999 | '/usr/include/@0@'.format(target_triplet) | |
2000 | ] | |
2001 | endif | |
2002 | endif | |
2003 | ||
2004 | bpf_o_unstripped_cmd += [ | |
2005 | '-idirafter', | |
2006 | libbpf_include_dir, | |
2007 | '@INPUT@', | |
2008 | '-o', | |
2009 | '@OUTPUT@' | |
2010 | ] | |
2011 | ||
2012 | if bpftool_strip | |
2013 | bpf_o_cmd = [ | |
2014 | bpftool, | |
2015 | 'gen', | |
2016 | 'object', | |
2017 | '@OUTPUT@', | |
2018 | '@INPUT@' | |
2019 | ] | |
2020 | elif bpf_compiler == 'clang' | |
2021 | bpf_o_cmd = [ | |
2022 | llvm_strip, | |
2023 | '-g', | |
2024 | '@INPUT@', | |
2025 | '-o', | |
2026 | '@OUTPUT@' | |
2027 | ] | |
2028 | endif | |
2029 | ||
2030 | skel_h_cmd = [ | |
2031 | bpftool, | |
2032 | 'gen', | |
2033 | 'skeleton', | |
2034 | '@INPUT@' | |
2035 | ] | |
2036 | endif | |
2037 | ||
dfca5587 JJ |
2038 | ##################################################################### |
2039 | ||
2040 | efi_arch = { | |
31ffb6b1 JJ |
2041 | 'aarch64' : 'aa64', |
2042 | 'arm' : 'arm', | |
2043 | 'loongarch32' : 'loongarch32', | |
2044 | 'loongarch64' : 'loongarch64', | |
2045 | 'riscv32' : 'riscv32', | |
2046 | 'riscv64' : 'riscv64', | |
2047 | 'x86_64' : 'x64', | |
2048 | 'x86' : 'ia32', | |
dfca5587 JJ |
2049 | }.get(host_machine.cpu_family(), '') |
2050 | ||
2051 | if get_option('bootloader') != 'false' and efi_arch != '' | |
2052 | conf.set_quoted('EFI_MACHINE_TYPE_NAME', efi_arch) | |
4729e84e LB |
2053 | elif get_option('bootloader') == 'false' and efi_arch != '' |
2054 | # Ensure that if the option is explicitly set to false, then no EFI code is built, including tests | |
2055 | efi_arch = '' | |
dfca5587 JJ |
2056 | elif get_option('bootloader') == 'true' and efi_arch == '' |
2057 | error('EFI not supported for this arch.') | |
2058 | endif | |
2afeaf16 JJ |
2059 | |
2060 | efi_arch_alt = '' | |
7ea44f17 | 2061 | efi_cpu_family_alt = '' |
2afeaf16 JJ |
2062 | if efi_arch == 'x64' and cc.links(''' |
2063 | #include <limits.h> | |
2064 | int main(int argc, char *argv[]) { | |
2065 | return __builtin_popcount(argc - CHAR_MAX); | |
2066 | }''', args : ['-m32', '-march=i686'], name : '32bit build possible') | |
2067 | efi_arch_alt = 'ia32' | |
7ea44f17 | 2068 | efi_cpu_family_alt = 'x86' |
2afeaf16 JJ |
2069 | endif |
2070 | ||
2071 | have_pyelftools = pymod.find_installation('python3', required : false, modules : ['elftools']).found() | |
09444a2e DDM |
2072 | if get_option('bootloader') == 'true' and not have_pyelftools |
2073 | error('EFI bootloader support requires pyelftools.') | |
2afeaf16 JJ |
2074 | endif |
2075 | ||
dfca5587 JJ |
2076 | conf.set10( |
2077 | 'ENABLE_BOOTLOADER', | |
2078 | get_option('efi') and | |
2079 | get_option('bootloader') in ['auto', 'true'] and | |
2afeaf16 | 2080 | efi_arch != '' and |
2afeaf16 | 2081 | have_pyelftools, |
dfca5587 JJ |
2082 | ) |
2083 | ||
9c45bfb2 | 2084 | if get_option('ukify') == 'auto' |
dfca5587 JJ |
2085 | want_ukify = python_39 and conf.get('ENABLE_BOOTLOADER') == 1 |
2086 | elif get_option('ukify') == 'true' and (not python_39 or conf.get('ENABLE_BOOTLOADER') != 1) | |
2087 | error('ukify requires Python >= 3.9 and -Dbootloader=true') | |
9c45bfb2 FS |
2088 | else |
2089 | want_ukify = get_option('ukify') == 'true' | |
2090 | endif | |
2091 | conf.set10('ENABLE_UKIFY', want_ukify) | |
2092 | ||
2093 | ############################################################ | |
b0bd2ae8 | 2094 | |
2afeaf16 JJ |
2095 | elf2efi_lds = project_source_root / 'tools/elf2efi.lds' |
2096 | elf2efi_py = find_program('tools/elf2efi.py') | |
2097 | export_dbus_interfaces_py = find_program('tools/dbus_exporter.py') | |
d3821a33 | 2098 | generate_gperfs = find_program('tools/generate-gperfs.py') |
f6fe732f YW |
2099 | make_autosuspend_rules_py = find_program('tools/make-autosuspend-rules.py') |
2100 | make_directive_index_py = find_program('tools/make-directive-index.py') | |
2101 | make_man_index_py = find_program('tools/make-man-index.py') | |
6b1aac3c | 2102 | meson_render_jinja2 = find_program('tools/meson-render-jinja2.py') |
d3821a33 | 2103 | update_dbus_docs_py = find_program('tools/update-dbus-docs.py') |
d3821a33 | 2104 | update_hwdb_autosuspend_sh = find_program('tools/update-hwdb-autosuspend.sh') |
2afeaf16 JJ |
2105 | update_hwdb_sh = find_program('tools/update-hwdb.sh') |
2106 | update_man_rules_py = find_program('tools/update-man-rules.py') | |
d3821a33 ZJS |
2107 | update_syscall_tables_sh = find_program('tools/update-syscall-tables.sh') |
2108 | xml_helper_py = find_program('tools/xml_helper.py') | |
f6fe732f | 2109 | |
db7f5ab6 | 2110 | ############################################################ |
5c23128d | 2111 | |
e95acdfe YW |
2112 | version_tag = get_option('version-tag') |
2113 | if version_tag == '' | |
2114 | # Check that we have either .git/ (a normal clone) or a .git file (a work-tree) and that we don't | |
2115 | # get confused if a tarball is extracted in a higher-level git repository. | |
2116 | if git.found() and fs.exists(project_source_root / '.git') | |
2117 | # Apparently git describe has a bug where it always considers the work-tree dirty when | |
2118 | # invoked with --git-dir (even though 'git status' is happy). Work around this issue by | |
2119 | # cd-ing to the source directory. | |
2120 | version_tag = run_command( | |
2121 | sh, '-c', | |
2122 | 'cd "$MESON_SOURCE_ROOT"; git describe --abbrev=7 --dirty=^ 2>/dev/null | sed "s/^v//; s/-rc/~rc/"', | |
2123 | check : true, | |
2124 | ).stdout().strip() | |
2125 | else | |
2126 | version_tag = meson.project_version() | |
2127 | endif | |
2128 | endif | |
2129 | ||
2130 | vcs_data = configuration_data() | |
2131 | vcs_data.set('VCS_TAG', version_tag) | |
2132 | version_h = configure_file(configuration : vcs_data, | |
2133 | input : 'src/version/version.h.in', | |
2134 | output : 'version.h') | |
2135 | ||
2136 | versiondep = declare_dependency( | |
2137 | sources : version_h, | |
2138 | include_directories : include_directories('.'), | |
2139 | ) | |
2140 | ||
2141 | shared_lib_tag = get_option('shared-lib-tag') | |
2142 | if shared_lib_tag == '' | |
2143 | shared_lib_tag = meson.project_version() | |
2144 | endif | |
2145 | ||
2146 | ############################################################ | |
2147 | ||
7e43be7d | 2148 | if get_option('b_coverage') |
92148283 | 2149 | userspace_c_args += ['-include', 'src/basic/coverage.h'] |
7e43be7d FS |
2150 | endif |
2151 | ||
2152 | ############################################################ | |
2153 | ||
5c23128d | 2154 | config_h = configure_file( |
37efbbd8 ZJS |
2155 | output : 'config.h', |
2156 | configuration : conf) | |
5c23128d | 2157 | |
92148283 | 2158 | userspace_c_args += ['-include', 'config.h'] |
f6fe732f | 2159 | |
8f04a1ca ZJS |
2160 | jinja2_cmdline = [meson_render_jinja2, config_h, version_h] |
2161 | ||
92148283 JJ |
2162 | userspace = declare_dependency( |
2163 | compile_args : userspace_c_args, | |
2164 | link_args : userspace_c_ld_args, | |
40c7d3c7 | 2165 | dependencies : versiondep, |
92148283 JJ |
2166 | ) |
2167 | ||
c18dde32 ZJS |
2168 | man_page_depends = [] |
2169 | ||
f6fe732f | 2170 | ############################################################ |
348b4437 | 2171 | |
1d21a7bd YW |
2172 | tests = [] |
2173 | simple_tests = [] | |
2174 | fuzzers = [] | |
2175 | simple_fuzzers = [] | |
2176 | catalogs = [] | |
c335921e YW |
2177 | modules = [] # nss, pam, and other plugins |
2178 | executables = [] | |
2179 | executables_by_name = {} | |
1d21a7bd | 2180 | |
b61016f2 YW |
2181 | # binaries that have --help and are intended for use by humans, |
2182 | # usually, but not always, installed in /bin. | |
2183 | public_programs = [] | |
2184 | ||
e3c68924 | 2185 | # D-Bus introspection XML export |
2186 | dbus_programs = [] | |
e3c68924 | 2187 | |
3f80c139 ZJS |
2188 | # A list of boot stubs. Required for testing of ukify. |
2189 | boot_stubs = [] | |
2190 | ||
8d40961c YW |
2191 | basic_includes = include_directories( |
2192 | 'src/basic', | |
e5bc5f1f | 2193 | 'src/fundamental', |
8d40961c YW |
2194 | 'src/systemd', |
2195 | '.') | |
2196 | ||
2197 | libsystemd_includes = [basic_includes, include_directories( | |
2198 | 'src/libsystemd/sd-bus', | |
2199 | 'src/libsystemd/sd-device', | |
2200 | 'src/libsystemd/sd-event', | |
2201 | 'src/libsystemd/sd-hwdb', | |
2202 | 'src/libsystemd/sd-id128', | |
2203 | 'src/libsystemd/sd-journal', | |
2204 | 'src/libsystemd/sd-netlink', | |
2205 | 'src/libsystemd/sd-network', | |
2206 | 'src/libsystemd/sd-resolve')] | |
2207 | ||
2208 | includes = [libsystemd_includes, include_directories('src/shared')] | |
5c23128d | 2209 | |
5c23128d ZJS |
2210 | subdir('po') |
2211 | subdir('catalog') | |
dfca5587 | 2212 | subdir('src/fundamental') |
5c23128d ZJS |
2213 | subdir('src/basic') |
2214 | subdir('src/libsystemd') | |
3976f372 YW |
2215 | subdir('src/shared') |
2216 | subdir('src/udev') | |
2217 | subdir('src/libudev') | |
5c23128d | 2218 | |
5c23128d | 2219 | libsystemd = shared_library( |
37efbbd8 | 2220 | 'systemd', |
56d50ab1 | 2221 | version : libsystemd_version, |
8d40961c | 2222 | include_directories : libsystemd_includes, |
37efbbd8 ZJS |
2223 | link_args : ['-shared', |
2224 | '-Wl,--version-script=' + libsystemd_sym_path], | |
34e221a5 | 2225 | link_with : [libbasic, |
acc50c92 LP |
2226 | libbasic_gcrypt, |
2227 | libbasic_compress], | |
99b9f8fd | 2228 | link_whole : [libsystemd_static], |
92148283 JJ |
2229 | dependencies : [librt, |
2230 | threads, | |
2231 | userspace], | |
37efbbd8 ZJS |
2232 | link_depends : libsystemd_sym, |
2233 | install : true, | |
0a5e638c | 2234 | install_tag: 'libsystemd', |
b0d3095f | 2235 | install_dir : libdir) |
5c23128d | 2236 | |
039f1673 LB |
2237 | alias_target('libsystemd', libsystemd) |
2238 | ||
70848ecf DC |
2239 | install_libsystemd_static = static_library( |
2240 | 'systemd', | |
2241 | libsystemd_sources, | |
975464e0 ZJS |
2242 | basic_sources, |
2243 | basic_gcrypt_sources, | |
acc50c92 | 2244 | basic_compress_sources, |
e5bc5f1f | 2245 | fundamental_sources, |
8d40961c | 2246 | include_directories : libsystemd_includes, |
70848ecf DC |
2247 | build_by_default : static_libsystemd != 'false', |
2248 | install : static_libsystemd != 'false', | |
0a5e638c | 2249 | install_tag: 'libsystemd', |
b0d3095f | 2250 | install_dir : libdir, |
40dbce36 | 2251 | pic : static_libsystemd_pic, |
92148283 | 2252 | dependencies : [libblkid, |
975464e0 | 2253 | libcap, |
92148283 | 2254 | libdl, |
011d129c | 2255 | libgcrypt, |
92148283 JJ |
2256 | liblz4, |
2257 | libmount, | |
c47511da | 2258 | libopenssl, |
92148283 JJ |
2259 | librt, |
2260 | libxz, | |
2261 | libzstd, | |
2262 | threads, | |
40c7d3c7 | 2263 | userspace], |
70848ecf DC |
2264 | c_args : libsystemd_c_args + (static_libsystemd_pic ? [] : ['-fno-PIC'])) |
2265 | ||
3976f372 YW |
2266 | libudev = shared_library( |
2267 | 'udev', | |
3976f372 YW |
2268 | version : libudev_version, |
2269 | include_directories : includes, | |
2270 | link_args : ['-shared', | |
2271 | '-Wl,--version-script=' + libudev_sym_path], | |
2272 | link_with : [libsystemd_static, libshared_static], | |
2273 | link_whole : libudev_basic, | |
92148283 JJ |
2274 | dependencies : [threads, |
2275 | userspace], | |
3976f372 YW |
2276 | link_depends : libudev_sym, |
2277 | install : true, | |
0a5e638c | 2278 | install_tag: 'libudev', |
b0d3095f | 2279 | install_dir : libdir) |
3976f372 | 2280 | |
039f1673 LB |
2281 | alias_target('libudev', libudev) |
2282 | ||
3976f372 YW |
2283 | install_libudev_static = static_library( |
2284 | 'udev', | |
2285 | basic_sources, | |
e5bc5f1f | 2286 | fundamental_sources, |
3976f372 YW |
2287 | shared_sources, |
2288 | libsystemd_sources, | |
2289 | libudev_sources, | |
3976f372 YW |
2290 | include_directories : includes, |
2291 | build_by_default : static_libudev != 'false', | |
2292 | install : static_libudev != 'false', | |
0a5e638c | 2293 | install_tag: 'libudev', |
b0d3095f | 2294 | install_dir : libdir, |
3976f372 | 2295 | link_depends : libudev_sym, |
92148283 JJ |
2296 | dependencies : [libmount, |
2297 | libshared_deps, | |
40c7d3c7 | 2298 | userspace], |
3976f372 YW |
2299 | c_args : static_libudev_pic ? [] : ['-fno-PIC'], |
2300 | pic : static_libudev_pic) | |
2301 | ||
47354b44 ZJS |
2302 | ############################################################ |
2303 | ||
c335921e YW |
2304 | executable_template = { |
2305 | 'include_directories' : includes, | |
2306 | 'link_with' : libshared, | |
2307 | 'install_rpath' : pkglibdir, | |
2308 | 'install' : true, | |
2309 | } | |
2310 | ||
2311 | generator_template = executable_template + { | |
2312 | 'install_dir' : systemgeneratordir, | |
2313 | } | |
2314 | ||
2315 | libexec_template = executable_template + { | |
2316 | 'install_dir' : libexecdir, | |
2317 | } | |
2318 | ||
2319 | executable_additional_kwargs = { | |
2320 | 'dependencies' : userspace, | |
2321 | } | |
2322 | ||
2323 | nss_template = { | |
2324 | 'version' : '2', | |
2325 | 'include_directories' : includes, | |
2326 | # Note that we link NSS modules with '-z nodelete' so that mempools never get orphaned | |
2327 | 'link_args' : ['-z', 'nodelete'], | |
2328 | 'link_with' : [ | |
2329 | libsystemd_static, | |
2330 | libshared_static, | |
2331 | libbasic, | |
2332 | ], | |
2333 | 'dependencies' : [ | |
2334 | librt, | |
2335 | threads, | |
2336 | ], | |
2337 | 'install' : true, | |
2338 | 'install_tag' : 'nss', | |
2339 | 'install_dir' : libdir, | |
2340 | } | |
2341 | ||
2342 | pam_template = { | |
2343 | 'name_prefix' : '', | |
2344 | 'include_directories' : includes, | |
2345 | 'link_with' : [ | |
2346 | libsystemd_static, | |
2347 | libshared_static, | |
2348 | ], | |
2349 | 'dependencies' : [ | |
2350 | libpam_misc, | |
2351 | libpam, | |
2352 | threads, | |
2353 | ], | |
2354 | 'install' : true, | |
2355 | 'install_tag' : 'pam', | |
2356 | 'install_dir' : pamlibdir, | |
2357 | } | |
2358 | ||
2359 | module_additional_kwargs = { | |
2360 | 'link_args' : ['-shared'], | |
2361 | 'dependencies' : userspace, | |
2362 | } | |
2363 | ||
2364 | ############################################################ | |
2365 | ||
b61016f2 | 2366 | # systemd-analyze requires 'libcore' |
83b6af36 | 2367 | subdir('src/core') |
b61016f2 YW |
2368 | # systemd-journal-remote requires 'libjournal_core' |
2369 | subdir('src/journal') | |
2370 | # systemd-networkd requires 'libsystemd_network' | |
2371 | subdir('src/libsystemd-network') | |
83b6af36 | 2372 | |
16b081d6 | 2373 | subdir('src/ac-power') |
83b6af36 | 2374 | subdir('src/analyze') |
7e6ca26f | 2375 | subdir('src/backlight') |
98e39a55 | 2376 | subdir('src/battery-check') |
2c2c3daa | 2377 | subdir('src/binfmt') |
cd4300f3 | 2378 | subdir('src/boot') |
dfca5587 | 2379 | subdir('src/boot/efi') |
f98df767 | 2380 | subdir('src/busctl') |
e2bdf00a | 2381 | subdir('src/cgroups-agent') |
b61016f2 | 2382 | subdir('src/coredump') |
98e39a55 | 2383 | subdir('src/creds') |
2ad279cf | 2384 | subdir('src/cryptenroll') |
b4d1892a | 2385 | subdir('src/cryptsetup') |
2a456620 | 2386 | subdir('src/debug-generator') |
98e39a55 | 2387 | subdir('src/delta') |
16b081d6 | 2388 | subdir('src/detect-virt') |
ec57a4ea | 2389 | subdir('src/dissect') |
2a456620 | 2390 | subdir('src/environment-d-generator') |
98e39a55 | 2391 | subdir('src/escape') |
df490fc7 YW |
2392 | subdir('src/firstboot') |
2393 | subdir('src/fsck') | |
2a456620 YW |
2394 | subdir('src/fstab-generator') |
2395 | subdir('src/getty-generator') | |
ec57a4ea | 2396 | subdir('src/gpt-auto-generator') |
74093422 | 2397 | subdir('src/hibernate-resume') |
b61016f2 | 2398 | subdir('src/home') |
83b6af36 | 2399 | subdir('src/hostname') |
e2bdf00a | 2400 | subdir('src/id128') |
83b6af36 | 2401 | subdir('src/import') |
81fe141b | 2402 | subdir('src/integritysetup') |
b61016f2 | 2403 | subdir('src/journal-remote') |
83b6af36 ZJS |
2404 | subdir('src/kernel-install') |
2405 | subdir('src/locale') | |
b61016f2 | 2406 | subdir('src/login') |
83b6af36 | 2407 | subdir('src/machine') |
df490fc7 | 2408 | subdir('src/machine-id-setup') |
b61016f2 | 2409 | subdir('src/network') |
98e39a55 | 2410 | subdir('src/notify') |
83b6af36 | 2411 | subdir('src/nspawn') |
2080c097 YW |
2412 | subdir('src/nss-myhostname') |
2413 | subdir('src/nss-mymachines') | |
2414 | subdir('src/nss-resolve') | |
2415 | subdir('src/nss-systemd') | |
b61016f2 YW |
2416 | subdir('src/oom') |
2417 | subdir('src/partition') | |
e2bdf00a | 2418 | subdir('src/path') |
b61016f2 YW |
2419 | subdir('src/portable') |
2420 | subdir('src/pstore') | |
c8c78771 | 2421 | subdir('src/random-seed') |
6c713961 | 2422 | subdir('src/rc-local-generator') |
df490fc7 | 2423 | subdir('src/remount-fs') |
83b6af36 | 2424 | subdir('src/resolve') |
7e6ca26f | 2425 | subdir('src/rfkill') |
2a9b4bbe | 2426 | subdir('src/rpm') |
2a456620 | 2427 | subdir('src/run-generator') |
b61016f2 | 2428 | subdir('src/shutdown') |
16b081d6 | 2429 | subdir('src/sleep') |
22f37744 | 2430 | subdir('src/socket-activate') |
16b081d6 | 2431 | subdir('src/sysctl') |
9bca4ae4 | 2432 | subdir('src/sysext') |
7e6ca26f | 2433 | subdir('src/system-update-generator') |
c3512573 | 2434 | subdir('src/systemctl') |
43cc7a3e | 2435 | subdir('src/sysupdate') |
6c713961 | 2436 | subdir('src/sysv-generator') |
83b6af36 ZJS |
2437 | subdir('src/timedate') |
2438 | subdir('src/timesync') | |
db64ba81 | 2439 | subdir('src/tmpfiles') |
dbab4fb9 | 2440 | subdir('src/user-sessions') |
b61016f2 | 2441 | subdir('src/userdb') |
c8c78771 | 2442 | subdir('src/vconsole') |
81fe141b | 2443 | subdir('src/veritysetup') |
e2bdf00a | 2444 | subdir('src/volatile-root') |
0275e918 | 2445 | subdir('src/xdg-autostart-generator') |
83b6af36 | 2446 | |
3976f372 YW |
2447 | subdir('src/systemd') |
2448 | ||
83b6af36 | 2449 | subdir('src/test') |
7db7d5b7 | 2450 | subdir('src/fuzz') |
ef2ad30a | 2451 | subdir('rules.d') |
83b6af36 | 2452 | subdir('test') |
a1d6dbb1 | 2453 | subdir('src/ukify/test') # needs to be last for test_env variable |
83b6af36 | 2454 | |
d30d9bf0 LB |
2455 | alias_target('devel', libsystemd_pc, libudev_pc, systemd_pc, udev_pc) |
2456 | ||
83b6af36 ZJS |
2457 | ############################################################ |
2458 | ||
c335921e YW |
2459 | foreach dict : executables |
2460 | name = dict.get('name') | |
2461 | ||
2462 | build = true | |
2463 | foreach cond : dict.get('conditions', []) | |
2464 | if conf.get(cond) != 1 | |
2465 | build = false | |
2466 | break | |
2467 | endif | |
2468 | endforeach | |
2469 | if not build | |
2470 | continue | |
2471 | endif | |
2472 | ||
2473 | kwargs = {} | |
2474 | foreach key, val : dict | |
2475 | if key in ['name', 'dbus', 'public', 'conditions'] | |
2476 | continue | |
2477 | endif | |
2478 | kwargs += { key : val } | |
2479 | endforeach | |
2480 | ||
2481 | foreach key, val : executable_additional_kwargs | |
2482 | kwargs += { key : [ kwargs.get(key, []), val ]} | |
2483 | endforeach | |
2484 | ||
2485 | exe = executable( | |
2486 | name, | |
2487 | kwargs : kwargs, | |
2488 | ) | |
2489 | ||
2490 | executables_by_name += { name : exe } | |
2491 | ||
2492 | if dict.get('build_by_default', true) | |
2493 | if dict.get('dbus', false) | |
2494 | dbus_programs += exe | |
2495 | endif | |
2496 | if dict.get('public', false) | |
2497 | public_programs += exe | |
2498 | endif | |
2499 | endif | |
2500 | endforeach | |
2501 | ||
2502 | ############################################################ | |
2503 | ||
83b6af36 ZJS |
2504 | # only static linking apart from libdl, to make sure that the |
2505 | # module is linked to all libraries that it uses. | |
2506 | test_dlopen = executable( | |
37efbbd8 ZJS |
2507 | 'test-dlopen', |
2508 | test_dlopen_c, | |
2509 | include_directories : includes, | |
2510 | link_with : [libbasic], | |
92148283 JJ |
2511 | dependencies : [libdl, |
2512 | userspace], | |
fd1939fb | 2513 | build_by_default : want_tests != 'false') |
83b6af36 | 2514 | |
c335921e YW |
2515 | foreach dict : modules |
2516 | name = dict.get('name') | |
2517 | is_nss = name.startswith('nss_') | |
2518 | is_pam = name.startswith('pam_') | |
2519 | ||
2520 | build = true | |
2521 | foreach cond : dict.get('conditions', []) | |
2522 | if conf.get(cond) != 1 | |
2523 | build = false | |
2524 | break | |
2525 | endif | |
2526 | endforeach | |
2527 | if not build | |
2528 | continue | |
2529 | endif | |
2530 | ||
2531 | kwargs = {} | |
2532 | foreach key, val : dict | |
2533 | if key in ['name', 'conditions'] | |
2534 | continue | |
2535 | endif | |
2536 | kwargs += { key : val } | |
2537 | endforeach | |
2538 | ||
2539 | sym = meson.current_source_dir() / '@0@'.format(dict.get('link_depends')[0]) | |
2540 | kwargs += { | |
2541 | 'link_args' : [ | |
2542 | kwargs.get('link_args', []), | |
2543 | '-Wl,--version-script=' + sym, | |
2544 | ], | |
2545 | } | |
2546 | foreach key, val : module_additional_kwargs | |
2547 | kwargs += { key : [ kwargs.get(key, []), val ]} | |
2548 | endforeach | |
2549 | ||
2550 | lib = shared_library( | |
2551 | name, | |
2552 | kwargs : kwargs, | |
2553 | ) | |
2554 | ||
2555 | if is_nss | |
2556 | # We cannot use shared_module because it does not support version suffix. | |
2557 | # Unfortunately shared_library insists on creating the symlink… | |
2558 | meson.add_install_script('sh', '-c', 'rm $DESTDIR@0@/lib@1@.so'.format(libdir, name), | |
2559 | install_tag : 'nss') | |
2560 | endif | |
2561 | ||
2562 | if want_tests != 'false' and (is_nss or is_pam) | |
2563 | test('dlopen-' + name, | |
2564 | test_dlopen, | |
2565 | # path to dlopen must include a slash | |
2566 | args : lib.full_path(), | |
2567 | depends : lib) | |
2568 | endif | |
2569 | endforeach | |
2570 | ||
5c23128d ZJS |
2571 | ############################################################ |
2572 | ||
4e8295f4 | 2573 | if want_tests != 'false' |
f727f3b9 | 2574 | exe = executables_by_name.get('systemd-analyze') |
4e8295f4 ZJS |
2575 | test('test-compare-versions', |
2576 | test_compare_versions_sh, | |
2577 | args : exe.full_path()) | |
2578 | endif | |
35a1ff4c | 2579 | |
8cc8a073 | 2580 | if want_tests != 'false' |
2a456620 | 2581 | exe = executables_by_name.get('systemd-fstab-generator') |
8cc8a073 YW |
2582 | test('test-fstab-generator', |
2583 | test_fstab_generator_sh, | |
2584 | # https://github.com/mesonbuild/meson/issues/2681 | |
e93ada98 | 2585 | args : exe.full_path(), |
e290bdb7 | 2586 | env : test_env, |
e93ada98 | 2587 | depends : exe) |
8cc8a073 YW |
2588 | endif |
2589 | ||
dfca5587 | 2590 | if conf.get('HAVE_BLKID') == 1 and conf.get('ENABLE_BOOTLOADER') == 1 |
50f2c32c | 2591 | if want_tests != 'false' |
bd31a348 | 2592 | exe = executables_by_name.get('bootctl') |
50f2c32c ZJS |
2593 | test('test-bootctl-json', |
2594 | test_bootctl_json_sh, | |
2595 | args : exe.full_path(), | |
2596 | depends : exe) | |
2597 | endif | |
6164ec4c ZJS |
2598 | endif |
2599 | ||
63e2d171 | 2600 | meson.add_install_script(meson_make_symlink, |
b0d3095f LB |
2601 | bindir / 'udevadm', |
2602 | libexecdir / 'systemd-udevd') | |
63e2d171 | 2603 | |
2a2d002f | 2604 | if want_tests != 'false' |
c2121630 | 2605 | systemctl = executables_by_name.get('systemctl') |
e2bdf00a | 2606 | systemd_id128 = executables_by_name.get('systemd-id128') |
2a2d002f ZJS |
2607 | test('test-systemctl-enable', |
2608 | test_systemctl_enable_sh, | |
2609 | # https://github.com/mesonbuild/meson/issues/2681 | |
2610 | args : [systemctl.full_path(), | |
2611 | systemd_id128.full_path()]) | |
2612 | endif | |
6164ec4c | 2613 | |
6164ec4c ZJS |
2614 | public_programs += executable( |
2615 | 'systemd-ask-password', | |
2616 | 'src/ask-password/ask-password.c', | |
2617 | include_directories : includes, | |
2618 | link_with : [libshared], | |
40c7d3c7 | 2619 | dependencies : [userspace], |
b0d3095f LB |
2620 | install_rpath : pkglibdir, |
2621 | install : true) | |
6164ec4c ZJS |
2622 | |
2623 | executable( | |
2624 | 'systemd-reply-password', | |
2625 | 'src/reply-password/reply-password.c', | |
2626 | include_directories : includes, | |
2627 | link_with : [libshared], | |
92148283 | 2628 | dependencies : userspace, |
b0d3095f | 2629 | install_rpath : pkglibdir, |
6164ec4c | 2630 | install : true, |
b0d3095f | 2631 | install_dir : libexecdir) |
6164ec4c ZJS |
2632 | |
2633 | public_programs += executable( | |
2634 | 'systemd-tty-ask-password-agent', | |
2635 | 'src/tty-ask-password-agent/tty-ask-password-agent.c', | |
2636 | include_directories : includes, | |
2637 | link_with : [libshared], | |
40c7d3c7 | 2638 | dependencies : [userspace], |
b0d3095f LB |
2639 | install_rpath : pkglibdir, |
2640 | install : true) | |
6164ec4c ZJS |
2641 | |
2642 | public_programs += executable( | |
2643 | 'systemd-cgls', | |
2644 | 'src/cgls/cgls.c', | |
2645 | include_directories : includes, | |
2646 | link_with : [libshared], | |
40c7d3c7 | 2647 | dependencies : [userspace], |
b0d3095f | 2648 | install_rpath : pkglibdir, |
6164ec4c ZJS |
2649 | install : true) |
2650 | ||
2651 | public_programs += executable( | |
2652 | 'systemd-cgtop', | |
2653 | 'src/cgtop/cgtop.c', | |
2654 | include_directories : includes, | |
2655 | link_with : [libshared], | |
40c7d3c7 | 2656 | dependencies : [userspace], |
b0d3095f | 2657 | install_rpath : pkglibdir, |
6164ec4c ZJS |
2658 | install : true) |
2659 | ||
2660 | executable( | |
2661 | 'systemd-initctl', | |
2662 | 'src/initctl/initctl.c', | |
2663 | include_directories : includes, | |
2664 | link_with : [libshared], | |
92148283 | 2665 | dependencies : userspace, |
b0d3095f | 2666 | install_rpath : pkglibdir, |
6589a569 | 2667 | install : (conf.get('HAVE_SYSV_COMPAT') == 1), |
b0d3095f | 2668 | install_dir : libexecdir) |
5c23128d | 2669 | |
6164ec4c ZJS |
2670 | public_programs += executable( |
2671 | 'systemd-mount', | |
2672 | 'src/mount/mount-tool.c', | |
2673 | include_directories : includes, | |
2674 | link_with : [libshared], | |
c47511da | 2675 | dependencies: [libmount, |
40c7d3c7 | 2676 | userspace], |
b0d3095f | 2677 | install_rpath : pkglibdir, |
6164ec4c | 2678 | install : true) |
5c23128d | 2679 | |
7b76fce1 | 2680 | meson.add_install_script(meson_make_symlink, |
fce9abb2 | 2681 | 'systemd-mount', bindir / 'systemd-umount') |
7b76fce1 | 2682 | |
6164ec4c ZJS |
2683 | public_programs += executable( |
2684 | 'systemd-run', | |
2685 | 'src/run/run.c', | |
2686 | include_directories : includes, | |
2687 | link_with : [libshared], | |
40c7d3c7 | 2688 | dependencies : [userspace], |
b0d3095f | 2689 | install_rpath : pkglibdir, |
6164ec4c ZJS |
2690 | install : true) |
2691 | ||
2692 | public_programs += executable( | |
2693 | 'systemd-stdio-bridge', | |
2694 | 'src/stdio-bridge/stdio-bridge.c', | |
2695 | include_directories : includes, | |
2696 | link_with : [libshared], | |
40c7d3c7 | 2697 | dependencies : [userspace], |
b0d3095f | 2698 | install_rpath : pkglibdir, |
6164ec4c ZJS |
2699 | install : true) |
2700 | ||
2701 | public_programs += executable( | |
2702 | 'busctl', | |
f98df767 | 2703 | busctl_sources, |
6164ec4c ZJS |
2704 | include_directories : includes, |
2705 | link_with : [libshared], | |
40c7d3c7 | 2706 | dependencies : [userspace], |
b0d3095f | 2707 | install_rpath : pkglibdir, |
6164ec4c | 2708 | install : true) |
5c23128d | 2709 | |
bd7e6aa7 ZJS |
2710 | if enable_sysusers |
2711 | exe = executable( | |
6164ec4c ZJS |
2712 | 'systemd-sysusers', |
2713 | 'src/sysusers/sysusers.c', | |
2714 | include_directories : includes, | |
2715 | link_with : [libshared], | |
40c7d3c7 | 2716 | dependencies : [userspace], |
b0d3095f LB |
2717 | install_rpath : pkglibdir, |
2718 | install : true) | |
bd7e6aa7 ZJS |
2719 | public_programs += exe |
2720 | ||
2721 | if want_tests != 'false' | |
2722 | test('test-sysusers', | |
2723 | test_sysusers_sh, | |
2724 | # https://github.com/mesonbuild/meson/issues/2681 | |
2725 | args : exe.full_path()) | |
2726 | endif | |
8ef8f3d5 | 2727 | |
b62ee354 ZJS |
2728 | exe = executable( |
2729 | 'systemd-sysusers.standalone', | |
2730 | 'src/sysusers/sysusers.c', | |
2731 | include_directories : includes, | |
2732 | c_args : '-DSTANDALONE', | |
2733 | link_with : [libshared_static, | |
2734 | libbasic, | |
2735 | libbasic_gcrypt, | |
2736 | libsystemd_static], | |
40c7d3c7 | 2737 | dependencies : [userspace], |
b62ee354 | 2738 | build_by_default: have_standalone_binaries, |
b0d3095f | 2739 | install : have_standalone_binaries) |
8ef8f3d5 | 2740 | if have_standalone_binaries |
bd7e6aa7 ZJS |
2741 | public_programs += exe |
2742 | ||
2743 | if want_tests != 'false' | |
2744 | test('test-sysusers.standalone', | |
2745 | test_sysusers_sh, | |
2746 | # https://github.com/mesonbuild/meson/issues/2681 | |
2747 | args : exe.full_path()) | |
2748 | endif | |
8ef8f3d5 | 2749 | endif |
5c23128d ZJS |
2750 | endif |
2751 | ||
349cc4a5 | 2752 | if conf.get('ENABLE_TMPFILES') == 1 |
6164ec4c ZJS |
2753 | exe = executable( |
2754 | 'systemd-tmpfiles', | |
db64ba81 | 2755 | systemd_tmpfiles_sources, |
6164ec4c ZJS |
2756 | include_directories : includes, |
2757 | link_with : [libshared], | |
c47511da | 2758 | dependencies : [libacl, |
40c7d3c7 | 2759 | userspace], |
b0d3095f LB |
2760 | install_rpath : pkglibdir, |
2761 | install : true) | |
5a8b1640 | 2762 | public_programs += exe |
d9daae55 | 2763 | |
938be089 ZJS |
2764 | if want_tests != 'false' |
2765 | test('test-systemd-tmpfiles', | |
2766 | test_systemd_tmpfiles_py, | |
2767 | # https://github.com/mesonbuild/meson/issues/2681 | |
2768 | args : exe.full_path()) | |
2769 | endif | |
db64ba81 | 2770 | |
b62ee354 ZJS |
2771 | exe = executable( |
2772 | 'systemd-tmpfiles.standalone', | |
2773 | systemd_tmpfiles_sources, | |
2774 | include_directories : includes, | |
2775 | c_args : '-DSTANDALONE', | |
2776 | link_with : [libshared_static, | |
2777 | libbasic, | |
2778 | libbasic_gcrypt, | |
2779 | libsystemd_static], | |
2780 | dependencies : [libacl, | |
40c7d3c7 | 2781 | userspace], |
b62ee354 | 2782 | build_by_default: have_standalone_binaries, |
b0d3095f | 2783 | install : have_standalone_binaries) |
db64ba81 | 2784 | if have_standalone_binaries |
bf93f24a MG |
2785 | public_programs += exe |
2786 | ||
2787 | if want_tests != 'false' | |
2788 | test('test-systemd-tmpfiles.standalone', | |
2789 | test_systemd_tmpfiles_py, | |
2790 | # https://github.com/mesonbuild/meson/issues/2681 | |
2791 | args : exe.full_path()) | |
2792 | endif | |
db64ba81 | 2793 | endif |
5c23128d ZJS |
2794 | endif |
2795 | ||
349cc4a5 | 2796 | if conf.get('ENABLE_HWDB') == 1 |
ecd1bfdd | 2797 | systemd_hwdb = executable( |
6164ec4c ZJS |
2798 | 'systemd-hwdb', |
2799 | 'src/hwdb/hwdb.c', | |
6164ec4c | 2800 | include_directories : includes, |
e4b127e2 | 2801 | link_with : udev_link_with, |
40c7d3c7 | 2802 | dependencies : [userspace], |
6164ec4c | 2803 | install_rpath : udev_rpath, |
b0d3095f | 2804 | install : true) |
ecd1bfdd ZJS |
2805 | public_programs += systemd_hwdb |
2806 | ||
2807 | if want_tests != 'false' | |
2808 | test('hwdb-test', | |
2809 | hwdb_test_sh, | |
02e0f430 | 2810 | suite : 'dist', |
ecd1bfdd ZJS |
2811 | args : [systemd_hwdb.full_path()], |
2812 | timeout : 90) | |
2813 | endif | |
37efbbd8 ZJS |
2814 | endif |
2815 | ||
349cc4a5 | 2816 | if conf.get('ENABLE_QUOTACHECK') == 1 |
6164ec4c ZJS |
2817 | executable( |
2818 | 'systemd-quotacheck', | |
2819 | 'src/quotacheck/quotacheck.c', | |
2820 | include_directories : includes, | |
2821 | link_with : [libshared], | |
92148283 | 2822 | dependencies : userspace, |
b0d3095f | 2823 | install_rpath : pkglibdir, |
6164ec4c | 2824 | install : true, |
b0d3095f | 2825 | install_dir : libexecdir) |
6164ec4c ZJS |
2826 | endif |
2827 | ||
2828 | public_programs += executable( | |
2829 | 'systemd-socket-proxyd', | |
2830 | 'src/socket-proxy/socket-proxyd.c', | |
2831 | include_directories : includes, | |
2832 | link_with : [libshared], | |
c47511da | 2833 | dependencies : [threads, |
40c7d3c7 | 2834 | userspace], |
b0d3095f | 2835 | install_rpath : pkglibdir, |
6164ec4c | 2836 | install : true, |
b0d3095f | 2837 | install_dir : libexecdir) |
5c23128d | 2838 | |
9b264c1d | 2839 | udevadm = executable( |
6164ec4c ZJS |
2840 | 'udevadm', |
2841 | udevadm_sources, | |
6164ec4c | 2842 | include_directories : includes, |
e4b127e2 | 2843 | link_with : [libudevd_core], |
92148283 | 2844 | dependencies : [libacl, |
c47511da | 2845 | libblkid, |
92148283 JJ |
2846 | libidn, |
2847 | libkmod, | |
2848 | threads, | |
40c7d3c7 | 2849 | userspace], |
6164ec4c | 2850 | install_rpath : udev_rpath, |
b0d3095f | 2851 | install : true) |
9b264c1d FS |
2852 | public_programs += udevadm |
2853 | ||
9382642c DL |
2854 | if want_tests != 'false' |
2855 | test('udev-rules-check', | |
2856 | udevadm, | |
02e0f430 | 2857 | suite : 'dist', |
9382642c DL |
2858 | args : ['verify', '--resolve-names=never', all_rules]) |
2859 | endif | |
2860 | ||
6164ec4c ZJS |
2861 | executable( |
2862 | 'systemd-shutdown', | |
2863 | systemd_shutdown_sources, | |
2864 | include_directories : includes, | |
bac11cd6 | 2865 | link_with : [libshared], |
c47511da | 2866 | dependencies : [libmount, |
40c7d3c7 | 2867 | userspace], |
b0d3095f | 2868 | install_rpath : pkglibdir, |
6164ec4c | 2869 | install : true, |
b0d3095f | 2870 | install_dir : libexecdir) |
6164ec4c | 2871 | |
b62ee354 ZJS |
2872 | executable( |
2873 | 'systemd-shutdown.standalone', | |
2874 | systemd_shutdown_sources, | |
2875 | include_directories : includes, | |
2876 | c_args : '-DSTANDALONE', | |
2877 | link_with : [libshared_static, | |
2878 | libbasic, | |
2879 | libsystemd_static], | |
2880 | dependencies : [libmount, | |
40c7d3c7 | 2881 | userspace], |
b62ee354 | 2882 | build_by_default: have_standalone_binaries, |
b0d3095f | 2883 | install_rpath : pkglibdir, |
b62ee354 | 2884 | install : have_standalone_binaries, |
b0d3095f | 2885 | install_dir : libexecdir) |
6ed3aca5 | 2886 | |
6164ec4c ZJS |
2887 | executable( |
2888 | 'systemd-update-done', | |
2889 | 'src/update-done/update-done.c', | |
2890 | include_directories : includes, | |
2891 | link_with : [libshared], | |
40c7d3c7 | 2892 | dependencies : [userspace], |
b0d3095f | 2893 | install_rpath : pkglibdir, |
6164ec4c | 2894 | install : true, |
b0d3095f | 2895 | install_dir : libexecdir) |
6164ec4c ZJS |
2896 | |
2897 | executable( | |
2898 | 'systemd-update-utmp', | |
2899 | 'src/update-utmp/update-utmp.c', | |
2900 | include_directories : includes, | |
2901 | link_with : [libshared], | |
c47511da | 2902 | dependencies : [libaudit, |
40c7d3c7 | 2903 | userspace], |
b0d3095f | 2904 | install_rpath : pkglibdir, |
55678b9e | 2905 | install : (conf.get('ENABLE_UTMP') == 1), |
b0d3095f | 2906 | install_dir : libexecdir) |
5c23128d | 2907 | |
349cc4a5 | 2908 | if conf.get('HAVE_KMOD') == 1 |
6164ec4c ZJS |
2909 | executable( |
2910 | 'systemd-modules-load', | |
2911 | 'src/modules-load/modules-load.c', | |
2912 | include_directories : includes, | |
2913 | link_with : [libshared], | |
c47511da | 2914 | dependencies : [libkmod, |
40c7d3c7 | 2915 | userspace], |
b0d3095f | 2916 | install_rpath : pkglibdir, |
6164ec4c | 2917 | install : true, |
b0d3095f | 2918 | install_dir : libexecdir) |
94e75a54 | 2919 | |
7c22f07c ZJS |
2920 | meson.add_install_script('sh', '-c', |
2921 | mkdir_p.format(modulesloaddir)) | |
d7aa78c3 | 2922 | if install_sysconfdir |
7c22f07c | 2923 | meson.add_install_script('sh', '-c', |
fce9abb2 | 2924 | mkdir_p.format(sysconfdir / 'modules-load.d')) |
d7aa78c3 | 2925 | endif |
5c23128d ZJS |
2926 | endif |
2927 | ||
6164ec4c ZJS |
2928 | public_programs += executable( |
2929 | 'systemd-nspawn', | |
2930 | systemd_nspawn_sources, | |
2931 | include_directories : includes, | |
bac11cd6 | 2932 | link_with : [libnspawn_core, |
6164ec4c ZJS |
2933 | libshared], |
2934 | dependencies : [libblkid, | |
c47511da | 2935 | libseccomp, |
40c7d3c7 | 2936 | userspace], |
b0d3095f | 2937 | install_rpath : pkglibdir, |
6164ec4c | 2938 | install : true) |
5c23128d | 2939 | |
349cc4a5 | 2940 | if conf.get('ENABLE_NETWORKD') == 1 |
9ff2b35f | 2941 | dbus_programs += executable( |
6164ec4c ZJS |
2942 | 'systemd-networkd', |
2943 | systemd_networkd_sources, | |
8d40961c | 2944 | include_directories : network_includes, |
6164ec4c ZJS |
2945 | link_with : [libnetworkd_core, |
2946 | libsystemd_network, | |
6164ec4c | 2947 | networkd_link_with], |
c47511da | 2948 | dependencies : [threads, |
40c7d3c7 | 2949 | userspace], |
b0d3095f | 2950 | install_rpath : pkglibdir, |
6164ec4c | 2951 | install : true, |
b0d3095f | 2952 | install_dir : libexecdir) |
6164ec4c | 2953 | |
3761002e | 2954 | public_programs += executable( |
6164ec4c ZJS |
2955 | 'systemd-networkd-wait-online', |
2956 | systemd_networkd_wait_online_sources, | |
2957 | include_directories : includes, | |
8d40961c | 2958 | link_with : [networkd_link_with], |
40c7d3c7 | 2959 | dependencies : [userspace], |
b0d3095f | 2960 | install_rpath : pkglibdir, |
6164ec4c | 2961 | install : true, |
b0d3095f | 2962 | install_dir : libexecdir) |
6164ec4c ZJS |
2963 | |
2964 | public_programs += executable( | |
2965 | 'networkctl', | |
2966 | networkctl_sources, | |
8d40961c | 2967 | include_directories : libsystemd_network_includes, |
6164ec4c ZJS |
2968 | link_with : [libsystemd_network, |
2969 | networkd_link_with], | |
40c7d3c7 | 2970 | dependencies : [userspace], |
b0d3095f LB |
2971 | install_rpath : pkglibdir, |
2972 | install : true) | |
987dd89c | 2973 | endif |
6164ec4c | 2974 | |
987dd89c YW |
2975 | exe = executable( |
2976 | 'systemd-network-generator', | |
2977 | network_generator_sources, | |
2978 | include_directories : includes, | |
2979 | link_with : [networkd_link_with], | |
40c7d3c7 | 2980 | dependencies : [userspace], |
b0d3095f | 2981 | install_rpath : pkglibdir, |
987dd89c | 2982 | install : true, |
b0d3095f | 2983 | install_dir : libexecdir) |
fbaa1137 | 2984 | |
987dd89c YW |
2985 | if want_tests != 'false' |
2986 | test('test-network-generator-conversion', | |
2987 | test_network_generator_conversion_sh, | |
2988 | # https://github.com/mesonbuild/meson/issues/2681 | |
e93ada98 DDM |
2989 | args : exe.full_path(), |
2990 | depends : exe) | |
dcfe072a | 2991 | endif |
e821f6a9 | 2992 | |
6164ec4c ZJS |
2993 | executable( |
2994 | 'systemd-sulogin-shell', | |
73e994f2 | 2995 | 'src/sulogin-shell/sulogin-shell.c', |
6164ec4c ZJS |
2996 | include_directories : includes, |
2997 | link_with : [libshared], | |
40c7d3c7 | 2998 | dependencies : [userspace], |
b0d3095f | 2999 | install_rpath : pkglibdir, |
6164ec4c | 3000 | install : true, |
b0d3095f | 3001 | install_dir : libexecdir) |
e821f6a9 | 3002 | |
42551ea7 | 3003 | kernel_install = executable( |
99d8cbce | 3004 | 'kernel-install', |
42551ea7 YW |
3005 | 'src/kernel-install/kernel-install.c', |
3006 | include_directories : includes, | |
3007 | link_with : [libshared], | |
40c7d3c7 | 3008 | dependencies : [userspace], |
b0d3095f LB |
3009 | install_rpath : pkglibdir, |
3010 | install : want_kernel_install) | |
42551ea7 | 3011 | public_programs += kernel_install |
f875e6bc | 3012 | |
f9a6cb0e | 3013 | ukify = custom_target( |
30ec2eae ZJS |
3014 | 'ukify', |
3015 | input : 'src/ukify/ukify.py', | |
3016 | output : 'ukify', | |
3017 | command : [jinja2_cmdline, '@INPUT@', '@OUTPUT@'], | |
9a01fe39 | 3018 | install : want_ukify, |
30ec2eae | 3019 | install_mode : 'rwxr-xr-x', |
b0d3095f | 3020 | install_dir : libexecdir) |
9a01fe39 | 3021 | if want_ukify |
42551ea7 | 3022 | public_programs += ukify |
f9a6cb0e ZJS |
3023 | endif |
3024 | ||
3025 | if want_tests != 'false' and want_kernel_install | |
42551ea7 YW |
3026 | args = [kernel_install.full_path(), loaderentry_install.full_path(), uki_copy_install] |
3027 | deps = [kernel_install, loaderentry_install] | |
3f80c139 | 3028 | if want_ukify and boot_stubs.length() > 0 |
42551ea7 YW |
3029 | args += [ukify.full_path(), ukify_install.full_path(), boot_stubs[0]] |
3030 | deps += [ukify, ukify_install, boot_stubs[0]] | |
f9a6cb0e ZJS |
3031 | endif |
3032 | ||
3033 | test('test-kernel-install', | |
3034 | test_kernel_install_sh, | |
3035 | env : test_env, | |
42551ea7 YW |
3036 | args : args, |
3037 | depends: deps) | |
30ec2eae ZJS |
3038 | endif |
3039 | ||
69e96427 ZJS |
3040 | ############################################################ |
3041 | ||
e93ada98 | 3042 | runtest_env = custom_target( |
e2d41370 FB |
3043 | 'systemd-runtest.env', |
3044 | output : 'systemd-runtest.env', | |
0f4c4f38 ZJS |
3045 | command : [sh, '-c', |
3046 | '{ echo SYSTEMD_TEST_DATA=@0@; echo SYSTEMD_CATALOG_DIR=@1@; } >@OUTPUT@'.format( | |
fce9abb2 ZJS |
3047 | project_source_root / 'test', |
3048 | project_build_root / 'catalog')], | |
e93ada98 | 3049 | depends : catalogs, |
e2d41370 FB |
3050 | build_by_default : true) |
3051 | ||
a626cb15 ZJS |
3052 | test_cflags = ['-DTEST_CODE=1'] |
3053 | # We intentionally do not do inline initializations with definitions for a | |
3054 | # bunch of _cleanup_ variables in tests, to ensure valgrind is triggered if we | |
3055 | # use the variable unexpectedly. This triggers a lot of maybe-uninitialized | |
3056 | # false positives when the combination of -O2 and -flto is used. Suppress them. | |
b528a628 | 3057 | if '-O2' in c_args and '-flto=auto' in c_args |
a626cb15 ZJS |
3058 | test_cflags += cc.first_supported_argument('-Wno-maybe-uninitialized') |
3059 | endif | |
3060 | ||
c12e10d7 | 3061 | foreach test : simple_tests |
822cd3ff | 3062 | tests += { 'sources' : [test] } |
c12e10d7 JJ |
3063 | endforeach |
3064 | ||
0454cf05 | 3065 | TESTS = {} |
822cd3ff JJ |
3066 | foreach test : tests |
3067 | sources = test.get('sources') | |
3068 | condition = test.get('condition', '') | |
3069 | type = test.get('type', '') | |
3070 | base = test.get('base', {}) | |
92148283 JJ |
3071 | deps = [ |
3072 | base.get('dependencies', []), | |
3073 | test.get('dependencies', []), | |
92148283 | 3074 | ] |
37efbbd8 | 3075 | |
c20d2914 | 3076 | name = fs.name(sources[0]) |
40c7d3c7 YW |
3077 | if name.endswith('.cc') |
3078 | deps += [versiondep] | |
3079 | else | |
92148283 JJ |
3080 | deps += [userspace] |
3081 | endif | |
c20d2914 | 3082 | name = fs.stem(name) |
3b2bdd62 | 3083 | |
ff5becf5 | 3084 | suite = fs.name(fs.parent(sources[0])).replace('sd-', '') |
c3191c6d | 3085 | |
822cd3ff | 3086 | if condition != '' and conf.get(condition) == 0 |
37efbbd8 | 3087 | message('Not compiling @0@ because @1@ is not true'.format(name, condition)) |
822cd3ff JJ |
3088 | continue |
3089 | endif | |
3090 | ||
3091 | exe = executable( | |
3092 | name, | |
3093 | sources, | |
3094 | include_directories : [base.get('includes', []), test.get('includes', includes)], | |
3095 | link_with : [base.get('link_with', []), test.get('link_with', libshared)], | |
92148283 | 3096 | dependencies : deps, |
822cd3ff JJ |
3097 | c_args : [test_cflags, test.get('c_args', [])], |
3098 | build_by_default : want_tests != 'false', | |
b0d3095f | 3099 | install_rpath : pkglibdir, |
822cd3ff | 3100 | install : install_tests, |
26c2b302 | 3101 | install_dir : unittestsdir / type, |
822cd3ff JJ |
3102 | link_depends : runtest_env) |
3103 | ||
3104 | if type == 'manual' | |
3105 | message('@0@ is a manual test'.format(name)) | |
3106 | elif type == 'unsafe' and want_tests != 'unsafe' | |
3107 | message('@0@ is an unsafe test'.format(name)) | |
3108 | elif want_tests != 'false' | |
3109 | test(name, exe, | |
b0bd2ae8 ZJS |
3110 | env : test_env, |
3111 | timeout : test.get('timeout', 30), | |
3112 | suite : suite, | |
3113 | is_parallel : test.get('parallel', true)) | |
37efbbd8 | 3114 | endif |
0454cf05 ZJS |
3115 | |
3116 | TESTS += { name : exe } | |
69e96427 ZJS |
3117 | endforeach |
3118 | ||
0632b4cd | 3119 | exe = executable( |
37efbbd8 ZJS |
3120 | 'test-libsystemd-sym', |
3121 | test_libsystemd_sym_c, | |
3122 | include_directories : includes, | |
3123 | link_with : [libsystemd], | |
92148283 | 3124 | dependencies : userspace, |
fd1939fb | 3125 | build_by_default : want_tests != 'false', |
37efbbd8 | 3126 | install : install_tests, |
26c2b302 | 3127 | install_dir : unittestsdir) |
938be089 ZJS |
3128 | if want_tests != 'false' |
3129 | test('test-libsystemd-sym', exe) | |
3130 | endif | |
37ab1a25 | 3131 | |
0632b4cd ZJS |
3132 | exe = executable( |
3133 | 'test-libsystemd-static-sym', | |
3134 | test_libsystemd_sym_c, | |
3135 | include_directories : includes, | |
0632b4cd | 3136 | link_with : [install_libsystemd_static], |
92148283 JJ |
3137 | dependencies : [ |
3138 | # threads is already included in dependencies on the library, | |
3139 | # but does not seem to get propagated. Add here as a work-around. | |
3140 | threads, | |
3141 | userspace, | |
3142 | ], | |
d37dee74 YW |
3143 | build_by_default : want_tests != 'false' and static_libsystemd != 'false', |
3144 | install : install_tests and static_libsystemd != 'false', | |
26c2b302 | 3145 | install_dir : unittestsdir) |
d37dee74 | 3146 | if want_tests != 'false' and static_libsystemd != 'false' |
0632b4cd ZJS |
3147 | test('test-libsystemd-static-sym', exe) |
3148 | endif | |
37ab1a25 | 3149 | |
0632b4cd | 3150 | exe = executable( |
37efbbd8 ZJS |
3151 | 'test-libudev-sym', |
3152 | test_libudev_sym_c, | |
e4b127e2 | 3153 | include_directories : libudev_includes, |
a626cb15 | 3154 | c_args : ['-Wno-deprecated-declarations'] + test_cflags, |
37efbbd8 | 3155 | link_with : [libudev], |
92148283 | 3156 | dependencies : userspace, |
fd1939fb | 3157 | build_by_default : want_tests != 'false', |
37efbbd8 | 3158 | install : install_tests, |
26c2b302 | 3159 | install_dir : unittestsdir) |
938be089 ZJS |
3160 | if want_tests != 'false' |
3161 | test('test-libudev-sym', exe) | |
3162 | endif | |
0632b4cd ZJS |
3163 | |
3164 | exe = executable( | |
3165 | 'test-libudev-static-sym', | |
3166 | test_libudev_sym_c, | |
e4b127e2 | 3167 | include_directories : libudev_includes, |
a626cb15 | 3168 | c_args : ['-Wno-deprecated-declarations'] + test_cflags, |
0632b4cd | 3169 | link_with : [install_libudev_static], |
92148283 | 3170 | dependencies : userspace, |
d37dee74 YW |
3171 | build_by_default : want_tests != 'false' and static_libudev != 'false', |
3172 | install : install_tests and static_libudev != 'false', | |
26c2b302 | 3173 | install_dir : unittestsdir) |
d37dee74 | 3174 | if want_tests != 'false' and static_libudev != 'false' |
0632b4cd ZJS |
3175 | test('test-libudev-static-sym', exe) |
3176 | endif | |
e0bec52f | 3177 | |
0454cf05 | 3178 | if want_tests != 'false' |
67b1c943 | 3179 | exe = TESTS.get('udev-rule-runner') |
0454cf05 ZJS |
3180 | test('test-udev', |
3181 | test_udev_py, | |
3182 | args : ['-v'], | |
67b1c943 YW |
3183 | env : ['UDEV_RULE_RUNNER=' + exe.full_path()], |
3184 | depends : exe, | |
0454cf05 ZJS |
3185 | timeout : 180) |
3186 | endif | |
3187 | ||
69e96427 | 3188 | ############################################################ |
5c23128d | 3189 | |
a9a7153c | 3190 | foreach fuzzer : simple_fuzzers |
2ed35b2f | 3191 | fuzzers += { 'sources' : [fuzzer] } |
a9a7153c JJ |
3192 | endforeach |
3193 | ||
7db7d5b7 JR |
3194 | fuzzer_exes = [] |
3195 | ||
2ed35b2f JJ |
3196 | foreach fuzzer : fuzzers |
3197 | sources = fuzzer.get('sources') | |
3198 | base = fuzzer.get('base', {}) | |
3199 | dependencies = [base.get('dependencies', []), fuzzer.get('dependencies', [])] | |
7e299ffe ZJS |
3200 | link_args = [] |
3201 | ||
3202 | if want_ossfuzz | |
3203 | dependencies += fuzzing_engine | |
3204 | elif want_libfuzzer | |
3205 | if fuzzing_engine.found() | |
9c5c4677 EV |
3206 | dependencies += fuzzing_engine |
3207 | else | |
7e299ffe | 3208 | link_args += ['-fsanitize=fuzzer'] |
9c5c4677 | 3209 | endif |
7e299ffe | 3210 | else |
2ed35b2f | 3211 | sources += files('src/fuzz/fuzz-main.c') |
7e299ffe | 3212 | endif |
7e343b53 | 3213 | sources += fuzz_generated_directives |
7db7d5b7 | 3214 | |
ff5becf5 | 3215 | name = fs.stem(sources[0]) |
7db7d5b7 | 3216 | |
f78ad5f0 | 3217 | exe = executable( |
7e299ffe ZJS |
3218 | name, |
3219 | sources, | |
2ed35b2f JJ |
3220 | include_directories : [ |
3221 | base.get('includes', []), | |
3222 | fuzzer.get('includes', includes), | |
3223 | include_directories('src/fuzz'), | |
3224 | ], | |
3225 | link_with : [base.get('link_with', []), fuzzer.get('link_with', libshared)], | |
92148283 JJ |
3226 | dependencies : [ |
3227 | dependencies, | |
3228 | userspace, | |
92148283 | 3229 | ], |
2ed35b2f | 3230 | c_args : [test_cflags, fuzzer.get('c_args', [])], |
7e299ffe ZJS |
3231 | link_args: link_args, |
3232 | install : false, | |
f78ad5f0 ZJS |
3233 | build_by_default : fuzzer_build) |
3234 | fuzzer_exes += exe | |
3235 | ||
7db5761d | 3236 | if want_tests != 'false' and name in fuzz_regression_tests |
f78ad5f0 ZJS |
3237 | # Run the fuzz regression tests without any sanitizers enabled. |
3238 | # Additional invocations with sanitizers may be added below. | |
7e343b53 MK |
3239 | foreach tuple : fuzz_regression_tests[name] |
3240 | fuzz_dir = tuple[0] | |
3241 | fuzz_in = tuple[1] | |
7db5761d MK |
3242 | test('@0@_@1@'.format(name, fuzz_in), |
3243 | exe, | |
ec2c6ac0 | 3244 | suite : 'fuzz', |
7e343b53 MK |
3245 | args : [fuzz_dir != '' ? project_source_root / fuzz_dir / name / fuzz_in |
3246 | : fuzz_generated_in_dir / '@0@_@1@'.format(name, fuzz_in)]) | |
f78ad5f0 ZJS |
3247 | endforeach |
3248 | endif | |
7e299ffe | 3249 | endforeach |
7db7d5b7 | 3250 | |
6839ce33 | 3251 | alias_target('fuzzers', fuzzer_exes) |
7db7d5b7 JR |
3252 | |
3253 | ############################################################ | |
3254 | ||
10783aef ZJS |
3255 | subdir('docs/sysvinit') |
3256 | subdir('docs/var-log') | |
3257 | subdir('hwdb.d') | |
3258 | subdir('man') | |
378e9d2b | 3259 | subdir('modprobe.d') |
10783aef ZJS |
3260 | subdir('network') |
3261 | subdir('presets') | |
3262 | subdir('shell-completion/bash') | |
3263 | subdir('shell-completion/zsh') | |
5c23128d ZJS |
3264 | subdir('sysctl.d') |
3265 | subdir('sysusers.d') | |
3266 | subdir('tmpfiles.d') | |
4f10b807 | 3267 | subdir('units') |
5c23128d | 3268 | |
5c23128d ZJS |
3269 | install_subdir('factory/etc', |
3270 | install_dir : factorydir) | |
623370e6 | 3271 | subdir('factory/templates') |
5c23128d | 3272 | |
d7aa78c3 JT |
3273 | if install_sysconfdir |
3274 | install_data('xorg/50-systemd-user.sh', | |
3275 | install_dir : xinitrcdir) | |
3276 | endif | |
f09eb768 | 3277 | install_data('LICENSE.GPL2', |
5c23128d | 3278 | 'LICENSE.LGPL2.1', |
f09eb768 LP |
3279 | 'NEWS', |
3280 | 'README', | |
eea98402 | 3281 | 'docs/CODING_STYLE.md', |
1d1cb168 | 3282 | 'docs/DISTRO_PORTING.md', |
9e825ebf | 3283 | 'docs/ENVIRONMENT.md', |
5425f8a5 | 3284 | 'docs/HACKING.md', |
9e825ebf | 3285 | 'docs/TRANSIENT-SETTINGS.md', |
b6dc0d7d | 3286 | 'docs/TRANSLATORS.md', |
9e825ebf | 3287 | 'docs/UIDS-GIDS.md', |
5c23128d | 3288 | install_dir : docdir) |
d68b342b | 3289 | |
9c6e32a2 LB |
3290 | install_subdir('LICENSES', |
3291 | install_dir : docdir) | |
3292 | ||
7c22f07c ZJS |
3293 | meson.add_install_script('sh', '-c', mkdir_p.format(systemdstatedir)) |
3294 | meson.add_install_script('sh', '-c', 'touch $DESTDIR@0@'.format(prefixdir)) | |
94e75a54 | 3295 | |
d68b342b ZJS |
3296 | ############################################################ |
3297 | ||
2d4efd1d LB |
3298 | # Ensure that changes to the docs/ directory do not break the |
3299 | # basic Github pages build. But only run it in developer mode, | |
3300 | # as it might be fragile due to changes in the tooling, and it is | |
3301 | # not generally useful for users. | |
3302 | jekyll = find_program('jekyll', required : false) | |
3303 | if get_option('mode') == 'developer' and want_tests != 'false' and jekyll.found() | |
3304 | test('github-pages', | |
3305 | jekyll, | |
02e0f430 | 3306 | suite : 'dist', |
2d4efd1d | 3307 | args : ['build', |
fce9abb2 ZJS |
3308 | '--source', project_source_root / 'docs', |
3309 | '--destination', project_build_root / '_site']) | |
2d4efd1d LB |
3310 | endif |
3311 | ||
3312 | ############################################################ | |
3313 | ||
dd1e33c8 | 3314 | check_help = find_program('tools/check-help.sh') |
ffb7406b | 3315 | check_version = find_program('tools/check-version.sh') |
005a29f2 ZJS |
3316 | |
3317 | foreach exec : public_programs | |
739a62bb | 3318 | name = fs.name(exec.full_path()) |
938be089 ZJS |
3319 | if want_tests != 'false' |
3320 | test('check-help-' + name, | |
dd1e33c8 | 3321 | check_help, |
02e0f430 | 3322 | suite : 'dist', |
e93ada98 DDM |
3323 | args : exec.full_path(), |
3324 | depends: exec) | |
ffb7406b ZJS |
3325 | |
3326 | test('check-version-' + name, | |
3327 | check_version, | |
02e0f430 | 3328 | suite : 'dist', |
ffb7406b ZJS |
3329 | args : [exec.full_path(), |
3330 | meson.project_version()], | |
3331 | depends: exec) | |
938be089 | 3332 | endif |
005a29f2 ZJS |
3333 | endforeach |
3334 | ||
52d4d1d3 | 3335 | # Enable tests for all supported sanitizers |
7db5761d | 3336 | foreach tuple : fuzz_sanitizers |
52d4d1d3 ZJS |
3337 | sanitizer = tuple[0] |
3338 | build = tuple[1] | |
b68dfb9e | 3339 | |
7a6397d2 | 3340 | if cc.has_link_argument('-fsanitize=@0@'.format(sanitizer)) |
7db5761d MK |
3341 | foreach fuzzer, fuzz_ins : fuzz_regression_tests |
3342 | name = '@0@:@1@'.format(fuzzer, sanitizer) | |
3343 | if want_tests == 'false' | |
3344 | message('Not compiling @0@ because tests is set to false'.format(name)) | |
3345 | continue | |
52d4d1d3 | 3346 | endif |
7db5761d MK |
3347 | if not fuzz_tests |
3348 | message('Not compiling @0@ because fuzz-tests is set to false'.format(name)) | |
3349 | continue | |
3350 | endif | |
3351 | exe = custom_target( | |
3352 | name, | |
3353 | output : name, | |
7e343b53 | 3354 | depends : [build] + fuzz_generated_directives, |
7db5761d MK |
3355 | command : [ln, '-fs', |
3356 | build.full_path() / fuzzer, | |
3357 | '@OUTPUT@'], | |
3358 | build_by_default : true) | |
3359 | ||
7e343b53 MK |
3360 | foreach tuple : fuzz_ins |
3361 | fuzz_dir = tuple[0] | |
3362 | fuzz_in = tuple[1] | |
3363 | ||
7db5761d | 3364 | test('@0@_@1@_@2@'.format(fuzzer, fuzz_in, sanitizer), |
52d4d1d3 | 3365 | env, |
14056a52 | 3366 | suite : 'fuzz+san', |
89767158 EV |
3367 | env : ['UBSAN_OPTIONS=print_stacktrace=1:print_summary=1:halt_on_error=1'], |
3368 | timeout : 60, | |
52d4d1d3 | 3369 | args : [exe.full_path(), |
7e343b53 MK |
3370 | fuzz_dir != '' ? project_source_root / fuzz_dir / fuzzer / fuzz_in |
3371 | : fuzz_generated_in_dir / '@0@_@1@'.format(fuzzer, fuzz_in)]) | |
7db5761d | 3372 | endforeach |
52d4d1d3 | 3373 | endforeach |
b68dfb9e ZJS |
3374 | endif |
3375 | endforeach | |
3376 | ||
3377 | ############################################################ | |
3378 | ||
0700e8ba | 3379 | if git.found() |
37efbbd8 | 3380 | all_files = run_command( |
0f4c4f38 ZJS |
3381 | env, '-u', 'GIT_WORK_TREE', |
3382 | git, '--git-dir=@0@/.git'.format(project_source_root), | |
ba9ca60a | 3383 | 'ls-files', ':/*.[ch]', ':/*.cc', |
e92777d2 ZJS |
3384 | check : false) |
3385 | if all_files.returncode() == 0 | |
3386 | all_files = files(all_files.stdout().split()) | |
3387 | ||
3388 | custom_target( | |
3389 | 'tags', | |
3390 | output : 'tags', | |
3391 | command : [env, 'etags', '-o', '@0@/TAGS'.format(project_source_root)] + all_files) | |
3392 | run_target( | |
3393 | 'ctags', | |
691db9a7 | 3394 | command : [env, 'ctags', '--tag-relative=never', '-o', '@0@/tags'.format(project_source_root)] + all_files) |
60892358 ZJS |
3395 | |
3396 | ############################################ | |
3397 | ||
3398 | if want_tests != 'false' and conf.get('BUILD_MODE_DEVELOPER') == 1 | |
3399 | test('check-includes', | |
3400 | files('tools/check-includes.py'), | |
3401 | args: all_files, | |
3402 | env : ['PROJECT_SOURCE_ROOT=@0@'.format(project_source_root)]) | |
3403 | endif | |
e92777d2 | 3404 | endif |
177929c2 | 3405 | |
60892358 ZJS |
3406 | #################################################### |
3407 | ||
dd1e33c8 | 3408 | git_contrib_sh = find_program('tools/git-contrib.sh') |
a923e085 | 3409 | run_target( |
37efbbd8 | 3410 | 'git-contrib', |
dd1e33c8 | 3411 | command : [git_contrib_sh]) |
dd6ab3df | 3412 | |
60892358 ZJS |
3413 | #################################################### |
3414 | ||
dd6ab3df | 3415 | git_head = run_command( |
e92777d2 ZJS |
3416 | git, '--git-dir=@0@/.git'.format(project_source_root), |
3417 | 'rev-parse', 'HEAD', | |
3418 | check : false).stdout().strip() | |
dd6ab3df | 3419 | git_head_short = run_command( |
e92777d2 ZJS |
3420 | git, '--git-dir=@0@/.git'.format(project_source_root), |
3421 | 'rev-parse', '--short=7', 'HEAD', | |
3422 | check : false).stdout().strip() | |
dd6ab3df ZJS |
3423 | |
3424 | run_target( | |
3425 | 'git-snapshot', | |
0f4c4f38 | 3426 | command : [git, 'archive', |
1485aacb | 3427 | '-o', '@0@/systemd-@1@.tar.gz'.format(project_source_root, |
dd6ab3df ZJS |
3428 | git_head_short), |
3429 | '--prefix', 'systemd-@0@/'.format(git_head), | |
3430 | 'HEAD']) | |
3431 | endif | |
829257d1 ZJS |
3432 | |
3433 | ############################################################ | |
3434 | ||
dd1e33c8 | 3435 | check_api_docs_sh = find_program('tools/check-api-docs.sh') |
51b13863 LP |
3436 | run_target( |
3437 | 'check-api-docs', | |
3438 | depends : [man, libsystemd, libudev], | |
dd1e33c8 | 3439 | command : [check_api_docs_sh, libsystemd.full_path(), libudev.full_path()]) |
51b13863 | 3440 | |
f12c5d36 ZJS |
3441 | alias_target('update-dbus-docs', update_dbus_docs) |
3442 | alias_target('update-man-rules', update_man_rules) | |
e3c368f6 | 3443 | |
0628d48e LB |
3444 | if not meson.is_cross_build() |
3445 | custom_target( | |
3446 | 'export-dbus-interfaces', | |
4645074e | 3447 | output : fs.name(dbus_interfaces_dir), |
0628d48e | 3448 | install : dbus_interfaces_dir != 'no', |
4645074e | 3449 | install_dir : fs.parent(dbus_interfaces_dir), |
0628d48e LB |
3450 | command : [export_dbus_interfaces_py, '@OUTPUT@', dbus_programs]) |
3451 | endif | |
e3c68924 | 3452 | |
51b13863 | 3453 | ############################################################ |
829257d1 | 3454 | |
e92777d2 ZJS |
3455 | alt_time_epoch = run_command('date', '-Is', '-u', '-d', '@@0@'.format(time_epoch), |
3456 | check : true).stdout().strip() | |
12085ebb ZJS |
3457 | |
3458 | summary({ | |
12085ebb ZJS |
3459 | 'split bin-sbin' : split_bin, |
3460 | 'prefix directory' : prefixdir, | |
12085ebb ZJS |
3461 | 'sysconf directory' : sysconfdir, |
3462 | 'include directory' : includedir, | |
3463 | 'lib directory' : libdir, | |
12085ebb ZJS |
3464 | 'SysV init scripts' : sysvinit_path, |
3465 | 'SysV rc?.d directories' : sysvrcnd_path, | |
3466 | 'PAM modules directory' : pamlibdir, | |
3467 | 'PAM configuration directory' : pamconfdir, | |
3468 | 'libcryptsetup plugins directory' : libcryptsetup_plugins_dir, | |
3469 | 'RPM macros directory' : rpmmacrosdir, | |
3470 | 'modprobe.d directory' : modprobedir, | |
3471 | 'D-Bus policy directory' : dbuspolicydir, | |
3472 | 'D-Bus session directory' : dbussessionservicedir, | |
3473 | 'D-Bus system directory' : dbussystemservicedir, | |
7e560e79 | 3474 | 'D-Bus interfaces directory' : dbus_interfaces_dir, |
12085ebb ZJS |
3475 | 'bash completions directory' : bashcompletiondir, |
3476 | 'zsh completions directory' : zshcompletiondir, | |
a2b0cd3f | 3477 | 'private shared lib version tag' : shared_lib_tag, |
12085ebb ZJS |
3478 | 'extra start script' : get_option('rc-local'), |
3479 | 'debug shell' : '@0@ @ @1@'.format(get_option('debug-shell'), | |
3480 | get_option('debug-tty')), | |
3481 | 'system UIDs' : '<=@0@ (alloc >=@1@)'.format(conf.get('SYSTEM_UID_MAX'), | |
3482 | conf.get('SYSTEM_ALLOC_UID_MIN')), | |
3483 | 'system GIDs' : '<=@0@ (alloc >=@1@)'.format(conf.get('SYSTEM_GID_MAX'), | |
3484 | conf.get('SYSTEM_ALLOC_GID_MIN')), | |
3485 | 'dynamic UIDs' : '@0@…@1@'.format(dynamic_uid_min, dynamic_uid_max), | |
3486 | 'container UID bases' : '@0@…@1@'.format(container_uid_base_min, container_uid_base_max), | |
3487 | 'static UID/GID allocations' : ' '.join(static_ugids), | |
3488 | '/dev/kvm access mode' : get_option('dev-kvm-mode'), | |
3489 | 'render group access mode' : get_option('group-render-mode'), | |
3490 | 'certificate root directory' : get_option('certificate-root'), | |
3491 | 'support URL' : support_url, | |
3492 | 'nobody user name' : nobody_user, | |
3493 | 'nobody group name' : nobody_group, | |
3494 | 'fallback hostname' : get_option('fallback-hostname'), | |
9798deaf | 3495 | 'default compression method' : compression, |
12085ebb ZJS |
3496 | 'default DNSSEC mode' : default_dnssec, |
3497 | 'default DNS-over-TLS mode' : default_dns_over_tls, | |
3498 | 'default mDNS mode' : default_mdns, | |
3499 | 'default LLMNR mode' : default_llmnr, | |
3500 | 'default DNS servers' : dns_servers.split(' '), | |
3501 | 'default NTP servers' : ntp_servers.split(' '), | |
3502 | 'default cgroup hierarchy' : default_hierarchy, | |
3503 | 'default net.naming-scheme value' : default_net_naming_scheme, | |
3504 | 'default KillUserProcesses value' : kill_user_processes, | |
3505 | 'default locale' : default_locale, | |
88b6f0de | 3506 | 'default nspawn locale' : nspawn_locale, |
79dec86a | 3507 | 'default status unit format' : status_unit_format_default, |
12085ebb ZJS |
3508 | 'default user $PATH' : |
3509 | default_user_path != '' ? default_user_path : '(same as system services)', | |
3510 | 'systemd service watchdog' : service_watchdog == '' ? 'disabled' : service_watchdog, | |
3511 | 'time epoch' : '@0@ (@1@)'.format(time_epoch, alt_time_epoch)}) | |
829257d1 ZJS |
3512 | |
3513 | # TODO: | |
3514 | # CFLAGS: ${OUR_CFLAGS} ${CFLAGS} | |
3515 | # CPPFLAGS: ${OUR_CPPFLAGS} ${CPPFLAGS} | |
3516 | # LDFLAGS: ${OUR_LDFLAGS} ${LDFLAGS} | |
3517 | ||
829257d1 ZJS |
3518 | found = [] |
3519 | missing = [] | |
3520 | ||
3521 | foreach tuple : [ | |
56d68e71 ZJS |
3522 | # dependencies |
3523 | ['ACL'], | |
829257d1 | 3524 | ['AUDIT'], |
829257d1 | 3525 | ['AppArmor'], |
56d68e71 ZJS |
3526 | ['IMA'], |
3527 | ['PAM'], | |
829257d1 | 3528 | ['SECCOMP'], |
56d68e71 | 3529 | ['SELinux'], |
829257d1 | 3530 | ['SMACK'], |
56d68e71 ZJS |
3531 | ['blkid'], |
3532 | ['elfutils'], | |
829257d1 | 3533 | ['gcrypt'], |
829257d1 | 3534 | ['gnutls'], |
7d861e12 | 3535 | ['libbpf'], |
56d68e71 | 3536 | ['libcryptsetup'], |
d1ae38d8 | 3537 | ['libcryptsetup-plugins'], |
829257d1 | 3538 | ['libcurl'], |
56d68e71 ZJS |
3539 | ['libfdisk'], |
3540 | ['libfido2'], | |
829257d1 | 3541 | ['libidn'], |
56d68e71 | 3542 | ['libidn2'], |
829257d1 | 3543 | ['libiptc'], |
56d68e71 ZJS |
3544 | ['microhttpd'], |
3545 | ['openssl'], | |
3546 | ['p11kit'], | |
1d8aae43 | 3547 | ['passwdqc'], |
56d68e71 ZJS |
3548 | ['pcre2'], |
3549 | ['pwquality'], | |
3550 | ['qrencode'], | |
3551 | ['tpm2'], | |
3552 | ['xkbcommon'], | |
3553 | ||
3554 | # compression libs | |
3555 | ['zstd'], | |
3556 | ['lz4'], | |
3557 | ['xz'], | |
3558 | ['zlib'], | |
3559 | ['bzip2'], | |
3560 | ||
3561 | # components | |
3562 | ['backlight'], | |
829257d1 | 3563 | ['binfmt'], |
dfca5587 | 3564 | ['bootloader'], |
0a0d4899 | 3565 | ['bpf-framework', conf.get('BPF_FRAMEWORK') == 1], |
56d68e71 | 3566 | ['coredump'], |
56d68e71 | 3567 | ['efi'], |
dfca5587 | 3568 | ['environment.d'], |
829257d1 | 3569 | ['firstboot'], |
56d68e71 ZJS |
3570 | ['hibernate'], |
3571 | ['homed'], | |
3572 | ['hostnamed'], | |
3573 | ['hwdb'], | |
3574 | ['importd'], | |
3575 | ['initrd'], | |
f887eab1 | 3576 | ['kernel-install'], |
56d68e71 | 3577 | ['localed'], |
829257d1 ZJS |
3578 | ['logind'], |
3579 | ['machined'], | |
56d68e71 ZJS |
3580 | ['networkd'], |
3581 | ['nss-myhostname'], | |
3582 | ['nss-mymachines'], | |
3583 | ['nss-resolve'], | |
3584 | ['nss-systemd'], | |
3585 | ['oomd'], | |
61d0578b | 3586 | ['portabled'], |
56d68e71 ZJS |
3587 | ['pstore'], |
3588 | ['quotacheck'], | |
3589 | ['randomseed'], | |
3590 | ['repart'], | |
3591 | ['resolve'], | |
3592 | ['rfkill'], | |
9bca4ae4 | 3593 | ['sysext'], |
0a0d4899 | 3594 | ['systemd-analyze', conf.get('ENABLE_ANALYZE') == 1], |
43cc7a3e | 3595 | ['sysupdate'], |
56d68e71 | 3596 | ['sysusers'], |
829257d1 ZJS |
3597 | ['timedated'], |
3598 | ['timesyncd'], | |
56d68e71 ZJS |
3599 | ['tmpfiles'], |
3600 | ['userdb'], | |
3601 | ['vconsole'], | |
3602 | ['xdg-autostart'], | |
3603 | ||
3604 | # optional features | |
56d68e71 | 3605 | ['idn'], |
829257d1 | 3606 | ['polkit'], |
56d68e71 | 3607 | ['nscd'], |
0a0d4899 | 3608 | ['legacy-pkla', install_polkit_pkla], |
829257d1 | 3609 | ['kmod'], |
ede5a78f | 3610 | ['xenctrl'], |
829257d1 ZJS |
3611 | ['dbus'], |
3612 | ['glib'], | |
829257d1 | 3613 | ['tpm'], |
0a0d4899 JH |
3614 | ['man pages', want_man], |
3615 | ['html pages', want_html], | |
3616 | ['man page indices', want_man and have_lxml], | |
829257d1 | 3617 | ['SysV compat'], |
56d68e71 | 3618 | ['compat-mutable-uid-boundaries'], |
829257d1 ZJS |
3619 | ['utmp'], |
3620 | ['ldconfig'], | |
0a0d4899 JH |
3621 | ['adm group', get_option('adm-group')], |
3622 | ['wheel group', get_option('wheel-group')], | |
b14e1b43 | 3623 | ['gshadow'], |
829257d1 ZJS |
3624 | ['debug hashmap'], |
3625 | ['debug mmap cache'], | |
d6601495 | 3626 | ['debug siphash'], |
0a0d4899 | 3627 | ['trace logging', conf.get('LOG_TRACE') == 1], |
69525346 YW |
3628 | ['slow tests', slow_tests], |
3629 | ['fuzz tests', fuzz_tests], | |
0a0d4899 JH |
3630 | ['install tests', install_tests], |
3631 | ['link-udev-shared', get_option('link-udev-shared')], | |
3632 | ['link-systemctl-shared', get_option('link-systemctl-shared')], | |
3633 | ['link-networkd-shared', get_option('link-networkd-shared')], | |
3634 | ['link-timesyncd-shared', get_option('link-timesyncd-shared')], | |
3635 | ['link-journalctl-shared', get_option('link-journalctl-shared')], | |
3636 | ['link-boot-shared', get_option('link-boot-shared')], | |
c06d2e44 | 3637 | ['link-portabled-shared', get_option('link-portabled-shared')], |
93651582 | 3638 | ['first-boot-full-preset'], |
ceedbf81 | 3639 | ['fexecve'], |
0a0d4899 JH |
3640 | ['standalone-binaries', get_option('standalone-binaries')], |
3641 | ['coverage', get_option('b_coverage')], | |
829257d1 ZJS |
3642 | ] |
3643 | ||
af4d7860 ZJS |
3644 | if tuple.length() >= 2 |
3645 | cond = tuple[1] | |
3646 | else | |
829257d1 ZJS |
3647 | ident1 = 'HAVE_' + tuple[0].underscorify().to_upper() |
3648 | ident2 = 'ENABLE_' + tuple[0].underscorify().to_upper() | |
349cc4a5 | 3649 | cond = conf.get(ident1, 0) == 1 or conf.get(ident2, 0) == 1 |
829257d1 ZJS |
3650 | endif |
3651 | if cond | |
5a8b1640 | 3652 | found += tuple[0] |
829257d1 | 3653 | else |
5a8b1640 | 3654 | missing += tuple[0] |
829257d1 ZJS |
3655 | endif |
3656 | endforeach | |
3657 | ||
c716c253 ZJS |
3658 | if static_libsystemd == 'false' |
3659 | missing += 'static-libsystemd' | |
3660 | else | |
3661 | found += 'static-libsystemd(@0@)'.format(static_libsystemd) | |
3662 | endif | |
3663 | ||
3664 | if static_libudev == 'false' | |
3665 | missing += 'static-libudev' | |
3666 | else | |
3667 | found += 'static-libudev(@0@)'.format(static_libudev) | |
3668 | endif | |
3669 | ||
57633d23 ZJS |
3670 | if conf.get('HAVE_OPENSSL_OR_GCRYPT') == 1 and conf.get('PREFER_OPENSSL') == 1 |
3671 | found += 'cryptolib(openssl)' | |
3672 | elif conf.get('HAVE_OPENSSL_OR_GCRYPT') == 1 | |
3673 | found += 'cryptolib(gcrypt)' | |
3674 | else | |
3675 | missing += 'cryptolib' | |
3676 | endif | |
3677 | ||
237f2da9 ZJS |
3678 | if conf.get('DNS_OVER_TLS_USE_GNUTLS') == 1 |
3679 | found += 'DNS-over-TLS(gnutls)' | |
3680 | elif conf.get('DNS_OVER_TLS_USE_OPENSSL') == 1 | |
3681 | found += 'DNS-over-TLS(openssl)' | |
3682 | else | |
3683 | missing += 'DNS-over-TLS' | |
3684 | endif | |
3685 | ||
12085ebb ZJS |
3686 | summary({ |
3687 | 'enabled' : ', '.join(found), | |
3688 | 'disabled' : ', '.join(missing)}, | |
3689 | section : 'Features') |