]> git.ipfire.org Git - thirdparty/systemd.git/blame - meson.build
meson: add test-libsystemd-sym, fix linking of libsystemd
[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
37ab1a25 970libsystemd_sym_path = '@0@/@1@'.format(meson.current_source_dir(), libsystemd_sym)
5c23128d
ZJS
971libsystemd = shared_library(
972 'systemd',
973 libsystemd_internal_sources,
37ab1a25 974 libsystemd_journal_internal_sources,
5c23128d
ZJS
975 version : '0.18.0',
976 include_directories : includes,
977 link_args : ['-shared',
37ab1a25
ZJS
978 '-Wl,--version-script=' + libsystemd_sym_path],
979 link_with : [libbasic],
980 dependencies : [threads,
981 librt,
982 libxz,
983 liblz4],
6b30f280 984 link_depends : libsystemd_sym,
5c23128d
ZJS
985 install : true,
986 install_dir : rootlibdir)
987
988############################################################
989
990foreach tuple : [['myhostname', 'HAVE_MYHOSTNAME', []],
991 ['systemd', '', []],
992 ['mymachines', 'ENABLE_MACHINED', []],
993 ['resolve', 'ENABLE_RESOLVED', [libdl]]]
994
995 condition = tuple[1] == '' or conf.get(tuple[1], 0) == 1
996 if condition
997 module = tuple[0]
998 extra_deps = tuple[2]
999
6b30f280
ZJS
1000 sym = 'src/nss-@0@/nss-@0@.sym'.format(module)
1001 version_script_arg = join_paths(meson.current_source_dir(), sym)
5c23128d
ZJS
1002
1003 shared_library(
1004 'nss_' + module,
1005 'src/nss-@0@/nss-@0@.c'.format(module),
1006 version : '2',
1007 include_directories : includes,
1008 link_args : ['-shared',
6b30f280 1009 '-Wl,--version-script=' + version_script_arg,
5c23128d
ZJS
1010 '-Wl,--undefined'],
1011 link_with : [libsystemd_internal,
1012 libbasic],
1013 dependencies : [threads,
1014 librt] + extra_deps,
6b30f280 1015 link_depends : sym,
5c23128d
ZJS
1016 install : true,
1017 install_dir : rootlibdir)
d7148676
ZJS
1018
1019 # We cannot use shared_module because it does not support version suffix.
1020 # Unfortunately shared_library insists on creating the symlink…
1021 meson.add_install_script('sh', '-c',
1022 'rm $DESTDIR@0@/libnss_@1@.so'
1023 .format(rootlibdir, module))
5c23128d
ZJS
1024 endif
1025endforeach
1026
1027############################################################
1028
1029subdir('src/libudev')
1030subdir('src/shared')
1031subdir('src/core')
1032subdir('src/udev')
1033subdir('src/network')
1034
69e96427
ZJS
1035subdir('src/analyze')
1036subdir('src/journal-remote')
1037subdir('src/coredump')
1038subdir('src/hostname')
1039subdir('src/import')
1040subdir('src/kernel-install')
1041subdir('src/locale')
1042subdir('src/machine')
1043subdir('src/nspawn')
1044subdir('src/resolve')
1045subdir('src/timedate')
1046subdir('src/timesync')
1047subdir('src/vconsole')
4e4ab1c3 1048subdir('src/sulogin-shell')
69e96427
ZJS
1049
1050subdir('src/test')
1051
5c23128d
ZJS
1052executable('systemd',
1053 systemd_sources,
1054 include_directories : includes,
1055 link_with : [libcore,
1056 libshared],
1057 dependencies : [threads,
1058 librt,
1059 libseccomp,
1060 libselinux,
f4ee10a2
ZJS
1061 libmount,
1062 libblkid],
5c23128d
ZJS
1063 install : true,
1064 install_dir : rootlibexecdir)
1065
1066executable('systemd-analyze',
1067 systemd_analyze_sources,
1068 include_directories : includes,
1069 link_with : [libcore,
1070 libshared],
1071 dependencies : [threads,
1072 librt,
1073 libseccomp,
1074 libselinux,
f4ee10a2
ZJS
1075 libmount,
1076 libblkid],
5c23128d
ZJS
1077 install : true)
1078
1079executable('systemd-journald',
1080 systemd_journald_sources,
1081 include_directories : includes,
1082 link_with : [libsystemd_journal_internal,
1083 libjournal_core,
1084 libshared,
1085 libudev],
1086 dependencies : [threads,
1087 libxz,
1088 liblz4],
1089 install : true,
1090 install_dir : rootlibexecdir)
1091
1092executable('systemd-cat',
1093 systemd_cat_sources,
1094 include_directories : includes,
1095 link_with : [libjournal_core,
1096 libshared,
1097 libudev],
1098 dependencies : [threads],
1099 install : true)
1100
1101executable('journalctl',
1102 journalctl_sources,
1103 include_directories : includes,
1104 link_with : [libshared,
1105 libudev],
1106 dependencies : [threads,
1107 libqrencode,
1108 libxz,
1109 liblz4],
1110 install : true,
1111 install_dir : rootbindir)
1112
1113executable('systemd-getty-generator',
1114 'src/getty-generator/getty-generator.c',
1115 install : true,
1116 install_dir : systemgeneratordir,
1117 include_directories : includes,
1118 link_with : [libshared])
1119
1120executable('systemd-debug-generator',
1121 'src/debug-generator/debug-generator.c',
1122 install : true,
1123 install_dir : systemgeneratordir,
1124 include_directories : includes,
1125 link_with : [libshared])
1126
1127executable('systemd-fstab-generator',
1128 'src/fstab-generator/fstab-generator.c',
1129 'src/core/mount-setup.c',
1130 install : true,
1131 install_dir : systemgeneratordir,
1132 include_directories : includes,
1133 link_with : [libshared])
1134
1135if conf.get('ENABLE_ENVIRONMENT_D', 0) == 1
1136 executable('30-systemd-environment-d-generator',
1137 'src/environment-d-generator/environment-d-generator.c',
1138 install : true,
1139 install_dir : userenvgeneratordir,
1140 include_directories : includes,
1141 link_with : [libshared])
7b76fce1
ZJS
1142
1143 meson.add_install_script(meson_make_symlink,
1144 sysconfdir + '/environment',
1145 environmentdir + '/99-environment.conf')
5c23128d
ZJS
1146endif
1147
1148if conf.get('ENABLE_HIBERNATE', 0) == 1
1149 executable('systemd-hibernate-resume-generator',
1150 'src/hibernate-resume/hibernate-resume-generator.c',
1151 include_directories : includes,
1152 link_with : [libshared],
1153 install : true,
1154 install_dir : systemgeneratordir)
1155
1156 executable('systemd-hibernate-resume',
1157 'src/hibernate-resume/hibernate-resume.c',
1158 include_directories : includes,
1159 link_with : [libshared],
1160 install : true,
1161 install_dir : rootlibexecdir)
1162endif
1163
1164if conf.get('HAVE_BLKID', 0) == 1
1165 executable('systemd-gpt-auto-generator',
1166 'src/gpt-auto-generator/gpt-auto-generator.c',
1167 'src/basic/blkid-util.h',
1168 install : true,
1169 install_dir : systemgeneratordir,
1170 include_directories : includes,
1171 link_with : libshared,
1172 dependencies : libblkid)
1173
1174 executable('systemd-dissect',
1175 'src/dissect/dissect.c',
1176 include_directories : includes,
1177 link_with : [libshared],
1178 install : true,
1179 install_dir : rootlibexecdir)
1180endif
1181
1182if conf.get('ENABLE_RESOLVED', 0) == 1
1183 executable('systemd-resolved',
1184 systemd_resolved_sources,
1185 include_directories : includes,
1186 link_with : [libshared,
1187 ],
1188 dependencies : [threads,
1189 libm,
1190 libidn],
1191 install : true,
1192 install_dir : rootlibexecdir)
1193
1194 executable('systemd-resolve',
1195 systemd_resolve_sources,
1196 include_directories : includes,
1197 link_with : [libshared,
1198 ],
1199 dependencies : [threads,
1200 libm,
1201 libidn],
1202 install : true)
1203endif
1204
1205if conf.get('ENABLE_LOGIND', 0) == 1
1206 executable('systemd-logind',
1207 systemd_logind_sources,
1208 include_directories : includes,
1209 link_with : [liblogind_core,
1210 libshared],
1211 dependencies : [threads,
1212 libacl],
1213 install : true,
1214 install_dir : rootlibexecdir)
1215
1216 executable('loginctl',
1217 loginctl_sources,
1218 include_directories : includes,
1219 link_with : [libshared],
1220 dependencies : [threads,
1221 liblz4,
1222 libxz],
1223 install : true,
1224 install_dir : rootbindir)
1225
1226 executable('systemd-inhibit',
1227 'src/login/inhibit.c',
1228 include_directories : includes,
1229 link_with : [libshared],
1230 install : true,
1231 install_dir : rootbindir)
1232
1233 if conf.get('HAVE_PAM', 0) == 1
6b30f280 1234 version_script_arg = join_paths(meson.current_source_dir(), pam_systemd_sym)
5c23128d
ZJS
1235 shared_library(
1236 'pam_systemd',
1237 pam_systemd_c,
1238 name_prefix : '',
1239 include_directories : includes,
1240 link_args : ['-shared',
6b30f280 1241 '-Wl,--version-script=' + version_script_arg],
5c23128d
ZJS
1242 link_with : [libshared],
1243 dependencies : [libpam,
1244 libpam_misc],
6b30f280 1245 link_depends : pam_systemd_sym,
5c23128d
ZJS
1246 install : true,
1247 install_dir : pamlibdir)
1248 endif
1249endif
1250
1251if conf.get('HAVE_PAM', 0) == 1
1252 executable('systemd-user-sessions',
1253 'src/user-sessions/user-sessions.c',
1254 include_directories : includes,
1255 link_with : [libshared],
1256 install : true,
1257 install_dir : rootlibexecdir)
1258endif
1259
1260if conf.get('ENABLE_EFI', 0) == 1
1261 executable('bootctl',
1262 'src/boot/bootctl.c',
1263 include_directories : includes,
1264 link_with : [libshared],
1265 dependencies : [libblkid],
1266 install : true)
1267endif
1268
1269executable('systemd-socket-activate', 'src/activate/activate.c',
1270 include_directories : includes,
1271 link_with : [libshared],
1272 dependencies : [threads],
1273 install : true)
1274
1275executable('systemctl', 'src/systemctl/systemctl.c',
1276 include_directories : includes,
1277 link_with : [libshared],
1278 dependencies : [threads,
1279 libcap,
1280 libselinux,
1281 libxz,
1282 liblz4],
1283 install : true,
1284 install_dir : rootbindir)
1285
1286if conf.get('ENABLE_BACKLIGHT', 0) == 1
1287 executable('systemd-backlight',
1288 'src/backlight/backlight.c',
1289 include_directories : includes,
1290 link_with : [libshared],
1291 install : true,
1292 install_dir : rootlibexecdir)
1293endif
1294
1295if conf.get('ENABLE_RFKILL', 0) == 1
1296 executable('systemd-rfkill',
1297 'src/rfkill/rfkill.c',
1298 include_directories : includes,
1299 link_with : [libshared],
1300 install : true,
1301 install_dir : rootlibexecdir)
1302endif
1303
1304executable('systemd-system-update-generator',
1305 'src/system-update-generator/system-update-generator.c',
1306 include_directories : includes,
1307 link_with : [libshared],
1308 install : true,
1309 install_dir : systemgeneratordir)
1310
1311if conf.get('HAVE_LIBCRYPTSETUP', 0) == 1
1312 executable('systemd-cryptsetup',
1313 'src/cryptsetup/cryptsetup.c',
1314 include_directories : includes,
1315 link_with : [libshared],
1316 dependencies : [libcryptsetup],
1317 install : true,
1318 install_dir : rootlibexecdir)
1319
1320 executable('systemd-cryptsetup-generator',
1321 'src/cryptsetup/cryptsetup-generator.c',
1322 include_directories : includes,
1323 link_with : [libshared],
1324 dependencies : [libcryptsetup],
1325 install : true,
1326 install_dir : systemgeneratordir)
1327
1328 executable('systemd-veritysetup',
1329 'src/veritysetup/veritysetup.c',
1330 include_directories : includes,
1331 link_with : [libshared],
1332 dependencies : [libcryptsetup],
1333 install : true,
1334 install_dir : rootlibexecdir)
1335
1336 executable('systemd-veritysetup-generator',
1337 'src/veritysetup/veritysetup-generator.c',
1338 include_directories : includes,
1339 link_with : [libshared],
1340 dependencies : [libcryptsetup],
1341 install : true,
1342 install_dir : systemgeneratordir)
1343endif
1344
1345if conf.get('HAVE_SYSV_COMPAT', 0) == 1
1346 executable('systemd-sysv-generator',
1347 'src/sysv-generator/sysv-generator.c',
1348 include_directories : includes,
1349 link_with : [libshared],
1350 install : true,
1351 install_dir : systemgeneratordir)
1352
1353 executable('systemd-rc-local-generator',
1354 'src/rc-local-generator/rc-local-generator.c',
1355 include_directories : includes,
1356 link_with : [libshared],
1357 install : true,
1358 install_dir : systemgeneratordir)
1359endif
1360
1361if conf.get('ENABLE_HOSTNAMED', 0) == 1
1362 executable('systemd-hostnamed',
1363 'src/hostname/hostnamed.c',
1364 include_directories : includes,
1365 link_with : [libshared],
1366 install : true,
1367 install_dir : rootlibexecdir)
1368
1369 executable('hostnamectl',
1370 'src/hostname/hostnamectl.c',
1371 include_directories : includes,
1372 link_with : [libshared],
1373 install : true)
1374endif
1375
1376if conf.get('ENABLE_LOCALED', 0) == 1
1377 executable('systemd-localed',
1378 systemd_localed_sources,
1379 include_directories : includes,
1380 link_with : [libshared],
1381 dependencies : [libdl],
1382 install : true,
1383 install_dir : rootlibexecdir)
1384
1385 executable('localectl',
1386 localectl_sources,
1387 include_directories : includes,
1388 link_with : [libshared],
1389 install : true)
1390endif
1391
1392if conf.get('ENABLE_TIMEDATED', 0) == 1
1393 executable('systemd-timedated',
1394 'src/timedate/timedated.c',
1395 include_directories : includes,
1396 link_with : [libshared],
1397 install : true,
1398 install_dir : rootlibexecdir)
1399
1400 executable('timedatectl',
1401 'src/timedate/timedatectl.c',
1402 include_directories : includes,
1403 link_with : [libshared],
1404 install : true)
1405endif
1406
1407if conf.get('ENABLE_TIMESYNCD', 0) == 1
1408 executable('systemd-timesyncd',
1409 systemd_timesyncd_sources,
1410 include_directories : includes,
1411 link_with : [libshared],
1412 dependencies : [threads,
1413 libm],
1414 install : true,
1415 install_dir : rootlibexecdir)
1416endif
1417
1418if conf.get('ENABLE_MACHINED', 0) == 1
1419 executable('systemd-machined',
1420 systemd_machined_sources,
1421 include_directories : includes,
1422 link_with : [libmachine_core,
1423 libshared],
1424 install : true,
1425 install_dir : rootlibexecdir)
1426
1427 executable('machinectl',
1428 'src/machine/machinectl.c',
1429 include_directories : includes,
1430 link_with : [libshared],
1431 dependencies : [threads,
1432 libxz,
1433 liblz4],
1434 install : true,
1435 install_dir : rootbindir)
1436endif
1437
1438if conf.get('ENABLE_IMPORTD', 0) == 1
1439 executable('systemd-importd',
1440 systemd_importd_sources,
1441 include_directories : includes,
1442 link_with : [libshared],
1443 install : true,
1444 install_dir : rootlibexecdir)
1445
1446 executable('systemd-pull',
1447 systemd_pull_sources,
1448 include_directories : includes,
1449 link_with : [libshared],
1450 dependencies : [libcurl,
1451 libz,
1452 libbzip2,
1453 libxz,
1454 libgcrypt],
1455 install : true,
1456 install_dir : rootlibexecdir)
1457
1458 executable('systemd-import',
1459 systemd_import_sources,
1460 include_directories : includes,
1461 link_with : [libshared],
1462 dependencies : [libcurl,
1463 libz,
1464 libbzip2,
1465 libxz],
1466 install : true,
1467 install_dir : rootlibexecdir)
1468
1469 executable('systemd-export',
1470 systemd_export_sources,
1471 include_directories : includes,
1472 link_with : [libshared],
1473 dependencies : [libcurl,
1474 libz,
1475 libbzip2,
1476 libxz],
1477 install : true,
1478 install_dir : rootlibexecdir)
1479endif
1480
1481if conf.get('ENABLE_REMOTE', 0) == 1 and conf.get('HAVE_LIBCURL', 0) == 1
1482 executable('systemd-journal-upload',
1483 systemd_journal_upload_sources,
1484 include_directories : includes,
1485 link_with : [libshared],
1486 dependencies : [threads,
1487 libcurl,
1488 libgnutls,
1489 libxz,
1490 liblz4],
1491 install : true,
1492 install_dir : rootlibexecdir)
1493endif
1494
1495if conf.get('ENABLE_REMOTE', 0) == 1 and conf.get('HAVE_MICROHTTPD', 0) == 1
1496 executable('systemd-journal-remote',
1497 systemd_journal_remote_sources,
1498 include_directories : includes,
1499 link_with : [libshared],
1500 dependencies : [threads,
1501 libmicrohttpd,
1502 libgnutls,
1503 libxz,
1504 liblz4],
1505 install : true,
1506 install_dir : rootlibexecdir)
1507
1508 executable('systemd-journal-gatewayd',
1509 systemd_journal_gatewayd_sources,
1510 include_directories : includes,
1511 link_with : [libshared],
1512 dependencies : [threads,
1513 libmicrohttpd,
1514 libgnutls,
1515 libxz,
1516 liblz4],
1517 install : true,
1518 install_dir : rootlibexecdir)
1519endif
1520
1521if conf.get('ENABLE_COREDUMP', 0) == 1
1522 executable('systemd-coredump',
1523 systemd_coredump_sources,
1524 include_directories : includes,
1525 link_with : [libshared],
1526 dependencies : [threads,
1527 libacl,
1528 libdw,
1529 libxz,
1530 liblz4],
1531 install : true,
1532 install_dir : rootlibexecdir)
1533
1534 executable('coredumpctl',
1535 coredumpctl_sources,
1536 include_directories : includes,
1537 link_with : [libshared],
1538 dependencies : [threads,
1539 libxz,
1540 liblz4],
1541 install : true)
1542endif
1543
1544if conf.get('ENABLE_BINFMT', 0) == 1
1545 executable('systemd-binfmt',
1546 'src/binfmt/binfmt.c',
1547 include_directories : includes,
1548 link_with : [libshared],
1549 install : true,
1550 install_dir : rootlibexecdir)
94e75a54
ZJS
1551
1552 meson.add_install_script('sh', '-c',
1553 mkdir_p.format(binfmtdir))
1554 meson.add_install_script('sh', '-c',
1555 mkdir_p.format(sysconfdir + '/binfmt.d'))
5c23128d
ZJS
1556endif
1557
1558if conf.get('ENABLE_VCONSOLE', 0) == 1
1559 executable('systemd-vconsole-setup',
1560 'src/vconsole/vconsole-setup.c',
1561 include_directories : includes,
1562 link_with : [libshared],
1563 install : true,
1564 install_dir : rootlibexecdir)
1565endif
1566
1567if conf.get('ENABLE_RANDOMSEED', 0) == 1
1568 executable('systemd-random-seed',
1569 'src/random-seed/random-seed.c',
1570 include_directories : includes,
1571 link_with : [libshared],
1572 install : true,
1573 install_dir : rootlibexecdir)
1574endif
1575
1576if conf.get('ENABLE_FIRSTBOOT', 0) == 1
1577 executable('systemd-firstboot',
1578 'src/firstboot/firstboot.c',
1579 include_directories : includes,
1580 link_with : [libshared],
1581 dependencies : [libcrypt],
1582 install : true,
1583 install_dir : rootbindir)
1584endif
1585
1586executable('systemd-remount-fs',
1587 'src/remount-fs/remount-fs.c',
1588 'src/core/mount-setup.c',
1589 'src/core/mount-setup.h',
1590 include_directories : includes,
1591 link_with : [libshared],
1592 install : true,
1593 install_dir : rootlibexecdir)
1594
1595executable('systemd-machine-id-setup',
1596 'src/machine-id-setup/machine-id-setup-main.c',
1597 'src/core/machine-id-setup.c',
1598 'src/core/machine-id-setup.h',
1599 include_directories : includes,
1600 link_with : [libshared],
1601 install : true,
1602 install_dir : rootbindir)
1603
1604executable('systemd-fsck',
1605 'src/fsck/fsck.c',
1606 include_directories : includes,
1607 link_with : [libshared],
1608 install : true,
1609 install_dir : rootlibexecdir)
1610
1611executable('systemd-sleep',
1612 'src/sleep/sleep.c',
1613 include_directories : includes,
1614 link_with : [libshared],
1615 install : true,
1616 install_dir : rootlibexecdir)
1617
1618executable('systemd-sysctl',
1619 'src/sysctl/sysctl.c',
1620 include_directories : includes,
1621 link_with : [libshared],
1622 install : true,
1623 install_dir : rootlibexecdir)
1624
1625executable('systemd-ac-power',
1626 'src/ac-power/ac-power.c',
1627 include_directories : includes,
1628 link_with : [libshared],
1629 install : true,
1630 install_dir : rootlibexecdir)
1631
1632executable('systemd-detect-virt',
1633 'src/detect-virt/detect-virt.c',
1634 include_directories : includes,
1635 link_with : [libshared],
1636 install : true)
1637
1638executable('systemd-delta',
1639 'src/delta/delta.c',
1640 include_directories : includes,
1641 link_with : [libshared],
1642 install : true)
1643
1644executable('systemd-escape',
1645 'src/escape/escape.c',
1646 include_directories : includes,
1647 link_with : [libshared],
1648 install : true,
1649 install_dir : rootbindir)
1650
1651executable('systemd-notify',
1652 'src/notify/notify.c',
1653 include_directories : includes,
1654 link_with : [libshared],
1655 install : true,
1656 install_dir : rootbindir)
1657
1658executable('systemd-volatile-root',
1659 'src/volatile-root/volatile-root.c',
1660 include_directories : includes,
1661 link_with : [libshared],
1662 install : true,
1663 install_dir : rootlibexecdir)
1664
1665executable('systemd-cgroups-agent',
1666 'src/cgroups-agent/cgroups-agent.c',
1667 include_directories : includes,
1668 link_with : [libshared],
1669 install : true,
1670 install_dir : rootlibexecdir)
1671
1672executable('systemd-path',
1673 'src/path/path.c',
1674 include_directories : includes,
1675 link_with : [libshared],
1676 install : true)
1677
1678executable('systemd-ask-password',
1679 'src/ask-password/ask-password.c',
1680 include_directories : includes,
1681 link_with : [libshared],
1682 install : true,
1683 install_dir : rootbindir)
1684
1685executable('systemd-reply-password',
1686 'src/reply-password/reply-password.c',
1687 include_directories : includes,
1688 link_with : [libshared],
1689 install : true,
1690 install_dir : rootlibexecdir)
1691
1692executable('systemd-tty-ask-password-agent',
1693 'src/tty-ask-password-agent/tty-ask-password-agent.c',
1694 include_directories : includes,
1695 link_with : [libshared],
1696 install : true,
1697 install_dir : rootbindir)
1698
1699executable('systemd-cgls',
1700 'src/cgls/cgls.c',
1701 include_directories : includes,
1702 link_with : [libshared],
1703 install : true)
1704
1705executable('systemd-cgtop',
1706 'src/cgtop/cgtop.c',
1707 include_directories : includes,
1708 link_with : [libshared],
1709 install : true)
1710
1711executable('systemd-initctl',
1712 'src/initctl/initctl.c',
1713 include_directories : includes,
1714 link_with : [libshared],
1715 install : true,
1716 install_dir : rootlibexecdir)
1717
1718executable('systemd-mount',
1719 'src/mount/mount-tool.c',
1720 include_directories : includes,
1721 link_with : [libshared],
1722 install : true)
1723
7b76fce1
ZJS
1724meson.add_install_script(meson_make_symlink,
1725 'systemd-mount', bindir + '/systemd-umount')
1726
5c23128d
ZJS
1727executable('systemd-run',
1728 'src/run/run.c',
1729 include_directories : includes,
1730 link_with : [libshared],
1731 install : true)
1732
1733executable('systemd-stdio-bridge',
1734 'src/stdio-bridge/stdio-bridge.c',
1735 include_directories : includes,
1736 link_with : [libshared],
1737 install : true)
1738
1739executable('busctl',
1740 'src/busctl/busctl.c',
1741 'src/busctl/busctl-introspect.c',
1742 'src/busctl/busctl-introspect.h',
1743 include_directories : includes,
1744 link_with : [libshared],
1745 install : true)
1746
1747if conf.get('ENABLE_SYSUSERS', 0) == 1
1748 executable('systemd-sysusers',
1749 'src/sysusers/sysusers.c',
1750 include_directories : includes,
1751 link_with : [libshared],
1752 install : true,
1753 install_dir : rootbindir)
1754endif
1755
1756if conf.get('ENABLE_TMPFILES', 0) == 1
1757 executable('systemd-tmpfiles',
1758 'src/tmpfiles/tmpfiles.c',
1759 include_directories : includes,
1760 link_with : [libshared],
1761 dependencies : [libacl],
1762 install : true,
1763 install_dir : rootbindir)
1764endif
1765
1766if conf.get('ENABLE_HWDB', 0) == 1
1767 executable('systemd-hwdb',
1768 'src/hwdb/hwdb.c',
1769 'src/libsystemd/sd-hwdb/hwdb-internal.h',
1770 include_directories : includes,
1771 link_with : [libshared],
1772 install : true,
1773 install_dir : rootbindir)
1774endif
1775
1776if conf.get('ENABLE_QUOTACHECK', 0) == 1
1777 executable('systemd-quotacheck',
1778 'src/quotacheck/quotacheck.c',
1779 include_directories : includes,
1780 link_with : [libshared],
1781 install : true,
1782 install_dir : rootlibexecdir)
1783endif
1784
1785executable('systemd-socket-proxyd',
1786 'src/socket-proxy/socket-proxyd.c',
1787 include_directories : includes,
1788 link_with : [libshared,
1789 libsystemd],
1790 dependencies : [threads],
1791 install : true,
1792 install_dir : rootlibexecdir)
1793
1794executable('systemd-udevd',
1795 systemd_udevd_sources,
1796 include_directories : includes,
1797 link_with : [libudev_core,
1798 libudev_internal,
1799 libsystemd_network,
1800 libshared],
1801 dependencies : [libkmod,
1802 libidn,
1803 libacl],
1804 install : true,
1805 install_dir : rootlibexecdir)
1806
1807executable('udevadm',
1808 udevadm_sources,
1809 include_directories : includes,
1810 link_with : [libudev_core,
1811 libudev_internal,
1812 libsystemd_network,
1813 libshared],
1814 dependencies : [libkmod,
1815 libidn,
1816 libacl],
1817 install : true,
1818 install_dir : rootbindir)
1819
1820executable('systemd-shutdown',
1821 systemd_shutdown_sources,
1822 include_directories : includes,
1823 link_with : [libshared],
1824 install : true,
1825 install_dir : rootlibexecdir)
1826
1827executable('systemd-update-done',
1828 'src/update-done/update-done.c',
1829 include_directories : includes,
1830 link_with : [libshared],
1831 install : true,
1832 install_dir : rootlibexecdir)
1833
1834executable('systemd-update-utmp',
1835 'src/update-utmp/update-utmp.c',
1836 include_directories : includes,
1837 link_with : [libshared],
1838 dependencies : [libaudit],
1839 install : true,
1840 install_dir : rootlibexecdir)
1841
1842if conf.get('HAVE_KMOD', 0) == 1
1843 executable('systemd-modules-load',
1844 'src/modules-load/modules-load.c',
1845 include_directories : includes,
1846 link_with : [libshared],
1847 dependencies : [libkmod],
1848 install : true,
1849 install_dir : rootlibexecdir)
94e75a54
ZJS
1850
1851 meson.add_install_script('sh', '-c',
1852 mkdir_p.format(modulesloaddir))
1853 meson.add_install_script('sh', '-c',
1854 mkdir_p.format(sysconfdir + '/modules-load.d'))
5c23128d
ZJS
1855endif
1856
1857executable('systemd-nspawn',
1858 systemd_nspawn_sources,
1859 'src/core/mount-setup.c', # FIXME: use a variable?
1860 'src/core/mount-setup.h',
1861 'src/core/loopback-setup.c',
1862 'src/core/loopback-setup.h',
1863 include_directories : [includes, include_directories('src/nspawn')],
1864 link_with : [libfirewall,
1865 libshared],
1866 dependencies : [libacl,
1867 libblkid,
1868 libseccomp,
1869 libselinux],
1870 install : true)
1871
1872executable('systemd-networkd',
1873 systemd_networkd_sources,
1874 include_directories : includes,
1875 link_with : [libnetworkd_core,
1876 libfirewall,
1877 libsystemd_network,
1878 libudev_internal,
1879 libshared],
1880 install : true,
1881 install_dir : rootlibexecdir)
1882
1883executable('systemd-networkd-wait-online',
1884 systemd_networkd_wait_online_sources,
1885 include_directories : includes,
1886 link_with : [libnetworkd_core,
1887 libshared],
1888 install : true,
1889 install_dir : rootlibexecdir)
1890
1891executable('networkctl',
1892 networkctl_sources,
1893 include_directories : includes,
1894 link_with : [libsystemd_network,
1895 libshared],
1896 install : true,
1897 install_dir : rootbindir)
1898
69e96427
ZJS
1899############################################################
1900
1901foreach tuple : tests
1902 sources = tuple[0]
1903 link_with = tuple[1].length() > 0 ? tuple[1] : [libshared]
1904 dependencies = tuple[2]
1905 condition = tuple.length() >= 4 ? tuple[3] : ''
1906 type = tuple.length() >= 5 ? tuple[4] : ''
1907 defs = tuple.length() >= 6 ? tuple[5] : []
1908 incs = tuple.length() >= 7 ? tuple[6] : includes
1909
1910 name = sources[0].split('/')[-1].split('.')[0]
1911
1912 if condition == '' or conf.get(condition, 0) == 1
572baca1
ZJS
1913 install = install_tests and type == ''
1914
69e96427
ZJS
1915 exe = executable(
1916 name,
1917 sources,
1918 include_directories : incs,
1919 link_with : link_with,
1920 dependencies : dependencies,
572baca1
ZJS
1921 c_args : defs,
1922 install : install,
1923 install_dir : testsdir)
1924
69e96427
ZJS
1925 if type == 'manual'
1926 message('@0@ is a manual test'.format(name))
1927 elif type == 'unsafe' and want_tests != 'unsafe'
1928 message('@0@ is an unsafe test'.format(name))
1929 else
1930 test(name, exe, env : test_env)
1931 endif
1932 else
1933 message('Not compiling @0@ because @1@ is not true'.format(name, condition))
1934 endif
1935endforeach
1936
37ab1a25
ZJS
1937test_libsystemd_sym = executable(
1938 'test-libsystemd-sym',
1939 test_libsystemd_sym_c,
1940 include_directories : includes,
1941 # link_with : [libsystemd],
1942 # TODO: try again with https://github.com/mesonbuild/meson/pull/1545
1943 link_args : ['libsystemd.so.0.18.0'],
1944 # link_depends : [libsystemd],
1945 # TODO: try again after "Link_depends arguments must be strings." is solved
1946 install : install_tests,
1947 install_dir : testsdir)
1948test('test-libsystemd-sym',
1949 test_libsystemd_sym)
1950
69e96427 1951############################################################
5c23128d
ZJS
1952
1953make_directive_index_py = find_program('tools/make-directive-index.py')
1954make_man_index_py = find_program('tools/make-man-index.py')
1955
1956subdir('units')
1957subdir('sysctl.d')
1958subdir('sysusers.d')
1959subdir('tmpfiles.d')
1960subdir('rules')
1961subdir('hwdb')
1962subdir('network')
1963subdir('man')
1964subdir('shell-completion/bash')
1965subdir('shell-completion/zsh')
1966subdir('docs/sysvinit')
1967subdir('docs/var-log')
1968
1969# FIXME: figure out if the warning is true:
1970# https://github.com/mesonbuild/meson/wiki/Reference-manual#install_subdir
1971install_subdir('factory/etc',
1972 install_dir : factorydir)
1973
1974
1975install_data('xorg/50-systemd-user.sh',
1976 install_dir : xinitrcdir)
1977install_data('system-preset/90-systemd.preset',
1978 install_dir : systempresetdir)
1979install_data('README',
1980 'NEWS',
1981 'CODING_STYLE',
1982 'DISTRO_PORTING',
1983 'ENVIRONMENT.md',
1984 'LICENSE.GPL2',
1985 'LICENSE.LGPL2.1',
1986 'src/libsystemd/sd-bus/GVARIANT-SERIALIZATION',
1987 install_dir : docdir)
d68b342b 1988
94e75a54
ZJS
1989meson.add_install_script('sh', '-c', mkdir_p.format(systemdstatedir))
1990meson.add_install_script('sh', '-c', 'touch $DESTDIR@0@'.format(prefixdir))
1991
d68b342b
ZJS
1992############################################################
1993
1994if git.found() and etags.found()
1995 all_files = run_command(
1996 git,
1997 ['--git-dir=@0@/.git'.format(meson.source_root()),
1998 'ls-files',
1999 ':/*.[ch]'])
2000 all_files = files(all_files.stdout().split())
2001
2002 custom_target(
2003 'TAGS',
2004 output : 'TAGS',
2005 input : all_files,
2006 command : [etags, '-o', '@OUTPUT@'] + all_files)
2007endif