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