]> git.ipfire.org Git - thirdparty/systemd.git/blob - meson.build
Merge pull request #6365 from keszybz/fast-tests
[thirdparty/systemd.git] / meson.build
1 project('systemd', 'c',
2 version : '234',
3 license : 'LGPLv2+',
4 default_options: [
5 'c_std=gnu99',
6 'prefix=/usr',
7 'sysconfdir=/etc',
8 'localstatedir=/var',
9 ],
10 meson_version : '>= 0.40',
11 )
12
13 # We need the same data in three different formats, ugh!
14 # Also, for hysterical reasons, we use different variable
15 # names, sometimes. Not all variables are included in every
16 # set. Ugh, ugh, ugh!
17 conf = configuration_data()
18 conf.set_quoted('PACKAGE_STRING', meson.project_name() + ' ' + meson.project_version())
19 conf.set_quoted('PACKAGE_VERSION', meson.project_version())
20
21 substs = configuration_data()
22 substs.set('PACKAGE_URL', 'https://www.freedesktop.org/wiki/Software/systemd')
23 substs.set('PACKAGE_VERSION', meson.project_version())
24
25 m4_defines = []
26
27 #####################################################################
28
29 # Try to install the git pre-commit hook
30 git_hook = run_command(join_paths(meson.source_root(), 'tools/add-git-hook.sh'))
31 if git_hook.returncode() == 0
32 message(git_hook.stdout().strip())
33 endif
34
35 #####################################################################
36
37 rootprefixdir = get_option('rootprefix')
38 if get_option('split-usr')
39 conf.set('HAVE_SPLIT_USR', true)
40 rootprefixdir = rootprefixdir != '' ? rootprefixdir : '/'
41 else
42 rootprefixdir = rootprefixdir != '' ? rootprefixdir : '/usr'
43 endif
44
45 sysvinit_path = get_option('sysvinit-path')
46 sysvrcnd_path = get_option('sysvrcnd-path')
47 if sysvinit_path != '' or sysvrcnd_path != ''
48 conf.set('HAVE_SYSV_COMPAT', true,
49 description : 'SysV init scripts and rcN.d links are supported')
50 m4_defines += ['-DHAVE_SYSV_COMPAT']
51 endif
52
53 # join_paths ignore the preceding arguments if an absolute component is
54 # encountered, so this should canonicalize various paths when they are
55 # absolute or relative.
56 prefixdir = get_option('prefix')
57 if not prefixdir.startswith('/')
58 error('Prefix is not absolute: "@0@"'.format(prefixdir))
59 endif
60 bindir = join_paths(prefixdir, get_option('bindir'))
61 libdir = join_paths(prefixdir, get_option('libdir'))
62 sysconfdir = join_paths(prefixdir, get_option('sysconfdir'))
63 includedir = join_paths(prefixdir, get_option('includedir'))
64 datadir = join_paths(prefixdir, get_option('datadir'))
65 localstatedir = join_paths('/', get_option('localstatedir'))
66
67 rootbindir = join_paths(rootprefixdir, 'bin')
68 rootlibexecdir = join_paths(rootprefixdir, 'lib/systemd')
69
70 rootlibdir = get_option('rootlibdir')
71 if rootlibdir == ''
72 rootlibdir = join_paths(rootprefixdir, libdir.split('/')[-1])
73 endif
74
75 # Dirs of external packages
76 pkgconfigdatadir = join_paths(datadir, 'pkgconfig')
77 pkgconfiglibdir = join_paths(libdir, 'pkgconfig')
78 polkitpolicydir = join_paths(datadir, 'polkit-1/actions')
79 polkitrulesdir = join_paths(datadir, 'polkit-1/rules.d')
80 polkitpkladir = join_paths(localstatedir, 'lib/polkit-1/localauthority/10-vendor.d')
81 varlogdir = join_paths(localstatedir, 'log')
82 xinitrcdir = join_paths(sysconfdir, 'X11/xinit/xinitrc.d')
83 rpmmacrosdir = get_option('rpmmacrosdir')
84
85 # Our own paths
86 pkgdatadir = join_paths(datadir, 'systemd')
87 environmentdir = join_paths(prefixdir, 'lib/environment.d')
88 pkgsysconfdir = join_paths(sysconfdir, 'systemd')
89 userunitdir = join_paths(prefixdir, 'lib/systemd/user')
90 userpresetdir = join_paths(prefixdir, 'lib/systemd/user-preset')
91 tmpfilesdir = join_paths(prefixdir, 'lib/tmpfiles.d')
92 sysusersdir = join_paths(prefixdir, 'lib/sysusers.d')
93 sysctldir = join_paths(prefixdir, 'lib/sysctl.d')
94 binfmtdir = join_paths(prefixdir, 'lib/binfmt.d')
95 modulesloaddir = join_paths(prefixdir, 'lib/modules-load.d')
96 networkdir = join_paths(rootprefixdir, 'lib/systemd/network')
97 pkgincludedir = join_paths(includedir, 'systemd')
98 systemgeneratordir = join_paths(rootlibexecdir, 'system-generators')
99 usergeneratordir = join_paths(prefixdir, 'lib/systemd/user-generators')
100 systemenvgeneratordir = join_paths(prefixdir, 'lib/systemd/system-environment-generators')
101 userenvgeneratordir = join_paths(prefixdir, 'lib/systemd/user-environment-generators')
102 systemshutdowndir = join_paths(rootlibexecdir, 'system-shutdown')
103 systemsleepdir = join_paths(rootlibexecdir, 'system-sleep')
104 systemunitdir = join_paths(rootprefixdir, 'lib/systemd/system')
105 systempresetdir = join_paths(rootprefixdir, 'lib/systemd/system-preset')
106 udevlibexecdir = join_paths(rootprefixdir, 'lib/udev')
107 udevhomedir = udevlibexecdir
108 udevrulesdir = join_paths(udevlibexecdir, 'rules.d')
109 udevhwdbdir = join_paths(udevlibexecdir, 'hwdb.d')
110 catalogdir = join_paths(prefixdir, 'lib/systemd/catalog')
111 kernelinstalldir = join_paths(prefixdir, 'lib/kernel/install.d')
112 factorydir = join_paths(datadir, 'factory')
113 docdir = join_paths(datadir, 'doc/systemd')
114 bootlibdir = join_paths(prefixdir, 'lib/systemd/boot/efi')
115 testsdir = join_paths(prefixdir, 'lib/systemd/tests')
116 systemdstatedir = join_paths(localstatedir, 'lib/systemd')
117 catalogstatedir = join_paths(systemdstatedir, 'catalog')
118 randomseeddir = join_paths(localstatedir, 'lib/systemd')
119
120 dbuspolicydir = get_option('dbuspolicydir')
121 if dbuspolicydir == ''
122 dbuspolicydir = join_paths(datadir, 'dbus-1/system.d')
123 endif
124
125 dbussessionservicedir = get_option('dbussessionservicedir')
126 if dbussessionservicedir == ''
127 dbussessionservicedir = join_paths(datadir, 'dbus-1/services')
128 endif
129
130 dbussystemservicedir = get_option('dbussystemservicedir')
131 if dbussystemservicedir == ''
132 dbussystemservicedir = join_paths(datadir, 'dbus-1/system-services')
133 endif
134
135 pamlibdir = get_option('pamlibdir')
136 if pamlibdir == ''
137 pamlibdir = join_paths(rootlibdir, 'security')
138 endif
139
140 pamconfdir = get_option('pamconfdir')
141 if pamconfdir == ''
142 pamconfdir = join_paths(sysconfdir, 'pam.d')
143 endif
144
145 conf.set_quoted('PKGSYSCONFDIR', pkgsysconfdir)
146 conf.set_quoted('SYSTEM_CONFIG_UNIT_PATH', join_paths(pkgsysconfdir, 'system'))
147 conf.set_quoted('SYSTEM_DATA_UNIT_PATH', systemunitdir)
148 conf.set_quoted('SYSTEM_SYSVINIT_PATH', sysvinit_path)
149 conf.set_quoted('SYSTEM_SYSVRCND_PATH', sysvrcnd_path)
150 conf.set_quoted('RC_LOCAL_SCRIPT_PATH_START', get_option('rc-local'))
151 conf.set_quoted('RC_LOCAL_SCRIPT_PATH_STOP', get_option('halt-local'))
152 conf.set_quoted('USER_CONFIG_UNIT_PATH', join_paths(pkgsysconfdir, 'user'))
153 conf.set_quoted('USER_DATA_UNIT_PATH', userunitdir)
154 conf.set_quoted('CERTIFICATE_ROOT', get_option('certificate-root'))
155 conf.set_quoted('CATALOG_DATABASE', join_paths(catalogstatedir, 'database'))
156 conf.set_quoted('SYSTEMD_CGROUP_AGENT_PATH', join_paths(rootlibexecdir, 'systemd-cgroups-agent'))
157 conf.set_quoted('SYSTEMD_BINARY_PATH', join_paths(rootlibexecdir, 'systemd'))
158 conf.set_quoted('SYSTEMD_FSCK_PATH', join_paths(rootlibexecdir, 'systemd-fsck'))
159 conf.set_quoted('SYSTEMD_SHUTDOWN_BINARY_PATH', join_paths(rootlibexecdir, 'systemd-shutdown'))
160 conf.set_quoted('SYSTEMD_SLEEP_BINARY_PATH', join_paths(rootlibexecdir, 'systemd-sleep'))
161 conf.set_quoted('SYSTEMCTL_BINARY_PATH', join_paths(rootbindir, 'systemctl'))
162 conf.set_quoted('SYSTEMD_TTY_ASK_PASSWORD_AGENT_BINARY_PATH', join_paths(rootbindir, 'systemd-tty-ask-password-agent'))
163 conf.set_quoted('SYSTEMD_STDIO_BRIDGE_BINARY_PATH', join_paths(bindir, 'systemd-stdio-bridge'))
164 conf.set_quoted('ROOTPREFIX', rootprefixdir)
165 conf.set_quoted('RANDOM_SEED_DIR', randomseeddir)
166 conf.set_quoted('RANDOM_SEED', join_paths(randomseeddir, 'random-seed'))
167 conf.set_quoted('SYSTEMD_CRYPTSETUP_PATH', join_paths(rootlibexecdir, 'systemd-cryptsetup'))
168 conf.set_quoted('SYSTEM_GENERATOR_PATH', systemgeneratordir)
169 conf.set_quoted('USER_GENERATOR_PATH', usergeneratordir)
170 conf.set_quoted('SYSTEM_ENV_GENERATOR_PATH', systemenvgeneratordir)
171 conf.set_quoted('USER_ENV_GENERATOR_PATH', userenvgeneratordir)
172 conf.set_quoted('SYSTEM_SHUTDOWN_PATH', systemshutdowndir)
173 conf.set_quoted('SYSTEM_SLEEP_PATH', systemsleepdir)
174 conf.set_quoted('SYSTEMD_KBD_MODEL_MAP', join_paths(pkgdatadir, 'kbd-model-map'))
175 conf.set_quoted('SYSTEMD_LANGUAGE_FALLBACK_MAP', join_paths(pkgdatadir, 'language-fallback-map'))
176 conf.set_quoted('UDEVLIBEXECDIR', udevlibexecdir)
177 conf.set_quoted('POLKIT_AGENT_BINARY_PATH', join_paths(bindir, 'pkttyagent'))
178 conf.set_quoted('LIBDIR', libdir)
179 conf.set_quoted('ROOTLIBDIR', rootlibdir)
180 conf.set_quoted('ROOTLIBEXECDIR', rootlibexecdir)
181 conf.set_quoted('BOOTLIBDIR', bootlibdir)
182 conf.set_quoted('SYSTEMD_PULL_PATH', join_paths(rootlibexecdir, 'systemd-pull'))
183 conf.set_quoted('SYSTEMD_IMPORT_PATH', join_paths(rootlibexecdir, 'systemd-import'))
184 conf.set_quoted('SYSTEMD_EXPORT_PATH', join_paths(rootlibexecdir, 'systemd-export'))
185 conf.set_quoted('VENDOR_KEYRING_PATH', join_paths(rootlibexecdir, 'import-pubring.gpg'))
186 conf.set_quoted('USER_KEYRING_PATH', join_paths(pkgsysconfdir, 'import-pubring.gpg'))
187 conf.set_quoted('DOCUMENT_ROOT', join_paths(pkgdatadir, 'gatewayd'))
188
189 conf.set_quoted('ABS_BUILD_DIR', meson.build_root())
190 conf.set_quoted('ABS_SRC_DIR', meson.source_root())
191
192 substs.set('prefix', prefixdir)
193 substs.set('exec_prefix', prefixdir)
194 substs.set('libdir', libdir)
195 substs.set('rootlibdir', rootlibdir)
196 substs.set('includedir', includedir)
197 substs.set('pkgsysconfdir', pkgsysconfdir)
198 substs.set('bindir', bindir)
199 substs.set('rootbindir', rootbindir)
200 substs.set('rootlibexecdir', rootlibexecdir)
201 substs.set('systemunitdir', systemunitdir)
202 substs.set('userunitdir', userunitdir)
203 substs.set('systempresetdir', systempresetdir)
204 substs.set('userpresetdir', userpresetdir)
205 substs.set('udevhwdbdir', udevhwdbdir)
206 substs.set('udevrulesdir', udevrulesdir)
207 substs.set('udevlibexecdir', udevlibexecdir)
208 substs.set('catalogdir', catalogdir)
209 substs.set('tmpfilesdir', tmpfilesdir)
210 substs.set('sysusersdir', sysusersdir)
211 substs.set('sysctldir', sysctldir)
212 substs.set('binfmtdir', binfmtdir)
213 substs.set('modulesloaddir', modulesloaddir)
214 substs.set('systemgeneratordir', systemgeneratordir)
215 substs.set('usergeneratordir', usergeneratordir)
216 substs.set('systemenvgeneratordir', systemenvgeneratordir)
217 substs.set('userenvgeneratordir', userenvgeneratordir)
218 substs.set('systemshutdowndir', systemshutdowndir)
219 substs.set('systemsleepdir', systemsleepdir)
220 substs.set('VARLOGDIR', varlogdir)
221 substs.set('CERTIFICATEROOT', get_option('certificate-root'))
222 substs.set('SYSTEMCTL', join_paths(rootbindir, 'systemctl'))
223 substs.set('RANDOM_SEED', join_paths(randomseeddir, 'random-seed'))
224 substs.set('SYSTEM_SYSVINIT_PATH', sysvinit_path)
225 substs.set('SYSTEM_SYSVRCND_PATH', sysvrcnd_path)
226 substs.set('RC_LOCAL_SCRIPT_PATH_START', get_option('rc-local'))
227 substs.set('RC_LOCAL_SCRIPT_PATH_STOP', get_option('halt-local'))
228
229 #####################################################################
230
231 cc = meson.get_compiler('c')
232 pkgconfig = import('pkgconfig')
233 check_compilation_sh = find_program('tools/meson-check-compilation.sh')
234
235 cxx = find_program('c++', required : false)
236 if cxx.found()
237 # Used only for tests
238 add_languages('cpp')
239 endif
240
241 foreach arg : ['-Wextra',
242 '-Wundef',
243 '-Wlogical-op',
244 '-Wmissing-include-dirs',
245 '-Wold-style-definition',
246 '-Wpointer-arith',
247 '-Winit-self',
248 '-Wdeclaration-after-statement',
249 '-Wfloat-equal',
250 '-Wsuggest-attribute=noreturn',
251 '-Werror=missing-prototypes',
252 '-Werror=implicit-function-declaration',
253 '-Werror=missing-declarations',
254 '-Werror=return-type',
255 '-Werror=incompatible-pointer-types',
256 '-Werror=format=2',
257 '-Wstrict-prototypes',
258 '-Wredundant-decls',
259 '-Wmissing-noreturn',
260 '-Wshadow',
261 '-Wendif-labels',
262 '-Wstrict-aliasing=2',
263 '-Wwrite-strings',
264 '-Werror=overflow',
265 '-Wdate-time',
266 '-Wnested-externs',
267 '-ffast-math',
268 '-fno-common',
269 '-fdiagnostics-show-option',
270 '-fno-strict-aliasing',
271 '-fvisibility=hidden',
272 '-fstack-protector',
273 '-fstack-protector-strong',
274 '-fPIE',
275 '--param=ssp-buffer-size=4',
276 ]
277 if cc.has_argument(arg)
278 add_project_arguments(arg, language : 'c')
279 endif
280 endforeach
281
282 # "negative" arguments: gcc on purpose does not return an error for "-Wno-"
283 # arguments, just emits a warnings. So test for the "positive" version instead.
284 foreach arg : ['unused-parameter',
285 'missing-field-initializers',
286 'unused-result',
287 'format-signedness']
288 if cc.has_argument('-W' + arg)
289 add_project_arguments('-Wno-' + arg, language : 'c')
290 endif
291 endforeach
292
293 if cc.compiles('
294 #include <time.h>
295 #include <inttypes.h>
296 typedef uint64_t usec_t;
297 usec_t now(clockid_t clock);
298 int main(void) {
299 struct timespec now;
300 return 0;
301 }
302 ', name : '-Werror=shadow with local shadowing')
303 add_project_arguments('-Werror=shadow', language : 'c')
304 endif
305
306 if cc.get_id() == 'clang'
307 foreach arg : ['-Wno-typedef-redefinition',
308 '-Wno-gnu-variable-sized-type-not-at-end',
309 ]
310 if cc.has_argument(arg,
311 name : '@0@ is supported'.format(arg))
312 add_project_arguments(arg, language : 'c')
313 endif
314 endforeach
315 endif
316
317 link_test_c = files('tools/meson-link-test.c')
318
319 # --as-needed and --no-undefined are provided by meson by default,
320 # run mesonconf to see what is enabled
321 foreach arg : ['-Wl,-z,relro',
322 '-Wl,-z,now',
323 '-pie',
324 ]
325
326 have = run_command(check_compilation_sh,
327 cc.cmd_array(), '-x', 'c', arg,
328 '-include', link_test_c).returncode() == 0
329 message('Linking with @0@ supported: @1@'.format(arg, have ? 'yes' : 'no'))
330 if have
331 add_project_link_arguments(arg, language : 'c')
332 endif
333 endforeach
334
335 if get_option('buildtype') != 'debug'
336 foreach arg : ['-ffunction-sections',
337 '-fdata-sections']
338 if cc.has_argument(arg,
339 name : '@0@ is supported'.format(arg))
340 add_project_arguments(arg, language : 'c')
341 endif
342 endforeach
343
344 foreach arg : ['-Wl,--gc-sections']
345 have = run_command(check_compilation_sh,
346 cc.cmd_array(), '-x', 'c', arg,
347 '-include', link_test_c).returncode() == 0
348 message('Linking with @0@ supported: @1@'.format(arg, have ? 'yes' : 'no'))
349 if have
350 add_project_link_arguments(arg, language : 'c')
351 endif
352 endforeach
353 endif
354
355 cpp = ' '.join(cc.cmd_array()) + ' -E'
356
357 #####################################################################
358 # compilation result tests
359
360 conf.set('_GNU_SOURCE', true)
361 conf.set('__SANE_USERSPACE_TYPES__', true)
362
363 conf.set('SIZEOF_PID_T', cc.sizeof('pid_t', prefix : '#include <sys/types.h>'))
364 conf.set('SIZEOF_UID_T', cc.sizeof('uid_t', prefix : '#include <sys/types.h>'))
365 conf.set('SIZEOF_GID_T', cc.sizeof('gid_t', prefix : '#include <sys/types.h>'))
366 conf.set('SIZEOF_DEV_T', cc.sizeof('dev_t', prefix : '#include <sys/types.h>'))
367 conf.set('SIZEOF_INO_T', cc.sizeof('ino_t', prefix : '#include <sys/types.h>'))
368 conf.set('SIZEOF_TIME_T', cc.sizeof('time_t', prefix : '#include <sys/time.h>'))
369 conf.set('SIZEOF_RLIM_T', cc.sizeof('rlim_t', prefix : '#include <sys/resource.h>'))
370
371 decl_headers = '''
372 #include <uchar.h>
373 #include <linux/ethtool.h>
374 '''
375 # FIXME: key_serial_t is only defined in keyutils.h, this is bound to fail
376
377 foreach decl : ['char16_t',
378 'char32_t',
379 'key_serial_t',
380 'struct ethtool_link_settings',
381 ]
382
383 # We get -1 if the size cannot be determined
384 have = cc.sizeof(decl, prefix : decl_headers) > 0
385 conf.set('HAVE_' + decl.underscorify().to_upper(), have)
386 endforeach
387
388 foreach decl : [['IFLA_INET6_ADDR_GEN_MODE', 'linux/if_link.h'],
389 ['IN6_ADDR_GEN_MODE_STABLE_PRIVACY', 'linux/if_link.h'],
390 ['IFLA_VRF_TABLE', 'linux/if_link.h'],
391 ['IFLA_MACVLAN_FLAGS', 'linux/if_link.h'],
392 ['IFLA_IPVLAN_MODE', 'linux/if_link.h'],
393 ['IFLA_PHYS_PORT_ID', 'linux/if_link.h'],
394 ['IFLA_BOND_AD_INFO', 'linux/if_link.h'],
395 ['IFLA_VLAN_PROTOCOL', 'linux/if_link.h'],
396 ['IFLA_VXLAN_REMCSUM_NOPARTIAL', 'linux/if_link.h'],
397 ['IFLA_VXLAN_GPE', 'linux/if_link.h'],
398 ['IFLA_GENEVE_LABEL', 'linux/if_link.h'],
399 # if_tunnel.h is buggy and cannot be included on its own
400 ['IFLA_VTI_REMOTE', 'linux/if_tunnel.h', '#include <net/if.h>'],
401 ['IFLA_IPTUN_ENCAP_DPORT', 'linux/if_tunnel.h', '#include <net/if.h>'],
402 ['IFLA_GRE_ENCAP_DPORT', 'linux/if_tunnel.h', '#include <net/if.h>'],
403 ['IFLA_BRIDGE_VLAN_INFO', 'linux/if_bridge.h'],
404 ['IFLA_BRPORT_PROXYARP', 'linux/if_link.h'],
405 ['IFLA_BRPORT_LEARNING_SYNC', 'linux/if_link.h'],
406 ['IFLA_BR_VLAN_DEFAULT_PVID', 'linux/if_link.h'],
407 ['NDA_IFINDEX', 'linux/neighbour.h'],
408 ['IFA_FLAGS', 'linux/if_addr.h'],
409 ['LO_FLAGS_PARTSCAN', 'linux/loop.h'],
410 ]
411 prefix = decl.length() > 2 ? decl[2] : ''
412 have = cc.has_header_symbol(decl[1], decl[0], prefix : prefix)
413 conf.set10('HAVE_DECL_' + decl[0], have)
414 endforeach
415
416 skip = false
417 foreach ident : ['secure_getenv', '__secure_getenv']
418 if not skip and cc.has_function(ident)
419 conf.set('HAVE_' + ident.to_upper(), true)
420 skip = true
421 endif
422 endforeach
423
424 foreach ident : [
425 ['memfd_create', '''#include <sys/memfd.h>'''],
426 ['gettid', '''#include <sys/types.h>'''],
427 ['pivot_root', '''#include <stdlib.h>'''], # no known header declares pivot_root
428 ['name_to_handle_at', '''#define _GNU_SOURCE
429 #include <sys/types.h>
430 #include <sys/stat.h>
431 #include <fcntl.h>'''],
432 ['setns', '''#define _GNU_SOURCE
433 #include <sched.h>'''],
434 ['renameat2', '''#include <stdio.h>'''],
435 ['kcmp', '''#include <linux/kcmp.h>'''],
436 ['keyctl', '''#include <sys/types.h>
437 #include <keyutils.h>'''],
438 ['copy_file_range', '''#include <sys/syscall.h>
439 #include <unistd.h>'''],
440 ['explicit_bzero' , '''#include <string.h>'''],
441 ]
442
443 have = cc.has_function(ident[0], prefix : ident[1])
444 conf.set10('HAVE_DECL_' + ident[0].to_upper(), have)
445 endforeach
446
447 if cc.has_function('getrandom', prefix : '''#include <sys/random.h>''')
448 conf.set('USE_SYS_RANDOM_H', true)
449 conf.set10('HAVE_DECL_GETRANDOM', true)
450 else
451 have = cc.has_function('getrandom', prefix : '''#include <linux/random.h>''')
452 conf.set10('HAVE_DECL_GETRANDOM', have)
453 endif
454
455 #####################################################################
456
457 sed = find_program('sed')
458 grep = find_program('grep')
459 awk = find_program('awk')
460 m4 = find_program('m4')
461 stat = find_program('stat')
462 git = find_program('git', required : false)
463
464 meson_make_symlink = meson.source_root() + '/tools/meson-make-symlink.sh'
465 mkdir_p = 'mkdir -p $DESTDIR/@0@'
466 test_efi_create_disk_sh = find_program('test/test-efi-create-disk.sh')
467 splash_bmp = files('test/splash.bmp')
468
469 # if -Dxxx-path option is found, use that. Otherwise, check in $PATH,
470 # /usr/sbin, /sbin, and fall back to the default from middle column.
471 progs = [['telinit', '/lib/sysvinit/telinit'],
472 ['quotaon', '/usr/sbin/quotaon' ],
473 ['quotacheck', '/usr/sbin/quotacheck' ],
474 ['kill', '/usr/bin/kill' ],
475 ['kmod', '/usr/bin/kmod' ],
476 ['kexec', '/usr/sbin/kexec' ],
477 ['sulogin', '/usr/sbin/sulogin' ],
478 ['mount', '/usr/bin/mount', 'MOUNT_PATH'],
479 ['umount', '/usr/bin/umount', 'UMOUNT_PATH'],
480 ['loadkeys', '/usr/bin/loadkeys', 'KBD_LOADKEYS'],
481 ['setfont', '/usr/bin/setfont', 'KBD_SETFONT'],
482 ]
483 foreach prog : progs
484 path = get_option(prog[0] + '-path')
485 if path != ''
486 message('Using @1@ for @0@'.format(prog[0], path))
487 else
488 exe = find_program(prog[0],
489 '/usr/sbin/' + prog[0],
490 '/sbin/' + prog[0],
491 required: false)
492 path = exe.found() ? exe.path() : prog[1]
493 endif
494 name = prog.length() > 2 ? prog[2] : prog[0].to_upper()
495 conf.set_quoted(name, path)
496 substs.set(name, path)
497 endforeach
498
499 if run_command('ln', '--relative', '--help').returncode() != 0
500 error('ln does not support --relative')
501 endif
502
503 ############################################################
504
505 gperf = find_program('gperf')
506
507 gperf_test_format = '''
508 #include <string.h>
509 const char * in_word_set(const char *, @0@);
510 @1@
511 '''
512 gperf_snippet_format = 'echo foo,bar | @0@ -L ANSI-C'
513 gperf_snippet = run_command('sh', '-c', gperf_snippet_format.format(gperf.path()))
514 gperf_test = gperf_test_format.format('size_t', gperf_snippet.stdout())
515 if cc.compiles(gperf_test)
516 gperf_len_type = 'size_t'
517 else
518 gperf_test = gperf_test_format.format('unsigned', gperf_snippet.stdout())
519 if cc.compiles(gperf_test)
520 gperf_len_type = 'unsigned'
521 else
522 error('unable to determine gperf len type')
523 endif
524 endif
525 message('gperf len type is @0@'.format(gperf_len_type))
526 conf.set('GPERF_LEN_TYPE', gperf_len_type,
527 description : 'The type of gperf "len" parameter')
528
529 ############################################################
530
531 if not cc.has_header('sys/capability.h')
532 error('POSIX caps headers not found')
533 endif
534 foreach header : ['linux/btrfs.h',
535 'linux/memfd.h',
536 'linux/vm_sockets.h',
537 'valgrind/memcheck.h',
538 'valgrind/valgrind.h',
539 ]
540
541 conf.set('HAVE_' + header.underscorify().to_upper(),
542 cc.has_header(header))
543 endforeach
544
545 ############################################################
546
547 conf.set_quoted('FALLBACK_HOSTNAME', get_option('fallback-hostname'))
548
549 default_hierarchy = get_option('default-hierarchy')
550 conf.set_quoted('DEFAULT_HIERARCHY_NAME', default_hierarchy,
551 description : 'default cgroup hierarchy as string')
552 if default_hierarchy == 'legacy'
553 conf.set('DEFAULT_HIERARCHY', 'CGROUP_UNIFIED_NONE')
554 elif default_hierarchy == 'hybrid'
555 conf.set('DEFAULT_HIERARCHY', 'CGROUP_UNIFIED_SYSTEMD')
556 else
557 conf.set('DEFAULT_HIERARCHY', 'CGROUP_UNIFIED_ALL')
558 endif
559
560 time_epoch = get_option('time-epoch')
561 if time_epoch == ''
562 NEWS = files('NEWS')
563 time_epoch = run_command(stat, '-c', '%Y', NEWS).stdout()
564 endif
565 time_epoch = time_epoch.to_int()
566 conf.set('TIME_EPOCH', time_epoch)
567
568 system_uid_max = get_option('system-uid-max')
569 if system_uid_max == ''
570 system_uid_max = run_command(
571 awk,
572 'BEGIN { uid=999 } /^\s*SYS_UID_MAX\s+/ { uid=$2 } END { print uid }',
573 '/etc/login.defs').stdout()
574 endif
575 system_uid_max = system_uid_max.to_int()
576 conf.set('SYSTEM_UID_MAX', system_uid_max)
577 substs.set('systemuidmax', system_uid_max)
578 message('maximum system UID is @0@'.format(system_uid_max))
579
580 conf.set_quoted('NOBODY_USER_NAME', get_option('nobody-user'))
581 conf.set_quoted('NOBODY_GROUP_NAME', get_option('nobody-group'))
582
583 system_gid_max = get_option('system-gid-max')
584 if system_gid_max == ''
585 system_gid_max = run_command(
586 awk,
587 'BEGIN { gid=999 } /^\s*SYS_GID_MAX\s+/ { gid=$2 } END { print gid }',
588 '/etc/login.defs').stdout()
589 endif
590 system_gid_max = system_gid_max.to_int()
591 conf.set('SYSTEM_GID_MAX', system_gid_max)
592 substs.set('systemgidmax', system_gid_max)
593 message('maximum system GID is @0@'.format(system_gid_max))
594
595 tty_gid = get_option('tty-gid')
596 conf.set('TTY_GID', tty_gid)
597 substs.set('TTY_GID', tty_gid)
598
599 if get_option('adm-group')
600 m4_defines += ['-DENABLE_ADM_GROUP']
601 endif
602
603 if get_option('wheel-group')
604 m4_defines += ['-DENABLE_WHEEL_GROUP']
605 endif
606
607 substs.set('DEV_KVM_MODE', get_option('dev-kvm-mode'))
608
609 kill_user_processes = get_option('default-kill-user-processes')
610 conf.set10('KILL_USER_PROCESSES', kill_user_processes)
611 substs.set('KILL_USER_PROCESSES', kill_user_processes ? 'yes' : 'no')
612
613 dns_servers = get_option('dns-servers')
614 conf.set_quoted('DNS_SERVERS', dns_servers)
615 substs.set('DNS_SERVERS', dns_servers)
616
617 ntp_servers = get_option('ntp-servers')
618 conf.set_quoted('NTP_SERVERS', ntp_servers)
619 substs.set('NTP_SERVERS', ntp_servers)
620
621 conf.set_quoted('GETTEXT_PACKAGE', meson.project_name())
622
623 substs.set('SUSHELL', get_option('debug-shell'))
624 substs.set('DEBUGTTY', get_option('debug-tty'))
625
626 debug = get_option('debug')
627 if debug != ''
628 foreach name : debug.split(',')
629 if name == 'hashmap'
630 conf.set('ENABLE_DEBUG_HASHMAP', true)
631 elif name == 'mmap-cache'
632 conf.set('ENABLE_DEBUG_MMAP_CACHE', true)
633 else
634 message('unknown debug option "@0@", ignoring'.format(name))
635 endif
636 endforeach
637 endif
638
639 #####################################################################
640
641 threads = dependency('threads')
642 librt = cc.find_library('rt')
643 libm = cc.find_library('m')
644 libdl = cc.find_library('dl')
645 libcrypt = cc.find_library('crypt')
646
647 libcap = dependency('libcap', required : false)
648 if not libcap.found()
649 # Compat with Ubuntu 14.04 which ships libcap w/o .pc file
650 libcap = cc.find_library('cap')
651 endif
652
653 libmount = dependency('mount',
654 version : '>= 2.27')
655
656 want_seccomp = get_option('seccomp')
657 if want_seccomp != 'false'
658 libseccomp = dependency('libseccomp',
659 version : '>= 2.3.1',
660 required : want_seccomp == 'true')
661 if libseccomp.found()
662 conf.set('HAVE_SECCOMP', true)
663 m4_defines += ['-DHAVE_SECCOMP']
664 endif
665 else
666 libseccomp = []
667 endif
668
669 want_selinux = get_option('selinux')
670 if want_selinux != 'false'
671 libselinux = dependency('libselinux',
672 version : '>= 2.1.9',
673 required : want_selinux == 'true')
674 if libselinux.found()
675 conf.set('HAVE_SELINUX', true)
676 m4_defines += ['-DHAVE_SELINUX']
677 endif
678 else
679 libselinux = []
680 endif
681
682 want_apparmor = get_option('apparmor')
683 if want_apparmor != 'false'
684 libapparmor = dependency('libapparmor',
685 required : want_apparmor == 'true')
686 if libapparmor.found()
687 conf.set('HAVE_APPARMOR', true)
688 m4_defines += ['-DHAVE_APPARMOR']
689 endif
690 else
691 libapparmor = []
692 endif
693
694 smack_run_label = get_option('smack-run-label')
695 if smack_run_label != ''
696 conf.set_quoted('SMACK_RUN_LABEL', smack_run_label)
697 m4_defines += ['-DHAVE_SMACK_RUN_LABEL']
698 endif
699
700 want_polkit = get_option('polkit')
701 install_polkit = false
702 install_polkit_pkla = false
703 if want_polkit != 'false'
704 conf.set('ENABLE_POLKIT', true)
705 install_polkit = true
706
707 libpolkit = dependency('polkit-gobject-1',
708 required : false)
709 if libpolkit.found() and libpolkit.version().version_compare('< 0.106')
710 message('Old polkit detected, will install pkla files')
711 install_polkit_pkla = true
712 endif
713 endif
714
715 want_acl = get_option('acl')
716 if want_acl != 'false'
717 libacl = cc.find_library('acl', required : want_acl == 'true')
718 if libacl.found()
719 conf.set('HAVE_ACL', true)
720 m4_defines += ['-DHAVE_ACL']
721 endif
722 else
723 libacl = []
724 endif
725
726 want_audit = get_option('audit')
727 if want_audit != 'false'
728 libaudit = dependency('audit', required : want_audit == 'true')
729 conf.set('HAVE_AUDIT', libaudit.found())
730 else
731 libaudit = []
732 endif
733
734 want_blkid = get_option('blkid')
735 if want_blkid != 'false'
736 libblkid = dependency('blkid', required : want_blkid == 'true')
737 conf.set('HAVE_BLKID', libblkid.found())
738 else
739 libblkid = []
740 endif
741
742 want_kmod = get_option('kmod')
743 if want_kmod != 'false'
744 libkmod = dependency('libkmod',
745 version : '>= 15',
746 required : want_kmod == 'true')
747 conf.set('HAVE_KMOD', libkmod.found())
748 else
749 libkmod = []
750 endif
751
752 want_pam = get_option('pam')
753 if want_pam != 'false'
754 libpam = cc.find_library('pam', required : want_pam == 'true')
755 libpam_misc = cc.find_library('pam_misc', required : want_pam == 'true')
756 if libpam.found() and libpam_misc.found()
757 conf.set('HAVE_PAM', true)
758 m4_defines += ['-DHAVE_PAM']
759 endif
760 else
761 libpam = []
762 libpam_misc = []
763 endif
764
765 want_microhttpd = get_option('microhttpd')
766 if want_microhttpd != 'false'
767 libmicrohttpd = dependency('libmicrohttpd',
768 version : '>= 0.9.33',
769 required : want_microhttpd == 'true')
770 if libmicrohttpd.found()
771 conf.set('HAVE_MICROHTTPD', true)
772 m4_defines += ['-DHAVE_MICROHTTPD']
773 endif
774 else
775 libmicrohttpd = []
776 endif
777
778 want_libcryptsetup = get_option('libcryptsetup')
779 if want_libcryptsetup != 'false'
780 libcryptsetup = dependency('libcryptsetup',
781 version : '>= 1.6.0',
782 required : want_libcryptsetup == 'true')
783 conf.set('HAVE_LIBCRYPTSETUP', libcryptsetup.found())
784 else
785 libcryptsetup = []
786 endif
787
788 want_libcurl = get_option('libcurl')
789 if want_libcurl != 'false'
790 libcurl = dependency('libcurl',
791 version : '>= 7.32.0',
792 required : want_libcurl == 'true')
793 if libcurl.found()
794 conf.set('HAVE_LIBCURL', true)
795 m4_defines += ['-DHAVE_LIBCURL']
796 endif
797 else
798 libcurl = []
799 endif
800
801 want_libidn = get_option('libidn')
802 want_libidn2 = get_option('libidn2')
803 if want_libidn == 'true' and want_libidn2 == 'true'
804 error('libidn and libidn2 cannot be requested simultaneously')
805 endif
806
807 if want_libidn != 'false' and want_libidn2 != 'true'
808 libidn = dependency('libidn',
809 required : want_libidn == 'true')
810 if libidn.found()
811 conf.set('HAVE_LIBIDN', true)
812 m4_defines += ['-DHAVE_LIBIDN']
813 endif
814 else
815 libidn = []
816 endif
817 if not conf.get('HAVE_LIBIDN', false) and want_libidn2 != 'false'
818 # libidn is used for both libidn and libidn2 objects
819 libidn = dependency('libidn2',
820 required : want_libidn2 == 'true')
821 if libidn.found()
822 conf.set('HAVE_LIBIDN2', true)
823 m4_defines += ['-DHAVE_LIBIDN2']
824 endif
825 endif
826
827 want_libiptc = get_option('libiptc')
828 if want_libiptc != 'false'
829 libiptc = dependency('libiptc',
830 required : want_libiptc == 'true')
831 if libiptc.found()
832 conf.set('HAVE_LIBIPTC', true)
833 m4_defines += ['-DHAVE_LIBIPTC']
834 endif
835 else
836 libiptc = []
837 endif
838
839 want_qrencode = get_option('qrencode')
840 if want_qrencode != 'false'
841 libqrencode = dependency('libqrencode',
842 required : want_qrencode == 'true')
843 conf.set('HAVE_QRENCODE', libqrencode.found())
844 else
845 libqrencode = []
846 endif
847
848 want_gcrypt = get_option('gcrypt')
849 if want_gcrypt != 'false'
850 libgcrypt = cc.find_library('gcrypt', required : want_gcrypt == 'true')
851 libgpg_error = cc.find_library('gpg-error', required : want_gcrypt == 'true')
852
853 have_deps = libgcrypt.found() and libgpg_error.found()
854 conf.set('HAVE_GCRYPT', have_deps)
855 if not have_deps
856 # link to neither of the libs if one is not found
857 libgcrypt = []
858 libgpg_error = []
859 endif
860 else
861 libgcrypt = []
862 libgpg_error = []
863 endif
864
865 want_gnutls = get_option('gnutls')
866 if want_gnutls != 'false'
867 libgnutls = dependency('gnutls',
868 version : '>= 3.1.4',
869 required : want_gnutls == 'true')
870 conf.set('HAVE_GNUTLS', libgnutls.found())
871 else
872 libgnutls = []
873 endif
874
875 want_elfutils = get_option('elfutils')
876 if want_elfutils != 'false'
877 libdw = dependency('libdw',
878 required : want_elfutils == 'true')
879 conf.set('HAVE_ELFUTILS', libdw.found())
880 else
881 libdw = []
882 endif
883
884 want_zlib = get_option('zlib')
885 if want_zlib != 'false'
886 libz = dependency('zlib',
887 required : want_zlib == 'true')
888 conf.set('HAVE_ZLIB', libz.found())
889 else
890 libz = []
891 endif
892
893 want_bzip2 = get_option('bzip2')
894 if want_bzip2 != 'false'
895 libbzip2 = cc.find_library('bz2',
896 required : want_bzip2 == 'true')
897 conf.set('HAVE_BZIP2', libbzip2.found())
898 else
899 libbzip2 = []
900 endif
901
902 want_xz = get_option('xz')
903 if want_xz != 'false'
904 libxz = dependency('liblzma',
905 required : want_xz == 'true')
906 conf.set('HAVE_XZ', libxz.found())
907 else
908 libxz = []
909 endif
910
911 want_lz4 = get_option('lz4')
912 if want_lz4 != 'false'
913 liblz4 = dependency('liblz4',
914 required : want_lz4 == 'true')
915 conf.set('HAVE_LZ4', liblz4.found())
916 else
917 liblz4 = []
918 endif
919
920 want_xkbcommon = get_option('xkbcommon')
921 if want_xkbcommon != 'false'
922 libxkbcommon = dependency('xkbcommon',
923 version : '>= 0.3.0',
924 required : want_xkbcommon == 'true')
925 conf.set('HAVE_XKBCOMMON', libxkbcommon.found())
926 else
927 libxkbcommon = []
928 endif
929
930 want_glib = get_option('glib')
931 if want_glib != 'false'
932 libglib = dependency('glib-2.0',
933 version : '>= 2.22.0',
934 required : want_glib == 'true')
935 libgobject = dependency('gobject-2.0',
936 version : '>= 2.22.0',
937 required : want_glib == 'true')
938 libgio = dependency('gio-2.0',
939 required : want_glib == 'true')
940 have = libglib.found() and libgobject.found() and libgio.found()
941 conf.set('HAVE_GLIB', have)
942 else
943 libglib = []
944 libgobject = []
945 libgio = []
946 endif
947
948 want_dbus = get_option('dbus')
949 if want_dbus != 'false'
950 libdbus = dependency('dbus-1',
951 version : '>= 1.3.2',
952 required : want_dbus == 'true')
953 conf.set('HAVE_DBUS', libdbus.found())
954 else
955 libdbus = []
956 endif
957
958 default_dnssec = get_option('default-dnssec')
959 if default_dnssec != 'no' and not conf.get('HAVE_GCRYPT', false)
960 message('default-dnssec cannot be set to yes or allow-downgrade when gcrypt is disabled. Setting default-dnssec to no.')
961 default_dnssec = 'no'
962 endif
963 conf.set('DEFAULT_DNSSEC_MODE',
964 'DNSSEC_' + default_dnssec.underscorify().to_upper())
965 substs.set('DEFAULT_DNSSEC_MODE', default_dnssec)
966
967 want_importd = get_option('importd')
968 if want_importd != 'false'
969 have_deps = (conf.get('HAVE_LIBCURL', false) and
970 conf.get('HAVE_ZLIB', false) and
971 conf.get('HAVE_BZIP2', false) and
972 conf.get('HAVE_XZ', false) and
973 conf.get('HAVE_GCRYPT', false))
974 conf.set('ENABLE_IMPORTD', have_deps)
975 if want_importd == 'true' and not have_deps
976 error('importd support was requested, but dependencies are not available')
977 endif
978 endif
979
980 want_remote = get_option('remote')
981 if want_remote != 'false'
982 have_deps = [conf.get('HAVE_MICROHTTPD', false),
983 conf.get('HAVE_LIBCURL', false)]
984 # sd-j-remote requires µhttpd, and sd-j-upload requires libcurl, so
985 # it's possible to build one without the other. Complain only if
986 # support was explictly requested. The auxiliary files like sysusers
987 # config should be installed when any of the programs are built.
988 if want_remote == 'true' and not (have_deps[0] and have_deps[1])
989 error('remote support was requested, but dependencies are not available')
990 endif
991 conf.set('ENABLE_REMOTE', have_deps[0] or have_deps[1])
992 endif
993
994 foreach pair : [['utmp', 'HAVE_UTMP'],
995 ['hibernate', 'ENABLE_HIBERNATE'],
996 ['environment-d', 'ENABLE_ENVIRONMENT_D'],
997 ['binfmt', 'ENABLE_BINFMT'],
998 ['coredump', 'ENABLE_COREDUMP'],
999 ['resolve', 'ENABLE_RESOLVED'],
1000 ['logind', 'ENABLE_LOGIND'],
1001 ['hostnamed', 'ENABLE_HOSTNAMED'],
1002 ['localed', 'ENABLE_LOCALED'],
1003 ['machined', 'ENABLE_MACHINED'],
1004 ['networkd', 'ENABLE_NETWORKD'],
1005 ['timedated', 'ENABLE_TIMEDATED'],
1006 ['timesyncd', 'ENABLE_TIMESYNCD'],
1007 ['myhostname', 'HAVE_MYHOSTNAME'],
1008 ['firstboot', 'ENABLE_FIRSTBOOT'],
1009 ['randomseed', 'ENABLE_RANDOMSEED'],
1010 ['backlight', 'ENABLE_BACKLIGHT'],
1011 ['vconsole', 'ENABLE_VCONSOLE'],
1012 ['quotacheck', 'ENABLE_QUOTACHECK'],
1013 ['sysusers', 'ENABLE_SYSUSERS'],
1014 ['tmpfiles', 'ENABLE_TMPFILES'],
1015 ['hwdb', 'ENABLE_HWDB'],
1016 ['rfkill', 'ENABLE_RFKILL'],
1017 ['ldconfig', 'ENABLE_LDCONFIG'],
1018 ['efi', 'ENABLE_EFI'],
1019 ['tpm', 'ENABLE_TPM'],
1020 ['ima', 'HAVE_IMA'],
1021 ['smack', 'HAVE_SMACK'],
1022 ['gshadow', 'ENABLE_GSHADOW'],
1023 ['idn', 'ENABLE_IDN'],
1024 ['nss-systemd', 'ENABLE_NSS_SYSTEMD'],
1025 ]
1026
1027 if get_option(pair[0])
1028 conf.set(pair[1], true)
1029 m4_defines += ['-D' + pair[1]]
1030 endif
1031 endforeach
1032
1033 want_tests = get_option('tests')
1034 install_tests = get_option('install-tests')
1035 tests = []
1036
1037 conf.set10('SYSTEMD_SLOW_TESTS_DEFAULT', get_option('slow-tests'))
1038
1039 #####################################################################
1040
1041 if get_option('efi')
1042 efi_arch = host_machine.cpu_family()
1043
1044 if efi_arch == 'x86'
1045 EFI_MACHINE_TYPE_NAME = 'ia32'
1046 gnu_efi_arch = 'ia32'
1047 elif efi_arch == 'x86_64'
1048 EFI_MACHINE_TYPE_NAME = 'x64'
1049 gnu_efi_arch = 'x86_64'
1050 elif efi_arch == 'arm'
1051 EFI_MACHINE_TYPE_NAME = 'arm'
1052 gnu_efi_arch = 'arm'
1053 elif efi_arch == 'aarch64'
1054 EFI_MACHINE_TYPE_NAME = 'aa64'
1055 gnu_efi_arch = 'aarch64'
1056 else
1057 EFI_MACHINE_TYPE_NAME = ''
1058 gnu_efi_arch = ''
1059 endif
1060
1061 conf.set('ENABLE_EFI', true)
1062 conf.set_quoted('EFI_MACHINE_TYPE_NAME', EFI_MACHINE_TYPE_NAME)
1063
1064 conf.set('SD_TPM_PCR', get_option('tpm-pcrindex').to_int())
1065 endif
1066
1067 #####################################################################
1068
1069 config_h = configure_file(
1070 output : 'config.h',
1071 configuration : conf)
1072
1073 includes = include_directories('src/basic',
1074 'src/shared',
1075 'src/systemd',
1076 'src/journal',
1077 'src/resolve',
1078 'src/timesync',
1079 'src/login',
1080 'src/udev',
1081 'src/libudev',
1082 'src/core',
1083 'src/libsystemd/sd-bus',
1084 'src/libsystemd/sd-device',
1085 'src/libsystemd/sd-hwdb',
1086 'src/libsystemd/sd-id128',
1087 'src/libsystemd/sd-netlink',
1088 'src/libsystemd/sd-network',
1089 'src/libsystemd-network',
1090 )
1091
1092 add_project_arguments('-include', 'config.h', language : 'c')
1093
1094 gcrypt_util_sources = files('src/shared/gcrypt-util.h',
1095 'src/shared/gcrypt-util.c')
1096
1097 subdir('po')
1098 subdir('catalog')
1099 subdir('src/systemd')
1100 subdir('src/basic')
1101 subdir('src/libsystemd')
1102 subdir('src/libsystemd-network')
1103 subdir('src/journal')
1104 subdir('src/login')
1105
1106 libjournal_core = static_library(
1107 'journal-core',
1108 libjournal_core_sources,
1109 journald_gperf_c,
1110 include_directories : includes,
1111 install : false)
1112
1113 libsystemd_sym_path = '@0@/@1@'.format(meson.current_source_dir(), libsystemd_sym)
1114 libsystemd = shared_library(
1115 'systemd',
1116 libsystemd_internal_sources,
1117 journal_internal_sources,
1118 version : '0.19.0',
1119 include_directories : includes,
1120 link_args : ['-shared',
1121 '-Wl,--version-script=' + libsystemd_sym_path],
1122 link_with : [libbasic],
1123 dependencies : [threads,
1124 libgcrypt,
1125 librt,
1126 libxz,
1127 liblz4],
1128 link_depends : libsystemd_sym,
1129 install : true,
1130 install_dir : rootlibdir)
1131
1132 ############################################################
1133
1134 # binaries that have --help and are intended for use by humans,
1135 # usually, but not always, installed in /bin.
1136 public_programs = []
1137
1138 subdir('src/libudev')
1139 subdir('src/shared')
1140 subdir('src/core')
1141 subdir('src/udev')
1142 subdir('src/network')
1143
1144 subdir('src/analyze')
1145 subdir('src/journal-remote')
1146 subdir('src/coredump')
1147 subdir('src/hostname')
1148 subdir('src/import')
1149 subdir('src/kernel-install')
1150 subdir('src/locale')
1151 subdir('src/machine')
1152 subdir('src/nspawn')
1153 subdir('src/resolve')
1154 subdir('src/timedate')
1155 subdir('src/timesync')
1156 subdir('src/vconsole')
1157 subdir('src/sulogin-shell')
1158 subdir('src/boot/efi')
1159
1160 subdir('src/test')
1161 subdir('test')
1162
1163 ############################################################
1164
1165 # only static linking apart from libdl, to make sure that the
1166 # module is linked to all libraries that it uses.
1167 test_dlopen = executable(
1168 'test-dlopen',
1169 test_dlopen_c,
1170 include_directories : includes,
1171 link_with : [libbasic],
1172 dependencies : [libdl])
1173
1174 foreach tuple : [['myhostname', 'HAVE_MYHOSTNAME'],
1175 ['systemd', 'ENABLE_NSS_SYSTEMD'],
1176 ['mymachines', 'ENABLE_MACHINED'],
1177 ['resolve', 'ENABLE_RESOLVED']]
1178
1179 condition = tuple[1] == '' or conf.get(tuple[1], false)
1180 if condition
1181 module = tuple[0]
1182
1183 sym = 'src/nss-@0@/nss-@0@.sym'.format(module)
1184 version_script_arg = join_paths(meson.current_source_dir(), sym)
1185
1186 nss = shared_library(
1187 'nss_' + module,
1188 'src/nss-@0@/nss-@0@.c'.format(module),
1189 version : '2',
1190 include_directories : includes,
1191 link_args : ['-shared',
1192 '-Wl,--version-script=' + version_script_arg,
1193 '-Wl,--undefined'],
1194 link_with : [libsystemd_internal,
1195 libbasic],
1196 dependencies : [threads,
1197 librt],
1198 link_depends : sym,
1199 install : true,
1200 install_dir : rootlibdir)
1201
1202 # We cannot use shared_module because it does not support version suffix.
1203 # Unfortunately shared_library insists on creating the symlink…
1204 meson.add_install_script('sh', '-c',
1205 'rm $DESTDIR@0@/libnss_@1@.so'
1206 .format(rootlibdir, module))
1207
1208 test('dlopen-nss_' + module,
1209 test_dlopen,
1210 args : [nss.full_path()]) # path to dlopen must include a slash
1211 endif
1212 endforeach
1213
1214 ############################################################
1215
1216 executable('systemd',
1217 systemd_sources,
1218 include_directories : includes,
1219 link_with : [libcore,
1220 libshared],
1221 dependencies : [threads,
1222 librt,
1223 libseccomp,
1224 libselinux,
1225 libmount,
1226 libblkid],
1227 install_rpath : rootlibexecdir,
1228 install : true,
1229 install_dir : rootlibexecdir)
1230
1231 exe = executable('systemd-analyze',
1232 systemd_analyze_sources,
1233 include_directories : includes,
1234 link_with : [libcore,
1235 libshared],
1236 dependencies : [threads,
1237 librt,
1238 libseccomp,
1239 libselinux,
1240 libmount,
1241 libblkid],
1242 install_rpath : rootlibexecdir,
1243 install : true)
1244 public_programs += [exe]
1245
1246 executable('systemd-journald',
1247 systemd_journald_sources,
1248 include_directories : includes,
1249 link_with : [libjournal_core,
1250 libshared],
1251 dependencies : [threads,
1252 libxz,
1253 liblz4,
1254 libselinux],
1255 install_rpath : rootlibexecdir,
1256 install : true,
1257 install_dir : rootlibexecdir)
1258
1259 exe = executable('systemd-cat',
1260 systemd_cat_sources,
1261 include_directories : includes,
1262 link_with : [libjournal_core,
1263 libshared],
1264 dependencies : [threads],
1265 install_rpath : rootlibexecdir,
1266 install : true)
1267 public_programs += [exe]
1268
1269 exe = executable('journalctl',
1270 journalctl_sources,
1271 include_directories : includes,
1272 link_with : [libshared],
1273 dependencies : [threads,
1274 libqrencode,
1275 libxz,
1276 liblz4],
1277 install_rpath : rootlibexecdir,
1278 install : true,
1279 install_dir : rootbindir)
1280 public_programs += [exe]
1281
1282 executable('systemd-getty-generator',
1283 'src/getty-generator/getty-generator.c',
1284 include_directories : includes,
1285 link_with : [libshared],
1286 install_rpath : rootlibexecdir,
1287 install : true,
1288 install_dir : systemgeneratordir)
1289
1290 executable('systemd-debug-generator',
1291 'src/debug-generator/debug-generator.c',
1292 include_directories : includes,
1293 link_with : [libshared],
1294 install_rpath : rootlibexecdir,
1295 install : true,
1296 install_dir : systemgeneratordir)
1297
1298 executable('systemd-fstab-generator',
1299 'src/fstab-generator/fstab-generator.c',
1300 'src/core/mount-setup.c',
1301 include_directories : includes,
1302 link_with : [libshared],
1303 install_rpath : rootlibexecdir,
1304 install : true,
1305 install_dir : systemgeneratordir)
1306
1307 if conf.get('ENABLE_ENVIRONMENT_D', false)
1308 executable('30-systemd-environment-d-generator',
1309 'src/environment-d-generator/environment-d-generator.c',
1310 include_directories : includes,
1311 link_with : [libshared],
1312 install_rpath : rootlibexecdir,
1313 install : true,
1314 install_dir : userenvgeneratordir)
1315
1316 meson.add_install_script(meson_make_symlink,
1317 join_paths(sysconfdir, 'environment'),
1318 join_paths(environmentdir, '99-environment.conf'))
1319 endif
1320
1321 if conf.get('ENABLE_HIBERNATE', false)
1322 executable('systemd-hibernate-resume-generator',
1323 'src/hibernate-resume/hibernate-resume-generator.c',
1324 include_directories : includes,
1325 link_with : [libshared],
1326 install_rpath : rootlibexecdir,
1327 install : true,
1328 install_dir : systemgeneratordir)
1329
1330 executable('systemd-hibernate-resume',
1331 'src/hibernate-resume/hibernate-resume.c',
1332 include_directories : includes,
1333 link_with : [libshared],
1334 install_rpath : rootlibexecdir,
1335 install : true,
1336 install_dir : rootlibexecdir)
1337 endif
1338
1339 if conf.get('HAVE_BLKID', false)
1340 executable('systemd-gpt-auto-generator',
1341 'src/gpt-auto-generator/gpt-auto-generator.c',
1342 'src/basic/blkid-util.h',
1343 include_directories : includes,
1344 link_with : [libshared],
1345 dependencies : libblkid,
1346 install_rpath : rootlibexecdir,
1347 install : true,
1348 install_dir : systemgeneratordir)
1349
1350 exe = executable('systemd-dissect',
1351 'src/dissect/dissect.c',
1352 include_directories : includes,
1353 link_with : [libshared],
1354 install_rpath : rootlibexecdir,
1355 install : true,
1356 install_dir : rootlibexecdir)
1357 public_programs += [exe]
1358 endif
1359
1360 if conf.get('ENABLE_RESOLVED', false)
1361 executable('systemd-resolved',
1362 systemd_resolved_sources,
1363 gcrypt_util_sources,
1364 include_directories : includes,
1365 link_with : [libshared],
1366 dependencies : [threads,
1367 libgcrypt,
1368 libgpg_error,
1369 libm,
1370 libidn],
1371 install_rpath : rootlibexecdir,
1372 install : true,
1373 install_dir : rootlibexecdir)
1374
1375 exe = executable('systemd-resolve',
1376 systemd_resolve_sources,
1377 gcrypt_util_sources,
1378 include_directories : includes,
1379 link_with : [libshared],
1380 dependencies : [threads,
1381 libgcrypt,
1382 libgpg_error,
1383 libm,
1384 libidn],
1385 install_rpath : rootlibexecdir,
1386 install : true)
1387 public_programs += [exe]
1388 endif
1389
1390 if conf.get('ENABLE_LOGIND', false)
1391 executable('systemd-logind',
1392 systemd_logind_sources,
1393 include_directories : includes,
1394 link_with : [liblogind_core,
1395 libshared],
1396 dependencies : [threads,
1397 libacl],
1398 install_rpath : rootlibexecdir,
1399 install : true,
1400 install_dir : rootlibexecdir)
1401
1402 exe = executable('loginctl',
1403 loginctl_sources,
1404 include_directories : includes,
1405 link_with : [libshared],
1406 dependencies : [threads,
1407 liblz4,
1408 libxz],
1409 install_rpath : rootlibexecdir,
1410 install : true,
1411 install_dir : rootbindir)
1412 public_programs += [exe]
1413
1414 exe = executable('systemd-inhibit',
1415 'src/login/inhibit.c',
1416 include_directories : includes,
1417 link_with : [libshared],
1418 install_rpath : rootlibexecdir,
1419 install : true,
1420 install_dir : rootbindir)
1421 public_programs += [exe]
1422
1423 if conf.get('HAVE_PAM', false)
1424 version_script_arg = join_paths(meson.current_source_dir(), pam_systemd_sym)
1425 pam_systemd = shared_library(
1426 'pam_systemd',
1427 pam_systemd_c,
1428 name_prefix : '',
1429 include_directories : includes,
1430 link_args : ['-shared',
1431 '-Wl,--version-script=' + version_script_arg],
1432 link_with : [libsystemd_internal,
1433 libshared_static],
1434 dependencies : [threads,
1435 libpam,
1436 libpam_misc],
1437 link_depends : pam_systemd_sym,
1438 install : true,
1439 install_dir : pamlibdir)
1440
1441 test('dlopen-pam_systemd',
1442 test_dlopen,
1443 args : [pam_systemd.full_path()]) # path to dlopen must include a slash
1444 endif
1445 endif
1446
1447 if conf.get('HAVE_PAM', false)
1448 executable('systemd-user-sessions',
1449 'src/user-sessions/user-sessions.c',
1450 include_directories : includes,
1451 link_with : [libshared],
1452 install_rpath : rootlibexecdir,
1453 install : true,
1454 install_dir : rootlibexecdir)
1455 endif
1456
1457 if conf.get('ENABLE_EFI', false) and conf.get('HAVE_BLKID', false)
1458 exe = executable('bootctl',
1459 'src/boot/bootctl.c',
1460 include_directories : includes,
1461 link_with : [libshared],
1462 dependencies : [libblkid],
1463 install_rpath : rootlibexecdir,
1464 install : true)
1465 public_programs += [exe]
1466 endif
1467
1468 exe = executable('systemd-socket-activate', 'src/activate/activate.c',
1469 include_directories : includes,
1470 link_with : [libshared],
1471 dependencies : [threads],
1472 install_rpath : rootlibexecdir,
1473 install : true)
1474 public_programs += [exe]
1475
1476 exe = executable('systemctl', 'src/systemctl/systemctl.c',
1477 include_directories : includes,
1478 link_with : [libshared],
1479 dependencies : [threads,
1480 libcap,
1481 libselinux,
1482 libxz,
1483 liblz4],
1484 install_rpath : rootlibexecdir,
1485 install : true,
1486 install_dir : rootbindir)
1487 public_programs += [exe]
1488
1489 if conf.get('ENABLE_BACKLIGHT', false)
1490 executable('systemd-backlight',
1491 'src/backlight/backlight.c',
1492 include_directories : includes,
1493 link_with : [libshared],
1494 install_rpath : rootlibexecdir,
1495 install : true,
1496 install_dir : rootlibexecdir)
1497 endif
1498
1499 if conf.get('ENABLE_RFKILL', false)
1500 executable('systemd-rfkill',
1501 'src/rfkill/rfkill.c',
1502 include_directories : includes,
1503 link_with : [libshared],
1504 install_rpath : rootlibexecdir,
1505 install : true,
1506 install_dir : rootlibexecdir)
1507 endif
1508
1509 executable('systemd-system-update-generator',
1510 'src/system-update-generator/system-update-generator.c',
1511 include_directories : includes,
1512 link_with : [libshared],
1513 install_rpath : rootlibexecdir,
1514 install : true,
1515 install_dir : systemgeneratordir)
1516
1517 if conf.get('HAVE_LIBCRYPTSETUP', false)
1518 executable('systemd-cryptsetup',
1519 'src/cryptsetup/cryptsetup.c',
1520 include_directories : includes,
1521 link_with : [libshared],
1522 dependencies : [libcryptsetup],
1523 install_rpath : rootlibexecdir,
1524 install : true,
1525 install_dir : rootlibexecdir)
1526
1527 executable('systemd-cryptsetup-generator',
1528 'src/cryptsetup/cryptsetup-generator.c',
1529 include_directories : includes,
1530 link_with : [libshared],
1531 dependencies : [libcryptsetup],
1532 install_rpath : rootlibexecdir,
1533 install : true,
1534 install_dir : systemgeneratordir)
1535
1536 executable('systemd-veritysetup',
1537 'src/veritysetup/veritysetup.c',
1538 include_directories : includes,
1539 link_with : [libshared],
1540 dependencies : [libcryptsetup],
1541 install_rpath : rootlibexecdir,
1542 install : true,
1543 install_dir : rootlibexecdir)
1544
1545 executable('systemd-veritysetup-generator',
1546 'src/veritysetup/veritysetup-generator.c',
1547 include_directories : includes,
1548 link_with : [libshared],
1549 dependencies : [libcryptsetup],
1550 install_rpath : rootlibexecdir,
1551 install : true,
1552 install_dir : systemgeneratordir)
1553 endif
1554
1555 if conf.get('HAVE_SYSV_COMPAT', false)
1556 executable('systemd-sysv-generator',
1557 'src/sysv-generator/sysv-generator.c',
1558 include_directories : includes,
1559 link_with : [libshared],
1560 install_rpath : rootlibexecdir,
1561 install : true,
1562 install_dir : systemgeneratordir)
1563
1564 executable('systemd-rc-local-generator',
1565 'src/rc-local-generator/rc-local-generator.c',
1566 include_directories : includes,
1567 link_with : [libshared],
1568 install_rpath : rootlibexecdir,
1569 install : true,
1570 install_dir : systemgeneratordir)
1571 endif
1572
1573 if conf.get('ENABLE_HOSTNAMED', false)
1574 executable('systemd-hostnamed',
1575 'src/hostname/hostnamed.c',
1576 include_directories : includes,
1577 link_with : [libshared],
1578 install_rpath : rootlibexecdir,
1579 install : true,
1580 install_dir : rootlibexecdir)
1581
1582 exe = executable('hostnamectl',
1583 'src/hostname/hostnamectl.c',
1584 include_directories : includes,
1585 link_with : [libshared],
1586 install_rpath : rootlibexecdir,
1587 install : true)
1588 public_programs += [exe]
1589 endif
1590
1591 if conf.get('ENABLE_LOCALED', false)
1592 if conf.get('HAVE_XKBCOMMON', false)
1593 # logind will load libxkbcommon.so dynamically on its own
1594 deps = [libdl]
1595 else
1596 deps = []
1597 endif
1598
1599 executable('systemd-localed',
1600 systemd_localed_sources,
1601 include_directories : includes,
1602 link_with : [libshared],
1603 dependencies : deps,
1604 install_rpath : rootlibexecdir,
1605 install : true,
1606 install_dir : rootlibexecdir)
1607
1608 exe = executable('localectl',
1609 localectl_sources,
1610 include_directories : includes,
1611 link_with : [libshared],
1612 install_rpath : rootlibexecdir,
1613 install : true)
1614 public_programs += [exe]
1615 endif
1616
1617 if conf.get('ENABLE_TIMEDATED', false)
1618 executable('systemd-timedated',
1619 'src/timedate/timedated.c',
1620 include_directories : includes,
1621 link_with : [libshared],
1622 install_rpath : rootlibexecdir,
1623 install : true,
1624 install_dir : rootlibexecdir)
1625
1626 exe = executable('timedatectl',
1627 'src/timedate/timedatectl.c',
1628 include_directories : includes,
1629 install_rpath : rootlibexecdir,
1630 link_with : [libshared],
1631 install : true)
1632 public_programs += [exe]
1633 endif
1634
1635 if conf.get('ENABLE_TIMESYNCD', false)
1636 executable('systemd-timesyncd',
1637 systemd_timesyncd_sources,
1638 include_directories : includes,
1639 link_with : [libshared],
1640 dependencies : [threads,
1641 libm],
1642 install_rpath : rootlibexecdir,
1643 install : true,
1644 install_dir : rootlibexecdir)
1645 endif
1646
1647 if conf.get('ENABLE_MACHINED', false)
1648 executable('systemd-machined',
1649 systemd_machined_sources,
1650 include_directories : includes,
1651 link_with : [libmachine_core,
1652 libshared],
1653 install_rpath : rootlibexecdir,
1654 install : true,
1655 install_dir : rootlibexecdir)
1656
1657 exe = executable('machinectl',
1658 'src/machine/machinectl.c',
1659 include_directories : includes,
1660 link_with : [libshared],
1661 dependencies : [threads,
1662 libxz,
1663 liblz4],
1664 install_rpath : rootlibexecdir,
1665 install : true,
1666 install_dir : rootbindir)
1667 public_programs += [exe]
1668 endif
1669
1670 if conf.get('ENABLE_IMPORTD', false)
1671 executable('systemd-importd',
1672 systemd_importd_sources,
1673 include_directories : includes,
1674 link_with : [libshared],
1675 dependencies : [threads],
1676 install_rpath : rootlibexecdir,
1677 install : true,
1678 install_dir : rootlibexecdir)
1679
1680 systemd_pull = executable('systemd-pull',
1681 systemd_pull_sources,
1682 include_directories : includes,
1683 link_with : [libshared],
1684 dependencies : [libcurl,
1685 libz,
1686 libbzip2,
1687 libxz,
1688 libgcrypt],
1689 install_rpath : rootlibexecdir,
1690 install : true,
1691 install_dir : rootlibexecdir)
1692
1693 systemd_import = executable('systemd-import',
1694 systemd_import_sources,
1695 include_directories : includes,
1696 link_with : [libshared],
1697 dependencies : [libcurl,
1698 libz,
1699 libbzip2,
1700 libxz],
1701 install_rpath : rootlibexecdir,
1702 install : true,
1703 install_dir : rootlibexecdir)
1704
1705 systemd_export = executable('systemd-export',
1706 systemd_export_sources,
1707 include_directories : includes,
1708 link_with : [libshared],
1709 dependencies : [libcurl,
1710 libz,
1711 libbzip2,
1712 libxz],
1713 install_rpath : rootlibexecdir,
1714 install : true,
1715 install_dir : rootlibexecdir)
1716 public_programs += [systemd_pull, systemd_import, systemd_export]
1717 endif
1718
1719 if conf.get('ENABLE_REMOTE', false) and conf.get('HAVE_LIBCURL', false)
1720 exe = executable('systemd-journal-upload',
1721 systemd_journal_upload_sources,
1722 include_directories : includes,
1723 link_with : [libshared],
1724 dependencies : [threads,
1725 libcurl,
1726 libgnutls,
1727 libxz,
1728 liblz4],
1729 install_rpath : rootlibexecdir,
1730 install : true,
1731 install_dir : rootlibexecdir)
1732 public_programs += [exe]
1733 endif
1734
1735 if conf.get('ENABLE_REMOTE', false) and conf.get('HAVE_MICROHTTPD', false)
1736 s_j_remote = executable('systemd-journal-remote',
1737 systemd_journal_remote_sources,
1738 include_directories : includes,
1739 link_with : [libshared],
1740 dependencies : [threads,
1741 libmicrohttpd,
1742 libgnutls,
1743 libxz,
1744 liblz4],
1745 install_rpath : rootlibexecdir,
1746 install : true,
1747 install_dir : rootlibexecdir)
1748
1749 s_j_gatewayd = executable('systemd-journal-gatewayd',
1750 systemd_journal_gatewayd_sources,
1751 include_directories : includes,
1752 link_with : [libshared],
1753 dependencies : [threads,
1754 libmicrohttpd,
1755 libgnutls,
1756 libxz,
1757 liblz4],
1758 install_rpath : rootlibexecdir,
1759 install : true,
1760 install_dir : rootlibexecdir)
1761 public_programs += [s_j_remote, s_j_gatewayd]
1762 endif
1763
1764 if conf.get('ENABLE_COREDUMP', false)
1765 executable('systemd-coredump',
1766 systemd_coredump_sources,
1767 include_directories : includes,
1768 link_with : [libshared],
1769 dependencies : [threads,
1770 libacl,
1771 libdw,
1772 libxz,
1773 liblz4],
1774 install_rpath : rootlibexecdir,
1775 install : true,
1776 install_dir : rootlibexecdir)
1777
1778 exe = executable('coredumpctl',
1779 coredumpctl_sources,
1780 include_directories : includes,
1781 link_with : [libshared],
1782 dependencies : [threads,
1783 libxz,
1784 liblz4],
1785 install_rpath : rootlibexecdir,
1786 install : true)
1787 public_programs += [exe]
1788 endif
1789
1790 if conf.get('ENABLE_BINFMT', false)
1791 exe = executable('systemd-binfmt',
1792 'src/binfmt/binfmt.c',
1793 include_directories : includes,
1794 link_with : [libshared],
1795 install_rpath : rootlibexecdir,
1796 install : true,
1797 install_dir : rootlibexecdir)
1798 public_programs += [exe]
1799
1800 meson.add_install_script('sh', '-c',
1801 mkdir_p.format(binfmtdir))
1802 meson.add_install_script('sh', '-c',
1803 mkdir_p.format(join_paths(sysconfdir, 'binfmt.d')))
1804 endif
1805
1806 if conf.get('ENABLE_VCONSOLE', false)
1807 executable('systemd-vconsole-setup',
1808 'src/vconsole/vconsole-setup.c',
1809 include_directories : includes,
1810 link_with : [libshared],
1811 install_rpath : rootlibexecdir,
1812 install : true,
1813 install_dir : rootlibexecdir)
1814 endif
1815
1816 if conf.get('ENABLE_RANDOMSEED', false)
1817 executable('systemd-random-seed',
1818 'src/random-seed/random-seed.c',
1819 include_directories : includes,
1820 link_with : [libshared],
1821 install_rpath : rootlibexecdir,
1822 install : true,
1823 install_dir : rootlibexecdir)
1824 endif
1825
1826 if conf.get('ENABLE_FIRSTBOOT', false)
1827 executable('systemd-firstboot',
1828 'src/firstboot/firstboot.c',
1829 include_directories : includes,
1830 link_with : [libshared],
1831 dependencies : [libcrypt],
1832 install_rpath : rootlibexecdir,
1833 install : true,
1834 install_dir : rootbindir)
1835 endif
1836
1837 executable('systemd-remount-fs',
1838 'src/remount-fs/remount-fs.c',
1839 'src/core/mount-setup.c',
1840 'src/core/mount-setup.h',
1841 include_directories : includes,
1842 link_with : [libshared],
1843 install_rpath : rootlibexecdir,
1844 install : true,
1845 install_dir : rootlibexecdir)
1846
1847 executable('systemd-machine-id-setup',
1848 'src/machine-id-setup/machine-id-setup-main.c',
1849 'src/core/machine-id-setup.c',
1850 'src/core/machine-id-setup.h',
1851 include_directories : includes,
1852 link_with : [libshared],
1853 install_rpath : rootlibexecdir,
1854 install : true,
1855 install_dir : rootbindir)
1856
1857 executable('systemd-fsck',
1858 'src/fsck/fsck.c',
1859 include_directories : includes,
1860 link_with : [libshared],
1861 install_rpath : rootlibexecdir,
1862 install : true,
1863 install_dir : rootlibexecdir)
1864
1865 executable('systemd-sleep',
1866 'src/sleep/sleep.c',
1867 include_directories : includes,
1868 link_with : [libshared],
1869 install_rpath : rootlibexecdir,
1870 install : true,
1871 install_dir : rootlibexecdir)
1872
1873 exe = executable('systemd-sysctl',
1874 'src/sysctl/sysctl.c',
1875 include_directories : includes,
1876 link_with : [libshared],
1877 install_rpath : rootlibexecdir,
1878 install : true,
1879 install_dir : rootlibexecdir)
1880 public_programs += [exe]
1881
1882 executable('systemd-ac-power',
1883 'src/ac-power/ac-power.c',
1884 include_directories : includes,
1885 link_with : [libshared],
1886 install_rpath : rootlibexecdir,
1887 install : true,
1888 install_dir : rootlibexecdir)
1889
1890 exe = executable('systemd-detect-virt',
1891 'src/detect-virt/detect-virt.c',
1892 include_directories : includes,
1893 link_with : [libshared],
1894 install_rpath : rootlibexecdir,
1895 install : true)
1896 public_programs += [exe]
1897
1898 exe = executable('systemd-delta',
1899 'src/delta/delta.c',
1900 include_directories : includes,
1901 link_with : [libshared],
1902 install_rpath : rootlibexecdir,
1903 install : true)
1904 public_programs += [exe]
1905
1906 exe = executable('systemd-escape',
1907 'src/escape/escape.c',
1908 include_directories : includes,
1909 link_with : [libshared],
1910 install_rpath : rootlibexecdir,
1911 install : true,
1912 install_dir : rootbindir)
1913 public_programs += [exe]
1914
1915 exe = executable('systemd-notify',
1916 'src/notify/notify.c',
1917 include_directories : includes,
1918 link_with : [libshared],
1919 install_rpath : rootlibexecdir,
1920 install : true,
1921 install_dir : rootbindir)
1922 public_programs += [exe]
1923
1924 executable('systemd-volatile-root',
1925 'src/volatile-root/volatile-root.c',
1926 include_directories : includes,
1927 link_with : [libshared],
1928 install_rpath : rootlibexecdir,
1929 install : true,
1930 install_dir : rootlibexecdir)
1931
1932 executable('systemd-cgroups-agent',
1933 'src/cgroups-agent/cgroups-agent.c',
1934 include_directories : includes,
1935 link_with : [libshared],
1936 install_rpath : rootlibexecdir,
1937 install : true,
1938 install_dir : rootlibexecdir)
1939
1940 exe = executable('systemd-path',
1941 'src/path/path.c',
1942 include_directories : includes,
1943 link_with : [libshared],
1944 install_rpath : rootlibexecdir,
1945 install : true)
1946 public_programs += [exe]
1947
1948 exe = executable('systemd-ask-password',
1949 'src/ask-password/ask-password.c',
1950 include_directories : includes,
1951 link_with : [libshared],
1952 install_rpath : rootlibexecdir,
1953 install : true,
1954 install_dir : rootbindir)
1955 public_programs += [exe]
1956
1957 executable('systemd-reply-password',
1958 'src/reply-password/reply-password.c',
1959 include_directories : includes,
1960 link_with : [libshared],
1961 install_rpath : rootlibexecdir,
1962 install : true,
1963 install_dir : rootlibexecdir)
1964
1965 exe = executable('systemd-tty-ask-password-agent',
1966 'src/tty-ask-password-agent/tty-ask-password-agent.c',
1967 include_directories : includes,
1968 link_with : [libshared],
1969 install_rpath : rootlibexecdir,
1970 install : true,
1971 install_dir : rootbindir)
1972 public_programs += [exe]
1973
1974 exe = executable('systemd-cgls',
1975 'src/cgls/cgls.c',
1976 include_directories : includes,
1977 link_with : [libshared],
1978 install_rpath : rootlibexecdir,
1979 install : true)
1980 public_programs += [exe]
1981
1982 exe = executable('systemd-cgtop',
1983 'src/cgtop/cgtop.c',
1984 include_directories : includes,
1985 link_with : [libshared],
1986 install_rpath : rootlibexecdir,
1987 install : true)
1988 public_programs += [exe]
1989
1990 executable('systemd-initctl',
1991 'src/initctl/initctl.c',
1992 include_directories : includes,
1993 link_with : [libshared],
1994 install_rpath : rootlibexecdir,
1995 install : true,
1996 install_dir : rootlibexecdir)
1997
1998 exe = executable('systemd-mount',
1999 'src/mount/mount-tool.c',
2000 include_directories : includes,
2001 link_with : [libshared],
2002 install_rpath : rootlibexecdir,
2003 install : true)
2004 public_programs += [exe]
2005
2006 meson.add_install_script(meson_make_symlink,
2007 'systemd-mount', join_paths(bindir, 'systemd-umount'))
2008
2009 exe = executable('systemd-run',
2010 'src/run/run.c',
2011 include_directories : includes,
2012 link_with : [libshared],
2013 install_rpath : rootlibexecdir,
2014 install : true)
2015 public_programs += [exe]
2016
2017 exe = executable('systemd-stdio-bridge',
2018 'src/stdio-bridge/stdio-bridge.c',
2019 include_directories : includes,
2020 link_with : [libshared],
2021 install_rpath : rootlibexecdir,
2022 install : true)
2023 public_programs += [exe]
2024
2025 exe = executable('busctl',
2026 'src/busctl/busctl.c',
2027 'src/busctl/busctl-introspect.c',
2028 'src/busctl/busctl-introspect.h',
2029 include_directories : includes,
2030 link_with : [libshared],
2031 install_rpath : rootlibexecdir,
2032 install : true)
2033 public_programs += [exe]
2034
2035 if conf.get('ENABLE_SYSUSERS', false)
2036 exe = executable('systemd-sysusers',
2037 'src/sysusers/sysusers.c',
2038 include_directories : includes,
2039 link_with : [libshared],
2040 install_rpath : rootlibexecdir,
2041 install : true,
2042 install_dir : rootbindir)
2043 public_programs += [exe]
2044 endif
2045
2046 if conf.get('ENABLE_TMPFILES', false)
2047 exe = executable('systemd-tmpfiles',
2048 'src/tmpfiles/tmpfiles.c',
2049 include_directories : includes,
2050 link_with : [libshared],
2051 dependencies : [libacl],
2052 install_rpath : rootlibexecdir,
2053 install : true,
2054 install_dir : rootbindir)
2055 public_programs += [exe]
2056 endif
2057
2058 if conf.get('ENABLE_HWDB', false)
2059 exe = executable('systemd-hwdb',
2060 'src/hwdb/hwdb.c',
2061 'src/libsystemd/sd-hwdb/hwdb-internal.h',
2062 include_directories : includes,
2063 link_with : [libudev_internal],
2064 install_rpath : udev_rpath,
2065 install : true,
2066 install_dir : rootbindir)
2067 public_programs += [exe]
2068 endif
2069
2070 if conf.get('ENABLE_QUOTACHECK', false)
2071 executable('systemd-quotacheck',
2072 'src/quotacheck/quotacheck.c',
2073 include_directories : includes,
2074 link_with : [libshared],
2075 install_rpath : rootlibexecdir,
2076 install : true,
2077 install_dir : rootlibexecdir)
2078 endif
2079
2080 exe = executable('systemd-socket-proxyd',
2081 'src/socket-proxy/socket-proxyd.c',
2082 include_directories : includes,
2083 link_with : [libshared],
2084 dependencies : [threads],
2085 install_rpath : rootlibexecdir,
2086 install : true,
2087 install_dir : rootlibexecdir)
2088 public_programs += [exe]
2089
2090 exe = executable('systemd-udevd',
2091 systemd_udevd_sources,
2092 include_directories : includes,
2093 c_args : ['-DLOG_REALM=LOG_REALM_UDEV'],
2094 link_with : [libudev_core,
2095 libsystemd_network,
2096 libudev_internal],
2097 dependencies : [threads,
2098 libkmod,
2099 libidn,
2100 libacl,
2101 libblkid],
2102 install_rpath : udev_rpath,
2103 install : true,
2104 install_dir : rootlibexecdir)
2105 public_programs += [exe]
2106
2107 exe = executable('udevadm',
2108 udevadm_sources,
2109 include_directories : includes,
2110 link_with : [libudev_core,
2111 libsystemd_network,
2112 libudev_internal],
2113 dependencies : [threads,
2114 libkmod,
2115 libidn,
2116 libacl,
2117 libblkid],
2118 install_rpath : udev_rpath,
2119 install : true,
2120 install_dir : rootbindir)
2121 public_programs += [exe]
2122
2123 executable('systemd-shutdown',
2124 systemd_shutdown_sources,
2125 include_directories : includes,
2126 link_with : [libshared],
2127 install_rpath : rootlibexecdir,
2128 install : true,
2129 install_dir : rootlibexecdir)
2130
2131 executable('systemd-update-done',
2132 'src/update-done/update-done.c',
2133 include_directories : includes,
2134 link_with : [libshared],
2135 install_rpath : rootlibexecdir,
2136 install : true,
2137 install_dir : rootlibexecdir)
2138
2139 executable('systemd-update-utmp',
2140 'src/update-utmp/update-utmp.c',
2141 include_directories : includes,
2142 link_with : [libshared],
2143 dependencies : [libaudit],
2144 install_rpath : rootlibexecdir,
2145 install : true,
2146 install_dir : rootlibexecdir)
2147
2148 if conf.get('HAVE_KMOD', false)
2149 executable('systemd-modules-load',
2150 'src/modules-load/modules-load.c',
2151 include_directories : includes,
2152 link_with : [libshared],
2153 dependencies : [libkmod],
2154 install_rpath : rootlibexecdir,
2155 install : true,
2156 install_dir : rootlibexecdir)
2157
2158 meson.add_install_script('sh', '-c',
2159 mkdir_p.format(modulesloaddir))
2160 meson.add_install_script('sh', '-c',
2161 mkdir_p.format(join_paths(sysconfdir, 'modules-load.d')))
2162 endif
2163
2164 exe = executable('systemd-nspawn',
2165 systemd_nspawn_sources,
2166 'src/core/mount-setup.c', # FIXME: use a variable?
2167 'src/core/mount-setup.h',
2168 'src/core/loopback-setup.c',
2169 'src/core/loopback-setup.h',
2170 include_directories : [includes, include_directories('src/nspawn')],
2171 link_with : [libshared],
2172 dependencies : [libacl,
2173 libblkid,
2174 libseccomp,
2175 libselinux],
2176 install_rpath : rootlibexecdir,
2177 install : true)
2178 public_programs += [exe]
2179
2180 if conf.get('ENABLE_NETWORKD', false)
2181 executable('systemd-networkd',
2182 systemd_networkd_sources,
2183 include_directories : includes,
2184 link_with : [libnetworkd_core,
2185 libsystemd_network,
2186 libudev_internal,
2187 libshared],
2188 dependencies : [threads],
2189 install_rpath : rootlibexecdir,
2190 install : true,
2191 install_dir : rootlibexecdir)
2192
2193 executable('systemd-networkd-wait-online',
2194 systemd_networkd_wait_online_sources,
2195 include_directories : includes,
2196 link_with : [libnetworkd_core,
2197 libshared],
2198 install_rpath : rootlibexecdir,
2199 install : true,
2200 install_dir : rootlibexecdir)
2201 endif
2202
2203 exe = executable('networkctl',
2204 networkctl_sources,
2205 include_directories : includes,
2206 link_with : [libsystemd_network,
2207 libshared],
2208 install_rpath : rootlibexecdir,
2209 install : true,
2210 install_dir : rootbindir)
2211 public_programs += [exe]
2212
2213 ############################################################
2214
2215 foreach tuple : tests
2216 sources = tuple[0]
2217 link_with = tuple[1].length() > 0 ? tuple[1] : [libshared]
2218 dependencies = tuple[2]
2219 condition = tuple.length() >= 4 ? tuple[3] : ''
2220 type = tuple.length() >= 5 ? tuple[4] : ''
2221 defs = tuple.length() >= 6 ? tuple[5] : []
2222 incs = tuple.length() >= 7 ? tuple[6] : includes
2223 timeout = 30
2224
2225 name = sources[0].split('/')[-1].split('.')[0]
2226 if type.startswith('timeout=')
2227 timeout = type.split('=')[1].to_int()
2228 type = ''
2229 endif
2230
2231 if condition == '' or conf.get(condition, false)
2232 exe = executable(
2233 name,
2234 sources,
2235 include_directories : incs,
2236 link_with : link_with,
2237 dependencies : dependencies,
2238 c_args : defs,
2239 install_rpath : rootlibexecdir,
2240 install : install_tests,
2241 install_dir : join_paths(testsdir, type))
2242
2243 if type == 'manual'
2244 message('@0@ is a manual test'.format(name))
2245 elif type == 'unsafe' and want_tests != 'unsafe'
2246 message('@0@ is an unsafe test'.format(name))
2247 else
2248 test(name, exe,
2249 env : test_env,
2250 timeout : timeout)
2251 endif
2252 else
2253 message('Not compiling @0@ because @1@ is not true'.format(name, condition))
2254 endif
2255 endforeach
2256
2257 test_libsystemd_sym = executable(
2258 'test-libsystemd-sym',
2259 test_libsystemd_sym_c,
2260 include_directories : includes,
2261 link_with : [libsystemd],
2262 install : install_tests,
2263 install_dir : testsdir)
2264 test('test-libsystemd-sym',
2265 test_libsystemd_sym)
2266
2267 test_libudev_sym = executable(
2268 'test-libudev-sym',
2269 test_libudev_sym_c,
2270 include_directories : includes,
2271 c_args : ['-Wno-deprecated-declarations'],
2272 link_with : [libudev],
2273 install : install_tests,
2274 install_dir : testsdir)
2275 test('test-libudev-sym',
2276 test_libudev_sym)
2277
2278 ############################################################
2279
2280 make_directive_index_py = find_program('tools/make-directive-index.py')
2281 make_man_index_py = find_program('tools/make-man-index.py')
2282 xml_helper_py = find_program('tools/xml_helper.py')
2283 hwdb_update_sh = find_program('tools/meson-hwdb-update.sh')
2284
2285 subdir('units')
2286 subdir('sysctl.d')
2287 subdir('sysusers.d')
2288 subdir('tmpfiles.d')
2289 subdir('rules')
2290 subdir('hwdb')
2291 subdir('network')
2292 subdir('man')
2293 subdir('shell-completion/bash')
2294 subdir('shell-completion/zsh')
2295 subdir('docs/sysvinit')
2296 subdir('docs/var-log')
2297
2298 # FIXME: figure out if the warning is true:
2299 # https://github.com/mesonbuild/meson/wiki/Reference-manual#install_subdir
2300 install_subdir('factory/etc',
2301 install_dir : factorydir)
2302
2303
2304 install_data('xorg/50-systemd-user.sh',
2305 install_dir : xinitrcdir)
2306 install_data('system-preset/90-systemd.preset',
2307 install_dir : systempresetdir)
2308 install_data('README',
2309 'NEWS',
2310 'CODING_STYLE',
2311 'DISTRO_PORTING',
2312 'ENVIRONMENT.md',
2313 'LICENSE.GPL2',
2314 'LICENSE.LGPL2.1',
2315 'src/libsystemd/sd-bus/GVARIANT-SERIALIZATION',
2316 install_dir : docdir)
2317
2318 meson.add_install_script('sh', '-c', mkdir_p.format(systemdstatedir))
2319 meson.add_install_script('sh', '-c', 'touch $DESTDIR@0@'.format(prefixdir))
2320
2321 ############################################################
2322
2323 meson_check_help = find_program('tools/meson-check-help.sh')
2324
2325 foreach exec : public_programs
2326 name = exec.full_path().split('/')[-1]
2327 test('check-help-' + name,
2328 meson_check_help,
2329 args : [exec.full_path()])
2330 endforeach
2331
2332 ############################################################
2333
2334 if git.found()
2335 all_files = run_command(
2336 git,
2337 ['--git-dir=@0@/.git'.format(meson.source_root()),
2338 'ls-files',
2339 ':/*.[ch]'])
2340 all_files = files(all_files.stdout().split())
2341
2342 run_target(
2343 'tags',
2344 input : all_files,
2345 command : ['env', 'etags', '-o', '@0@/TAGS'.format(meson.source_root())] + all_files)
2346 run_target(
2347 'ctags',
2348 input : all_files,
2349 command : ['env', 'ctags', '-o', '@0@/tags'.format(meson.source_root())] + all_files)
2350 endif
2351
2352 if git.found()
2353 meson_git_contrib_sh = find_program('tools/meson-git-contrib.sh')
2354 run_target(
2355 'git-contrib',
2356 command : [meson_git_contrib_sh])
2357 endif
2358
2359 if git.found()
2360 git_head = run_command(
2361 git,
2362 ['--git-dir=@0@/.git'.format(meson.source_root()),
2363 'rev-parse', 'HEAD']).stdout().strip()
2364 git_head_short = run_command(
2365 git,
2366 ['--git-dir=@0@/.git'.format(meson.source_root()),
2367 'rev-parse', '--short=7', 'HEAD']).stdout().strip()
2368
2369 run_target(
2370 'git-snapshot',
2371 command : ['git', 'archive',
2372 '-o', '@0@/systemd-@1@.tar.gz'.format(meson.source_root(),
2373 git_head_short),
2374 '--prefix', 'systemd-@0@/'.format(git_head),
2375 'HEAD'])
2376 endif
2377
2378 ############################################################
2379
2380 status = [
2381 '@0@ @1@'.format(meson.project_name(), meson.project_version()),
2382
2383 'prefix: @0@'.format(prefixdir),
2384 'rootprefix: @0@'.format(rootprefixdir),
2385 'sysconf dir: @0@'.format(sysconfdir),
2386 'includedir: @0@'.format(includedir),
2387 'lib dir: @0@'.format(libdir),
2388 'rootlib dir: @0@'.format(rootlibdir),
2389 'SysV init scripts: @0@'.format(sysvinit_path),
2390 'SysV rc?.d directories: @0@'.format(sysvrcnd_path),
2391 'PAM modules dir: @0@'.format(pamlibdir),
2392 'PAM configuration dir: @0@'.format(pamconfdir),
2393 'RPM macros dir: @0@'.format(rpmmacrosdir),
2394 'D-Bus policy dir: @0@'.format(dbuspolicydir),
2395 'D-Bus session dir: @0@'.format(dbussessionservicedir),
2396 'D-Bus system dir: @0@'.format(dbussystemservicedir),
2397 'bash completions dir: @0@'.format(bashcompletiondir),
2398 'zsh completions dir: @0@'.format(zshcompletiondir),
2399 'extra start script: @0@'.format(get_option('rc-local')),
2400 'extra stop script: @0@'.format(get_option('halt-local')),
2401 'debug shell: @0@ @ @1@'.format(get_option('debug-shell'),
2402 get_option('debug-tty')),
2403 'TTY GID: @0@'.format(tty_gid),
2404 'maximum system UID: @0@'.format(system_uid_max),
2405 'maximum system GID: @0@'.format(system_gid_max),
2406 '/dev/kvm access mode: @0@'.format(get_option('dev-kvm-mode')),
2407 'certificate root: @0@'.format(get_option('certificate-root')),
2408 'support URL: @0@'.format(support_url),
2409 'nobody user name: @0@'.format(get_option('nobody-user')),
2410 'nobody group name: @0@'.format(get_option('nobody-group')),
2411 'fallback hostname: @0@'.format(get_option('fallback-hostname')),
2412
2413 'default DNSSEC mode: @0@'.format(default_dnssec),
2414 'default cgroup hierarchy: @0@'.format(default_hierarchy),
2415 'default KillUserProcesses setting: @0@'.format(kill_user_processes)]
2416
2417 alt_dns_servers = '\n '.join(dns_servers.split(' '))
2418 alt_ntp_servers = '\n '.join(ntp_servers.split(' '))
2419 status += [
2420 'default DNS servers: @0@'.format(alt_dns_servers),
2421 'default NTP servers: @0@'.format(alt_ntp_servers)]
2422
2423 alt_time_epoch = run_command('date', '-Is', '-u', '-d',
2424 '@@0@'.format(time_epoch)).stdout().strip()
2425 status += [
2426 'time epoch: @0@ (@1@)'.format(time_epoch, alt_time_epoch)]
2427
2428 # TODO:
2429 # CFLAGS: ${OUR_CFLAGS} ${CFLAGS}
2430 # CPPFLAGS: ${OUR_CPPFLAGS} ${CPPFLAGS}
2431 # LDFLAGS: ${OUR_LDFLAGS} ${LDFLAGS}
2432
2433 if conf.get('ENABLE_EFI', false)
2434 status += [
2435 'efi arch: @0@'.format(efi_arch)]
2436
2437 if have_gnu_efi
2438 status += [
2439 'EFI machine type: @0@'.format(EFI_MACHINE_TYPE_NAME),
2440 'EFI CC @0@'.format(efi_cc),
2441 'EFI libdir: @0@'.format(efi_libdir),
2442 'EFI ldsdir: @0@'.format(efi_ldsdir),
2443 'EFI includedir: @0@'.format(efi_incdir)]
2444 endif
2445 endif
2446
2447 found = []
2448 missing = []
2449
2450 foreach tuple : [
2451 ['libcryptsetup'],
2452 ['PAM'],
2453 ['AUDIT'],
2454 ['IMA'],
2455 ['AppArmor'],
2456 ['SELinux'],
2457 ['SECCOMP'],
2458 ['SMACK'],
2459 ['zlib'],
2460 ['xz'],
2461 ['lz4'],
2462 ['bzip2'],
2463 ['ACL'],
2464 ['gcrypt'],
2465 ['qrencode'],
2466 ['microhttpd'],
2467 ['gnutls'],
2468 ['libcurl'],
2469 ['idn'],
2470 ['libidn2'],
2471 ['libidn'],
2472 ['nss-systemd'],
2473 ['libiptc'],
2474 ['elfutils'],
2475 ['binfmt'],
2476 ['vconsole'],
2477 ['quotacheck'],
2478 ['tmpfiles'],
2479 ['environment.d'],
2480 ['sysusers'],
2481 ['firstboot'],
2482 ['randomseed'],
2483 ['backlight'],
2484 ['rfkill'],
2485 ['logind'],
2486 ['machined'],
2487 ['importd'],
2488 ['hostnamed'],
2489 ['timedated'],
2490 ['timesyncd'],
2491 ['localed'],
2492 ['networkd'],
2493 ['resolved'],
2494 ['coredump'],
2495 ['polkit'],
2496 ['legacy pkla', install_polkit_pkla],
2497 ['efi'],
2498 ['gnu-efi', have_gnu_efi],
2499 ['kmod'],
2500 ['xkbcommon'],
2501 ['blkid'],
2502 ['dbus'],
2503 ['glib'],
2504 ['nss-myhostname', conf.get('HAVE_MYHOSTNAME', false)],
2505 ['hwdb'],
2506 ['tpm'],
2507 ['man pages', want_man],
2508 ['html pages', want_html],
2509 ['man page indices', want_man and have_lxml],
2510 ['split /usr', conf.get('HAVE_SPLIT_USR', false)],
2511 ['SysV compat'],
2512 ['utmp'],
2513 ['ldconfig'],
2514 ['hibernate'],
2515 ['adm group', get_option('adm-group')],
2516 ['wheel group', get_option('wheel-group')],
2517 ['gshadow'],
2518 ['debug hashmap'],
2519 ['debug mmap cache'],
2520 ]
2521
2522 cond = tuple.get(1, '')
2523 if cond == ''
2524 ident1 = 'HAVE_' + tuple[0].underscorify().to_upper()
2525 ident2 = 'ENABLE_' + tuple[0].underscorify().to_upper()
2526 cond = conf.get(ident1, false) or conf.get(ident2, false)
2527 endif
2528 if cond
2529 found += [tuple[0]]
2530 else
2531 missing += [tuple[0]]
2532 endif
2533 endforeach
2534
2535 status += [
2536 '',
2537 'enabled features: @0@'.format(', '.join(found)),
2538 '',
2539 'disabled features: @0@'.format(', '.join(missing)),
2540 '']
2541 message('\n '.join(status))