]> git.ipfire.org Git - thirdparty/systemd.git/blame - meson.build
meson: install systemd-sulogin-shell too
[thirdparty/systemd.git] / meson.build
CommitLineData
5c23128d
ZJS
1# -*- mode: meson -*-
2
3project('systemd', 'c',
4 version : '233',
5 license : 'LGPLv2+',
6 default_options: [
7 'c_std=gnu99',
8 'prefix=/usr',
9 'sysconfdir=/etc',
10 'localstatedir=/var',
11 ],
12 meson_version : '>= 0.39.1',
13 )
14
15# We need the same data in three different formats, ugh!
16# Also, for hysterical reasons, we use different variable
17# names, sometimes. Not all variables are included in every
18# set. Ugh, ugh, ugh!
19conf = configuration_data()
20conf.set_quoted('PACKAGE_STRING', meson.project_name() + ' ' + meson.project_version())
21conf.set_quoted('PACKAGE_VERSION', meson.project_version())
22
23substs = configuration_data()
24substs.set('PACKAGE_URL', 'https://www.freedesktop.org/wiki/Software/systemd')
25substs.set('PACKAGE_VERSION', meson.project_version())
26
27m4_defines = []
28
29#####################################################################
30
31if get_option('split-usr')
32 conf.set('HAVE_SPLIT_USR', 1)
33 rootprefixdir = '/'
34else
35 rootprefixdir = '/usr'
36endif
37
38sysvinit_path = get_option('sysvinit-path')
39sysvrcnd_path = get_option('sysvrcnd-path')
40if sysvinit_path != '' or sysvrcnd_path != ''
41 conf.set('HAVE_SYSV_COMPAT', 1,
42 description : 'SysV init scripts and rcN.d links are supported')
43endif
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.
48prefixdir = get_option('prefix')
49if not prefixdir.startswith('/')
50 error('Prefix is not absolute: "@0@"'.format(prefixdir))
51endif
52bindir = join_paths(prefixdir, get_option('bindir'))
53libdir = join_paths(prefixdir, get_option('libdir'))
54sysconfdir = join_paths(prefixdir, get_option('sysconfdir'))
55includedir = join_paths(prefixdir, get_option('includedir'))
56datadir = join_paths(prefixdir, get_option('datadir'))
57localstatedir = join_paths('/', get_option('localstatedir'))
58
59rootbindir = join_paths(rootprefixdir, 'bin')
60rootlibexecdir = join_paths(rootprefixdir, 'lib/systemd')
61
62rootlibdir = get_option('rootlibdir')
63if rootlibdir == ''
64 rootlibdir = join_paths(rootprefixdir, libdir.split('/')[-1])
65endif
66
67# Dirs of external packages
68pkgconfigdatadir = datadir + '/pkgconfig'
69pkgconfiglibdir = libdir + '/pkgconfig'
70polkitpolicydir = datadir + '/polkit-1/actions'
71polkitrulesdir = datadir + '/polkit-1/rules.d'
72polkitpkladir = localstatedir + '/lib/polkit-1/localauthority/10-vendor.d'
73varlogdir = localstatedir + '/log'
74xinitrcdir = sysconfdir + '/X11/xinit/xinitrc.d'
75rpmmacrosdir = get_option('rpmmacrosdir')
76
77# Our own paths
78pkgdatadir = datadir + '/systemd'
79environmentdir = prefixdir + '/lib/environment.d'
80pkgsysconfdir = sysconfdir + '/systemd'
81userunitdir = prefixdir + '/lib/systemd/user'
82userpresetdir = prefixdir + '/lib/systemd/user-preset'
83tmpfilesdir = prefixdir + '/lib/tmpfiles.d'
84sysusersdir = prefixdir + '/lib/sysusers.d'
85sysctldir = prefixdir + '/lib/sysctl.d'
86binfmtdir = prefixdir + '/lib/binfmt.d'
87modulesloaddir = prefixdir + '/lib/modules-load.d'
88networkdir = rootprefixdir + '/lib/systemd/network'
89pkgincludedir = includedir + '/systemd'
90systemgeneratordir = rootlibexecdir + '/system-generators'
91usergeneratordir = prefixdir + '/lib/systemd/user-generators'
92systemenvgeneratordir = prefixdir + '/lib/systemd/system-environment-generators'
93userenvgeneratordir = prefixdir + '/lib/systemd/user-environment-generators'
94systemshutdowndir = rootlibexecdir + '/system-shutdown'
95systemsleepdir = rootlibexecdir + '/system-sleep'
96systemunitdir = rootprefixdir + '/lib/systemd/system'
97systempresetdir = rootprefixdir + '/lib/systemd/system-preset'
98udevlibexecdir = rootprefixdir + '/lib/udev'
99udevhomedir = udevlibexecdir + ''
100udevrulesdir = udevlibexecdir + '/rules.d'
101udevhwdbdir = udevlibexecdir + '/hwdb.d'
102catalogdir = prefixdir + '/lib/systemd/catalog'
103kernelinstalldir = prefixdir + '/lib/kernel/install.d'
104factorydir = datadir + '/factory'
105docdir = datadir + '/doc/systemd'
106bootlibdir = prefixdir + '/lib/systemd/boot/efi'
107testsdir = prefixdir + '/lib/systemd/tests'
108systemdstatedir = localstatedir + '/lib/systemd'
109catalogstatedir = systemdstatedir + '/catalog'
110
111dbuspolicydir = get_option('dbuspolicydir')
112if dbuspolicydir == ''
113 dbuspolicydir = datadir + '/dbus-1/system.d'
114endif
115
116dbussessionservicedir = get_option('dbussessionservicedir')
117if dbussessionservicedir == ''
118 dbussessionservicedir = datadir + '/dbus-1/services'
119endif
120
121dbussystemservicedir = get_option('dbussystemservicedir')
122if dbussystemservicedir == ''
123 dbussystemservicedir = datadir + '/dbus-1/system-services'
124endif
125
126pamlibdir = get_option('pamlibdir')
127if pamlibdir == ''
128 pamlibdir = rootlibdir + '/security'
129endif
130
131pamconfdir = get_option('pamconfdir')
132if pamconfdir == ''
133 pamconfdir = sysconfdir + '/pam.d'
134endif
135
136conf.set_quoted('PKGSYSCONFDIR', pkgsysconfdir)
137conf.set_quoted('SYSTEM_CONFIG_UNIT_PATH', pkgsysconfdir + '/system')
138conf.set_quoted('SYSTEM_DATA_UNIT_PATH', systemunitdir)
139conf.set_quoted('SYSTEM_SYSVINIT_PATH', sysvinit_path)
140conf.set_quoted('SYSTEM_SYSVRCND_PATH', sysvrcnd_path)
141conf.set_quoted('USER_CONFIG_UNIT_PATH', pkgsysconfdir + '/user')
142conf.set_quoted('USER_DATA_UNIT_PATH', userunitdir)
143conf.set_quoted('CERTIFICATE_ROOT', get_option('certificate-root'))
144conf.set_quoted('CATALOG_DATABASE', catalogstatedir + '/database')
145conf.set_quoted('SYSTEMD_CGROUP_AGENT_PATH', rootlibexecdir + '/systemd-cgroups-agent')
146conf.set_quoted('SYSTEMD_BINARY_PATH', rootlibexecdir + '/systemd')
147conf.set_quoted('SYSTEMD_FSCK_PATH', rootlibexecdir + '/systemd-fsck')
148conf.set_quoted('SYSTEMD_SHUTDOWN_BINARY_PATH', rootlibexecdir + '/systemd-shutdown')
149conf.set_quoted('SYSTEMD_SLEEP_BINARY_PATH', rootlibexecdir + '/systemd-sleep')
150conf.set_quoted('SYSTEMCTL_BINARY_PATH', rootbindir + '/systemctl')
151conf.set_quoted('SYSTEMD_TTY_ASK_PASSWORD_AGENT_BINARY_PATH', rootbindir + '/systemd-tty-ask-password-agent')
152conf.set_quoted('SYSTEMD_STDIO_BRIDGE_BINARY_PATH', bindir + '/systemd-stdio-bridge')
153conf.set_quoted('ROOTPREFIX', rootprefixdir)
154conf.set_quoted('RANDOM_SEED_DIR', localstatedir + '/lib/systemd/')
155conf.set_quoted('RANDOM_SEED', localstatedir + '/lib/systemd/random-seed')
156conf.set_quoted('SYSTEMD_CRYPTSETUP_PATH', rootlibexecdir + '/systemd-cryptsetup')
157conf.set_quoted('SYSTEM_GENERATOR_PATH', systemgeneratordir)
158conf.set_quoted('USER_GENERATOR_PATH', usergeneratordir)
159conf.set_quoted('SYSTEM_ENV_GENERATOR_PATH', systemenvgeneratordir)
160conf.set_quoted('USER_ENV_GENERATOR_PATH', userenvgeneratordir)
161conf.set_quoted('SYSTEM_SHUTDOWN_PATH', systemshutdowndir)
162conf.set_quoted('SYSTEM_SLEEP_PATH', systemsleepdir)
163conf.set_quoted('SYSTEMD_KBD_MODEL_MAP', pkgdatadir + '/kbd-model-map')
164conf.set_quoted('SYSTEMD_LANGUAGE_FALLBACK_MAP', pkgdatadir + '/language-fallback-map')
165conf.set_quoted('UDEVLIBEXECDIR', udevlibexecdir)
166conf.set_quoted('POLKIT_AGENT_BINARY_PATH', bindir + '/pkttyagent')
167conf.set_quoted('LIBDIR', libdir)
168conf.set_quoted('ROOTLIBDIR', rootlibdir)
169conf.set_quoted('ROOTLIBEXECDIR', rootlibexecdir)
170conf.set_quoted('BOOTLIBDIR', bootlibdir)
171conf.set_quoted('SYSTEMD_PULL_PATH', rootlibexecdir + '/systemd-pull')
172conf.set_quoted('SYSTEMD_IMPORT_PATH', rootlibexecdir + '/systemd-import')
173conf.set_quoted('SYSTEMD_EXPORT_PATH', rootlibexecdir + '/systemd-export')
174conf.set_quoted('VENDOR_KEYRING_PATH', rootlibexecdir + '/import-pubring.gpg')
175conf.set_quoted('USER_KEYRING_PATH', pkgsysconfdir + '/import-pubring.gpg')
176conf.set_quoted('DOCUMENT_ROOT', pkgdatadir + '/gatewayd')
177
178conf.set_quoted('ABS_BUILD_DIR', meson.build_root())
179conf.set_quoted('ABS_SRC_DIR', meson.source_root())
180
181substs.set('prefix', prefixdir)
182substs.set('pkgsysconfdir', pkgsysconfdir)
183substs.set('rootlibexecdir', rootlibexecdir)
184substs.set('systemunitdir', systemunitdir)
185substs.set('userunitdir', userunitdir)
186substs.set('systempresetdir', systempresetdir)
187substs.set('userpresetdir', userpresetdir)
188substs.set('udevhwdbdir', udevhwdbdir)
189substs.set('udevrulesdir', udevrulesdir)
190substs.set('catalogdir', catalogdir)
191substs.set('tmpfilesdir', tmpfilesdir)
192substs.set('sysusersdir', sysusersdir)
193substs.set('sysctldir', sysctldir)
194substs.set('binfmtdir', binfmtdir)
195substs.set('modulesloaddir', modulesloaddir)
196substs.set('systemgeneratordir', systemgeneratordir)
197substs.set('usergeneratordir', usergeneratordir)
198substs.set('systemenvgeneratordir', systemenvgeneratordir)
199substs.set('userenvgeneratordir', userenvgeneratordir)
200substs.set('systemshutdowndir', systemshutdowndir)
201substs.set('systemsleepdir', systemsleepdir)
4e4ab1c3 202substs.set('SYSTEMCTL', rootbindir + '/systemctl')
5c23128d
ZJS
203
204#####################################################################
205
206cc = meson.get_compiler('c')
207pkgconfig = import('pkgconfig')
208
209foreach arg : ['-Wundef',
210 '-Wlogical-op',
211 '-Wmissing-include-dirs',
212 '-Wold-style-definition',
213 '-Wpointer-arith',
214 '-Winit-self',
215 '-Wdeclaration-after-statement',
216 '-Wfloat-equal',
217 '-Wsuggest-attribute=noreturn',
218 '-Werror=missing-prototypes',
219 '-Werror=implicit-function-declaration',
220 '-Werror=missing-declarations',
221 '-Werror=return-type',
222 '-Werror=incompatible-pointer-types',
223 '-Werror=format=2',
224 '-Wstrict-prototypes',
225 '-Wredundant-decls',
226 '-Wmissing-noreturn',
227 '-Wshadow',
228 '-Wendif-labels',
229 '-Wstrict-aliasing=2',
230 '-Wwrite-strings',
231 '-Wno-unused-parameter',
232 '-Wno-missing-field-initializers',
233 '-Wno-unused-result',
234 '-Wno-format-signedness',
235 '-Werror=overflow',
236 '-Wdate-time',
237 '-Wnested-externs',
238 '-ffast-math',
239 '-fno-common',
240 '-fdiagnostics-show-option',
241 '-fno-strict-aliasing',
242 '-fvisibility=hidden',
243 '-fstack-protector',
244 '-fstack-protector-strong',
245 '-fPIE',
246 '--param=ssp-buffer-size=4',
247 ]
248 if cc.has_argument(arg)
249 add_project_arguments(arg, language : 'c')
250 endif
251endforeach
252
253if cc.compiles('
254 #include <time.h>
255 #include <inttypes.h>
256 typedef uint64_t usec_t;
257 usec_t now(clockid_t clock);
258 int main(void) {
259 struct timespec now;
260 return 0;
261 }
262')
263 # TODO: message?
264 add_project_arguments('-Werror=shadow', language : 'c')
265endif
266
267if cc.get_id() == 'clang'
268 foreach arg : ['-Wno-typedef-redefinition',
269 '-Wno-gnu-variable-sized-type-not-at-end',
270 ]
271 if cc.has_argument(arg)
272 add_project_arguments(arg, language : 'c')
273 endif
274 endforeach
275endif
276
277# --as-needed and --no-undefined are provided by meson by default,
278# run mesonconf to see what is enabled
279foreach arg : ['-Wl,-z,relro',
280 '-Wl,-z,now',
281 '-pie',
282 '-Wl,-fuse-ld=gold',
283 ]
284 if cc.has_argument(arg)
285 add_project_link_arguments(arg, language : 'c')
286 endif
287endforeach
288
289#####################################################################
290# compilation result tests
291
292conf.set('_GNU_SOURCE', 1)
293conf.set('__SANE_USERSPACE_TYPES__', 1)
294
295conf.set('SIZEOF_PID_T', cc.sizeof('pid_t', prefix : '#include <sys/types.h>'))
296conf.set('SIZEOF_UID_T', cc.sizeof('uid_t', prefix : '#include <sys/types.h>'))
297conf.set('SIZEOF_GID_T', cc.sizeof('gid_t', prefix : '#include <sys/types.h>'))
298conf.set('SIZEOF_DEV_T', cc.sizeof('dev_t', prefix : '#include <sys/types.h>'))
299conf.set('SIZEOF_INO_T', cc.sizeof('ino_t', prefix : '#include <sys/types.h>'))
300conf.set('SIZEOF_TIME_T', cc.sizeof('time_t', prefix : '#include <sys/time.h>'))
301conf.set('SIZEOF_RLIM_T', cc.sizeof('rlim_t', prefix : '#include <sys/resource.h>'))
302
303decl_headers = '''
304#include <uchar.h>
305#include <linux/ethtool.h>
306'''
307# FIXME: key_serial_t is only defined in keyutils.h, this is bound to fail
308
309foreach decl : ['char16_t',
310 'char32_t',
311 'key_serial_t',
312 'struct ethtool_link_settings',
313 ]
314 if cc.sizeof(decl, prefix : decl_headers) > 0
315 # We get -1 if the size cannot be determined
316 conf.set('HAVE_' + decl.underscorify().to_upper(), 1)
317 endif
318endforeach
319
320foreach decl : [['IFLA_INET6_ADDR_GEN_MODE', 'linux/if_link.h'],
321 ['IN6_ADDR_GEN_MODE_STABLE_PRIVACY', 'linux/if_link.h'],
322 ['IFLA_VRF_TABLE', 'linux/if_link.h'],
323 ['IFLA_MACVLAN_FLAGS', 'linux/if_link.h'],
324 ['IFLA_IPVLAN_MODE', 'linux/if_link.h'],
325 ['IFLA_PHYS_PORT_ID', 'linux/if_link.h'],
326 ['IFLA_BOND_AD_INFO', 'linux/if_link.h'],
327 ['IFLA_VLAN_PROTOCOL', 'linux/if_link.h'],
328 ['IFLA_VXLAN_REMCSUM_NOPARTIAL', 'linux/if_link.h'],
329 ['IFLA_VXLAN_GPE', 'linux/if_link.h'],
330 # if_tunnel.h is buggy and cannot be included on its own
331 ['IFLA_VTI_REMOTE', 'linux/if_tunnel.h', '#include <net/if.h>'],
332 ['IFLA_IPTUN_ENCAP_DPORT', 'linux/if_tunnel.h', '#include <net/if.h>'],
333 ['IFLA_GRE_ENCAP_DPORT', 'linux/if_tunnel.h', '#include <net/if.h>'],
334 ['IFLA_BRIDGE_VLAN_INFO', 'linux/if_bridge.h'],
335 ['IFLA_BRPORT_PROXYARP', 'linux/if_link.h'],
336 ['IFLA_BRPORT_LEARNING_SYNC', 'linux/if_link.h'],
337 ['IFLA_BR_VLAN_DEFAULT_PVID', 'linux/if_link.h'],
338 ['NDA_IFINDEX', 'linux/neighbour.h'],
339 ['IFA_FLAGS', 'linux/if_addr.h'],
340 ['LO_FLAGS_PARTSCAN', 'linux/loop.h'],
341 ]
342 prefix = decl.length() > 2 ? decl[2] : ''
343 have = cc.has_header_symbol(decl[1], decl[0], prefix : prefix)
344 conf.set10('HAVE_DECL_' + decl[0], have)
345endforeach
346
347skip = false
348foreach ident : ['secure_getenv', '__secure_getenv']
349 if not skip and cc.has_function(ident)
350 conf.set('HAVE_' + ident.to_upper(), 1)
351 skip = true
352 endif
353endforeach
354
355foreach ident : [
356 ['memfd_create', '''#include <sys/memfd.h>'''],
357 ['gettid', '''#include <sys/types.h>'''],
358 ['pivot_root', '''#include <stdlib.h>'''], # no known header declares pivot_root
359 ['name_to_handle_at', '''#define _GNU_SOURCE
360 #include <sys/types.h>
361 #include <sys/stat.h>
362 #include <fcntl.h>'''],
363 ['setns', '''#define _GNU_SOURCE
364 #include <sched.h>'''],
365 ['getrandom', '''#include <sys/random.h>'''],
366 ['renameat2', '''#include <stdio.h>'''],
367 ['kcmp', '''#include <linux/kcmp.h>'''],
368 ['keyctl', '''#include <sys/types.h>
369 #include <keyutils.h>'''],
370 ['copy_file_range', '''#include <sys/syscall.h>
371 #include <unistd.h>'''],
372 ['explicit_bzero' , '''#include <strings.h>'''],
373 ]
374
375 have = cc.has_function(ident[0], prefix : ident[1])
376 conf.set10('HAVE_DECL_' + ident[0].to_upper(), have)
377endforeach
378
379#####################################################################
380
381sed = find_program('sed')
382grep = find_program('grep')
383awk = find_program('awk')
78b68dcb 384m4 = find_program('/usr/bin/m4')
5c23128d 385stat = find_program('stat')
d68b342b
ZJS
386git = find_program('git', required : false)
387etags = find_program('etags', required : false)
5c23128d 388
7b76fce1 389meson_make_symlink = meson.source_root() + '/tools/meson-make-symlink.sh'
94e75a54
ZJS
390mkdir_p = 'mkdir -p $DESTDIR/@0@'
391
5c23128d
ZJS
392# if -Dxxx-path option is found, use that. Otherwise, check in $PATH,
393# /usr/sbin, /sbin, and fall back to the default from middle column.
394progs = [['telinit', '/lib/sysvinit/telinit'],
395 ['quotaon', '/usr/sbin/quotaon' ],
396 ['quotacheck', '/usr/sbin/quotacheck' ],
397 ['kill', '/usr/bin/kill' ],
398 ['kmod', '/usr/bin/kmod' ],
399 ['kexec', '/usr/sbin/kexec' ],
400 ['sulogin', '/usr/sbin/sulogin' ],
401 ['mount', '/usr/bin/mount', 'MOUNT_PATH'],
402 ['umount', '/usr/bin/umount', 'UMOUNT_PATH'],
403 ['loadkeys', '/usr/bin/loadkeys', 'KBD_LOADKEYS'],
404 ['setfont', '/usr/bin/setfont', 'KBD_SETFONT'],
405 ]
406foreach prog : progs
407 path = get_option(prog[0] + '-path')
408 if path != ''
409 message('Using @1@ for @0@'.format(prog[0], path))
410 else
411 exe = find_program(prog[0], '/usr/sbin/' + prog[0], '/sbin/' + prog[0], required: false)
412 path = exe.found() ? exe.path() : prog[1]
413 endif
414 name = prog.length() > 2 ? prog[2] : prog[0].to_upper()
415 conf.set_quoted(name, path)
4e4ab1c3 416 substs.set(name, path)
5c23128d
ZJS
417endforeach
418
419# TODO: add ln --relative check
420# AS_IF([! ln --relative --help > /dev/null 2>&1], [AC_MSG_ERROR([*** ln doesn't support --relative ***])])
421
422############################################################
423
424gperf = find_program('gperf')
425
426gperf_test_format = '''
427#include <string.h>
428const char * in_word_set(const char *, @0@);
429@1@
430'''
431gperf_snippet_format = 'echo foo,bar | @0@ -L ANSI-C'
432gperf_snippet = run_command('sh', '-c', gperf_snippet_format.format(gperf.path()))
433gperf_test = gperf_test_format.format('size_t', gperf_snippet.stdout())
434if cc.compiles(gperf_test)
435 gperf_len_type = 'size_t'
436else
437 gperf_test = gperf_test_format.format('unsigned', gperf_snippet.stdout())
438 if cc.compiles(gperf_test)
439 gperf_len_type = 'unsigned'
440 else
441 error('unable to determine gperf len type')
442 endif
443endif
444message('gperf len type is @0@'.format(gperf_len_type))
445conf.set('GPERF_LEN_TYPE', gperf_len_type, description : 'The type of gperf "len" parameter')
446
447############################################################
448
449if not cc.has_header('sys/capability.h')
450 error('POSIX caps headers not found')
451endif
452foreach header : ['linux/btrfs.h',
453 'linux/memfd.h',
454 'linux/vm_sockets.h',
455 'valgrind/memcheck.h',
456 'valgrind/valgrind.h',
457 ]
458 if cc.has_header(header)
459 conf.set('HAVE_' + header.underscorify().to_upper(), 1)
460 endif
461endforeach
462
463############################################################
464
465conf.set_quoted('FALLBACK_HOSTNAME', get_option('fallback-hostname'))
466
467default_hierarchy = get_option('default-hierarchy')
468conf.set_quoted('DEFAULT_HIERARCHY_NAME', default_hierarchy,
469 description : 'default cgroup hierarchy as string')
470if default_hierarchy == 'legacy'
471 conf.set('DEFAULT_HIERARCHY', 'CGROUP_UNIFIED_NONE')
472elif default_hierarchy == 'hybrid'
473 conf.set('DEFAULT_HIERARCHY', 'CGROUP_UNIFIED_SYSTEMD')
474else
475 conf.set('DEFAULT_HIERARCHY', 'CGROUP_UNIFIED_ALL')
476endif
477
478time_epoch = get_option('time-epoch')
479if time_epoch == ''
480 NEWS = files('NEWS')
481 time_epoch = run_command(stat, '-c', '%Y', NEWS).stdout()
482endif
483time_epoch = time_epoch.to_int()
484conf.set('TIME_EPOCH', time_epoch)
485
486system_uid_max = get_option('system-uid-max')
487if system_uid_max == ''
488 system_uid_max = run_command(
489 awk,
490 'BEGIN { uid=999 } /^\s*SYS_UID_MAX\s+/ { uid=$2 } END { print uid }',
491 '/etc/login.defs').stdout()
492endif
493system_uid_max = system_uid_max.to_int()
494conf.set('SYSTEM_UID_MAX', system_uid_max)
495substs.set('systemuidmax', system_uid_max)
496message('Maximum system UID is @0@'.format(system_uid_max))
497
498conf.set_quoted('NOBODY_USER_NAME', get_option('nobody-user'))
499conf.set_quoted('NOBODY_GROUP_NAME', get_option('nobody-group'))
500
501system_gid_max = get_option('system-gid-max')
502if system_gid_max == ''
503 system_gid_max = run_command(
504 awk,
505 'BEGIN { gid=999 } /^\s*SYS_GID_MAX\s+/ { gid=$2 } END { print gid }',
506 '/etc/login.defs').stdout()
507endif
508system_gid_max = system_gid_max.to_int()
509conf.set('SYSTEM_GID_MAX', system_gid_max)
510substs.set('systemgidmax', system_gid_max)
511message('Maximum system GID is @0@'.format(system_gid_max))
512
513tty_gid = get_option('tty-gid')
514conf.set('TTY_GID', tty_gid)
515m4_defines += ['-DTTY_GID=' + tty_gid]
516
517if get_option('adm-group')
518 m4_defines += ['-DENABLE_ADM_GROUP']
519endif
520
521if get_option('wheel-group')
522 m4_defines += ['-DENABLE_WHEEL_GROUP']
523endif
524
525substs.set('DEV_KVM_MODE', get_option('dev-kvm-mode'))
526
527conf.set10('KILL_USER_PROCESSES', get_option('default-kill-user-processes'))
528
529default_dnssec = get_option('default-dnssec')
530conf.set('DEFAULT_DNSSEC_MODE',
531 'DNSSEC_' + default_dnssec.underscorify().to_upper())
532
533conf.set_quoted('DNS_SERVERS', get_option('dns-servers'))
534
535conf.set_quoted('NTP_SERVERS', get_option('ntp-servers'))
536
537conf.set_quoted('GETTEXT_PACKAGE', meson.project_name())
538
539#####################################################################
540
541threads = dependency('threads')
542librt = cc.find_library('rt')
543libm = cc.find_library('m')
544libdl = cc.find_library('dl')
545libcrypt = cc.find_library('crypt')
546
547libcap = dependency('libcap')
548libmount = dependency('mount',
549 version : '>= 2.27')
550
551want_seccomp = get_option('seccomp')
552if want_seccomp != 'no'
553 libseccomp = dependency('libseccomp',
554 required : want_seccomp == 'yes')
555 if libseccomp.found()
556 conf.set('HAVE_SECCOMP', 1)
557 m4_defines += ['-DHAVE_SECCOMP']
558 endif
559else
560 libseccomp = []
561endif
562
563want_selinux = get_option('selinux')
564if want_selinux != 'no'
565 libselinux = dependency('libselinux',
566 version : '>= 2.1.9',
567 required : want_selinux == 'yes')
568 if libselinux.found()
569 conf.set('HAVE_SELINUX', 1)
570 m4_defines += ['-DHAVE_SELINUX']
571 endif
572else
573 libselinux = []
574endif
575
576want_apparmor = get_option('apparmor')
577if want_apparmor != 'no'
578 libapparmor = dependency('libapparmor',
579 required : want_apparmor == 'yes')
580 if libapparmor.found()
581 conf.set('HAVE_APPARMOR', 1)
582 m4_defines += ['-DHAVE_APPARMOR']
583 endif
584else
585 libapparmor = []
586endif
587
588want_smack = get_option('smack')
589if want_smack != 'no'
590 libsmack = dependency('libsmack',
591 required : want_smack == 'yes')
592 if libsmack.found()
593 conf.set('HAVE_SMACK', 1)
594 m4_defines += ['-DHAVE_SMACK']
595 endif
596else
597 libsmack = []
598endif
599
600smack_run_label = get_option('smack-run-label')
601if smack_run_label != ''
602 conf.set_quoted('SMACK_RUN_LABEL', smack_run_label)
603 m4_defines += ['-DHAVE_SMACK_RUN_LABEL']
604endif
605
606want_audit = get_option('audit')
607if want_audit != 'no'
608 libaudit = dependency('audit', required : want_audit == 'yes')
609 if libaudit.found()
610 conf.set('HAVE_AUDIT', 1)
611 endif
612else
613 libaudit = []
614endif
615
616want_blkid = get_option('blkid')
617if want_blkid != 'no'
618 libblkid = dependency('blkid', required : want_blkid == 'yes')
619 if libblkid.found()
620 conf.set('HAVE_BLKID', 1)
621 endif
622else
623 libblkid = []
624endif
625
626want_kmod = get_option('kmod')
627if want_kmod != 'no'
628 libkmod = dependency('libkmod',
629 version : '>= 15',
630 required : want_kmod == 'yes')
631 if libkmod.found()
632 conf.set('HAVE_KMOD', 1)
633 endif
634else
635 libkmod = []
636endif
637
638want_pam = get_option('pam')
639if want_pam != 'no'
640 libpam = cc.find_library('pam', required : want_pam == 'yes')
641 libpam_misc = cc.find_library('pam_misc', required : want_pam == 'yes')
642 if libpam.found() and libpam_misc.found()
643 conf.set('HAVE_PAM', 1)
644 m4_defines += ['-DHAVE_PAM']
645 endif
646else
647 libpam = []
648 libpam_misc = []
649endif
650
651want_microhttpd = get_option('microhttpd')
652if want_microhttpd != 'no'
653 libmicrohttpd = dependency('libmicrohttpd',
654 version : '>= 0.9.33',
655 required : want_microhttpd == 'yes')
656 if libmicrohttpd.found()
657 conf.set('HAVE_MICROHTTPD', 1)
658 m4_defines += ['-DHAVE_MICROHTTPD']
659 endif
660else
661 libmicrohttpd = []
662endif
663
664want_libcryptsetup = get_option('libcryptsetup')
665if want_libcryptsetup != 'no'
666 libcryptsetup = dependency('libcryptsetup',
667 version : '>= 1.6.0',
668 required : want_libcryptsetup == 'yes')
669 if libcryptsetup.found()
670 conf.set('HAVE_LIBCRYPTSETUP', 1)
671 endif
672else
673 libcryptsetup = []
674endif
675
676want_libcurl = get_option('libcurl')
677if want_libcurl != 'no'
678 libcurl = dependency('libcurl',
679 version : '>= 7.32.0',
680 required : want_libcurl == 'yes')
681 if libcurl.found()
682 conf.set('HAVE_LIBCURL', 1)
683 m4_defines += ['-DHAVE_LIBCURL']
684 endif
685else
686 libcurl = []
687endif
688
689want_libidn = get_option('libidn')
690if want_libidn != 'no'
691 libidn = dependency('libidn',
692 required : want_libidn == 'yes')
693 if libidn.found()
694 conf.set('HAVE_LIBIDN', 1)
695 m4_defines += ['-DHAVE_LIBIDN']
696 endif
697else
698 libidn = []
699endif
700
701want_libiptc = get_option('libiptc')
702if want_libiptc != 'no'
703 libiptc = dependency('libiptc',
704 required : want_libiptc == 'yes')
705 if libiptc.found()
706 conf.set('HAVE_LIBIPTC', 1)
707 m4_defines += ['-DHAVE_LIBIPTC']
708 endif
709else
710 libiptc = []
711endif
712
713want_qrencode = get_option('qrencode')
714if want_qrencode != 'no'
715 libqrencode = dependency('libqrencode',
716 required : want_qrencode == 'yes')
717 if libqrencode.found()
718 conf.set('HAVE_QRENCODE', 1)
719 endif
720else
721 libqrencode = []
722endif
723
724want_gnutls = get_option('gnutls')
725if want_gnutls != 'no'
726 libgnutls = dependency('gnutls',
727 version : '>= 3.1.4',
728 required : want_gnutls == 'yes')
729 if libgnutls.found()
730 conf.set('HAVE_GNUTLS', 1)
731 endif
732else
733 libgnutls = []
734endif
735
736want_elfutils = get_option('elfutils')
737if want_elfutils != 'no'
738 libdw = dependency('libdw',
739 required : want_elfutils == 'yes')
740 if libdw.found()
741 conf.set('HAVE_ELFUTILS', 1)
742 endif
743else
744 libdw = []
745endif
746
747want_zlib = get_option('zlib')
748if want_zlib != 'no'
749 libz = dependency('zlib',
750 required : want_zlib == 'yes')
751 if libz.found()
752 conf.set('HAVE_ZLIB', 1)
753 endif
754else
755 libz = []
756endif
757
758want_bzip2 = get_option('bzip2')
759if want_bzip2 != 'no'
760 libbzip2 = cc.find_library('bz2',
761 required : want_bzip2 == 'yes')
762 if libbzip2.found()
763 conf.set('HAVE_BZIP2', 1)
764 endif
765else
766 libbzip2 = []
767endif
768
769want_xz = get_option('xz')
770if want_xz != 'no'
771 libxz = dependency('liblzma',
772 required : want_xz == 'yes')
773 if libxz.found()
774 conf.set('HAVE_XZ', 1)
775 endif
776else
777 libxz = []
778endif
779
780want_lz4 = get_option('lz4')
781if want_lz4 != 'no'
782 liblz4 = dependency('liblz4',
783 required : want_lz4 == 'yes')
784 if liblz4.found()
785 conf.set('HAVE_LZ4', 1)
786 endif
787else
788 liblz4 = []
789endif
790
791libacl = cc.find_library('acl', required : false)
792if libacl.found()
793 conf.set('HAVE_ACL', 1)
794 m4_defines += ['-DHAVE_ACL']
795endif
796
69e96427
ZJS
797want_glib = get_option('glib')
798if want_glib != 'no'
799 libglib = dependency('glib-2.0',
800 version : '>= 2.22.0',
801 required : want_glib == 'yes')
802 libgobject = dependency('gobject-2.0',
803 version : '>= 2.22.0',
804 required : want_glib == 'yes')
805 libgio = dependency('gio-2.0',
806 required : want_glib == 'yes')
807 if libglib.found() and libgobject.found() and libgio.found()
808 conf.set('HAVE_GLIB', 1)
809 endif
810else
811 libglib = []
812 libgobject = []
813 libgio = []
814endif
815
816want_dbus = get_option('dbus')
817if want_dbus != 'no'
818 libdbus = dependency('dbus-1',
819 version : '>= 1.3.2',
820 required : want_dbus == 'yes')
821 if libdbus.found()
822 conf.set('HAVE_DBUS', 1)
823 endif
824else
825 libdbus = []
826endif
827
5c23128d
ZJS
828want_libgcrypt = get_option('libgcrypt')
829if want_libgcrypt != 'no'
830 libgcrypt = cc.find_library('gcrypt', required : want_libgcrypt == 'yes')
831 if libgcrypt.found()
832 conf.set('HAVE_LIBGCRYPT', 1)
833 endif
834else
835 libgcrypt = []
836endif
837
838want_importd = get_option('importd')
839if want_importd != 'no'
840 have_deps = (conf.get('HAVE_LIBCURL', 0) == 1 and
841 conf.get('HAVE_ZLIB', 0) == 1 and
842 conf.get('HAVE_BZIP2', 0) == 1 and
843 conf.get('HAVE_XZ', 0) == 1 and
844 conf.get('HAVE_LZ4', 0) == 1)
845 if have_deps
846 conf.set('ENABLE_IMPORTD', 1)
847 elif want_importd == 'yes'
848 error('importd support was requested, but dependencies are not available')
849 endif
850endif
851
852want_remote = get_option('remote')
853if want_remote != 'no'
854 have_deps = [conf.get('HAVE_MICROHTTPD', 0) == 1,
855 conf.get('HAVE_LIBCURL', 0) == 1]
856 # sd-j-remote requires µhttpd, and sd-j-upload requires libcurl, so
857 # it's possible to build one without the other. Complain only if
858 # support was explictly requested. The auxiliary files like sysusers
859 # config should be installed when any of the programs are built.
860 if want_remote == 'yes' and not (have_deps[0] and have_deps[1])
861 error('remote support was requested, but dependencies are not available')
862 endif
863 if have_deps[0] or have_deps[1]
864 conf.set('ENABLE_REMOTE', 1)
865 endif
866endif
867
868foreach pair : [['utmp', 'HAVE_UTMP'],
869 ['hibernate', 'ENABLE_HIBERNATE'],
870 ['environment-d', 'ENABLE_ENVIRONMENT_D'],
871 ['binfmt', 'ENABLE_BINFMT'],
872 ['coredump', 'ENABLE_COREDUMP'],
873 ['resolve', 'ENABLE_RESOLVED'],
874 ['logind', 'ENABLE_LOGIND'],
875 ['hostnamed', 'ENABLE_HOSTNAMED'],
876 ['localed', 'ENABLE_LOCALED'],
877 ['machined', 'ENABLE_MACHINED'],
878 ['networkd', 'ENABLE_NETWORKD'],
879 ['timedated', 'ENABLE_TIMEDATED'],
880 ['timesyncd', 'ENABLE_TIMESYNCD'],
881 ['myhostname', 'HAVE_MYHOSTNAME'],
882 ['firstboot', 'ENABLE_FIRSTBOOT'],
883 ['randomseed', 'ENABLE_RANDOMSEED'],
884 ['backlight', 'ENABLE_BACKLIGHT'],
885 ['vconsole', 'ENABLE_VCONSOLE'],
886 ['quotacheck', 'ENABLE_QUOTACHECK'],
887 ['sysusers', 'ENABLE_SYSUSERS'],
888 ['tmpfiles', 'ENABLE_TMPFILES'],
889 ['hwdb', 'ENABLE_HWDB'],
890 ['rfkill', 'ENABLE_RFKILL'],
891 ['ldconfig', 'ENABLE_LDCONFIG'],
892 ]
893
894 if get_option(pair[0])
895 conf.set(pair[1], 1)
896 endif
897endforeach
898
69e96427 899want_tests = get_option('tests')
572baca1 900install_tests = get_option('install-tests')
69e96427
ZJS
901tests = []
902
5c23128d
ZJS
903#####################################################################
904
905if get_option('efi')
906 efi_arch = host_machine.cpu_family() # TODO: check this works at all
907 if efi_arch == 'ia32'
908 EFI_MACHINE_TYPE_NAME = 'ia32'
909 elif efi_arch == 'x86_64'
910 EFI_MACHINE_TYPE_NAME = 'x64'
911 elif efi_arch == 'aarch64'
912 EFI_MACHINE_TYPE_NAME = 'x64'
913 else
914 EFI_MACHINE_TYPE_NAME = efi_arch
915 endif
916
917 conf.set('ENABLE_EFI', 1)
918 conf.set_quoted('EFI_MACHINE_TYPE_NAME', EFI_MACHINE_TYPE_NAME)
919endif
920
921#####################################################################
922
923config_h = configure_file(
924 output : 'config.h',
925 configuration : conf)
926
927includes = include_directories('src/basic',
928 'src/shared',
929 'src/systemd',
930 'src/journal',
931 'src/resolve',
932 'src/timesync',
933 'src/login',
934 'src/udev',
935 'src/libudev',
936 'src/core',
937 'src/libsystemd/sd-bus',
938 'src/libsystemd/sd-device',
939 'src/libsystemd/sd-hwdb',
940 'src/libsystemd/sd-id128',
941 'src/libsystemd/sd-netlink',
942 'src/libsystemd/sd-network',
943 'src/libsystemd-network',
944 )
945
946add_project_arguments('-include', 'config.h', language : 'c')
947
948gcrypt_util_sources = files('src/shared/gcrypt-util.h',
949 'src/shared/gcrypt-util.c')
950
951subdir('po')
952subdir('catalog')
953subdir('src/systemd')
954subdir('src/basic')
955subdir('src/libsystemd')
956subdir('src/libsystemd-network')
5c23128d 957subdir('src/journal')
5c23128d 958subdir('src/login')
5c23128d
ZJS
959
960libjournal_core = static_library(
961 'journal-core',
962 libjournal_core_sources,
963 journald_gperf_c,
964 include_directories : includes,
965 link_with : [libbasic,
966 libsystemd_internal,
967 libsystemd_journal_internal],
968 install : false)
969
6b30f280 970version_script_arg = '@0@/@1@'.format(meson.current_source_dir(), libsystemd_sym)
5c23128d
ZJS
971libsystemd = shared_library(
972 'systemd',
973 libsystemd_internal_sources,
974 version : '0.18.0',
975 include_directories : includes,
976 link_args : ['-shared',
6b30f280 977 '-Wl,--version-script=' + version_script_arg],
5c23128d
ZJS
978 link_with : [libbasic,
979 libsystemd_internal,
980 libsystemd_journal_internal],
981 dependencies : [threads],
6b30f280 982 link_depends : libsystemd_sym,
5c23128d
ZJS
983 install : true,
984 install_dir : rootlibdir)
985
986############################################################
987
988foreach tuple : [['myhostname', 'HAVE_MYHOSTNAME', []],
989 ['systemd', '', []],
990 ['mymachines', 'ENABLE_MACHINED', []],
991 ['resolve', 'ENABLE_RESOLVED', [libdl]]]
992
993 condition = tuple[1] == '' or conf.get(tuple[1], 0) == 1
994 if condition
995 module = tuple[0]
996 extra_deps = tuple[2]
997
6b30f280
ZJS
998 sym = 'src/nss-@0@/nss-@0@.sym'.format(module)
999 version_script_arg = join_paths(meson.current_source_dir(), sym)
5c23128d
ZJS
1000
1001 shared_library(
1002 'nss_' + module,
1003 'src/nss-@0@/nss-@0@.c'.format(module),
1004 version : '2',
1005 include_directories : includes,
1006 link_args : ['-shared',
6b30f280 1007 '-Wl,--version-script=' + version_script_arg,
5c23128d
ZJS
1008 '-Wl,--undefined'],
1009 link_with : [libsystemd_internal,
1010 libbasic],
1011 dependencies : [threads,
1012 librt] + extra_deps,
6b30f280 1013 link_depends : sym,
5c23128d
ZJS
1014 install : true,
1015 install_dir : rootlibdir)
d7148676
ZJS
1016
1017 # We cannot use shared_module because it does not support version suffix.
1018 # Unfortunately shared_library insists on creating the symlink…
1019 meson.add_install_script('sh', '-c',
1020 'rm $DESTDIR@0@/libnss_@1@.so'
1021 .format(rootlibdir, module))
5c23128d
ZJS
1022 endif
1023endforeach
1024
1025############################################################
1026
1027subdir('src/libudev')
1028subdir('src/shared')
1029subdir('src/core')
1030subdir('src/udev')
1031subdir('src/network')
1032
69e96427
ZJS
1033subdir('src/analyze')
1034subdir('src/journal-remote')
1035subdir('src/coredump')
1036subdir('src/hostname')
1037subdir('src/import')
1038subdir('src/kernel-install')
1039subdir('src/locale')
1040subdir('src/machine')
1041subdir('src/nspawn')
1042subdir('src/resolve')
1043subdir('src/timedate')
1044subdir('src/timesync')
1045subdir('src/vconsole')
4e4ab1c3 1046subdir('src/sulogin-shell')
69e96427
ZJS
1047
1048subdir('src/test')
1049
5c23128d
ZJS
1050executable('systemd',
1051 systemd_sources,
1052 include_directories : includes,
1053 link_with : [libcore,
1054 libshared],
1055 dependencies : [threads,
1056 librt,
1057 libseccomp,
1058 libselinux,
f4ee10a2
ZJS
1059 libmount,
1060 libblkid],
5c23128d
ZJS
1061 install : true,
1062 install_dir : rootlibexecdir)
1063
1064executable('systemd-analyze',
1065 systemd_analyze_sources,
1066 include_directories : includes,
1067 link_with : [libcore,
1068 libshared],
1069 dependencies : [threads,
1070 librt,
1071 libseccomp,
1072 libselinux,
f4ee10a2
ZJS
1073 libmount,
1074 libblkid],
5c23128d
ZJS
1075 install : true)
1076
1077executable('systemd-journald',
1078 systemd_journald_sources,
1079 include_directories : includes,
1080 link_with : [libsystemd_journal_internal,
1081 libjournal_core,
1082 libshared,
1083 libudev],
1084 dependencies : [threads,
1085 libxz,
1086 liblz4],
1087 install : true,
1088 install_dir : rootlibexecdir)
1089
1090executable('systemd-cat',
1091 systemd_cat_sources,
1092 include_directories : includes,
1093 link_with : [libjournal_core,
1094 libshared,
1095 libudev],
1096 dependencies : [threads],
1097 install : true)
1098
1099executable('journalctl',
1100 journalctl_sources,
1101 include_directories : includes,
1102 link_with : [libshared,
1103 libudev],
1104 dependencies : [threads,
1105 libqrencode,
1106 libxz,
1107 liblz4],
1108 install : true,
1109 install_dir : rootbindir)
1110
1111executable('systemd-getty-generator',
1112 'src/getty-generator/getty-generator.c',
1113 install : true,
1114 install_dir : systemgeneratordir,
1115 include_directories : includes,
1116 link_with : [libshared])
1117
1118executable('systemd-debug-generator',
1119 'src/debug-generator/debug-generator.c',
1120 install : true,
1121 install_dir : systemgeneratordir,
1122 include_directories : includes,
1123 link_with : [libshared])
1124
1125executable('systemd-fstab-generator',
1126 'src/fstab-generator/fstab-generator.c',
1127 'src/core/mount-setup.c',
1128 install : true,
1129 install_dir : systemgeneratordir,
1130 include_directories : includes,
1131 link_with : [libshared])
1132
1133if conf.get('ENABLE_ENVIRONMENT_D', 0) == 1
1134 executable('30-systemd-environment-d-generator',
1135 'src/environment-d-generator/environment-d-generator.c',
1136 install : true,
1137 install_dir : userenvgeneratordir,
1138 include_directories : includes,
1139 link_with : [libshared])
7b76fce1
ZJS
1140
1141 meson.add_install_script(meson_make_symlink,
1142 sysconfdir + '/environment',
1143 environmentdir + '/99-environment.conf')
5c23128d
ZJS
1144endif
1145
1146if conf.get('ENABLE_HIBERNATE', 0) == 1
1147 executable('systemd-hibernate-resume-generator',
1148 'src/hibernate-resume/hibernate-resume-generator.c',
1149 include_directories : includes,
1150 link_with : [libshared],
1151 install : true,
1152 install_dir : systemgeneratordir)
1153
1154 executable('systemd-hibernate-resume',
1155 'src/hibernate-resume/hibernate-resume.c',
1156 include_directories : includes,
1157 link_with : [libshared],
1158 install : true,
1159 install_dir : rootlibexecdir)
1160endif
1161
1162if conf.get('HAVE_BLKID', 0) == 1
1163 executable('systemd-gpt-auto-generator',
1164 'src/gpt-auto-generator/gpt-auto-generator.c',
1165 'src/basic/blkid-util.h',
1166 install : true,
1167 install_dir : systemgeneratordir,
1168 include_directories : includes,
1169 link_with : libshared,
1170 dependencies : libblkid)
1171
1172 executable('systemd-dissect',
1173 'src/dissect/dissect.c',
1174 include_directories : includes,
1175 link_with : [libshared],
1176 install : true,
1177 install_dir : rootlibexecdir)
1178endif
1179
1180if conf.get('ENABLE_RESOLVED', 0) == 1
1181 executable('systemd-resolved',
1182 systemd_resolved_sources,
1183 include_directories : includes,
1184 link_with : [libshared,
1185 ],
1186 dependencies : [threads,
1187 libm,
1188 libidn],
1189 install : true,
1190 install_dir : rootlibexecdir)
1191
1192 executable('systemd-resolve',
1193 systemd_resolve_sources,
1194 include_directories : includes,
1195 link_with : [libshared,
1196 ],
1197 dependencies : [threads,
1198 libm,
1199 libidn],
1200 install : true)
1201endif
1202
1203if conf.get('ENABLE_LOGIND', 0) == 1
1204 executable('systemd-logind',
1205 systemd_logind_sources,
1206 include_directories : includes,
1207 link_with : [liblogind_core,
1208 libshared],
1209 dependencies : [threads,
1210 libacl],
1211 install : true,
1212 install_dir : rootlibexecdir)
1213
1214 executable('loginctl',
1215 loginctl_sources,
1216 include_directories : includes,
1217 link_with : [libshared],
1218 dependencies : [threads,
1219 liblz4,
1220 libxz],
1221 install : true,
1222 install_dir : rootbindir)
1223
1224 executable('systemd-inhibit',
1225 'src/login/inhibit.c',
1226 include_directories : includes,
1227 link_with : [libshared],
1228 install : true,
1229 install_dir : rootbindir)
1230
1231 if conf.get('HAVE_PAM', 0) == 1
6b30f280 1232 version_script_arg = join_paths(meson.current_source_dir(), pam_systemd_sym)
5c23128d
ZJS
1233 shared_library(
1234 'pam_systemd',
1235 pam_systemd_c,
1236 name_prefix : '',
1237 include_directories : includes,
1238 link_args : ['-shared',
6b30f280 1239 '-Wl,--version-script=' + version_script_arg],
5c23128d
ZJS
1240 link_with : [libshared],
1241 dependencies : [libpam,
1242 libpam_misc],
6b30f280 1243 link_depends : pam_systemd_sym,
5c23128d
ZJS
1244 install : true,
1245 install_dir : pamlibdir)
1246 endif
1247endif
1248
1249if conf.get('HAVE_PAM', 0) == 1
1250 executable('systemd-user-sessions',
1251 'src/user-sessions/user-sessions.c',
1252 include_directories : includes,
1253 link_with : [libshared],
1254 install : true,
1255 install_dir : rootlibexecdir)
1256endif
1257
1258if conf.get('ENABLE_EFI', 0) == 1
1259 executable('bootctl',
1260 'src/boot/bootctl.c',
1261 include_directories : includes,
1262 link_with : [libshared],
1263 dependencies : [libblkid],
1264 install : true)
1265endif
1266
1267executable('systemd-socket-activate', 'src/activate/activate.c',
1268 include_directories : includes,
1269 link_with : [libshared],
1270 dependencies : [threads],
1271 install : true)
1272
1273executable('systemctl', 'src/systemctl/systemctl.c',
1274 include_directories : includes,
1275 link_with : [libshared],
1276 dependencies : [threads,
1277 libcap,
1278 libselinux,
1279 libxz,
1280 liblz4],
1281 install : true,
1282 install_dir : rootbindir)
1283
1284if conf.get('ENABLE_BACKLIGHT', 0) == 1
1285 executable('systemd-backlight',
1286 'src/backlight/backlight.c',
1287 include_directories : includes,
1288 link_with : [libshared],
1289 install : true,
1290 install_dir : rootlibexecdir)
1291endif
1292
1293if conf.get('ENABLE_RFKILL', 0) == 1
1294 executable('systemd-rfkill',
1295 'src/rfkill/rfkill.c',
1296 include_directories : includes,
1297 link_with : [libshared],
1298 install : true,
1299 install_dir : rootlibexecdir)
1300endif
1301
1302executable('systemd-system-update-generator',
1303 'src/system-update-generator/system-update-generator.c',
1304 include_directories : includes,
1305 link_with : [libshared],
1306 install : true,
1307 install_dir : systemgeneratordir)
1308
1309if conf.get('HAVE_LIBCRYPTSETUP', 0) == 1
1310 executable('systemd-cryptsetup',
1311 'src/cryptsetup/cryptsetup.c',
1312 include_directories : includes,
1313 link_with : [libshared],
1314 dependencies : [libcryptsetup],
1315 install : true,
1316 install_dir : rootlibexecdir)
1317
1318 executable('systemd-cryptsetup-generator',
1319 'src/cryptsetup/cryptsetup-generator.c',
1320 include_directories : includes,
1321 link_with : [libshared],
1322 dependencies : [libcryptsetup],
1323 install : true,
1324 install_dir : systemgeneratordir)
1325
1326 executable('systemd-veritysetup',
1327 'src/veritysetup/veritysetup.c',
1328 include_directories : includes,
1329 link_with : [libshared],
1330 dependencies : [libcryptsetup],
1331 install : true,
1332 install_dir : rootlibexecdir)
1333
1334 executable('systemd-veritysetup-generator',
1335 'src/veritysetup/veritysetup-generator.c',
1336 include_directories : includes,
1337 link_with : [libshared],
1338 dependencies : [libcryptsetup],
1339 install : true,
1340 install_dir : systemgeneratordir)
1341endif
1342
1343if conf.get('HAVE_SYSV_COMPAT', 0) == 1
1344 executable('systemd-sysv-generator',
1345 'src/sysv-generator/sysv-generator.c',
1346 include_directories : includes,
1347 link_with : [libshared],
1348 install : true,
1349 install_dir : systemgeneratordir)
1350
1351 executable('systemd-rc-local-generator',
1352 'src/rc-local-generator/rc-local-generator.c',
1353 include_directories : includes,
1354 link_with : [libshared],
1355 install : true,
1356 install_dir : systemgeneratordir)
1357endif
1358
1359if conf.get('ENABLE_HOSTNAMED', 0) == 1
1360 executable('systemd-hostnamed',
1361 'src/hostname/hostnamed.c',
1362 include_directories : includes,
1363 link_with : [libshared],
1364 install : true,
1365 install_dir : rootlibexecdir)
1366
1367 executable('hostnamectl',
1368 'src/hostname/hostnamectl.c',
1369 include_directories : includes,
1370 link_with : [libshared],
1371 install : true)
1372endif
1373
1374if conf.get('ENABLE_LOCALED', 0) == 1
1375 executable('systemd-localed',
1376 systemd_localed_sources,
1377 include_directories : includes,
1378 link_with : [libshared],
1379 dependencies : [libdl],
1380 install : true,
1381 install_dir : rootlibexecdir)
1382
1383 executable('localectl',
1384 localectl_sources,
1385 include_directories : includes,
1386 link_with : [libshared],
1387 install : true)
1388endif
1389
1390if conf.get('ENABLE_TIMEDATED', 0) == 1
1391 executable('systemd-timedated',
1392 'src/timedate/timedated.c',
1393 include_directories : includes,
1394 link_with : [libshared],
1395 install : true,
1396 install_dir : rootlibexecdir)
1397
1398 executable('timedatectl',
1399 'src/timedate/timedatectl.c',
1400 include_directories : includes,
1401 link_with : [libshared],
1402 install : true)
1403endif
1404
1405if conf.get('ENABLE_TIMESYNCD', 0) == 1
1406 executable('systemd-timesyncd',
1407 systemd_timesyncd_sources,
1408 include_directories : includes,
1409 link_with : [libshared],
1410 dependencies : [threads,
1411 libm],
1412 install : true,
1413 install_dir : rootlibexecdir)
1414endif
1415
1416if conf.get('ENABLE_MACHINED', 0) == 1
1417 executable('systemd-machined',
1418 systemd_machined_sources,
1419 include_directories : includes,
1420 link_with : [libmachine_core,
1421 libshared],
1422 install : true,
1423 install_dir : rootlibexecdir)
1424
1425 executable('machinectl',
1426 'src/machine/machinectl.c',
1427 include_directories : includes,
1428 link_with : [libshared],
1429 dependencies : [threads,
1430 libxz,
1431 liblz4],
1432 install : true,
1433 install_dir : rootbindir)
1434endif
1435
1436if conf.get('ENABLE_IMPORTD', 0) == 1
1437 executable('systemd-importd',
1438 systemd_importd_sources,
1439 include_directories : includes,
1440 link_with : [libshared],
1441 install : true,
1442 install_dir : rootlibexecdir)
1443
1444 executable('systemd-pull',
1445 systemd_pull_sources,
1446 include_directories : includes,
1447 link_with : [libshared],
1448 dependencies : [libcurl,
1449 libz,
1450 libbzip2,
1451 libxz,
1452 libgcrypt],
1453 install : true,
1454 install_dir : rootlibexecdir)
1455
1456 executable('systemd-import',
1457 systemd_import_sources,
1458 include_directories : includes,
1459 link_with : [libshared],
1460 dependencies : [libcurl,
1461 libz,
1462 libbzip2,
1463 libxz],
1464 install : true,
1465 install_dir : rootlibexecdir)
1466
1467 executable('systemd-export',
1468 systemd_export_sources,
1469 include_directories : includes,
1470 link_with : [libshared],
1471 dependencies : [libcurl,
1472 libz,
1473 libbzip2,
1474 libxz],
1475 install : true,
1476 install_dir : rootlibexecdir)
1477endif
1478
1479if conf.get('ENABLE_REMOTE', 0) == 1 and conf.get('HAVE_LIBCURL', 0) == 1
1480 executable('systemd-journal-upload',
1481 systemd_journal_upload_sources,
1482 include_directories : includes,
1483 link_with : [libshared],
1484 dependencies : [threads,
1485 libcurl,
1486 libgnutls,
1487 libxz,
1488 liblz4],
1489 install : true,
1490 install_dir : rootlibexecdir)
1491endif
1492
1493if conf.get('ENABLE_REMOTE', 0) == 1 and conf.get('HAVE_MICROHTTPD', 0) == 1
1494 executable('systemd-journal-remote',
1495 systemd_journal_remote_sources,
1496 include_directories : includes,
1497 link_with : [libshared],
1498 dependencies : [threads,
1499 libmicrohttpd,
1500 libgnutls,
1501 libxz,
1502 liblz4],
1503 install : true,
1504 install_dir : rootlibexecdir)
1505
1506 executable('systemd-journal-gatewayd',
1507 systemd_journal_gatewayd_sources,
1508 include_directories : includes,
1509 link_with : [libshared],
1510 dependencies : [threads,
1511 libmicrohttpd,
1512 libgnutls,
1513 libxz,
1514 liblz4],
1515 install : true,
1516 install_dir : rootlibexecdir)
1517endif
1518
1519if conf.get('ENABLE_COREDUMP', 0) == 1
1520 executable('systemd-coredump',
1521 systemd_coredump_sources,
1522 include_directories : includes,
1523 link_with : [libshared],
1524 dependencies : [threads,
1525 libacl,
1526 libdw,
1527 libxz,
1528 liblz4],
1529 install : true,
1530 install_dir : rootlibexecdir)
1531
1532 executable('coredumpctl',
1533 coredumpctl_sources,
1534 include_directories : includes,
1535 link_with : [libshared],
1536 dependencies : [threads,
1537 libxz,
1538 liblz4],
1539 install : true)
1540endif
1541
1542if conf.get('ENABLE_BINFMT', 0) == 1
1543 executable('systemd-binfmt',
1544 'src/binfmt/binfmt.c',
1545 include_directories : includes,
1546 link_with : [libshared],
1547 install : true,
1548 install_dir : rootlibexecdir)
94e75a54
ZJS
1549
1550 meson.add_install_script('sh', '-c',
1551 mkdir_p.format(binfmtdir))
1552 meson.add_install_script('sh', '-c',
1553 mkdir_p.format(sysconfdir + '/binfmt.d'))
5c23128d
ZJS
1554endif
1555
1556if conf.get('ENABLE_VCONSOLE', 0) == 1
1557 executable('systemd-vconsole-setup',
1558 'src/vconsole/vconsole-setup.c',
1559 include_directories : includes,
1560 link_with : [libshared],
1561 install : true,
1562 install_dir : rootlibexecdir)
1563endif
1564
1565if conf.get('ENABLE_RANDOMSEED', 0) == 1
1566 executable('systemd-random-seed',
1567 'src/random-seed/random-seed.c',
1568 include_directories : includes,
1569 link_with : [libshared],
1570 install : true,
1571 install_dir : rootlibexecdir)
1572endif
1573
1574if conf.get('ENABLE_FIRSTBOOT', 0) == 1
1575 executable('systemd-firstboot',
1576 'src/firstboot/firstboot.c',
1577 include_directories : includes,
1578 link_with : [libshared],
1579 dependencies : [libcrypt],
1580 install : true,
1581 install_dir : rootbindir)
1582endif
1583
1584executable('systemd-remount-fs',
1585 'src/remount-fs/remount-fs.c',
1586 'src/core/mount-setup.c',
1587 'src/core/mount-setup.h',
1588 include_directories : includes,
1589 link_with : [libshared],
1590 install : true,
1591 install_dir : rootlibexecdir)
1592
1593executable('systemd-machine-id-setup',
1594 'src/machine-id-setup/machine-id-setup-main.c',
1595 'src/core/machine-id-setup.c',
1596 'src/core/machine-id-setup.h',
1597 include_directories : includes,
1598 link_with : [libshared],
1599 install : true,
1600 install_dir : rootbindir)
1601
1602executable('systemd-fsck',
1603 'src/fsck/fsck.c',
1604 include_directories : includes,
1605 link_with : [libshared],
1606 install : true,
1607 install_dir : rootlibexecdir)
1608
1609executable('systemd-sleep',
1610 'src/sleep/sleep.c',
1611 include_directories : includes,
1612 link_with : [libshared],
1613 install : true,
1614 install_dir : rootlibexecdir)
1615
1616executable('systemd-sysctl',
1617 'src/sysctl/sysctl.c',
1618 include_directories : includes,
1619 link_with : [libshared],
1620 install : true,
1621 install_dir : rootlibexecdir)
1622
1623executable('systemd-ac-power',
1624 'src/ac-power/ac-power.c',
1625 include_directories : includes,
1626 link_with : [libshared],
1627 install : true,
1628 install_dir : rootlibexecdir)
1629
1630executable('systemd-detect-virt',
1631 'src/detect-virt/detect-virt.c',
1632 include_directories : includes,
1633 link_with : [libshared],
1634 install : true)
1635
1636executable('systemd-delta',
1637 'src/delta/delta.c',
1638 include_directories : includes,
1639 link_with : [libshared],
1640 install : true)
1641
1642executable('systemd-escape',
1643 'src/escape/escape.c',
1644 include_directories : includes,
1645 link_with : [libshared],
1646 install : true,
1647 install_dir : rootbindir)
1648
1649executable('systemd-notify',
1650 'src/notify/notify.c',
1651 include_directories : includes,
1652 link_with : [libshared],
1653 install : true,
1654 install_dir : rootbindir)
1655
1656executable('systemd-volatile-root',
1657 'src/volatile-root/volatile-root.c',
1658 include_directories : includes,
1659 link_with : [libshared],
1660 install : true,
1661 install_dir : rootlibexecdir)
1662
1663executable('systemd-cgroups-agent',
1664 'src/cgroups-agent/cgroups-agent.c',
1665 include_directories : includes,
1666 link_with : [libshared],
1667 install : true,
1668 install_dir : rootlibexecdir)
1669
1670executable('systemd-path',
1671 'src/path/path.c',
1672 include_directories : includes,
1673 link_with : [libshared],
1674 install : true)
1675
1676executable('systemd-ask-password',
1677 'src/ask-password/ask-password.c',
1678 include_directories : includes,
1679 link_with : [libshared],
1680 install : true,
1681 install_dir : rootbindir)
1682
1683executable('systemd-reply-password',
1684 'src/reply-password/reply-password.c',
1685 include_directories : includes,
1686 link_with : [libshared],
1687 install : true,
1688 install_dir : rootlibexecdir)
1689
1690executable('systemd-tty-ask-password-agent',
1691 'src/tty-ask-password-agent/tty-ask-password-agent.c',
1692 include_directories : includes,
1693 link_with : [libshared],
1694 install : true,
1695 install_dir : rootbindir)
1696
1697executable('systemd-cgls',
1698 'src/cgls/cgls.c',
1699 include_directories : includes,
1700 link_with : [libshared],
1701 install : true)
1702
1703executable('systemd-cgtop',
1704 'src/cgtop/cgtop.c',
1705 include_directories : includes,
1706 link_with : [libshared],
1707 install : true)
1708
1709executable('systemd-initctl',
1710 'src/initctl/initctl.c',
1711 include_directories : includes,
1712 link_with : [libshared],
1713 install : true,
1714 install_dir : rootlibexecdir)
1715
1716executable('systemd-mount',
1717 'src/mount/mount-tool.c',
1718 include_directories : includes,
1719 link_with : [libshared],
1720 install : true)
1721
7b76fce1
ZJS
1722meson.add_install_script(meson_make_symlink,
1723 'systemd-mount', bindir + '/systemd-umount')
1724
5c23128d
ZJS
1725executable('systemd-run',
1726 'src/run/run.c',
1727 include_directories : includes,
1728 link_with : [libshared],
1729 install : true)
1730
1731executable('systemd-stdio-bridge',
1732 'src/stdio-bridge/stdio-bridge.c',
1733 include_directories : includes,
1734 link_with : [libshared],
1735 install : true)
1736
1737executable('busctl',
1738 'src/busctl/busctl.c',
1739 'src/busctl/busctl-introspect.c',
1740 'src/busctl/busctl-introspect.h',
1741 include_directories : includes,
1742 link_with : [libshared],
1743 install : true)
1744
1745if conf.get('ENABLE_SYSUSERS', 0) == 1
1746 executable('systemd-sysusers',
1747 'src/sysusers/sysusers.c',
1748 include_directories : includes,
1749 link_with : [libshared],
1750 install : true,
1751 install_dir : rootbindir)
1752endif
1753
1754if conf.get('ENABLE_TMPFILES', 0) == 1
1755 executable('systemd-tmpfiles',
1756 'src/tmpfiles/tmpfiles.c',
1757 include_directories : includes,
1758 link_with : [libshared],
1759 dependencies : [libacl],
1760 install : true,
1761 install_dir : rootbindir)
1762endif
1763
1764if conf.get('ENABLE_HWDB', 0) == 1
1765 executable('systemd-hwdb',
1766 'src/hwdb/hwdb.c',
1767 'src/libsystemd/sd-hwdb/hwdb-internal.h',
1768 include_directories : includes,
1769 link_with : [libshared],
1770 install : true,
1771 install_dir : rootbindir)
1772endif
1773
1774if conf.get('ENABLE_QUOTACHECK', 0) == 1
1775 executable('systemd-quotacheck',
1776 'src/quotacheck/quotacheck.c',
1777 include_directories : includes,
1778 link_with : [libshared],
1779 install : true,
1780 install_dir : rootlibexecdir)
1781endif
1782
1783executable('systemd-socket-proxyd',
1784 'src/socket-proxy/socket-proxyd.c',
1785 include_directories : includes,
1786 link_with : [libshared,
1787 libsystemd],
1788 dependencies : [threads],
1789 install : true,
1790 install_dir : rootlibexecdir)
1791
1792executable('systemd-udevd',
1793 systemd_udevd_sources,
1794 include_directories : includes,
1795 link_with : [libudev_core,
1796 libudev_internal,
1797 libsystemd_network,
1798 libshared],
1799 dependencies : [libkmod,
1800 libidn,
1801 libacl],
1802 install : true,
1803 install_dir : rootlibexecdir)
1804
1805executable('udevadm',
1806 udevadm_sources,
1807 include_directories : includes,
1808 link_with : [libudev_core,
1809 libudev_internal,
1810 libsystemd_network,
1811 libshared],
1812 dependencies : [libkmod,
1813 libidn,
1814 libacl],
1815 install : true,
1816 install_dir : rootbindir)
1817
1818executable('systemd-shutdown',
1819 systemd_shutdown_sources,
1820 include_directories : includes,
1821 link_with : [libshared],
1822 install : true,
1823 install_dir : rootlibexecdir)
1824
1825executable('systemd-update-done',
1826 'src/update-done/update-done.c',
1827 include_directories : includes,
1828 link_with : [libshared],
1829 install : true,
1830 install_dir : rootlibexecdir)
1831
1832executable('systemd-update-utmp',
1833 'src/update-utmp/update-utmp.c',
1834 include_directories : includes,
1835 link_with : [libshared],
1836 dependencies : [libaudit],
1837 install : true,
1838 install_dir : rootlibexecdir)
1839
1840if conf.get('HAVE_KMOD', 0) == 1
1841 executable('systemd-modules-load',
1842 'src/modules-load/modules-load.c',
1843 include_directories : includes,
1844 link_with : [libshared],
1845 dependencies : [libkmod],
1846 install : true,
1847 install_dir : rootlibexecdir)
94e75a54
ZJS
1848
1849 meson.add_install_script('sh', '-c',
1850 mkdir_p.format(modulesloaddir))
1851 meson.add_install_script('sh', '-c',
1852 mkdir_p.format(sysconfdir + '/modules-load.d'))
5c23128d
ZJS
1853endif
1854
1855executable('systemd-nspawn',
1856 systemd_nspawn_sources,
1857 'src/core/mount-setup.c', # FIXME: use a variable?
1858 'src/core/mount-setup.h',
1859 'src/core/loopback-setup.c',
1860 'src/core/loopback-setup.h',
1861 include_directories : [includes, include_directories('src/nspawn')],
1862 link_with : [libfirewall,
1863 libshared],
1864 dependencies : [libacl,
1865 libblkid,
1866 libseccomp,
1867 libselinux],
1868 install : true)
1869
1870executable('systemd-networkd',
1871 systemd_networkd_sources,
1872 include_directories : includes,
1873 link_with : [libnetworkd_core,
1874 libfirewall,
1875 libsystemd_network,
1876 libudev_internal,
1877 libshared],
1878 install : true,
1879 install_dir : rootlibexecdir)
1880
1881executable('systemd-networkd-wait-online',
1882 systemd_networkd_wait_online_sources,
1883 include_directories : includes,
1884 link_with : [libnetworkd_core,
1885 libshared],
1886 install : true,
1887 install_dir : rootlibexecdir)
1888
1889executable('networkctl',
1890 networkctl_sources,
1891 include_directories : includes,
1892 link_with : [libsystemd_network,
1893 libshared],
1894 install : true,
1895 install_dir : rootbindir)
1896
69e96427
ZJS
1897############################################################
1898
1899foreach tuple : tests
1900 sources = tuple[0]
1901 link_with = tuple[1].length() > 0 ? tuple[1] : [libshared]
1902 dependencies = tuple[2]
1903 condition = tuple.length() >= 4 ? tuple[3] : ''
1904 type = tuple.length() >= 5 ? tuple[4] : ''
1905 defs = tuple.length() >= 6 ? tuple[5] : []
1906 incs = tuple.length() >= 7 ? tuple[6] : includes
1907
1908 name = sources[0].split('/')[-1].split('.')[0]
1909
1910 if condition == '' or conf.get(condition, 0) == 1
572baca1
ZJS
1911 install = install_tests and type == ''
1912
69e96427
ZJS
1913 exe = executable(
1914 name,
1915 sources,
1916 include_directories : incs,
1917 link_with : link_with,
1918 dependencies : dependencies,
572baca1
ZJS
1919 c_args : defs,
1920 install : install,
1921 install_dir : testsdir)
1922
69e96427
ZJS
1923 if type == 'manual'
1924 message('@0@ is a manual test'.format(name))
1925 elif type == 'unsafe' and want_tests != 'unsafe'
1926 message('@0@ is an unsafe test'.format(name))
1927 else
1928 test(name, exe, env : test_env)
1929 endif
1930 else
1931 message('Not compiling @0@ because @1@ is not true'.format(name, condition))
1932 endif
1933endforeach
1934
1935############################################################
5c23128d
ZJS
1936
1937make_directive_index_py = find_program('tools/make-directive-index.py')
1938make_man_index_py = find_program('tools/make-man-index.py')
1939
1940subdir('units')
1941subdir('sysctl.d')
1942subdir('sysusers.d')
1943subdir('tmpfiles.d')
1944subdir('rules')
1945subdir('hwdb')
1946subdir('network')
1947subdir('man')
1948subdir('shell-completion/bash')
1949subdir('shell-completion/zsh')
1950subdir('docs/sysvinit')
1951subdir('docs/var-log')
1952
1953# FIXME: figure out if the warning is true:
1954# https://github.com/mesonbuild/meson/wiki/Reference-manual#install_subdir
1955install_subdir('factory/etc',
1956 install_dir : factorydir)
1957
1958
1959install_data('xorg/50-systemd-user.sh',
1960 install_dir : xinitrcdir)
1961install_data('system-preset/90-systemd.preset',
1962 install_dir : systempresetdir)
1963install_data('README',
1964 'NEWS',
1965 'CODING_STYLE',
1966 'DISTRO_PORTING',
1967 'ENVIRONMENT.md',
1968 'LICENSE.GPL2',
1969 'LICENSE.LGPL2.1',
1970 'src/libsystemd/sd-bus/GVARIANT-SERIALIZATION',
1971 install_dir : docdir)
d68b342b 1972
94e75a54
ZJS
1973meson.add_install_script('sh', '-c', mkdir_p.format(systemdstatedir))
1974meson.add_install_script('sh', '-c', 'touch $DESTDIR@0@'.format(prefixdir))
1975
d68b342b
ZJS
1976############################################################
1977
1978if git.found() and etags.found()
1979 all_files = run_command(
1980 git,
1981 ['--git-dir=@0@/.git'.format(meson.source_root()),
1982 'ls-files',
1983 ':/*.[ch]'])
1984 all_files = files(all_files.stdout().split())
1985
1986 custom_target(
1987 'TAGS',
1988 output : 'TAGS',
1989 input : all_files,
1990 command : [etags, '-o', '@OUTPUT@'] + all_files)
1991endif