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