]> git.ipfire.org Git - thirdparty/util-linux.git/blame - meson.build
tests: (lsns::filedesc) enable debug output and show the exit status
[thirdparty/util-linux.git] / meson.build
CommitLineData
d4c880d5 1project('util-linux', 'c',
e0c1a86b 2 version : run_command('tools/git-version-gen', check: true).stdout(),
c12276dd 3 meson_version: '>=0.60.0',
6240e445
TW
4 license : 'GPLv2+',
5 default_options : [
6 'c_std=c99',
7 'cpp_std=c++11',
8 ])
d4c880d5 9
3e0bbb12 10fs = import('fs')
d4c880d5
ZJS
11pkgconfig = import('pkgconfig')
12
311ea4e7
KZ
13# soname versions; This never change because we use symbols versioing. There is also
14# API version (LIB*_VERSION macros) and it follow package version.
d4c880d5 15libblkid_version = '1.1.0'
50736e49 16libblkid_date = '01-Jun-2021'
d4c880d5 17libuuid_version = '1.3.0'
476c8614 18liblastlog2_version = '2.0.0'
d4c880d5
ZJS
19libmount_version = '1.1.0'
20libsmartcols_version = '1.1.0'
21libfdisk_version = '1.1.0'
22
23prefixdir = get_option('prefix')
24if not prefixdir.startswith('/')
25 error('Prefix is not absolute: "@0@"'.format(prefixdir))
26endif
27bindir = join_paths(prefixdir, get_option('bindir'))
28sbindir = join_paths(prefixdir, get_option('sbindir'))
29sysconfstaticdir = join_paths(prefixdir, 'lib')
12ebed03 30docdir = join_paths(prefixdir, get_option('datadir'), 'doc', 'util-linux')
53b37016 31mandir = join_paths(prefixdir, get_option('mandir'))
d4c880d5 32runstatedir = '/run'
107b2fbe 33localstatedir = '/var'
0eb2a476 34execprefixdir = prefixdir
5e67b421 35sysconfdir = join_paths(prefixdir, get_option('sysconfdir'))
0eb2a476
KL
36usrbin_exec_dir = join_paths(execprefixdir, bindir)
37usrsbin_exec_dir = join_paths(execprefixdir, sbindir)
38bb89ee 38bash_completion = dependency('bash-completion', required : get_option('build-bash-completion'))
d4c880d5 39
308a0979
KZ
40vendordir = get_option('vendordir')
41
b1a76c22 42add_project_arguments('-D_GNU_SOURCE', '-fsigned-char', language : 'c')
d4c880d5
ZJS
43
44cc = meson.get_compiler('c')
45
46conf = configuration_data()
3e43f629
RP
47conf.set_quoted('PACKAGE', meson.project_name())
48conf.set_quoted('PACKAGE_VERSION', meson.project_version())
d4c880d5
ZJS
49package_string = '@0@ @1@'.format(meson.project_name(), meson.project_version())
50conf.set_quoted('PACKAGE_STRING', package_string)
d4c880d5 51
d4c880d5 52pc_version = []
922d025a 53pc_version = meson.project_version().split('-')[0].split('.')
54
55if pc_version.length() < 3
56 pc_version += '0'
57endif
58
d4c880d5
ZJS
59pc_version = '.'.join(pc_version)
60
311ea4e7 61conf.set_quoted('LIBBLKID_VERSION', pc_version)
d4c880d5
ZJS
62conf.set_quoted('LIBBLKID_DATE', libblkid_date)
63
64conf.set('bindir', bindir)
65conf.set('sbindir', sbindir)
66conf.set('runstatedir', runstatedir)
107b2fbe 67conf.set('localstatedir', localstatedir)
5e67b421 68conf.set('sysconfdir', sysconfdir)
7c080286 69conf.set('usrbin_execdir', usrbin_exec_dir)
d4c880d5
ZJS
70conf.set('usrsbin_execdir', usrsbin_exec_dir)
71conf.set('docdir', docdir)
72conf.set_quoted('_PATH_SYSCONFSTATICDIR', sysconfstaticdir)
73conf.set_quoted('_PATH_RUNSTATEDIR', runstatedir)
107b2fbe 74conf.set_quoted('_PATH_LOCALSTATEDIR', localstatedir)
d4c880d5
ZJS
75conf.set_quoted('CONFIG_ADJTIME_PATH', '/etc/adjtime')
76conf.set_quoted('ADJTIME_PATH', '/etc/adjtime') # yes, both are used :(
77
308a0979
KZ
78conf.set_quoted('_PATH_VENDORDIR', vendordir)
79conf.set('USE_VENDORDIR', vendordir == '' ? false : 1)
80
b6799ccb 81build_libblkid = not get_option('build-libblkid').require(get_option('build-libmount').allowed()).disabled()
d4c880d5
ZJS
82conf.set('HAVE_LIBBLKID', build_libblkid ? 1 : false)
83summary('libblkid', build_libblkid ? 'enabled' : 'disabled', section : 'components')
84
85build_libuuid = not get_option('build-libuuid').disabled()
86conf.set('HAVE_LIBUUID', build_libuuid ? 1 : false)
87summary('libuuid', build_libuuid ? 'enabled' : 'disabled', section : 'components')
88
66463f0c
JW
89lib_sqlite3 = dependency('sqlite3', required : get_option('build-liblastlog2'))
90build_liblastlog2 = get_option('build-liblastlog2').require(lib_sqlite3.found()).allowed()
c2e299d0
SS
91conf.set('HAVE_LIBLASTLOG2', build_liblastlog2 ? 1 : false)
92summary('liblastlog2', build_liblastlog2 ? 'enabled' : 'disabled', section : 'components')
93
e8b6e4ea
SS
94login_lastlogin = get_option('login-lastlogin')
95conf.set('USE_LOGIN_LASTLOG', login_lastlogin ? 1 : false)
96summary('login-lastlogin', login_lastlogin ? 'enabled' : 'disabled', section : 'components')
97
e23c3262
KZ
98have_mountfd_api = cc.sizeof('struct mount_attr', prefix : '#include <linux/mount.h>') > 0
99conf.set('HAVE_STRUCT_MOUNT_ATTR', have_mountfd_api ? 1 : false)
100conf.set('HAVE_MOUNTFD_API', have_mountfd_api ? 1 : false)
101
7d679f29 102have_struct_statx = cc.sizeof('struct statx', prefix : '#include <sys/stat.h>') > 0
8bcf89d3
TW
103conf.set('HAVE_STRUCT_STATX', have_struct_statx ? 1 : false)
104
b6799ccb
JW
105build_libmount = get_option('build-libmount').require(get_option('build-libblkid').allowed()).allowed()
106
d4c880d5 107conf.set('HAVE_LIBMOUNT', build_libmount ? 1 : false)
375ccf08 108conf.set('USE_LIBMOUNT_SUPPORT_NAMESPACES', 1)
e23c3262 109conf.set('USE_LIBMOUNT_MOUNTFD_SUPPORT', have_mountfd_api ? 1 : false)
d4c880d5
ZJS
110summary('libmount', build_libmount ? 'enabled' : 'disabled', section : 'components')
111
112build_libsmartcols = not get_option('build-libsmartcols').disabled()
113conf.set('HAVE_LIBSMARTCOLS', build_libsmartcols ? 1 : false)
114summary('libsmartcols', build_libsmartcols ? 'enabled' : 'disabled', section : 'components')
115
b6799ccb 116build_libfdisk = not get_option('build-libfdisk').require(get_option('build-libblkid').allowed()).disabled()
d4c880d5
ZJS
117conf.set('HAVE_LIBFDISK', build_libfdisk ? 1 : false)
118summary('libfdisk', build_libfdisk ? 'enabled' : 'disabled', section : 'components')
119
120build_uuidd = not get_option('build-uuidd').disabled()
121conf.set('HAVE_UUIDD', build_uuidd ? 1 : false)
122summary('uuidd', build_uuidd ? 'enabled' : 'disabled', section : 'components')
123
69939195
ZJS
124static_programs = get_option('static-programs')
125need_static_libs = static_programs.length() > 0 # a rough estimate...
126summary('static programs', static_programs)
127
d4c880d5
ZJS
128LINUX = host_machine.system() in ['linux']
129BSD = host_machine.system() in ['dragonfly', 'freebsd', 'netbsd', 'openbsd']
130
131############################################################
132
133code = '''
134#include <wchar.h>
135#include <wctype.h>
136#include <stdio.h>
137#include <stdlib.h>
138int main(void) {
139 wchar_t wc;
140 wint_t w;
141 w = fgetwc(stdin);
142 if (w == WEOF)
143 return 1;
144 wc = w;
145 fputwc(wc,stdout);
146 return 0;
147}
148'''
149have = cc.compiles(code, name : 'wchar_t support')
150if not have and get_option('widechar').enabled()
151 error('widechar support requested but unavailable')
152endif
153if get_option('ncurses').enabled() and get_option('widechar').enabled()
154 error('widechar support is incompatible with non-wide ncurses')
155endif
156conf.set('HAVE_WIDECHAR', have ? 1 : false)
157
158headers = '''
159 byteswap.h
160 crypt.h
161 endian.h
162 err.h
163 errno.h
164 fcntl.h
165 getopt.h
166 inttypes.h
167 langinfo.h
168 lastlog.h
169 libutil.h
170 locale.h
171 mntent.h
172 paths.h
173 pty.h
174 shadow.h
175 stdint.h
176 stdio_ext.h
177 stdlib.h
178 string.h
179 strings.h
180 unistd.h
181 utmp.h
182 utmpx.h
908ac36f
MY
183 asm-generic/fcntl.h
184 asm/fcntl.h
d4c880d5
ZJS
185 asm/io.h
186 linux/blkzoned.h
187 linux/capability.h
188 linux/cdrom.h
189 linux/compiler.h
190 linux/falloc.h
191 linux/fd.h
0e186591 192 linux/fs.h
647f80e4
KZ
193 linux/fiemap.h
194 linux/gsmmux.h
0e186591 195 linux/if_alg.h
ae015d71 196 linux/landlock.h
0e186591 197 linux/kcmp.h
d4c880d5 198 linux/net_namespace.h
647f80e4 199 linux/nsfs.h
241e4a48 200 linux/mount.h
0e186591 201 linux/pr.h
d4c880d5
ZJS
202 linux/securebits.h
203 linux/tiocl.h
204 linux/version.h
205 linux/watchdog.h
206 net/if.h
207 net/if_dl.h
208 netinet/in.h
209 security/openpam.h
210 security/pam_appl.h
211 security/pam_misc.h
6b61e282 212 security/pam_modules.h
d4c880d5
ZJS
213 sys/disk.h
214 sys/disklabel.h
215 sys/endian.h
216 sys/file.h
217 sys/io.h
218 sys/ioccom.h
219 sys/ioctl.h
220 sys/mkdev.h
221 sys/mount.h
222 sys/param.h
aa5adf24 223 sys/pidfd.h
d4c880d5
ZJS
224 sys/prctl.h
225 sys/resource.h
6e92db54 226 sys/sendfile.h
d4c880d5
ZJS
227 sys/signalfd.h
228 sys/socket.h
229 sys/sockio.h
230 sys/stat.h
0e186591 231 sys/statfs.h
d4c880d5
ZJS
232 sys/swap.h
233 sys/syscall.h
234 sys/sysmacros.h
235 sys/time.h
236 sys/timex.h
237 sys/ttydefaults.h
238 sys/types.h
239 sys/ucred.h
240 sys/un.h
0e186591 241 sys/vfs.h
647f80e4 242 sys/xattr.h
d4c880d5
ZJS
243'''.split()
244
245lib_m = cc.find_library('m')
246
247lib_tinfo = dependency(
248 'tinfo',
249 required : get_option('tinfo'))
250
251lib_ncursesw = dependency(
252 'ncursesw',
253 required : get_option('ncursesw'))
254if lib_ncursesw.found()
255 headers += ['ncursesw/ncurses.h',
256 'ncursesw/term.h',
257 'ncurses.h',
258 'term.h']
259 lib_ncurses = disabler()
260else
261 lib_ncurses = dependency(
262 'ncurses',
263 required : get_option('ncurses'))
264 headers += ['ncurses.h',
265 'term.h']
266endif
267
268conf.set('HAVE_LIBNCURSESW', lib_ncursesw.found())
269conf.set('HAVE_LIBNCURSES', lib_ncurses.found())
270conf.set('HAVE_NCURSES', lib_ncursesw.found() or lib_ncurses.found())
271
272lib_slang = dependency(
273 'slang',
274 required : get_option('slang'))
275if lib_slang.found()
276 headers += ['slang.h',
277 'slang/slang.h',
278 'slcurses.h',
279 'slang/slcurses.h']
280endif
281conf.set('HAVE_SLANG', lib_slang.found())
282
283foreach curses_libs : [lib_slang, lib_ncursesw, lib_ncurses]
284 if curses_libs.found()
6e13cfed
KZ
285 have = cc.has_function('use_default_colors', dependencies : curses_libs)
286 conf.set('HAVE_USE_DEFAULT_COLORS', have ? 1 : false)
287 have = cc.has_function('resizeterm', dependencies : curses_libs)
288 conf.set('HAVE_RESIZETERM', have ? 1 : false)
d4c880d5
ZJS
289 break
290 endif
291endforeach
292
293lib_z = dependency(
294 'zlib',
295 required : get_option('zlib'))
296
297lib_readline = dependency(
298 'readline',
299 required : get_option('readline'))
300conf.set('HAVE_LIBREADLINE', lib_readline.found() ? 1 : false)
301
69939195
ZJS
302lib_readline_static = dependency(
303 'readline',
304 static : true,
305 required : need_static_libs ? get_option('readline') : disabler())
306
fc63a3d0
RP
307if meson.version().version_compare('>= 0.59.0')
308 lib_intl = dependency(
309 'intl',
310 required : get_option('nls'))
311 conf.set('ENABLE_NLS', lib_intl.found() ? 1 : false)
312else
313 if get_option('nls').enabled()
314 error('nls is not supported with meson before 0.59.0')
315 endif
316 lib_intl = dependency('', required : false)
317endif
318
d4c880d5
ZJS
319lib_user = dependency(
320 'libuser',
321 version : '>= 0.58',
322 required : get_option('libuser'))
323conf.set('HAVE_LIBUSER', lib_user.found() ? 1 : false)
324
325lib_util = cc.find_library(
326 'util',
327 required : get_option('libutil'))
328conf.set('HAVE_LIBUTIL', lib_util.found() ? 1 : false)
329
330lib_utempter = cc.find_library(
331 'utempter',
332 required : get_option('libutempter'))
333conf.set('HAVE_LIBUTEMPTER', lib_utempter.found() ? 1 : false)
334
335systemd = dependency(
336 'systemd',
337 required : get_option('systemd'))
338
339lib_systemd = dependency(
340 'libsystemd',
341 required : get_option('systemd'))
342conf.set('HAVE_LIBSYSTEMD', lib_systemd.found() ? 1 : false)
0e186591 343conf.set('USE_SYSTEMD', lib_systemd.found() ? 1 : false)
d4c880d5 344
87fcd95a
TK
345have = cc.has_function(
346 'sd_session_get_username',
347 dependencies : lib_systemd)
348conf.set('HAVE_DECL_SD_SESSION_GET_USERNAME', have ? 1 : false)
349
d4c880d5
ZJS
350lib_udev = dependency(
351 'libudev',
352 required : get_option('systemd'))
353conf.set('HAVE_LIBUDEV', lib_udev.found() ? 1 : false)
354
d0a07e7f
JW
355lib_crypt = cc.find_library('crypt', required : get_option('build-newgrp'))
356if not lib_crypt.found()
357 lib_crypt = cc.find_library('crypt', required : get_option('build-sulogin'))
358endif
d4c880d5 359
9e3c5d1b
JW
360lib_pam = cc.find_library(
361 'pam',
362 disabler : true,
363 required : get_option('build-login').enabled() or \
364 get_option('build-chfn-chsh').enabled() or \
365 get_option('build-su').enabled() or \
366 get_option('build-runuser').enabled())
d4c880d5
ZJS
367if lib_pam.found()
368 lib_pam_misc = cc.find_library('pam_misc')
369 lib_pam = [lib_pam, lib_pam_misc]
7bce9496
RP
370else
371 lib_pam_misc = declare_dependency()
d4c880d5
ZJS
372endif
373
374lib_cryptsetup = dependency(
375 'libcryptsetup',
376 required : get_option('cryptsetup'))
377conf.set('HAVE_CRYPTSETUP', lib_cryptsetup.found() ? 1 : false)
378
c12f8998
ZJS
379cryptsetup_dlopen = not get_option('cryptsetup').disabled() and get_option('cryptsetup-dlopen').enabled()
380if cryptsetup_dlopen
324aa32c
RP
381 if meson.version().version_compare('>= 0.62.0')
382 lib_dl = dependency('dl')
383 else
384 lib_dl = cc.find_library('dl')
385 endif
e6a4b4a1
LB
386 conf.set('CRYPTSETUP_VIA_DLOPEN', 1)
387 summary('cryptsetup support (dlopen)',
388 'enabled',
389 section : 'components')
390else
391 summary('cryptsetup support',
392 lib_cryptsetup.found() ? 'enabled' : 'disabled',
393 section : 'components')
394endif
6e92db54 395
d4c880d5
ZJS
396have = cc.has_function(
397 'crypt_activate_by_signed_key',
398 dependencies : lib_cryptsetup)
5a6e9adf 399conf.set('HAVE_CRYPT_ACTIVATE_BY_SIGNED_KEY', have ? 1 : false)
d4c880d5
ZJS
400
401lib_cap_ng = dependency(
cd23a433
RP
402 'libcap-ng',
403 required : get_option('build-setpriv'))
512c91a6
TW
404if not lib_cap_ng.found()
405 lib_cap_ng = disabler()
406endif
d4c880d5
ZJS
407
408lib_selinux = dependency(
409 'libselinux',
6e92db54 410 version : '>= 2.5',
d4c880d5
ZJS
411 required : get_option('selinux'))
412conf.set('HAVE_LIBSELINUX', lib_selinux.found() ? 1 : false)
413
6e92db54
KZ
414lib_magic = dependency(
415 'libmagic',
416 required : get_option('magic'))
417conf.set('HAVE_MAGIC', lib_magic.found() ? 1 : false)
418
419lib_econf = dependency(
420 'libeconf',
421 required : get_option('econf'))
422conf.set('HAVE_LIBECONF', lib_econf.found() ? 1 : false)
423
d4c880d5 424lib_audit = dependency(
b2ae39f6 425 'audit',
d4c880d5
ZJS
426 required : get_option('audit'))
427conf.set('HAVE_LIBAUDIT', lib_audit.found() ? 1 : false)
428
429conf.set('HAVE_SMACK', not get_option('smack').disabled())
430
9e970370 431
d4c880d5
ZJS
432foreach header : headers
433 have = cc.has_header(header)
434 conf.set('HAVE_' + header.underscorify().to_upper(), have ? 1 : false)
435endforeach
436
437header = 'linux/btrfs.h'
438enable_btrfs = cc.has_header(header,
439 required : get_option('btrfs'))
440conf.set('HAVE_' + header.underscorify().to_upper(), enable_btrfs ? 1 : false)
441conf.set('HAVE_BTRFS_SUPPORT', enable_btrfs ? 1 : false)
442
443prefix = conf.get('HAVE_LINUX_COMPILER_H') ? '#include <linux/compiler.h>' : ''
444foreach header : [
445 'linux/blkpg.h',
446 'linux/major.h',
447]
448 have = cc.has_header(header,
449 prefix : prefix)
450 conf.set('HAVE_' + header.underscorify().to_upper(), have ? 1 : false)
451endforeach
452
453have = cc.has_header('sched.h')
454conf.set10('HAVE_DECL_CPU_ALLOC', have)
455# We get -1 if the size cannot be determined
4194bb5b 456have_cpu_set_t = cc.sizeof('cpu_set_t', prefix : '#define _GNU_SOURCE\n#include <sched.h>') > 0
d4c880d5
ZJS
457conf.set('HAVE_CPU_SET_T', have_cpu_set_t ? 1 : false)
458
5afe34ef 459have = cc.has_header_symbol('unistd.h', 'environ', args : '-D_GNU_SOURCE')
640754e2 460conf.set('HAVE_ENVIRON_DECL', have ? 1 : false)
d4c880d5 461
5afe34ef 462have = cc.has_header_symbol('signal.h', 'sighandler_t', args : '-D_GNU_SOURCE')
d4c880d5
ZJS
463conf.set('HAVE_SIGHANDLER_T', have ? 1 : false)
464
f3b9a18e 465have = cc.has_function('strsignal')
d4c880d5
ZJS
466conf.set10('HAVE_STRSIGNAL_DECL', have)
467
468have = cc.sizeof('union semun', prefix : '#include <sys/sem.h>') > 0
469conf.set('HAVE_UNION_SEMUN', have ? 1 : false)
470
1eeabbb4
TW
471have = cc.has_type('loff_t',
472 args : '-D_GNU_SOURCE',
473 prefix : '#include <sys/types.h>')
0e186591
TW
474conf.set('HAVE_LOFF_T', have ? 1 : false)
475
d4c880d5
ZJS
476have = cc.compiles('''
477 #define _GNU_SOURCE 1
478 #include <langinfo.h>
479 int main(void) {
480 char *str;
481 str = nl_langinfo (ALTMON_1);
482 str = nl_langinfo (ALTMON_2);
483 str = nl_langinfo (ALTMON_3);
484 str = nl_langinfo (ALTMON_4);
485 str = nl_langinfo (ALTMON_5);
486 str = nl_langinfo (ALTMON_6);
487 str = nl_langinfo (ALTMON_7);
488 str = nl_langinfo (ALTMON_8);
489 str = nl_langinfo (ALTMON_9);
490 str = nl_langinfo (ALTMON_10);
491 str = nl_langinfo (ALTMON_11);
492 str = nl_langinfo (ALTMON_12);
493 return 0;
494 }
495 ''',
496 name : 'langinfo.h defines ALTMON_x constants')
497conf.set('HAVE_LANGINFO_ALTMON', have ? 1 : false)
498
499have = cc.compiles('''
500 #define _GNU_SOURCE 1
501 #include <langinfo.h>
502 int main(void) {
503 char *str;
504 str = nl_langinfo (_NL_ABALTMON_1);
505 str = nl_langinfo (_NL_ABALTMON_2);
506 str = nl_langinfo (_NL_ABALTMON_3);
507 str = nl_langinfo (_NL_ABALTMON_4);
508 str = nl_langinfo (_NL_ABALTMON_5);
509 str = nl_langinfo (_NL_ABALTMON_6);
510 str = nl_langinfo (_NL_ABALTMON_7);
511 str = nl_langinfo (_NL_ABALTMON_8);
512 str = nl_langinfo (_NL_ABALTMON_9);
513 str = nl_langinfo (_NL_ABALTMON_10);
514 str = nl_langinfo (_NL_ABALTMON_11);
515 str = nl_langinfo (_NL_ABALTMON_12);
516 return 0;
517 }
518 ''',
519 name : 'langinfo.h defines _NL_ABALTMON_x constants')
520conf.set('HAVE_LANGINFO_NL_ABALTMON', have ? 1 : false)
521
17bc58e0
CH
522have = cc.compiles('''
523 #define _GNU_SOURCE 1
524 #include <langinfo.h>
525 int main(void) {
526 char *str;
527 str = nl_langinfo (_NL_TIME_WEEK_1STDAY);
528 return 0;
529 }
530 ''',
531 name : 'langinfo.h defines _NL_TIME_WEEK_1STDAY constant')
532conf.set('HAVE_DECL__NL_TIME_WEEK_1STDAY', have ? 1 : false)
533
d4c880d5 534funcs = '''
c214cbeb 535 cachestat
d4c880d5 536 clearenv
5bd1462d 537 close_range
d4c880d5
ZJS
538 __fpurge
539 fpurge
540 __fpending
541 secure_getenv
542 __secure_getenv
543 eaccess
544 err
545 errx
546 explicit_bzero
d9b022bd 547 fnmatch
d4c880d5 548 fseeko
0120be6f
KZ
549 fsconfig
550 fsmount
551 fsopen
552 fspick
d4c880d5 553 fsync
0e186591 554 getttynam
d4c880d5
ZJS
555 utimensat
556 getdomainname
557 getdtablesize
558 getexecname
559 getmntinfo
560 getrandom
561 getrlimit
562 getsgnam
563 inotify_init
564 jrand48
ae015d71
TW
565 landlock_create_ruleset
566 landlock_add_rule
567 landlock_restrict_self
d4c880d5 568 lchown
6124a6a3
TW
569 lgetxattr
570 llistxattr
d4c880d5 571 llseek
5bd1462d 572 newlocale
d4c880d5 573 mkostemp
10efb9ea
KZ
574 move_mount
575 mount_setattr
d4c880d5
ZJS
576 nanosleep
577 ntp_gettime
10efb9ea 578 open_tree
d4c880d5
ZJS
579 personality
580 pidfd_open
581 pidfd_send_signal
582 posix_fadvise
583 prctl
584 qsort_r
0322c9cd 585 reallocarray
cd094a05 586 renameat2
d4c880d5
ZJS
587 rpmatch
588 scandirat
589 setprogname
5bd1462d 590 sendfile
d4c880d5
ZJS
591 setns
592 setresgid
593 setresuid
594 sched_setattr
595 sched_setscheduler
596 sigqueue
597 srandom
30c59d67 598 statx
d4c880d5
ZJS
599 strnchr
600 strndup
601 strnlen
5bd1462d 602 strtod_l
d4c880d5
ZJS
603 sysconf
604 sysinfo
605 swapon
606 swapoff
607 timegm
608 unshare
609 usleep
5bd1462d
TW
610 uselocale
611 utimensat
d4c880d5
ZJS
612 vwarnx
613 warn
614 warnx
615 prlimit
616
617 openat
618 fstatat
619 unlinkat
620 ioperm
621 iopl
622 futimens
623 inotify_init1
624 open_memstream
625 reboot
626 getusershell
627'''.split()
628
629foreach func: funcs
630 have = cc.has_function(func)
993556aa 631 # For autotools compatibility, use either #define FOO 1 or #undef FOO.
d4c880d5
ZJS
632 # This makes little sense, but is necessary to avoid warnings about
633 # redefined macros from Python.h, which uses this convention.
634 conf.set('HAVE_' + func.to_upper(), have ? 1 : false)
d4c880d5
ZJS
635endforeach
636
2c5a42b3
JW
637have_mempcpy = cc.has_function('mempcpy', prefix: '#include <string.h>', args: '-D_GNU_SOURCE')
638conf.set('HAVE_MEMPCPY', have_mempcpy ? 1 : false)
639
d4c880d5
ZJS
640have = conf.get('HAVE_FUTIMENS') in [1] and conf.get('HAVE_INOTIFY_INIT1') in [1]
641conf.set('AGETTY_RELOAD', have ? 1 : false)
642if not have
643 warning('futimens or inotify_init1 not found; agetty(8) will not provide --reload functionality')
644endif
645
646have_dirfd = (cc.has_function('dirfd') or
647 cc.has_header_symbol('dirent.h', 'dirfd',
648 prefix : '#include <sys/types.h>'))
649conf.set('HAVE_DIRFD', have_dirfd ? 1 : false)
650
651have_ddfd = cc.has_member('DIR', 'dd_fd',
652 prefix : '''
653 #include <sys/types.h>
654 #include <dirent.h>
655 ''')
656conf.set('HAVE_DECL_DDFD', have_ddfd ? 1 : false)
657
658have = cc.has_member('struct tm', 'tm_gmtoff',
1eeabbb4 659 args : '-D_GNU_SOURCE',
d4c880d5
ZJS
660 prefix : '''
661 #include <time.h>
662 #include <unistd.h>
663 ''')
664conf.set('HAVE_TM_GMTOFF', have ? 1 : false)
665
10efb9ea 666
10efb9ea 667
0120be6f 668have = cc.sizeof('enum fsconfig_command', prefix : '#include <linux/mount.h>') > 0
e23c3262 669conf.set('HAVE_ENUM_FSCONFIG_COMMAND', have ? 1 : false)
0120be6f 670
d4c880d5
ZJS
671have = cc.has_member('struct termios', 'c_line',
672 prefix : '#include <termios.h>')
673conf.set('HAVE_STRUCT_TERMIOS_C_LINE', have ? 1 : false)
674
675have = cc.has_member('struct stat', 'st_mtim.tv_nsec',
1eeabbb4 676 args : '-D_GNU_SOURCE',
d4c880d5
ZJS
677 prefix : '#include <sys/stat.h>')
678conf.set('HAVE_STRUCT_STAT_ST_MTIM_TV_NSEC', have ? 1 : false)
679
2f82c248 680have = cc.has_member('struct statx', 'stx_mnt_id',
7d679f29 681 prefix : '#include <sys/stat.h>')
2f82c248
KZ
682conf.set('HAVE_STRUCT_STATX_STX_MNT_ID', have ? 1 : false)
683
d4c880d5
ZJS
684# replacement for AC_STRUCT_TIMEZONE
685have = cc.has_member('struct tm', 'tm_zone',
1eeabbb4 686 args : '-D_GNU_SOURCE',
d4c880d5
ZJS
687 prefix : '#include <time.h>')
688conf.set('HAVE_STRUCT_TM_TM_ZONE', have ? 1 : false)
689
5afe34ef 690have = cc.has_header_symbol('time.h', 'tzname', args: '-D_GNU_SOURCE')
d4c880d5
ZJS
691conf.set('HAVE_DECL_TZNAME', have ? 1 : false)
692
0e186591
TW
693have = cc.has_header_symbol('linux/blkzoned.h', 'BLK_ZONE_REP_CAPACITY')
694conf.set('HAVE_DECL_BLK_ZONE_REP_CAPACITY', have ? 1 : false)
695
696have = cc.has_header_symbol('linux/pr.h', 'PR_REP_CAPACITY')
697conf.set('HAVE_DECL_PR_REP_CAPACITY', have ? 1 : false)
698
d4c880d5
ZJS
699code = '''
700#include <time.h>
701#if !@0@
702extern char *tzname[];
703#endif
704int main(void) {
705 return tzname ? 0 : 1;
706}
707'''.format(have ? 1 : 0)
e25db916 708have = cc.compiles(code, name : 'using tzname[]')
d4c880d5
ZJS
709conf.set('HAVE_TZNAME', have ? 1 : false)
710
a31f4c4f
TW
711have = cc.sizeof('time_t', prefix : '#include <time.h>')
712if have < 8
713 add_global_arguments('-D_TIME_BITS=64', language : 'c')
714 have = cc.sizeof('time_t', args : '-D_TIME_BITS=64', prefix : '#include <time.h>')
715 if have < 8
716 if get_option('allow-32bit-time')
717 warning('Could not make time_t 64bits wide')
718 else
719 error('Could not make time_t 64bits wide')
720 endif
721 endif
722endif
723
d4c880d5
ZJS
724socket_libs = []
725if not cc.has_function('socket')
726 socket_libs += cc.find_library('socket', required : true)
727 have = cc.has_function('socket',
728 dependencies : socket_libs)
729 if not have
730 error('socket() function not available')
731 endif
732endif
733
24395027 734lib_rt = cc.find_library('rt', required : false)
d4c880d5
ZJS
735realtime_libs = []
736have = cc.has_function('clock_gettime')
737if not have
06b27058
JW
738 if lib_rt.found()
739 realtime_libs += lib_rt
740 have = cc.has_function('clock_gettime',
741 dependencies : realtime_libs)
742 endif
d4c880d5 743endif
e51565b6 744conf.set('HAVE_CLOCK_GETTIME', have ? 1 : false)
d4c880d5
ZJS
745
746thread_libs = dependency('threads')
747
748have = cc.has_function('timer_create')
749if not have
06b27058
JW
750 if lib_rt.found()
751 realtime_libs = [lib_rt]
752 have = cc.has_function('timer_create',
753 dependencies : realtime_libs)
754 endif
d4c880d5
ZJS
755 if not have
756 realtime_libs += thread_libs
757 have = cc.has_function('timer_create',
758 dependencies : realtime_libs)
759 endif
760endif
761conf.set('HAVE_TIMER_CREATE', have ? 1 : false)
762if not have
763 have = cc.has_function('setitimer')
764 conf.set('HAVE_SETITIMER', have ? 1 : false)
765endif
766
767rtas_libs = cc.find_library('rtas', required : false)
768conf.set('HAVE_LIBRTAS', rtas_libs.found() ? 1 : false)
769
770math_libs = []
77765258 771if not cc.has_header_symbol('math.h', 'isnan')
d4c880d5
ZJS
772 lib = cc.find_library('m', required : true)
773 if (cc.has_function('isnan', dependencies : lib) and
774 cc.has_function('__isnan', dependencies : lib))
775 math_libs += lib
776 endif
777endif
778
779have = cc.has_header_symbol('errno.h', 'program_invocation_short_name',
780 args : '-D_GNU_SOURCE')
781conf.set('HAVE_PROGRAM_INVOCATION_SHORT_NAME', have ? 1 : false)
782
783code = '''
784extern char *__progname;
785int main(void) {
786 return (*__progname != 0);
787}
788'''
e25db916 789have = cc.compiles(code, name : 'using __progname')
d4c880d5
ZJS
790conf.set('HAVE___PROGNAME', have ? 1 : false)
791
941e1d55
TW
792have = conf.get('HAVE_PTY_H').to_string() == '1' \
793 and conf.get('HAVE_SYS_SIGNALFD_H').to_string() == '1'
44475360
ZJS
794conf.set('HAVE_PTY', have ? 1 : false)
795
a0cf9105
LB
796have_opal_get_status= cc.has_header_symbol('linux/sed-opal.h', 'IOC_OPAL_GET_STATUS')
797conf.set('HAVE_OPAL_GET_STATUS', have_opal_get_status ? 1 : false)
798
d4c880d5
ZJS
799build_plymouth_support = get_option('build-plymouth-support')
800have_tiocglcktrmios = cc.has_header_symbol(
801 'sys/ioctl.h', 'TIOCGLCKTRMIOS',
802 required : build_plymouth_support.enabled())
803have_sock_cloexec = cc.has_header_symbol(
804 'sys/socket.h', 'SOCK_CLOEXEC',
805 prefix : '#include <sys/types.h>',
806 required : build_plymouth_support.enabled())
807have_sock_nonblock = cc.has_header_symbol(
808 'sys/socket.h', 'SOCK_NONBLOCK',
809 prefix : '#include <sys/types.h>',
810 required : build_plymouth_support.enabled())
811have_so_passcred = cc.has_header_symbol(
812 'sys/socket.h', 'SO_PASSCRED',
b24dd22d 813 args : ['-D_GNU_SOURCE'],
d4c880d5
ZJS
814 prefix : '#include <sys/types.h>',
815 required : build_plymouth_support.enabled())
816
817build_plymouth_support = (not build_plymouth_support.disabled() and
818 have_tiocglcktrmios and
819 have_sock_cloexec and
820 have_sock_nonblock and
821 have_so_passcred)
822conf.set('ENABLE_PLYMOUTH_SUPPORT', build_plymouth_support ? 1 : false)
823summary('plymouth support',
824 build_plymouth_support ? 'enabled' : 'disabled',
825 section : 'components')
826
827# check for valid fallocate() function
828# with 32 bits glibc 2.10, fallocate() exists but not fallocate64()
829# when _FILE_OFFSET_BITS==64, fallocate() is redirect to fallocate64()
830# and program can't be linked.
831code = '''
832#define _GNU_SOURCE
833#include <unistd.h>
834#include <fcntl.h>
835
836int main(void) {
837 long ret;
838 ret = fallocate(0, FALLOC_FL_KEEP_SIZE, 0xfffffffful, 0xfffffffful);
839 return ret == 0 ? 0 : 1;
840}
841'''
842have = cc.links(code, name : 'fallocate() function')
843conf.set('HAVE_FALLOCATE', have ? 1 : false)
844
845code = '''
846#include <unistd.h>
847#include <fcntl.h>
848
849int main(void) {
850 long ret;
851 ret = posix_fallocate(0, 0xfffffffful, 0xfffffffful);
852 return ret == 0 ? 0 : 1;
853}
854'''
855have = cc.links(code, name : 'posix_fallocate() function')
856conf.set('HAVE_POSIX_FALLOCATE', have ? 1 : false)
857
858use_hwclock_cmos = host_machine.cpu_family() in ['x86', 'x86_64']
859message('Use CMOS clock: @0@'.format(use_hwclock_cmos))
860conf.set('USE_HWCLOCK_CMOS', use_hwclock_cmos ? 1 : false)
861
862conf.set('HAVE_TLS', get_option('use-tls') ? 1 : false)
863conf.set('PG_BELL', get_option('pg-bell') ? 1 : false)
e0806c40 864conf.set('USE_COLORS_BY_DEFAULT', get_option('colors-default') ? 1 : false)
d4c880d5 865
8886d84e
TW
866is_glibc = cc.has_header_symbol('limits.h', '__GLIBC__')
867
d4c880d5
ZJS
868############################################################
869
6e92db54 870
d4c880d5
ZJS
871fs_search_path = get_option('fs-search-path')
872fs_search_path_extra = get_option('fs-search-path-extra')
873if fs_search_path_extra != ''
874 fs_search_path = ':'.join(fs_search_path, fs_search_path_extra)
875endif
876conf.set_quoted('FS_SEARCH_PATH', fs_search_path)
877
38b15ca2 878systemdsystemunitdir = ''
fcbcb0cd 879if systemd.found()
e2b4f5be 880 systemdsystemunitdir = systemd.get_variable(pkgconfig : 'systemdsystemunitdir')
fcbcb0cd 881endif
6e92db54 882
5e67b421
CH
883sysvinit = get_option('sysvinit').enabled()
884sysvinitrcdir = sysconfdir + '/init.d'
885
ba30b89c 886program_tests = get_option('program-tests')
887
d4c880d5
ZJS
888chfn_chsh_password = get_option('chfn-chsh-password') or lib_user.found()
889conf.set('CHFN_CHSH_PASSWORD', chfn_chsh_password ? 1 : false)
890
891have = get_option('chsh-only-listed')
892conf.set('ONLY_LISTED_SHELLS', have ? 1 : false)
893
894have = get_option('use-tty-group')
895conf.set('USE_TTY_GROUP', have ? 1 : false)
896
a4eeda56
KZ
897bison = find_program('bison')
898flex = find_program('flex')
899
d4c880d5 900build_hwclock = not get_option('build-hwclock').disabled()
d4c880d5
ZJS
901bison_gen = generator(
902 bison,
903 output : ['@BASENAME@.tab.c', '@BASENAME@.tab.h'],
904 arguments : ['@INPUT@', '--defines=@OUTPUT1@', '--output=@OUTPUT0@'])
905
b6799ccb
JW
906python_module = import('python')
907python = python_module.find_installation(
908 get_option('python'),
909 required : true,
910 disabler : true)
911
d4c880d5 912meson_make_symlink = meson.current_source_dir() + '/tools/meson-make-symlink.sh'
38bb89ee 913meson_make_manpage_stub = meson.current_source_dir() + '/tools/meson-make-manpage-stub.sh'
d4c880d5 914
7da59534 915configure_file(
d4c880d5
ZJS
916 output : 'config.h',
917 configuration : conf)
918
5f2c862a 919add_project_arguments('-include', meson.current_build_dir() / 'config.h', language : 'c')
d4c880d5 920
24b8804b
TW
921compiler_flags = [
922 '-fno-common',
923
924 '-Waddress-of-packed-member',
925 '-Wdiscarded-qualifiers',
926 '-Wembedded-directive',
927 '-Wextra-semi',
928 '-Wformat-security',
929 '-Wimplicit-function-declaration',
930 '-Wmissing-declarations',
931 '-Wmissing-parameter-type',
932 '-Wmissing-prototypes',
933 '-Wnested-externs',
934 '-Wno-missing-field-initializers',
9df5ac34 935 '-Wold-style-definition',
24b8804b
TW
936 '-Wpointer-arith',
937 '-Wredundant-decls',
938 '-Wsign-compare',
939 '-Wstrict-prototypes',
940 '-Wtype-limits',
941 '-Wuninitialized',
942 '-Wunused-but-set-parameter',
943 '-Wunused-but-set-variable',
944 '-Wunused-parameter',
945 '-Wunused-result',
946 '-Wunused-variable',
a52f9bdd 947 '-Wvla',
2a91b213 948 '-Walloca',
24b8804b
TW
949]
950foreach compiler_flag : compiler_flags
951 if cc.has_argument(compiler_flag)
952 add_project_arguments(compiler_flag, language : 'c')
953 endif
954endforeach
955
53b37016 956manadocs = []
38bb89ee 957manlinks = {}
aa519054 958
38bb89ee 959bashcompletions = []
aa519054 960bashcompletionslinks = {}
53b37016 961
d4c880d5
ZJS
962subdir('include')
963subdir('lib')
964subdir('libblkid')
965subdir('libmount')
966subdir('libsmartcols')
967subdir('libuuid')
c2e299d0 968subdir('liblastlog2')
d4c880d5 969subdir('libfdisk')
c2e299d0 970subdir('pam_lastlog2')
d4c880d5
ZJS
971subdir('login-utils')
972subdir('sys-utils')
973subdir('disk-utils')
974subdir('misc-utils')
975subdir('text-utils')
976subdir('term-utils')
977subdir('po')
978
979includes = [dir_include,
d4c880d5 980 dir_libsmartcols,
d4c880d5
ZJS
981 dir_libfdisk,
982 dir_libuuid,
c2e299d0 983 dir_liblastlog2,
d4c880d5
ZJS
984 dir_sys_utils]
985
986exes = []
987
988opt = not get_option('build-chfn-chsh').disabled()
989exe = executable(
990 'chfn',
991 chfn_sources,
992 chfn_chsh_sources,
993 include_directories : includes,
0333c40b 994 link_with : [lib_common, logindefs_c],
d4c880d5
ZJS
995 dependencies : chfn_chsh_deps,
996 install_dir : usrbin_exec_dir,
60d457f5 997 install_mode : 'rwsr-xr-x',
d4c880d5
ZJS
998 install : opt,
999 build_by_default : opt)
38bb89ee 1000
d4c880d5
ZJS
1001exe2 = executable(
1002 'chsh',
1003 'login-utils/chsh.c',
4b724469 1004 'lib/shells.c',
d4c880d5
ZJS
1005 chfn_chsh_sources,
1006 include_directories : includes,
1007 link_with : lib_common,
1008 dependencies : chfn_chsh_deps,
1009 install_dir : usrbin_exec_dir,
a13574b1 1010 install_mode : 'rwsr-xr-x',
d4c880d5
ZJS
1011 install : opt,
1012 build_by_default : opt)
1013if opt and not is_disabler(exe)
1014 exes += [exe, exe2]
38bb89ee
TW
1015 manadocs += ['login-utils/chfn.1.adoc', 'login-utils/chsh.1.adoc']
1016 bashcompletions += ['chfn', 'chsh']
d4c880d5
ZJS
1017endif
1018
1019exe = executable(
1020 'test_islocal',
1021 test_islocal_sources,
1022 include_directories : includes,
ba30b89c 1023 c_args : '-DTEST_PROGRAM',
1024 build_by_default : program_tests)
d4c880d5
ZJS
1025exes += exe
1026
d4c880d5
ZJS
1027exe = executable(
1028 'test-consoles',
1029 test_consoles_sources,
1030 c_args : ['-DTEST_PROGRAM'],
1031 include_directories : includes,
ba30b89c 1032 link_with : lib_common,
1033 build_by_default : program_tests)
d4c880d5
ZJS
1034exes += exe
1035
1036opt = not get_option('build-last').disabled()
1037exe = executable(
1038 'last',
1039 last_sources,
1040 include_directories : includes,
1041 link_with : [lib_common],
1042 install_dir : usrbin_exec_dir,
1043 install : opt,
1044 build_by_default : opt)
1045if opt and not is_disabler(exe)
1046 exes += exe
1047 meson.add_install_script(meson_make_symlink,
1048 'last',
1049 join_paths(usrbin_exec_dir, 'lastb'))
38bb89ee
TW
1050 manadocs += ['login-utils/last.1.adoc']
1051 manlinks += {'lastb.1': 'last.1'}
1052 bashcompletions += ['last']
aa519054 1053 bashcompletionslinks += {'lastb': 'last'}
d4c880d5
ZJS
1054endif
1055
1056opt = not get_option('build-nologin').disabled()
1057exe = executable(
1058 'nologin',
1059 'login-utils/nologin.c',
1060 include_directories : includes,
1061 install_dir : sbindir,
308a0979 1062 link_with : [lib_common],
d4c880d5
ZJS
1063 install : opt,
1064 build_by_default : opt)
1065if opt and not is_disabler(exe)
1066 exes += exe
38bb89ee 1067 manadocs += ['login-utils/nologin.8.adoc']
d4c880d5
ZJS
1068endif
1069
1070opt = not get_option('build-utmpdump').disabled()
1071exe = executable(
1072 'utmpdump',
1073 'login-utils/utmpdump.c',
1074 include_directories : includes,
1075 link_with : [lib_common],
1076 install_dir : usrbin_exec_dir,
1077 install : opt,
1078 build_by_default : opt)
1079if opt and not is_disabler(exe)
1080 exes += exe
38bb89ee
TW
1081 manadocs += ['login-utils/utmpdump.1.adoc']
1082 bashcompletions += ['utmpdump']
d4c880d5
ZJS
1083endif
1084
1085opt = not get_option('build-su').disabled()
1086exe = executable(
1087 'su',
1088 'login-utils/su.c',
1089 'login-utils/su-common.c',
1090 'login-utils/su-common.h',
4b724469 1091 'lib/shells.c',
d4c880d5
ZJS
1092 pty_session_c,
1093 monotonic_c,
1094 include_directories : includes,
0333c40b 1095 link_with : [lib_common, logindefs_c],
d4c880d5
ZJS
1096 dependencies : [lib_pam,
1097 lib_pam_misc,
1098 lib_util,
1099 realtime_libs],
fb8c224e 1100 install_mode : 'rwsr-xr-x',
d4c880d5
ZJS
1101 install : opt,
1102 build_by_default : opt)
1103if opt and not is_disabler(exe)
1104 exes += exe
38bb89ee
TW
1105 manadocs += ['login-utils/su.1.adoc']
1106 bashcompletions += ['su']
d4c880d5
ZJS
1107endif
1108
1109opt = not get_option('build-newgrp').disabled()
1110exe = executable(
1111 'newgrp',
1112 'login-utils/newgrp.c',
1113 include_directories : includes,
1114 dependencies : [lib_crypt],
1115 install_dir : usrbin_exec_dir,
cb3dee5a 1116 install_mode : 'rwsr-xr-x',
d4c880d5
ZJS
1117 install : opt,
1118 build_by_default : opt)
1119if opt and not is_disabler(exe)
1120 exes += exe
38bb89ee 1121 manadocs += ['login-utils/newgrp.1.adoc']
f265b432 1122 bashcompletions += ['newgrp']
d4c880d5
ZJS
1123endif
1124
1125opt = not get_option('build-lslogins').disabled()
1126exe = executable(
1127 'lslogins',
1128 'login-utils/lslogins.c',
d4c880d5
ZJS
1129 include_directories : includes,
1130 link_with : [lib_common,
0333c40b 1131 lib_smartcols,
13d2fd8f
TW
1132 logindefs_c] +
1133 (build_liblastlog2 ? [lib_lastlog2] : []),
d4c880d5
ZJS
1134 dependencies : [lib_selinux,
1135 lib_systemd],
1136 install_dir : usrbin_exec_dir,
1137 install : opt,
1138 build_by_default : opt)
1139if opt and not is_disabler(exe)
1140 exes += exe
38bb89ee
TW
1141 manadocs += ['login-utils/lslogins.1.adoc']
1142 bashcompletions += ['lslogins']
d4c880d5
ZJS
1143endif
1144
1145opt = not get_option('build-vipw').disabled()
1146exe = executable(
1147 'vipw',
1148 'login-utils/vipw.c',
1149 'login-utils/setpwnam.h',
1150 include_directories : includes,
1151 link_with : [lib_common],
1152 dependencies : [lib_selinux],
1153 install_dir : usrbin_exec_dir,
1154 install : opt,
1155 build_by_default : opt)
1156if opt and not is_disabler(exe)
1157 exes += exe
1158 meson.add_install_script(meson_make_symlink,
1159 'vipw',
1160 join_paths(usrbin_exec_dir, 'vigr'))
38bb89ee 1161 manadocs += ['login-utils/vipw.8.adoc']
f6fb7fa7
CH
1162 meson.add_install_script(meson_make_symlink,
1163 'vipw.8',
1164 join_paths(mandir, 'man8/vigr.8'))
d4c880d5
ZJS
1165endif
1166
1167opt = not get_option('build-runuser').disabled()
1168exe = executable(
1169 'runuser',
1170 'login-utils/runuser.c',
1171 'login-utils/su-common.c',
1172 'login-utils/su-common.h',
4b724469 1173 'lib/shells.c',
d4c880d5
ZJS
1174 pty_session_c,
1175 monotonic_c,
1176 include_directories : includes,
0333c40b 1177 link_with : [lib_common, logindefs_c],
d4c880d5
ZJS
1178 dependencies : [lib_pam,
1179 lib_pam_misc,
1180 lib_util,
1181 realtime_libs],
1182 install_dir : sbindir,
1183 install : opt,
1184 build_by_default : opt)
1185if opt and not is_disabler(exe)
1186 exes += exe
38bb89ee 1187 manadocs += ['login-utils/runuser.1.adoc']
aa519054 1188 bashcompletionslinks += {'runuser': 'su'}
d4c880d5
ZJS
1189endif
1190
1191############################################################
1192
8886d84e
TW
1193if is_glibc
1194 exe = executable(
1195 'col',
1196 col_sources,
1197 include_directories : includes,
1198 link_with : lib_common,
1199 install_dir : usrbin_exec_dir,
1200 install : true)
1201 exes += exe
1202 manadocs += ['text-utils/col.1.adoc']
1203 bashcompletions += ['col']
1204endif
d4c880d5
ZJS
1205
1206exe = executable(
1207 'colcrt',
1208 colcrt_sources,
1209 include_directories : includes,
1210 install_dir : usrbin_exec_dir,
1211 install : true)
1212exes += exe
38bb89ee
TW
1213manadocs += ['text-utils/colcrt.1.adoc']
1214bashcompletions += ['colcrt']
d4c880d5
ZJS
1215
1216exe = executable(
1217 'colrm',
1218 colrm_sources,
1219 include_directories : includes,
1220 link_with : lib_common,
1221 install_dir : usrbin_exec_dir,
1222 install : true)
1223exes += exe
38bb89ee
TW
1224manadocs += ['text-utils/colrm.1.adoc']
1225bashcompletions += ['colrm']
d4c880d5
ZJS
1226
1227exe = executable(
1228 'rev',
1229 rev_sources,
1230 include_directories : includes,
1231 install_dir : usrbin_exec_dir,
1232 install : true)
1233exes += exe
38bb89ee
TW
1234manadocs += ['text-utils/rev.1.adoc']
1235bashcompletions += ['rev']
d4c880d5
ZJS
1236
1237exe = executable(
1238 'column',
1239 column_sources,
1240 include_directories : includes,
1241 link_with : [lib_common,
1242 lib_smartcols],
1243 install_dir : usrbin_exec_dir,
1244 install : true)
1245if not is_disabler(exe)
1246 exes += exe
38bb89ee
TW
1247 manadocs += ['text-utils/column.1.adoc']
1248 bashcompletions += ['column']
d4c880d5
ZJS
1249endif
1250
1251opt = not get_option('build-line').disabled()
1252exe = executable(
1253 'line',
1254 line_sources,
1255 include_directories : includes,
1256 install_dir : usrbin_exec_dir,
1257 install : opt,
1258 build_by_default : opt)
1259if opt and not is_disabler(exe)
1260 exes += exe
38bb89ee 1261 manadocs += ['text-utils/line.1.adoc']
d4c880d5
ZJS
1262endif
1263
1264opt = not get_option('build-pg').disabled()
1265exe = executable(
1266 'pg',
1267 pg_sources,
1268 link_with : lib_common,
1269 include_directories : includes,
1270 dependencies : [lib_tinfo,
1271 curses_libs],
1272 install_dir : usrbin_exec_dir,
1273 install : opt,
1274 build_by_default : opt)
1275if opt and not is_disabler(exe)
1276 exes += exe
38bb89ee
TW
1277 manadocs += ['text-utils/pg.1.adoc']
1278 bashcompletions += ['pg']
d4c880d5
ZJS
1279endif
1280
1281opt = not get_option('build-ul').disabled()
1282exe = executable(
1283 'ul',
1284 ul_sources,
1285 include_directories : includes,
1286 dependencies : [lib_tinfo,
1287 curses_libs],
1288 install_dir : usrbin_exec_dir,
1289 install : opt,
1290 build_by_default : opt)
1291if opt and not is_disabler(exe)
1292 exes += exe
38bb89ee
TW
1293 manadocs += ['text-utils/ul.1.adoc']
1294 bashcompletions += ['ul']
d4c880d5
ZJS
1295endif
1296
1297opt = not get_option('build-more').disabled()
1298exe = executable(
1299 'more',
1300 more_sources,
308a0979 1301 link_with : [lib_common],
d4c880d5
ZJS
1302 include_directories : includes,
1303 dependencies : [lib_tinfo,
6e92db54
KZ
1304 curses_libs,
1305 lib_magic],
d4c880d5
ZJS
1306 install : opt,
1307 build_by_default : opt)
1308exe2 = executable(
1309 'test_more',
1310 more_sources,
308a0979 1311 link_with : [lib_common],
d4c880d5
ZJS
1312 include_directories : includes,
1313 c_args : '-DTEST_PROGRAM',
1314 dependencies : [lib_tinfo,
6e92db54
KZ
1315 curses_libs,
1316 lib_magic],
ba30b89c 1317 build_by_default : opt and program_tests)
d4c880d5
ZJS
1318exes += exe
1319if opt and not is_disabler(exe)
1320 exes += [exe, exe2]
38bb89ee
TW
1321 manadocs += ['text-utils/more.1.adoc']
1322 bashcompletions += ['more']
d4c880d5
ZJS
1323endif
1324
1325exe = executable(
1326 'hexdump',
1327 hexdump_sources,
1328 include_directories : includes,
1329 link_with : [lib_common,
1330 lib_tcolors],
1331 install_dir : usrbin_exec_dir,
1332 install : true)
1333if not is_disabler(exe)
1334 exes += exe
53b37016 1335 manadocs += ['text-utils/hexdump.1.adoc']
38bb89ee 1336 bashcompletions += ['hexdump']
d4c880d5
ZJS
1337endif
1338
1339opt = not get_option('build-lsmem').disabled()
1340exe = executable(
1341 'lsmem',
1342 lsmem_sources,
1343 include_directories : includes,
1344 link_with : [lib_common,
1345 lib_smartcols],
1346 install_dir : usrbin_exec_dir,
1347 install : opt,
1348 build_by_default : opt)
1349if opt and not is_disabler(exe)
1350 exes += exe
53b37016 1351 manadocs += ['sys-utils/lsmem.1.adoc']
38bb89ee 1352 bashcompletions += ['lsmem']
d4c880d5
ZJS
1353endif
1354
1355opt = not get_option('build-chmem').disabled()
1356exe = executable(
1357 'chmem',
1358 chmem_sources,
1359 include_directories : includes,
1360 link_with : [lib_common],
1361 install_dir : usrbin_exec_dir,
1362 install : opt,
1363 build_by_default : opt)
1364if opt and not is_disabler(exe)
1365 exes += exe
53b37016 1366 manadocs += ['sys-utils/chmem.8.adoc']
38bb89ee 1367 bashcompletions += ['chmem']
d4c880d5
ZJS
1368endif
1369
1370exe = executable(
1371 'choom',
1372 choom_sources,
1373 include_directories : includes,
1374 link_with : [lib_common],
1375 install_dir : usrbin_exec_dir,
1376 install : true)
1377exes += exe
53b37016 1378manadocs += ['sys-utils/choom.1.adoc']
d4c880d5
ZJS
1379
1380exe = executable(
1381 'ipcmk',
1382 ipcmk_sources,
1383 include_directories : includes,
1384 link_with : [lib_common],
1385 install_dir : usrbin_exec_dir,
1386 install : true)
1387exes += exe
53b37016 1388manadocs += ['sys-utils/ipcmk.1.adoc']
38bb89ee 1389bashcompletions += ['ipcmk']
d4c880d5
ZJS
1390
1391exe = executable(
1392 'ipcrm',
1393 ipcrm_sources,
1394 include_directories : includes,
1395 link_with : [lib_common],
1396 install_dir : usrbin_exec_dir,
1397 install : true)
1398exes += exe
53b37016 1399manadocs += ['sys-utils/ipcrm.1.adoc']
38bb89ee 1400bashcompletions += ['ipcrm']
d4c880d5
ZJS
1401
1402opt = not get_option('build-ipcs').disabled()
1403exe = executable(
1404 'ipcs',
1405 ipcs_sources,
1406 include_directories : includes,
1407 link_with : [lib_common],
1408 install_dir : usrbin_exec_dir,
1409 install : opt,
1410 build_by_default : opt)
1411if opt and not is_disabler(exe)
1412 exes += exe
53b37016 1413 manadocs += ['sys-utils/ipcs.1.adoc']
38bb89ee 1414 bashcompletions += ['ipcs']
d4c880d5
ZJS
1415endif
1416
1417opt = not get_option('build-rfkill').disabled()
1418exe = executable(
1419 'rfkill',
1420 rfkill_sources,
1421 include_directories : includes,
1422 link_with : [lib_common,
1423 lib_smartcols],
1424 install_dir : usrsbin_exec_dir,
1425 install : opt,
1426 build_by_default : opt)
1427if opt and not is_disabler(exe)
1428 exes += exe
53b37016 1429 manadocs += ['sys-utils/rfkill.8.adoc']
38bb89ee 1430 bashcompletions += ['rfkill']
d4c880d5
ZJS
1431endif
1432
1433exe = executable(
1434 'renice',
1435 renice_sources,
1436 include_directories : includes,
1437 link_with : [lib_common,
1438 lib_smartcols],
1439 install_dir : usrbin_exec_dir,
1440 install : true)
1441if not is_disabler(exe)
1442 exes += exe
53b37016 1443 manadocs += ['sys-utils/renice.1.adoc']
38bb89ee 1444 bashcompletions += ['renice']
d4c880d5
ZJS
1445endif
1446
f092076f
DDM
1447exe = executable(
1448 'setpgid',
1449 setpgid_sources,
1450 include_directories: includes,
1451 link_with : [lib_common,
1452 lib_smartcols],
1453 install_dir : usrbin_exec_dir,
1454 install : true)
1455if opt and not is_disabler(exe)
1456 exes += exe
1457 manadocs += ['sys-utils/setpgid.1.adoc']
1458 bashcompletions += ['setpgid']
1459endif
1460
d4c880d5
ZJS
1461exe = executable(
1462 'setsid',
1463 setsid_sources,
1464 include_directories : includes,
1465 link_with : [lib_common,
1466 lib_smartcols],
1467 install_dir : usrbin_exec_dir,
1468 install : true)
1469if opt and not is_disabler(exe)
1470 exes += exe
53b37016 1471 manadocs += ['sys-utils/setsid.1.adoc']
38bb89ee 1472 bashcompletions += ['setsid']
d4c880d5
ZJS
1473endif
1474
1475exe = executable(
1476 'readprofile',
1477 readprofile_sources,
1478 include_directories : includes,
1479 link_with : [lib_common,
1480 lib_smartcols],
1481 install_dir : usrsbin_exec_dir,
1482 install : true)
1483if not is_disabler(exe)
1484 exes += exe
53b37016 1485 manadocs += ['sys-utils/readprofile.8.adoc']
38bb89ee 1486 bashcompletions += ['readprofile']
d4c880d5
ZJS
1487endif
1488
1489opt = not get_option('build-tunelp').disabled()
1490exe = executable(
1491 'tunelp',
1492 tunelp_sources,
1493 include_directories : includes,
1494 link_with : [lib_common],
1495 install_dir : usrsbin_exec_dir,
1496 install : opt,
1497 build_by_default : opt)
1498if opt and not is_disabler(exe)
1499 exes += exe
53b37016 1500 manadocs += ['sys-utils/tunelp.8.adoc']
38bb89ee 1501 bashcompletions += ['tunelp']
d4c880d5
ZJS
1502endif
1503
b6799ccb 1504opt = not get_option('build-fstrim').disabled()
d4c880d5
ZJS
1505exe = executable(
1506 'fstrim',
1507 fstrim_sources,
1508 include_directories : includes,
c43b185a
JW
1509 link_with : [lib_common],
1510 dependencies : [mount_dep],
d4c880d5 1511 install_dir : sbindir,
b6799ccb
JW
1512 install : opt,
1513 build_by_default : opt)
1514if opt and not is_disabler(exe)
d4c880d5 1515 exes += exe
53b37016 1516 manadocs += ['sys-utils/fstrim.8.adoc']
38bb89ee 1517 bashcompletions += ['fstrim']
d4c880d5
ZJS
1518endif
1519
1520exe = executable(
1521 'dmesg',
1522 dmesg_sources,
1523 include_directories : includes,
1524 link_with : [lib_common,
1525 lib_tcolors],
1526 install : true)
1527if not is_disabler(exe)
1528 exes += exe
53b37016 1529 manadocs += ['sys-utils/dmesg.1.adoc']
38bb89ee 1530 bashcompletions += ['dmesg']
d4c880d5
ZJS
1531endif
1532
1533exe = executable(
1534 'test_dmesg',
1535 dmesg_sources,
1536 include_directories : dir_include,
1537 c_args : '-DTEST_DMESG',
1538 link_with : [lib_common,
ba30b89c 1539 lib_tcolors],
1540 build_by_default : program_tests)
d4c880d5
ZJS
1541if not is_disabler(exe)
1542 exes += exe
1543endif
1544
1545exe = executable(
1546 'ctrlaltdel',
1547 ctrlaltdel_sources,
1548 include_directories : includes,
1549 link_with : [lib_common],
1550 install_dir : sbindir,
1551 install : true)
1552exes += exe
53b37016 1553manadocs += ['sys-utils/ctrlaltdel.8.adoc']
38bb89ee 1554bashcompletions += ['ctrlaltdel']
d4c880d5
ZJS
1555
1556exe = executable(
1557 'fsfreeze',
1558 fsfreeze_sources,
1559 include_directories : includes,
1560 install_dir : sbindir,
1561 install : true)
1562exes += exe
53b37016 1563manadocs += ['sys-utils/fsfreeze.8.adoc']
38bb89ee 1564bashcompletions += ['fsfreeze']
d4c880d5
ZJS
1565
1566exe = executable(
1567 'blkdiscard',
1568 blkdiscard_sources,
1569 include_directories : includes,
a764efb5
JW
1570 link_with : [lib_common],
1571 dependencies : [blkid_dep],
d4c880d5
ZJS
1572 install_dir : sbindir,
1573 install : true)
1574exes += exe
53b37016 1575manadocs += ['sys-utils/blkdiscard.8.adoc']
38bb89ee 1576bashcompletions += ['blkdiscard']
d4c880d5 1577
1a374511
JW
1578if cc.has_header('linux/blkzoned.h')
1579 exe = executable(
1580 'blkzone',
1581 blkzone_sources,
1582 include_directories : includes,
1583 link_with : [lib_common],
1584 install_dir : sbindir,
1585 install : true)
1586 exes += exe
1587 manadocs += ['sys-utils/blkzone.8.adoc']
1588 bashcompletions += ['blkzone']
1589endif
d4c880d5 1590
1a374511
JW
1591if cc.has_header('linux/pr.h')
1592 exe = executable(
1593 'blkpr',
1594 blkpr_sources,
1595 include_directories : includes,
1596 link_with : [lib_common],
1597 install_dir : sbindir,
1598 install : true)
1599 exes += exe
1600 manadocs += ['sys-utils/blkpr.8.adoc']
1601endif
61c2946d 1602
d4c880d5
ZJS
1603exe = executable(
1604 'ldattach',
1605 ldattach_sources,
1606 include_directories : includes,
1607 link_with : [lib_common],
1608 install_dir : usrsbin_exec_dir,
1609 install : true)
1610exes += exe
53b37016 1611manadocs += ['sys-utils/ldattach.8.adoc']
38bb89ee 1612bashcompletions += ['ldattach']
d4c880d5
ZJS
1613
1614exe = executable(
1615 'rtcwake',
1616 rtcwake_sources,
1617 include_directories : includes,
1618 link_with : [lib_common],
1619 install_dir : usrsbin_exec_dir,
1620 install : true)
1621exes += exe
53b37016 1622manadocs += ['sys-utils/rtcwake.8.adoc']
38bb89ee 1623bashcompletions += ['rtcwake']
d4c880d5
ZJS
1624
1625exe = executable(
1626 'setarch',
1627 setarch_sources,
1628 include_directories : includes,
035fc2d9 1629 link_with : [lib_common],
d4c880d5
ZJS
1630 install_dir : usrbin_exec_dir,
1631 install : true)
1632exes += exe
53b37016 1633manadocs += ['sys-utils/setarch.8.adoc']
38bb89ee 1634bashcompletions += ['setarch']
d4c880d5
ZJS
1635
1636setarch_links = ['uname26', 'linux32', 'linux64']
1637setarch_links_arch = {
1638 's390x' : ['s390', 's390x'],
1639 'x86' : ['i386'],
1640 'x86_64' : ['i386', 'x86_64'],
1641 'ppc64' : ['ppc', 'ppc64', 'ppc32'],
1642 'space64' : ['sparc', 'sparc64', 'sparc32', 'sparc32bash'],
1643 'mips64' : ['mips', 'mips64', 'mips32'],
1644 'ia64' : ['i386', 'ia64'],
1645 'hppa' : ['parisc', 'parisc64', 'parisc32'],
1646}
1647setarch_links += setarch_links_arch.get(host_machine.cpu_family(), [])
1648
1649foreach link: setarch_links
1650 meson.add_install_script(meson_make_symlink,
1651 'setarch',
1652 join_paths(usrbin_exec_dir, link))
38bb89ee 1653 manlinks += {link + '.8': 'setarch.8'}
d4c880d5
ZJS
1654endforeach
1655
1656opt = not get_option('build-eject').disabled()
1657exe = executable(
1658 'eject',
1659 eject_sources,
1660 include_directories : includes,
c43b185a
JW
1661 link_with : [lib_common],
1662 dependencies : [mount_dep],
d4c880d5
ZJS
1663 install_dir : usrbin_exec_dir,
1664 install : opt,
1665 build_by_default : opt)
1666if opt and not is_disabler(exe)
1667 exe = exe
53b37016 1668 manadocs += ['sys-utils/eject.1.adoc']
38bb89ee 1669 bashcompletions += ['eject']
d4c880d5
ZJS
1670endif
1671
1672opt = not get_option('build-losetup').disabled()
1673exe = executable(
1674 'losetup',
1675 losetup_sources,
1676 include_directories : includes,
1677 link_with : [lib_common,
1678 lib_smartcols],
1679 install_dir : sbindir,
1680 install : opt,
1681 build_by_default : opt)
1682if opt and not is_disabler(exe)
53b37016 1683 manadocs += ['sys-utils/losetup.8.adoc']
d4c880d5 1684 exes += exe
38bb89ee 1685 bashcompletions += ['losetup']
d4c880d5
ZJS
1686endif
1687
69939195
ZJS
1688opt = opt and 'losetup' in static_programs
1689exe = executable(
1690 'losetup.static',
1691 losetup_sources,
1692 include_directories : includes,
1693 link_args : ['--static'],
1694 link_with : [lib_common,
1695 lib_smartcols.get_static_lib()],
1696 install_dir : sbindir,
1697 install : opt,
1698 build_by_default : opt)
1699if opt and not is_disabler(exe)
1700 exes += exe
1701endif
1702
d4c880d5
ZJS
1703opt = not get_option('build-zramctl').disabled()
1704exe = executable(
1705 'zramctl',
1706 zramctl_sources,
1707 include_directories : includes,
1708 link_with : [lib_common,
1709 lib_smartcols],
1710 install_dir : sbindir,
1711 install : opt,
1712 build_by_default : opt)
1713if opt and not is_disabler(exe)
1714 exes += exe
53b37016 1715 manadocs += ['sys-utils/zramctl.8.adoc']
38bb89ee 1716 bashcompletions += ['zramctl']
d4c880d5
ZJS
1717endif
1718
1719exe = executable(
1720 'prlimit',
1721 prlimit_sources,
1722 include_directories : includes,
1723 link_with : [lib_common,
1724 lib_smartcols],
1725 install_dir : usrbin_exec_dir,
1726 install : true)
1727if not is_disabler(exe)
1728 exes += exe
53b37016 1729 manadocs += ['sys-utils/prlimit.1.adoc']
38bb89ee 1730 bashcompletions += ['prlimit']
d4c880d5
ZJS
1731endif
1732
b6799ccb 1733opt = not get_option('build-lsns').disabled()
d4c880d5
ZJS
1734exe = executable(
1735 'lsns',
1736 lsns_sources,
1737 include_directories : includes,
1738 link_with : [lib_common,
c43b185a
JW
1739 lib_smartcols],
1740 dependencies : [mount_dep],
d4c880d5 1741 install_dir : usrbin_exec_dir,
b6799ccb
JW
1742 install : opt,
1743 build_by_default : opt)
1744if opt and not is_disabler(exe)
d4c880d5 1745 exes += exe
53b37016 1746 manadocs += ['sys-utils/lsns.8.adoc']
38bb89ee 1747 bashcompletions += ['lsns']
d4c880d5
ZJS
1748endif
1749
1750opt = not get_option('build-mount').disabled()
1751exe = executable(
1752 'mount',
1753 mount_sources,
1754 include_directories : includes,
1755 link_with : [lib_common,
c43b185a
JW
1756 lib_smartcols],
1757 dependencies : [lib_selinux, mount_dep],
8f49b369 1758 install_mode : 'rwsr-xr-x',
d4c880d5
ZJS
1759 install : opt,
1760 build_by_default : opt)
1761exe2 = executable(
1762 'umount',
1763 umount_sources,
1764 include_directories : includes,
c43b185a
JW
1765 link_with : [lib_common],
1766 dependencies : [mount_dep],
1cb3c90c 1767 install_mode : 'rwsr-xr-x',
d4c880d5
ZJS
1768 install : opt,
1769 build_by_default : opt)
1770if opt and not is_disabler(exe)
1771 exes += [exe, exe2]
53b37016
KZ
1772 manadocs += ['sys-utils/fstab.5.adoc',
1773 'sys-utils/mount.8.adoc',
1774 'sys-utils/umount.8.adoc']
38bb89ee 1775 bashcompletions += ['mount', 'umount']
d4c880d5
ZJS
1776endif
1777
69939195
ZJS
1778opt2 = opt and 'mount' in static_programs
1779exe = executable(
1780 'mount.static',
1781 mount_sources,
1782 include_directories : includes,
1783 link_args : ['--static'],
1784 link_with : [lib_common,
c43b185a
JW
1785 lib_smartcols_static],
1786 dependencies : [mount_static_dep],
69939195
ZJS
1787 install : opt2,
1788 build_by_default : opt2)
1789if opt2 and not is_disabler(exe)
1790 exes += exe
1791endif
1792
1793opt2 = opt and 'umount' in static_programs
1794exe = executable(
1795 'umount.static',
1796 umount_sources,
1797 include_directories : includes,
1798 link_args : ['--static'],
c43b185a
JW
1799 link_with : [lib_common],
1800 dependencies : [mount_static_dep],
69939195
ZJS
1801 install : opt2,
1802 build_by_default : opt2)
1803if opt2 and not is_disabler(exe)
1804 exes += exe
1805endif
1806
d4c880d5
ZJS
1807# setuid?
1808
b6799ccb 1809opt = not get_option('build-swapon').disabled()
d4c880d5
ZJS
1810exe = executable(
1811 'swapon',
1812 swapon_sources,
1813 include_directories : includes,
1814 link_with : [lib_common,
d4c880d5 1815 lib_smartcols],
a764efb5 1816 dependencies : [blkid_dep, mount_dep],
d4c880d5 1817 install_dir : sbindir,
b6799ccb
JW
1818 install : opt,
1819 build_by_default : opt)
1820if opt and not is_disabler(exe)
d4c880d5 1821 exes += exe
53b37016 1822 manadocs += ['sys-utils/swapon.8.adoc']
38bb89ee 1823 bashcompletions += ['swapon']
d4c880d5
ZJS
1824endif
1825
b6799ccb 1826opt = not get_option('build-swapoff').disabled()
d4c880d5
ZJS
1827exe = executable(
1828 'swapoff',
1829 swapoff_sources,
1830 include_directories : includes,
a764efb5
JW
1831 link_with : [lib_common],
1832 dependencies : [blkid_dep, mount_dep],
d4c880d5 1833 install_dir : sbindir,
b6799ccb
JW
1834 install : opt,
1835 build_by_default : opt)
1836if opt and not is_disabler(exe)
d4c880d5 1837 exes += exe
38bb89ee
TW
1838 manlinks += {'swapoff.8': 'swapon.8'}
1839 bashcompletions += ['swapoff']
d4c880d5
ZJS
1840endif
1841
1842exe = executable(
1843 'lscpu',
1844 lscpu_sources,
1845 include_directories : includes,
1846 link_with : [lib_common,
1847 lib_smartcols],
1848 dependencies : [rtas_libs],
1849 install_dir : usrbin_exec_dir,
1850 install : true)
1851if not is_disabler(exe)
1852 exes += exe
53b37016 1853 manadocs += ['sys-utils/lscpu.1.adoc']
38bb89ee 1854 bashcompletions += ['lscpu']
d4c880d5
ZJS
1855endif
1856
1857exe = executable(
1858 'chcpu',
1859 chcpu_sources,
1860 include_directories : includes,
1861 link_with : [lib_common],
1862 install_dir : sbindir,
1863 install : true)
1864exes += exe
53b37016 1865manadocs += ['sys-utils/chcpu.8.adoc']
38bb89ee 1866bashcompletions += ['chcpu']
d4c880d5
ZJS
1867
1868exe = executable(
1869 'wdctl',
1870 wdctl_sources,
1871 include_directories : includes,
1872 link_with : [lib_common,
1873 lib_smartcols],
1874 install : true)
1875if not is_disabler(exe)
1876 exes += exe
53b37016 1877 manadocs += ['sys-utils/wdctl.8.adoc']
38bb89ee 1878 bashcompletions += ['wdctl']
d4c880d5
ZJS
1879endif
1880
1881opt = not get_option('build-mountpoint').disabled()
1882exe = executable(
1883 'mountpoint',
1884 mountpoint_sources,
1885 include_directories : includes,
c43b185a 1886 dependencies : [mount_dep],
d4c880d5
ZJS
1887 install : opt,
1888 build_by_default : opt)
1889if opt and not is_disabler(exe)
1890 exes += exe
53b37016 1891 manadocs += ['sys-utils/mountpoint.1.adoc']
38bb89ee 1892 bashcompletions += ['mountpoint']
d4c880d5
ZJS
1893endif
1894
1895opt = not get_option('build-fallocate').disabled()
1896exe = executable(
1897 'fallocate',
1898 fallocate_sources,
1899 include_directories : includes,
1900 link_with : [lib_common],
1901 install_dir : usrbin_exec_dir,
1902 install : opt,
1903 build_by_default : opt)
1904if opt and not is_disabler(exe)
1905 exes += exe
53b37016 1906 manadocs += ['sys-utils/fallocate.1.adoc']
38bb89ee 1907 bashcompletions += ['fallocate']
d4c880d5
ZJS
1908endif
1909
1910opt = not get_option('build-pivot_root').disabled()
1911exe = executable(
1912 'pivot_root',
1913 pivot_root_sources,
1914 include_directories : includes,
1915 install_dir : sbindir,
1916 install : opt,
1917 build_by_default : opt)
1918if opt and not is_disabler(exe)
1919 exes += exe
53b37016 1920 manadocs += ['sys-utils/pivot_root.8.adoc']
38bb89ee 1921 bashcompletions += ['pivot_root']
d4c880d5
ZJS
1922endif
1923
1924opt = not get_option('build-switch_root').disabled()
1925if opt and not have_dirfd and not have_ddfd
1926 error('neither dirfd nor ddfd are available')
1927endif
1928exe = executable(
1929 'switch_root',
1930 switch_root_sources,
1931 include_directories : includes,
1932 install_dir : sbindir,
1933 install : opt,
1934 build_by_default : opt)
1935if opt and not is_disabler(exe)
1936 exes += exe
53b37016 1937 manadocs += ['sys-utils/switch_root.8.adoc']
d4c880d5
ZJS
1938endif
1939
1940opt = not get_option('build-unshare').disabled()
1941exe = executable(
1942 'unshare',
1943 unshare_sources,
1944 include_directories : includes,
1945 link_with : [lib_common],
c43b185a 1946 dependencies : [mount_dep],
d4c880d5
ZJS
1947 install_dir : usrbin_exec_dir,
1948 install : opt,
1949 build_by_default : opt)
1950if opt and not is_disabler(exe)
1951 exes += exe
53b37016 1952 manadocs += ['sys-utils/unshare.1.adoc']
38bb89ee 1953 bashcompletions += ['unshare']
d4c880d5
ZJS
1954endif
1955
69939195
ZJS
1956opt = opt and 'unshare' in static_programs
1957exe = executable(
1958 'unshare.static',
1959 unshare_sources,
1960 include_directories : includes,
1961 link_with : [lib_common],
c43b185a 1962 dependencies : [mount_dep],
69939195
ZJS
1963 install_dir : usrbin_exec_dir,
1964 install : opt,
1965 build_by_default : opt)
1966if opt and not is_disabler(exe)
1967 exes += exe
1968endif
1969
d4c880d5
ZJS
1970opt = not get_option('build-nsenter').disabled()
1971exe = executable(
1972 'nsenter',
1973 nsenter_sources,
1974 include_directories : includes,
1975 link_with : [lib_common],
1976 dependencies : [lib_selinux],
1977 install_dir : usrbin_exec_dir,
1978 install : opt,
1979 build_by_default : opt)
1980if opt and not is_disabler(exe)
1981 exes += exe
53b37016 1982 manadocs += ['sys-utils/nsenter.1.adoc']
38bb89ee 1983 bashcompletions += ['nsenter']
d4c880d5
ZJS
1984endif
1985
69939195
ZJS
1986opt = opt and 'nsenter' in static_programs
1987exe = executable(
1988 'nsenter.static',
1989 nsenter_sources,
1990 include_directories : includes,
1991 link_with : [lib_common],
1992 dependencies : [lib_selinux],
1993 install_dir : usrbin_exec_dir,
1994 install : opt,
1995 build_by_default : opt)
1996if opt and not is_disabler(exe)
1997 exes += exe
1998endif
1999
cd23a433 2000opt = not get_option('build-setpriv').disabled() and lib_cap_ng.found()
d4c880d5
ZJS
2001exe = executable(
2002 'setpriv',
2003 setpriv_sources,
2004 include_directories : includes,
2005 link_with : [lib_common],
2006 dependencies : [lib_cap_ng],
2007 install_dir : usrbin_exec_dir,
2008 install : opt,
2009 build_by_default : opt)
2010if opt and not is_disabler(exe)
2011 exes += exe
53b37016 2012 manadocs += ['sys-utils/setpriv.1.adoc']
38bb89ee 2013 bashcompletions += ['setpriv']
d4c880d5
ZJS
2014endif
2015
2016exe = executable(
2017 'flock',
2018 flock_sources,
2019 include_directories : includes,
2020 link_with : [lib_common],
2021 dependencies : realtime_libs,
2022 install_dir : usrbin_exec_dir,
2023 install : true)
2024exes += exe
53b37016 2025manadocs += ['sys-utils/flock.1.adoc']
38bb89ee 2026bashcompletions += ['flock']
d4c880d5 2027
645577c7
KZ
2028opt = not get_option('build-lsirq').disabled()
2029exe = executable(
2030 'lsirq',
2031 lsirq_sources,
2032 include_directories : includes,
2033 link_with : [lib_common,
2034 lib_smartcols],
2035 install_dir : usrbin_exec_dir,
2036 install : opt,
2037 build_by_default : opt)
2038if opt and not is_disabler(exe)
2039 exes += exe
53b37016 2040 manadocs += ['sys-utils/lsirq.1.adoc']
38bb89ee 2041 bashcompletions += ['lsirq']
645577c7
KZ
2042endif
2043
2044opt = not get_option('build-irqtop').disabled()
2045exe = executable(
2046 'irqtop',
2047 irqtop_sources,
2048 include_directories : includes,
2049 dependencies : [realtime_libs, curses_libs],
2050 link_with : [lib_common,
2051 lib_smartcols,
2052 lib_tcolors],
2053 install_dir : usrbin_exec_dir,
2054 install : opt,
2055 build_by_default : opt)
2056if opt and not is_disabler(exe)
2057 exes += exe
53b37016 2058 manadocs += ['sys-utils/irqtop.1.adoc']
38bb89ee 2059 bashcompletions += ['irqtop']
645577c7
KZ
2060endif
2061
d4c880d5
ZJS
2062opt = not get_option('build-ipcs').disabled()
2063exe = executable(
2064 'lsipc',
2065 lsipc_sources,
2066 include_directories : includes,
2067 link_with : [lib_common,
2068 lib_smartcols],
2069 install_dir : usrbin_exec_dir,
2070 install : opt,
2071 build_by_default : opt)
2072if opt and not is_disabler(exe)
2073 exes += exe
53b37016 2074 manadocs += ['sys-utils/lsipc.1.adoc']
38bb89ee 2075 bashcompletions += ['lsipc']
d4c880d5
ZJS
2076endif
2077
2078opt = build_hwclock
2079exe = executable(
2080 'hwclock',
2081 hwclock_sources,
2082 include_directories : includes,
2083 link_with : [lib_common],
2084 dependencies : [lib_m,
2085 lib_audit],
2086 install_dir : sbindir,
2087 install : opt,
2088 build_by_default : opt)
2089if opt and not is_disabler(exe)
2090 exes += exe
38bb89ee
TW
2091 manadocs += ['sys-utils/hwclock.8.adoc', 'sys-utils/adjtime_config.5.adoc']
2092 bashcompletions += ['hwclock']
d4c880d5
ZJS
2093endif
2094
2095exe = executable(
2096 'mkfs',
2097 mkfs_sources,
2098 include_directories : includes,
2099 install_dir : sbindir,
2100 install : true)
2101exes += exe
53b37016 2102manadocs += ['disk-utils/mkfs.8.adoc']
38bb89ee 2103bashcompletions += ['mkfs']
d4c880d5
ZJS
2104
2105opt = not get_option('build-bfs').disabled()
2106exe = executable(
2107 'mkfs.bfs',
2108 mkfs_bfs_sources,
2109 include_directories : includes,
2110 link_with : [lib_common],
2111 install_dir : sbindir,
2112 install : opt,
2113 build_by_default : opt)
2114if opt and not is_disabler(exe)
2115 exes += exe
53b37016 2116 manadocs += ['disk-utils/mkfs.bfs.8.adoc']
38bb89ee 2117 bashcompletions += ['mkfs.bfs']
d4c880d5
ZJS
2118endif
2119
2120exe = executable(
2121 'isosize',
2122 isosize_sources,
2123 include_directories : includes,
2124 link_with : [lib_common],
2125 install_dir : usrbin_exec_dir,
2126 install : true)
2127exes += exe
53b37016 2128manadocs += ['disk-utils/isosize.8.adoc']
38bb89ee 2129bashcompletions += ['isosize']
d4c880d5
ZJS
2130
2131exe = executable(
2132 'mkswap',
2133 mkswap_sources,
2134 include_directories : includes,
2135 link_with : [lib_common,
d4c880d5 2136 lib_uuid],
a764efb5 2137 dependencies: [blkid_dep, lib_selinux],
d4c880d5
ZJS
2138 install_dir : sbindir,
2139 install : true)
765961c3 2140if not is_disabler(exe)
d4c880d5 2141 exes += exe
53b37016 2142 manadocs += ['disk-utils/mkswap.8.adoc']
38bb89ee 2143 bashcompletions += ['mkswap']
d4c880d5
ZJS
2144endif
2145
2146exe = executable(
2147 'swaplabel',
2148 swaplabel_sources,
2149 include_directories : includes,
2150 link_with : [lib_common,
d4c880d5 2151 lib_uuid],
a764efb5 2152 dependencies : [blkid_dep],
d4c880d5
ZJS
2153 install_dir : sbindir,
2154 install : true)
765961c3 2155if not is_disabler(exe)
d4c880d5 2156 exes += exe
53b37016 2157 manadocs += ['disk-utils/swaplabel.8.adoc']
38bb89ee 2158 bashcompletions += ['swaplabel']
d4c880d5
ZJS
2159endif
2160
2161opt = not get_option('build-fsck').disabled()
2162exe = executable(
2163 'fsck',
2164 fsck_sources,
2165 include_directories : includes,
a764efb5
JW
2166 link_with : [lib_common],
2167 dependencies : [blkid_dep, mount_dep, realtime_libs],
d4c880d5
ZJS
2168 install_dir : sbindir,
2169 install : opt,
2170 build_by_default : opt)
2171if opt and not is_disabler(exe)
2172 exes += exe
53b37016 2173 manadocs += ['disk-utils/fsck.8.adoc']
38bb89ee 2174 bashcompletions += ['fsck']
d4c880d5
ZJS
2175endif
2176
2177opt = not get_option('build-minix').disabled()
2178exe = executable(
2179 'mkfs.minix',
2180 mkfs_minix_sources,
2181 include_directories : includes,
2182 link_with : [lib_common],
2183 install_dir : sbindir,
2184 install : opt,
2185 build_by_default : opt)
2186exe2 = executable(
2187 'test_mkfs_minix',
2188 mkfs_minix_sources,
2189 include_directories : includes,
2190 c_args : '-DTEST_SCRIPT',
2191 link_with : [lib_common],
ba30b89c 2192 build_by_default : opt and program_tests)
d4c880d5
ZJS
2193exe3 = executable(
2194 'fsck.minix',
2195 fsck_minix_sources,
2196 include_directories : includes,
2197 link_with : [lib_common],
2198 install_dir : sbindir,
2199 install : opt,
2200 build_by_default : opt)
2201if opt and not is_disabler(exe)
2202 exes += [exe, exe2, exe3]
53b37016 2203 manadocs += ['disk-utils/mkfs.minix.8.adoc','disk-utils/fsck.minix.8.adoc']
38bb89ee 2204 bashcompletions += ['mkfs.minix', 'fsck.minix']
d4c880d5
ZJS
2205endif
2206
2207opt = not get_option('build-cramfs').disabled()
2208exe = executable(
2209 'mkfs.cramfs',
2210 mkfs_cramfs_sources,
2211 include_directories : includes,
2212 link_with : [lib_common],
2213 dependencies : [lib_z],
2214 install_dir : sbindir,
2215 install : opt,
2216 build_by_default : opt)
2217exe2 = executable(
2218 'fsck.cramfs',
2219 fsck_cramfs_sources,
2220 include_directories : includes,
2221 link_with : [lib_common],
2222 dependencies : [lib_z],
2223 install_dir : sbindir,
2224 install : opt,
2225 build_by_default : opt)
2226if not is_disabler(exe)
2227 exes += [exe, exe2]
53b37016 2228 manadocs += ['disk-utils/mkfs.cramfs.8.adoc','disk-utils/fsck.cramfs.8.adoc']
38bb89ee 2229 bashcompletions += ['mkfs.cramfs', 'fsck.cramfs']
d4c880d5
ZJS
2230endif
2231
2232opt = not get_option('build-raw').disabled()
dff176e2 2233if opt
433e4b77 2234 cc.has_header('linux/raw.h', required: opt)
dff176e2 2235endif
d4c880d5
ZJS
2236exe = executable(
2237 'raw',
2238 raw_sources,
2239 include_directories : includes,
2240 install_dir : sbindir,
2241 install : opt,
2242 build_by_default : opt)
2243if opt and not is_disabler(exe)
2244 exes += exe
53b37016 2245 manadocs += ['disk-utils/raw.8.adoc']
38bb89ee 2246 bashcompletions += ['raw']
d4c880d5
ZJS
2247endif
2248
2249opt = not get_option('build-fdformat').disabled()
2250exe = executable(
2251 'fdformat',
2252 fdformat_sources,
2253 include_directories : includes,
2254 link_with : [lib_common],
2255 install_dir : usrsbin_exec_dir,
2256 install : opt,
2257 build_by_default : opt)
2258if opt and not is_disabler(exe)
2259 exes += exe
53b37016 2260 manadocs += ['disk-utils/fdformat.8.adoc']
669071f6 2261 bashcompletions += ['fdformat']
d4c880d5
ZJS
2262endif
2263
2264exe = executable(
2265 'blockdev',
2266 blockdev_sources,
2267 include_directories : includes,
2268 link_with : [lib_common],
2269 install_dir : sbindir,
2270 install : true)
53b37016 2271manadocs += ['disk-utils/blockdev.8.adoc']
38bb89ee 2272bashcompletions += ['blockdev']
d4c880d5
ZJS
2273
2274opt = not get_option('build-fdisks').disabled()
2275if opt and not have_dirfd and not have_ddfd
2276 error('neither dirfd nor ddfd are available')
2277endif
2278exe = executable(
2279 'fdisk',
2280 fdisk_sources,
2281 include_directories : includes,
2282 link_with : [lib_common,
2283 lib_fdisk,
2284 lib_smartcols,
2285 lib_tcolors],
2286 dependencies : [lib_readline],
2287 install_dir : sbindir,
2288 install : opt,
2289 build_by_default : opt)
2290if opt and not is_disabler(exe)
2291 exes += exe
38bb89ee 2292 bashcompletions += ['fdisk']
d4c880d5
ZJS
2293endif
2294
69939195
ZJS
2295opt2 = opt and 'fdisk' in static_programs
2296exe = executable(
2297 'fdisk.static',
2298 fdisk_sources,
2299 link_args : ['--static'],
2300 include_directories : includes,
2301 link_with : [lib_common,
2302 lib_tcolors,
2303 lib_fdisk_static,
2304 lib_smartcols.get_static_lib()],
2305 dependencies : [lib_readline_static],
2306 install_dir : sbindir,
2307 install : opt2,
2308 build_by_default : opt2)
2309if opt2 and not is_disabler(exe)
2310 exes += exe
2311endif
d4c880d5
ZJS
2312
2313exe = executable(
2314 'sfdisk',
2315 sfdisk_sources,
2316 include_directories : includes,
2317 link_with : [lib_common,
2318 lib_fdisk,
2319 lib_smartcols,
2320 lib_tcolors],
2321 dependencies : [lib_readline],
2322 install_dir : sbindir,
2323 install : opt,
2324 build_by_default : opt)
2325if opt and not is_disabler(exe)
2326 exes += exe
38bb89ee 2327 bashcompletions += ['sfdisk']
d4c880d5
ZJS
2328endif
2329
69939195
ZJS
2330opt2 = opt and 'sfdisk' in static_programs
2331exe = executable(
2332 'sfdisk.static',
2333 sfdisk_sources,
2334 include_directories : includes,
2335 link_with : [lib_common,
2336 lib_tcolors,
2337 lib_fdisk_static,
2338 lib_smartcols.get_static_lib()],
2339 dependencies : [lib_readline_static],
2340 install_dir : sbindir,
2341 install : opt2,
2342 build_by_default : opt2)
2343if opt2 and not is_disabler(exe)
2344 exes += exe
2345endif
d4c880d5
ZJS
2346
2347exe = executable(
2348 'cfdisk',
2349 cfdisk_sources,
2350 include_directories : includes,
2351 link_with : [lib_common,
2352 lib_fdisk,
2353 lib_smartcols,
c43b185a
JW
2354 lib_tcolors],
2355 dependencies : [curses_libs, mount_dep],
d4c880d5
ZJS
2356 install_dir : sbindir,
2357 install : opt,
2358 build_by_default : opt)
2359if opt and not is_disabler(exe)
2360 exes += exe
53b37016
KZ
2361 manadocs += ['disk-utils/fdisk.8.adoc',
2362 'disk-utils/sfdisk.8.adoc',
2363 'disk-utils/cfdisk.8.adoc']
38bb89ee 2364 bashcompletions += ['cfdisk']
d4c880d5
ZJS
2365endif
2366
2367opt = not get_option('build-partx').disabled()
2368exe = executable(
2369 'addpart',
2370 addpart_sources,
2371 include_directories : includes,
2372 link_with : [lib_common],
2373 install_dir : usrsbin_exec_dir,
2374 install : opt,
2375 build_by_default : opt)
2376exe2 = executable(
2377 'delpart',
2378 delpart_sources,
2379 include_directories : includes,
2380 link_with : [lib_common],
2381 install_dir : usrsbin_exec_dir,
2382 install : opt,
2383 build_by_default : opt)
2384exe3 = executable(
2385 'resizepart',
2386 resizepart_sources,
2387 include_directories : includes,
2388 link_with : [lib_common],
2389 install_dir : usrsbin_exec_dir,
2390 install : opt,
2391 build_by_default : opt)
2392exe4 = executable(
2393 'partx',
2394 partx_sources,
2395 include_directories : includes,
2396 link_with : [lib_common,
d4c880d5 2397 lib_smartcols],
a764efb5 2398 dependencies : [blkid_dep],
d4c880d5
ZJS
2399 install_dir : usrsbin_exec_dir,
2400 install : opt,
2401 build_by_default : opt)
2402if opt
2403 exes += [exe, exe2, exe3, exe4]
53b37016
KZ
2404 manadocs += ['disk-utils/addpart.8.adoc',
2405 'disk-utils/delpart.8.adoc',
2406 'disk-utils/resizepart.8.adoc',
2407 'disk-utils/partx.8.adoc']
38bb89ee 2408 bashcompletions += ['addpart', 'delpart', 'resizepart', 'partx']
d4c880d5 2409endif
44bf6d80
B
2410opt = opt and 'partx' in static_programs
2411exe = executable(
2412 'addpart.static',
2413 addpart_sources,
2414 include_directories : includes,
2415 link_args : ['--static'],
2416 link_with : [lib_common],
2417 install_dir : usrsbin_exec_dir,
2418 install : opt,
2419 build_by_default : opt)
2420exe2 = executable(
2421 'delpart.static',
2422 delpart_sources,
2423 include_directories : includes,
2424 link_args : ['--static'],
2425 link_with : [lib_common],
2426 install_dir : usrsbin_exec_dir,
2427 install : opt,
2428 build_by_default : opt)
2429exe3 = executable(
2430 'resizepart.static',
2431 resizepart_sources,
2432 include_directories : includes,
2433 link_args : ['--static'],
2434 link_with : [lib_common],
2435 install_dir : usrsbin_exec_dir,
2436 install : opt,
2437 build_by_default : opt)
2438exe4 = executable(
2439 'partx.static',
2440 partx_sources,
2441 include_directories : includes,
2442 link_args : ['--static'],
2443 link_with : [lib_common,
44bf6d80 2444 lib_smartcols.get_static_lib()],
a764efb5 2445 dependencies : [blkid_static_dep],
44bf6d80
B
2446 install_dir : usrsbin_exec_dir,
2447 install : opt,
2448 build_by_default : opt)
2449
2450if opt
2451 exes += [exe, exe2, exe3, exe4]
2452endif
d4c880d5
ZJS
2453
2454############################################################
2455
2456exe = executable(
2457 'script',
2458 script_sources,
2459 include_directories : includes,
2460 link_with : [lib_common],
2461 dependencies : [lib_util,
2462 lib_utempter,
2463 realtime_libs,
2464 math_libs],
2465 install_dir : usrbin_exec_dir,
2466 install : true)
2467exes += exe
53b37016 2468manadocs += ['term-utils/script.1.adoc']
38bb89ee 2469bashcompletions += ['script']
d4c880d5
ZJS
2470
2471exe = executable(
2472 'test_script',
2473 script_sources,
2474 include_directories : includes,
2475 c_args : '-DTEST_SCRIPT',
2476 link_with : [lib_common],
2477 dependencies : [lib_util,
2478 lib_utempter,
2479 realtime_libs,
ba30b89c 2480 math_libs],
2481 build_by_default : program_tests)
d4c880d5
ZJS
2482exes += exe
2483
2484exe = executable(
2485 'scriptlive',
2486 scriptlive_sources,
2487 include_directories : includes,
2488 link_with : [lib_common],
2489 dependencies : [lib_util,
2490 realtime_libs,
2491 math_libs],
2492 install_dir : usrbin_exec_dir,
2493 install : true)
2494exes += exe
53b37016 2495manadocs += ['term-utils/scriptlive.1.adoc']
38bb89ee 2496bashcompletions += ['scriptlive']
d4c880d5
ZJS
2497
2498exe = executable(
2499 'scriptreplay',
2500 scriptreplay_sources,
2501 include_directories : includes,
2502 link_with : [lib_common],
2503 dependencies : [math_libs],
2504 install_dir : usrbin_exec_dir,
2505 install : true)
2506exes += exe
53b37016 2507manadocs += ['term-utils/scriptreplay.1.adoc']
38bb89ee 2508bashcompletions += ['scriptreplay']
d4c880d5
ZJS
2509
2510opt = not get_option('build-agetty').disabled()
2511exe = executable(
2512 'agetty',
2513 agetty_sources,
2514 include_directories : includes,
0333c40b 2515 link_with : [lib_common, logindefs_c],
87fcd95a 2516 dependencies : [BSD ? lib_util : [], lib_systemd],
d4c880d5
ZJS
2517 install_dir : sbindir,
2518 install : opt,
2519 build_by_default : opt)
2520if opt
2521 exes += exe
53b37016 2522 manadocs += ['term-utils/agetty.8.adoc']
d4c880d5
ZJS
2523endif
2524
2525opt = not get_option('build-setterm').disabled()
2526exe = executable(
2527 'setterm',
2528 setterm_sources,
2529 include_directories : includes,
2530 link_with : [lib_common],
2531 dependencies : [curses_libs],
2532 install_dir : usrbin_exec_dir,
2533 install : opt,
2534 build_by_default : opt)
2535if opt
2536 exes += exe
53b37016 2537 manadocs += ['term-utils/setterm.1.adoc']
38bb89ee 2538 bashcompletions += ['setterm']
d4c880d5
ZJS
2539endif
2540
2541opt = not get_option('build-mesg').disabled()
2542exe = executable(
2543 'mesg',
2544 mesg_sources,
2545 include_directories : includes,
2546 link_with : [lib_common],
2547 install_dir : usrbin_exec_dir,
2548 install : opt,
2549 build_by_default : opt)
2550if opt
2551 exes += exe
53b37016 2552 manadocs += ['term-utils/mesg.1.adoc']
38bb89ee 2553 bashcompletions += ['mesg']
d4c880d5
ZJS
2554endif
2555
2556opt = not get_option('build-wall').disabled()
2557exe = executable(
2558 'wall',
2559 wall_sources,
2560 include_directories : includes,
2561 link_with : [lib_common],
87fcd95a 2562 dependencies : [lib_systemd],
d4c880d5 2563 install_dir : usrbin_exec_dir,
5f3359c5 2564 install_mode : [ 'rwxr-sr-x', 'root', 'tty' ],
d4c880d5
ZJS
2565 install : opt,
2566 build_by_default : opt)
2567if opt
2568 exes += exe
53b37016 2569 manadocs += ['term-utils/wall.1.adoc']
38bb89ee 2570 bashcompletions += ['wall']
d4c880d5
ZJS
2571endif
2572
2573# chgrp tty $(DESTDIR)$(usrbin_execdir)/wall
2574# chmod g+s $(DESTDIR)$(usrbin_execdir)/wall
2575
2576opt = not get_option('build-write').disabled()
2577exe = executable(
2578 'write',
2579 write_sources,
2580 include_directories : includes,
2581 link_with : [lib_common],
87fcd95a 2582 dependencies : [lib_systemd],
d4c880d5 2583 install_dir : usrbin_exec_dir,
00f115d8 2584 install_mode : [ 'rwxr-sr-x', 'root', 'tty' ],
d4c880d5
ZJS
2585 install : opt,
2586 build_by_default : opt)
2587if opt
2588 exes += exe
53b37016 2589 manadocs += ['term-utils/write.1.adoc']
e1cd4002 2590 bashcompletions += ['write']
d4c880d5
ZJS
2591endif
2592
2593# chgrp tty $(DESTDIR)$(usrbin_execdir)/write
2594# chmod g+s $(DESTDIR)$(usrbin_execdir)/write
2595
2596opt = not get_option('build-login').disabled()
2597exe = executable(
2598 'login',
2599 login_sources,
2600 include_directories : includes,
0333c40b 2601 link_with : [lib_common, logindefs_c],
d4c880d5
ZJS
2602 dependencies : [lib_pam,
2603 lib_audit,
2604 lib_selinux],
2605 install : opt,
2606 build_by_default : opt)
2607if not is_disabler(exe)
2608 exes += exe
53b37016 2609 manadocs += ['login-utils/login.1.adoc']
d4c880d5
ZJS
2610endif
2611
2612opt = not get_option('build-sulogin').disabled()
2613exe = executable(
2614 'sulogin',
2615 sulogin_sources,
2616 include_directories : includes,
2617 link_with : [lib_common],
2618 dependencies : [lib_crypt,
2619 lib_selinux],
2620 install_dir : sbindir,
2621 install : opt,
2622 build_by_default : opt)
2623if not is_disabler(exe)
2624 exes += exe
53b37016 2625 manadocs += ['login-utils/sulogin.8.adoc']
d4c880d5
ZJS
2626endif
2627
2628exe = executable(
2629 'cal',
2630 cal_sources,
2631 include_directories : includes,
2632 link_with : [lib_common,
2633 lib_tcolors],
2634 dependencies : [curses_libs],
2635 install_dir : usrbin_exec_dir,
2636 install : true)
2637exes += exe
53b37016 2638manadocs += ['misc-utils/cal.1.adoc']
38bb89ee 2639bashcompletions += ['cal']
d4c880d5
ZJS
2640
2641opt = not get_option('build-logger').disabled()
2642exe = executable(
2643 'logger',
2644 logger_sources,
2645 include_directories : includes,
dbb9999f 2646 link_with : [lib_common],
d4c880d5
ZJS
2647 dependencies : [lib_systemd],
2648 install_dir : usrbin_exec_dir,
2649 install : opt,
2650 build_by_default : opt)
2651if opt and not is_disabler(exe)
2652 exes += exe
53b37016 2653 manadocs += ['misc-utils/logger.1.adoc']
38bb89ee 2654 bashcompletions += ['logger']
d4c880d5
ZJS
2655endif
2656
2657exe = executable(
2658 'test_logger',
2659 logger_sources,
2660 include_directories : includes,
2661 c_args : '-DTEST_LOGGER',
dbb9999f 2662 link_with : [lib_common],
ba30b89c 2663 dependencies : [lib_systemd],
2664 build_by_default: program_tests)
d4c880d5
ZJS
2665if not is_disabler(exe)
2666 exes += exe
2667endif
2668
2669exe = executable(
2670 'look',
2671 look_sources,
2672 include_directories : includes,
2673 install_dir : usrbin_exec_dir,
2674 install : true)
2675exes += exe
53b37016 2676manadocs += ['misc-utils/look.1.adoc']
38bb89ee 2677bashcompletions += ['look']
d4c880d5
ZJS
2678
2679exe = executable(
2680 'mcookie',
2681 mcookie_sources,
2682 include_directories : includes,
2683 link_with : [lib_common],
2684 install_dir : usrbin_exec_dir,
2685 install : true)
2686exes += exe
53b37016 2687manadocs += ['misc-utils/mcookie.1.adoc']
38bb89ee 2688bashcompletions += ['mcookie']
d4c880d5 2689
c2e299d0
SS
2690if build_liblastlog2
2691 exe = executable(
2692 'lastlog2',
2693 lastlog2_sources,
2694 include_directories : includes,
2695 link_with : [lib_common, lib_lastlog2],
2696 install_dir : usrbin_exec_dir,
2697 install : true)
2698 exes += exe
2699 manadocs += ['misc-utils/lastlog2.8.adoc']
2700 bashcompletions += ['lastlog2']
2701 manadocs += ['liblastlog2/man/lastlog2.3.adoc',
2702 'liblastlog2/man/ll2_write_entry.3.adoc',
2703 'liblastlog2/man/ll2_read_entry.3.adoc',
2704 'liblastlog2/man/ll2_import_lastlog.3.adoc',
2705 'liblastlog2/man/ll2_read_all.3.adoc',
2706 'liblastlog2/man/ll2_remove_entry.3.adoc',
2707 'liblastlog2/man/ll2_rename_user.3.adoc',
2708 'liblastlog2/man/ll2_update_login_time.3.adoc'
2709 ]
2710endif
2711
d4c880d5
ZJS
2712exe = executable(
2713 'namei',
2714 namei_sources,
2715 include_directories : includes,
c07f7b4e 2716 dependencies : [lib_selinux],
d4c880d5
ZJS
2717 install_dir : usrbin_exec_dir,
2718 install : true)
2719exes += exe
53b37016 2720manadocs += ['misc-utils/namei.1.adoc']
38bb89ee 2721bashcompletions += ['namei']
d4c880d5
ZJS
2722
2723exe = executable(
2724 'whereis',
2725 whereis_sources,
2726 include_directories : includes,
2727 link_with : [lib_common],
2728 install_dir : usrbin_exec_dir,
2729 install : true)
2730exes += exe
53b37016 2731manadocs += ['misc-utils/whereis.1.adoc']
38bb89ee 2732bashcompletions += ['whereis']
d4c880d5 2733
b6799ccb 2734opt = not get_option('build-lslocks').disabled()
d4c880d5
ZJS
2735exe = executable(
2736 'lslocks',
2737 lslocks_sources,
2738 include_directories : includes,
2739 link_with : [lib_common,
d4c880d5 2740 lib_smartcols],
c43b185a 2741 dependencies : [mount_dep],
d4c880d5 2742 install_dir : usrbin_exec_dir,
b6799ccb
JW
2743 install : opt,
2744 build_by_default : opt)
2745if opt and not is_disabler(exe)
d4c880d5 2746 exes += exe
53b37016 2747 manadocs += ['misc-utils/lslocks.8.adoc']
38bb89ee 2748 bashcompletions += ['lslocks']
d4c880d5
ZJS
2749endif
2750
b6799ccb 2751opt = not get_option('build-lsblk').disabled()
d4c880d5
ZJS
2752exe = executable(
2753 'lsblk',
2754 lsblk_sources,
2755 include_directories : includes,
2756 link_with : [lib_common,
c3317cdc 2757 lib_tcolors,
d4c880d5 2758 lib_smartcols],
a764efb5 2759 dependencies : [blkid_dep, lib_udev, mount_dep],
b6799ccb
JW
2760 install : opt,
2761 build_by_default : opt)
2762if opt and not is_disabler(exe)
d4c880d5 2763 exes += exe
53b37016 2764 manadocs += ['misc-utils/lsblk.8.adoc']
38bb89ee 2765 bashcompletions += ['lsblk']
d4c880d5
ZJS
2766endif
2767
a125e2ee
MY
2768errnos_h = custom_target('errnos.h',
2769 input : 'tools/all_errnos',
2770 output : 'errnos.h',
8e7f1439 2771 command : ['tools/all_errnos', cc.cmd_array(), get_option('c_args')],
a125e2ee
MY
2772)
2773
24395027 2774opt = not get_option('build-lsfd').require(lib_rt.found()).disabled()
ee194909
KZ
2775exe = executable(
2776 'lsfd',
a125e2ee 2777 lsfd_sources, errnos_h,
ee194909
KZ
2778 include_directories : includes,
2779 link_with : [lib_common,
2780 lib_smartcols],
06b27058 2781 dependencies : [lib_rt],
ee194909 2782 install_dir : usrbin_exec_dir,
06b27058
JW
2783 install : opt,
2784 build_by_default : opt)
2785if opt and not is_disabler(exe)
ee194909
KZ
2786 exes += exe
2787 manadocs += ['misc-utils/lsfd.1.adoc']
2788endif
2789
d4c880d5
ZJS
2790exe = executable(
2791 'uuidgen',
2792 uuidgen_sources,
2793 include_directories : includes,
06d3a851
KZ
2794 link_with : [lib_common,
2795 lib_uuid],
d4c880d5
ZJS
2796 install_dir : usrbin_exec_dir,
2797 install : true)
2798if not is_disabler(exe)
2799 exes += exe
53b37016 2800 manadocs += ['misc-utils/uuidgen.1.adoc']
38bb89ee 2801 bashcompletions += ['uuidgen']
d4c880d5
ZJS
2802endif
2803
2804exe = executable(
2805 'uuidparse',
2806 uuidparse_sources,
2807 include_directories : includes,
2808 link_with : [lib_common,
2809 lib_uuid,
2810 lib_smartcols],
2811 install_dir : usrbin_exec_dir,
2812 install : true)
2813if not is_disabler(exe)
2814 exes += exe
53b37016 2815 manadocs += ['misc-utils/uuidparse.1.adoc']
38bb89ee 2816 bashcompletions += ['uuidparse']
d4c880d5
ZJS
2817endif
2818
2819opt = build_uuidd
2820exe = executable(
2821 'uuidd',
2822 uuidd_sources,
2823 include_directories : includes,
2824 link_with : [lib_common,
2825 lib_uuid],
2826 dependencies : [realtime_libs,
2827 lib_systemd],
2828 install_dir : usrsbin_exec_dir,
2829 install : opt,
2830 build_by_default : opt)
2831exe2 = executable(
2832 'test_uuidd',
2833 test_uuidd_sources,
2834 include_directories : includes,
2835 link_with : [lib_common,
2836 lib_uuid],
2837 dependencies : thread_libs,
ba30b89c 2838 build_by_default : opt and program_tests)
d4c880d5
ZJS
2839if not is_disabler(exe)
2840 exes += [exe, exe2]
53b37016 2841 manadocs += ['misc-utils/uuidd.8.adoc']
38bb89ee 2842 bashcompletions += ['uuidd']
d4c880d5
ZJS
2843endif
2844
2845opt = build_libblkid
2846exe = executable(
2847 'blkid',
2848 blkid_sources,
2849 include_directories : includes,
a764efb5
JW
2850 link_with : [lib_common],
2851 dependencies : [blkid_dep],
d4c880d5
ZJS
2852 install_dir : sbindir,
2853 install : opt,
2854 build_by_default : opt)
2855if opt and not is_disabler(exe)
2856 exes += exe
53b37016 2857 manadocs += ['misc-utils/blkid.8.adoc']
38bb89ee 2858 bashcompletions += ['blkid']
d4c880d5
ZJS
2859endif
2860
69939195
ZJS
2861opt = opt and 'blkid' in static_programs
2862exe = executable(
2863 'blkid.static',
2864 blkid_sources,
2865 include_directories : includes,
a764efb5
JW
2866 link_with : [lib_common],
2867 dependencies : [blkid_static_dep],
69939195
ZJS
2868 install_dir : sbindir,
2869 install : opt,
2870 build_by_default : opt)
2871if opt and not is_disabler(exe)
2872 exes += exe
2873endif
d4c880d5
ZJS
2874
2875exe = executable(
2876 'sample-mkfs',
2877 'libblkid/samples/mkfs.c',
2878 include_directories : includes,
a764efb5 2879 dependencies : [blkid_dep])
d4c880d5
ZJS
2880if not is_disabler(exe)
2881 exes += exe
2882endif
2883
2884exe = executable(
2885 'sample-partitions',
2886 'libblkid/samples/partitions.c',
2887 include_directories : includes,
a764efb5 2888 dependencies : [blkid_dep])
d4c880d5
ZJS
2889if not is_disabler(exe)
2890 exes += exe
2891endif
2892
2893exe = executable(
2894 'sample-superblocks',
2895 'libblkid/samples/superblocks.c',
2896 include_directories : includes,
a764efb5 2897 dependencies : [blkid_dep])
d4c880d5
ZJS
2898if not is_disabler(exe)
2899 exes += exe
2900endif
2901
2902exe = executable(
2903 'sample-topology',
2904 'libblkid/samples/topology.c',
2905 include_directories : includes,
a764efb5 2906 dependencies : [blkid_dep])
d4c880d5
ZJS
2907if not is_disabler(exe)
2908 exes += exe
2909endif
2910
97e673a0
TW
2911exe = executable(
2912 'test_blkid_fuzz_sample',
2913 'libblkid/src/fuzz.c',
2914 include_directories: includes,
a764efb5 2915 dependencies : [blkid_dep],
ba30b89c 2916 build_by_default: program_tests)
97e673a0
TW
2917if not is_disabler(exe)
2918 exes += exe
2919endif
2920
d4c880d5
ZJS
2921############################################################
2922
2923exe = executable(
2924 'findfs',
2925 findfs_sources,
2926 include_directories : includes,
a764efb5 2927 dependencies : [blkid_dep],
d4c880d5
ZJS
2928 install_dir : sbindir,
2929 install : true)
2930if not is_disabler(exe)
2931 exes += exe
53b37016 2932 manadocs += ['misc-utils/findfs.8.adoc']
38bb89ee 2933 bashcompletions += ['findfs']
d4c880d5
ZJS
2934endif
2935
2936exe = executable(
2937 'wipefs',
2938 wipefs_sources,
2939 include_directories : includes,
2940 link_with : [lib_common,
d4c880d5 2941 lib_smartcols],
a764efb5 2942 dependencies : [blkid_dep],
d4c880d5
ZJS
2943 install_dir : sbindir,
2944 install : true)
2945if not is_disabler(exe)
2946 exes += exe
53b37016 2947 manadocs += ['misc-utils/wipefs.8.adoc']
38bb89ee 2948 bashcompletions += ['wipefs']
d4c880d5
ZJS
2949endif
2950
b6799ccb 2951opt = not get_option('build-findmnt').disabled()
d4c880d5
ZJS
2952exe = executable(
2953 'findmnt',
2954 findmnt_sources,
2955 include_directories : includes,
2956 link_with : [lib_common,
d4c880d5 2957 lib_smartcols],
a764efb5 2958 dependencies : [blkid_dep, lib_udev, mount_dep],
b6799ccb
JW
2959 install : opt,
2960 build_by_default : opt)
2961if opt and not is_disabler(exe)
d4c880d5 2962 exes += exe
53b37016 2963 manadocs += ['misc-utils/findmnt.8.adoc']
38bb89ee 2964 bashcompletions += ['findmnt']
d4c880d5
ZJS
2965endif
2966
2967exe = executable(
2968 'kill',
2969 kill_sources,
2970 include_directories : includes,
2971 link_with : [lib_common],
2972 install : true)
2973if not is_disabler(exe)
2974 exes += exe
53b37016 2975 manadocs += ['misc-utils/kill.1.adoc']
d4c880d5
ZJS
2976endif
2977
2978opt = not get_option('build-rename').disabled()
2979exe = executable(
2980 'rename',
2981 rename_sources,
2982 include_directories : includes,
2983 install_dir : usrbin_exec_dir,
2984 install : opt,
2985 build_by_default : opt)
2986if opt and not is_disabler(exe)
2987 exes += exe
53b37016 2988 manadocs += ['misc-utils/rename.1.adoc']
38bb89ee 2989 bashcompletions += ['rename']
d4c880d5
ZJS
2990endif
2991
2992exe = executable(
2993 'getopt',
2994 getopt_sources,
2995 include_directories : includes,
308a0979 2996 link_with : [lib_common],
d4c880d5
ZJS
2997 install_dir : usrbin_exec_dir,
2998 install : true)
2999exes += exe
53b37016 3000manadocs += ['misc-utils/getopt.1.adoc']
38bb89ee 3001bashcompletions += ['getopt']
d4c880d5
ZJS
3002
3003exe = executable(
3004 'fincore',
3005 fincore_sources,
3006 include_directories : includes,
3007 link_with : [lib_common,
3008 lib_smartcols],
3009 install_dir : usrbin_exec_dir,
3010 install : true)
3011if not is_disabler(exe)
3012 exes += exe
53b37016 3013 manadocs += ['misc-utils/fincore.1.adoc']
38bb89ee 3014 bashcompletions += ['fincore']
d4c880d5
ZJS
3015endif
3016
3017exe = executable(
3018 'hardlink',
3019 hardlink_sources,
3020 include_directories : includes,
3021 link_with : [lib_common],
d4c880d5
ZJS
3022 install_dir : usrbin_exec_dir,
3023 install : true)
3024if not is_disabler(exe)
3025 exes += exe
53b37016 3026 manadocs += ['misc-utils/hardlink.1.adoc']
38bb89ee 3027 bashcompletions += ['hardlink']
d4c880d5
ZJS
3028endif
3029
c221578e
NS
3030opt = not get_option('build-pipesz').disabled()
3031exe = executable(
3032 'pipesz',
3033 pipesz_sources,
3034 include_directories : includes,
3035 link_with : [lib_common],
3036 install_dir : usrbin_exec_dir,
3037 install : true)
3038if opt and not is_disabler(exe)
3039 exes += exe
62c27bd0 3040 manadocs += ['misc-utils/pipesz.1.adoc']
80af57ed 3041 bashcompletions += ['pipesz']
c221578e
NS
3042endif
3043
d4c880d5
ZJS
3044exe = executable(
3045 'test_cal',
3046 cal_sources,
3047 include_directories : includes,
3048 c_args : '-DTEST_CAL',
3049 link_with : [lib_common,
3050 lib_tcolors],
ba30b89c 3051 dependencies : [curses_libs],
3052 build_by_default: program_tests)
d4c880d5
ZJS
3053if not is_disabler(exe)
3054 exes += exe
3055endif
3056
64bc8ab5
MY
3057exe = executable(
3058 'fadvise',
3059 fadvise_sources,
3060 include_directories : includes,
3061 link_with : [lib_common],
3062 install_dir : usrbin_exec_dir,
3063 install : true)
3064if not is_disabler(exe)
3065 exes += exe
3066 manadocs += ['misc-utils/fadvise.1.adoc']
3067 bashcompletions += ['fadvise']
3068endif
3069
941e1d55 3070if LINUX and conf.get('HAVE_PIDFD_OPEN').to_string() == '1'
334939a1
ZJS
3071 exe = executable(
3072 'waitpid',
3073 waitpid_sources,
3074 include_directories : includes,
3075 link_with : [lib_common],
3076 install_dir : usrbin_exec_dir,
3077 install : true)
3078 if not is_disabler(exe)
3079 exes += exe
3080 manadocs += ['misc-utils/waitpid.1.adoc']
3081 bashcompletions += ['waitpid']
3082 endif
550d32c4
TW
3083endif
3084
69e542bd
TW
3085syscalls_h = custom_target('syscalls.h',
3086 input : 'tools/all_syscalls',
3087 output : 'syscalls.h',
8e7f1439 3088 command : ['tools/all_syscalls', cc.cmd_array(), get_option('c_args')],
69e542bd
TW
3089)
3090
3e0bbb12
TW
3091if cc.compiles(fs.read('include/audit-arch.h'), name : 'has AUDIT_ARCH_NATIVE')
3092 exe = executable(
3093 'enosys',
ced129dc 3094 'misc-utils/enosys.c', syscalls_h, errnos_h,
3e0bbb12
TW
3095 include_directories : includes,
3096 link_with : [lib_common],
3097 install_dir : usrbin_exec_dir,
3098 install : true)
3099 if not is_disabler(exe)
3100 exes += exe
3101 manadocs += ['misc-utils/enosys.1.adoc']
3102 bashcompletions += ['enosys']
3103 endif
cba52cc1
TW
3104endif
3105
e9ddea79
TW
3106exe = executable(
3107 'lsclocks',
3108 lsclocks_sources,
3109 include_directories : includes,
3110 link_with : [lib_common, lib_smartcols],
3111 install_dir : usrbin_exec_dir,
3112 install : true)
3113if not is_disabler(exe)
3114 exes += exe
3115 manadocs += ['misc-utils/lsclocks.1.adoc']
3116 bashcompletions += ['lsclocks']
3117endif
3118
cd094a05
MY
3119if conf.get('HAVE_RENAMEAT2').to_string() == '1'
3120exe = executable(
3121 'exch',
3122 exch_sources,
3123 include_directories : includes,
3124 link_with : [lib_common],
3125 install_dir : usrbin_exec_dir,
3126 install : true)
3127if not is_disabler(exe)
3128 exes += exe
3129 manadocs += ['misc-utils/exch.1.adoc']
3130 bashcompletions += ['exch']
3131endif
3132endif
3133
d4c880d5
ZJS
3134############################################################
3135
3136opt = not get_option('build-schedutils').disabled()
3137exe = executable(
3138 'chrt',
3139 'schedutils/chrt.c',
3140 include_directories : includes,
3141 link_with : lib_common,
3142 install_dir : usrbin_exec_dir,
3143 install : opt,
3144 build_by_default : opt)
3145
3146exe2 = executable(
3147 'ionice',
3148 'schedutils/ionice.c',
3149 include_directories : includes,
3150 link_with : lib_common,
3151 install_dir : usrbin_exec_dir,
3152 install : opt,
3153 build_by_default : opt)
3154
3155exe3 = executable(
3156 'taskset',
3157 'schedutils/taskset.c',
3158 include_directories : includes,
3159 link_with : lib_common,
3160 install_dir : usrbin_exec_dir,
3161 install : opt,
3162 build_by_default : opt)
3163
6e92db54
KZ
3164exe4 = executable(
3165 'uclampset',
3166 'schedutils/uclampset.c',
3167 include_directories : includes,
3168 link_with : lib_common,
3169 install_dir : usrbin_exec_dir,
3170 install : opt,
3171 build_by_default : opt)
3172
d4c880d5 3173if opt and not is_disabler(exe)
6e92db54 3174 exes += [exe, exe2, exe3, exe4]
53b37016
KZ
3175 manadocs += ['schedutils/chrt.1.adoc',
3176 'schedutils/ionice.1.adoc',
3177 'schedutils/taskset.1.adoc',
3178 'schedutils/uclampset.1.adoc']
38bb89ee 3179 bashcompletions += ['chrt', 'ionice', 'taskset', 'uclampset']
d4c880d5
ZJS
3180endif
3181
3182############################################################
3183
3184# TODO: when autotools compat is not needed, s/_/-/g in file names?
3185
3186exe = executable(
3187 'test_ttyutils',
3188 'lib/ttyutils.c',
3189 c_args : ['-DTEST_PROGRAM_TTYUTILS'],
3190 include_directories : dir_include,
ba30b89c 3191 link_with : lib_common,
3192 build_by_default: program_tests)
d4c880d5
ZJS
3193exes += exe
3194
3195exe = executable(
3196 'test_blkdev',
3197 'lib/blkdev.c',
3198 c_args : ['-DTEST_PROGRAM_BLKDEV'],
3199 include_directories : dir_include,
ba30b89c 3200 link_with : lib_common,
3201 build_by_default: program_tests)
d4c880d5
ZJS
3202exes += exe
3203
3204exe = executable(
3205 'test_ismounted',
3206 'lib/ismounted.c',
3207 c_args : ['-DTEST_PROGRAM_ISMOUNTED'],
3208 include_directories : dir_include,
ba30b89c 3209 link_with : lib_common,
3210 build_by_default: program_tests)
d4c880d5
ZJS
3211exes += exe
3212
3213exe = executable(
3214 'test_mangle',
3215 'lib/mangle.c',
3216 c_args : ['-DTEST_PROGRAM_MANGLE'],
ba30b89c 3217 include_directories : dir_include,
3218 build_by_default: program_tests)
d4c880d5
ZJS
3219exes += exe
3220
3221exe = executable(
3222 'test_strutils',
3223 'lib/strutils.c',
3224 c_args : ['-DTEST_PROGRAM_STRUTILS'],
ba30b89c 3225 include_directories : dir_include,
3226 build_by_default: program_tests)
d4c880d5
ZJS
3227exes += exe
3228
3229exe = executable(
3230 'test_colors',
3231 'lib/colors.c',
3232 'lib/color-names.c',
3233 c_args : ['-DTEST_PROGRAM_COLORS'],
3234 include_directories : dir_include,
ba30b89c 3235 link_with : [lib_common, lib_tcolors],
3236 build_by_default: program_tests)
d4c880d5
ZJS
3237exes += exe
3238
3239exe = executable(
3240 'test_randutils',
3241 'lib/randutils.c',
3242 c_args : ['-DTEST_PROGRAM_RANDUTILS'],
ba30b89c 3243 include_directories : dir_include,
3244 build_by_default: program_tests)
d4c880d5
ZJS
3245exes += exe
3246
941e1d55
TW
3247if conf.get('HAVE_OPENAT').to_string() == '1' \
3248 and conf.get('HAVE_DIRFD').to_string() == '1'
d6418774
ZJS
3249 exe = executable(
3250 'test_procfs',
3251 'lib/procfs.c',
3252 c_args : ['-DTEST_PROGRAM_PROCFS'],
3253 include_directories : dir_include,
ba30b89c 3254 link_with : lib_common,
3255 build_by_default: program_tests)
d6418774 3256 exes += exe
d4c880d5 3257
d6418774
ZJS
3258 exe = executable(
3259 'test_path',
3260 'lib/path.c',
3261 'lib/fileutils.c',
3262 have_cpu_set_t ? 'lib/cpuset.c' : [],
3263 c_args : ['-DTEST_PROGRAM_PATH'],
3264 include_directories : dir_include,
ba30b89c 3265 link_with : lib_common,
3266 build_by_default: program_tests)
d6418774
ZJS
3267 exes += exe
3268endif
d4c880d5 3269
941e1d55 3270if conf.get('HAVE_PTY').to_string() == '1'
44475360
ZJS
3271 exe = executable(
3272 'test_pty',
3273 pty_session_c,
3274 monotonic_c,
3275 c_args : ['-DTEST_PROGRAM_PTY'],
3276 include_directories : dir_include,
3277 link_with : [lib_common],
3278 dependencies : [lib_m,
3279 realtime_libs,
ba30b89c 3280 lib_util],
3281 build_by_default: program_tests)
44475360
ZJS
3282 exes += exe
3283endif
d4c880d5 3284
d6418774
ZJS
3285if LINUX
3286 exe = executable(
3287 'test_cpuset',
3288 'lib/cpuset.c',
3289 c_args : ['-DTEST_PROGRAM_CPUSET'],
ba30b89c 3290 include_directories : dir_include,
3291 build_by_default: program_tests)
d6418774
ZJS
3292 exes += exe
3293endif
d4c880d5
ZJS
3294
3295exe = executable(
3296 'test_sysfs',
3297 'lib/sysfs.c',
3298 'lib/path.c',
35d26ae8 3299 'lib/buffer.c',
fb8493fd 3300 'lib/mbsalign.c',
d4c880d5
ZJS
3301 'lib/fileutils.c',
3302 have_cpu_set_t ? 'lib/cpuset.c' : [],
3303 c_args : ['-DTEST_PROGRAM_SYSFS'],
ba30b89c 3304 include_directories : dir_include,
3305 build_by_default: program_tests)
d4c880d5
ZJS
3306exes += exe
3307
3308exe = executable(
3309 'test_pager',
3310 'lib/pager.c',
3311 c_args : ['-DTEST_PROGRAM_PAGER'],
ba30b89c 3312 include_directories : dir_include,
3313 build_by_default: program_tests)
d4c880d5
ZJS
3314exes += exe
3315
3316exe = executable(
3317 'test_linux_version',
3318 'lib/linux_version.c',
3319 c_args : ['-DTEST_PROGRAM_LINUXVERSION'],
ba30b89c 3320 include_directories : dir_include,
3321 build_by_default: program_tests)
d4c880d5
ZJS
3322exes += exe
3323
3324exe = executable(
3325 'test_fileutils',
3326 'lib/fileutils.c',
3327 c_args : ['-DTEST_PROGRAM_FILEUTILS'],
ba30b89c 3328 include_directories : dir_include,
3329 build_by_default: program_tests)
d4c880d5
ZJS
3330exes += exe
3331
3332exe = executable(
3333 'test_canonicalize',
3334 'lib/canonicalize.c',
3335 c_args : ['-DTEST_PROGRAM_CANONICALIZE'],
ba30b89c 3336 include_directories : dir_include,
3337 build_by_default: program_tests)
d4c880d5
ZJS
3338exes += exe
3339
3340exe = executable(
3341 'test_timeutils',
3342 'lib/timeutils.c',
3343 'lib/strutils.c',
3344 c_args : ['-DTEST_PROGRAM_TIMEUTILS'],
ba30b89c 3345 include_directories : dir_include,
3346 build_by_default: program_tests)
d4c880d5
ZJS
3347exes += exe
3348
3349exe = executable(
3350 'test_pwdutils',
3351 'lib/pwdutils.c',
3352 c_args : ['-DTEST_PROGRAM'],
3353 include_directories : dir_include,
ba30b89c 3354 link_with : lib_common,
3355 build_by_default: program_tests)
d4c880d5
ZJS
3356exes += exe
3357
866d922b
KZ
3358exe = executable(
3359 'test_logindefs',
3360 'lib/logindefs.c',
3361 c_args : ['-DTEST_PROGRAM'],
3362 include_directories : dir_include,
ba30b89c 3363 link_with : [lib_common, logindefs_c],
3364 build_by_default: program_tests)
866d922b
KZ
3365exes += exe
3366
3367
d4c880d5
ZJS
3368############################################################
3369
3370exe = executable(
3371 'test_uuid_parser',
3372 'libuuid/src/test_uuid.c',
3373 include_directories : [dir_include, dir_libuuid],
3374 link_with : lib_uuid,
ba30b89c 3375 dependencies : socket_libs,
3376 build_by_default: program_tests)
d4c880d5
ZJS
3377if not is_disabler(exe)
3378 exes += exe
3379endif
3380
3381############################################################
3382
2a472ae8 3383libfdisk_tests_cflags = ['-DTEST_PROGRAM']
a764efb5
JW
3384libfdisk_tests_ldadd = [lib_fdisk_static, lib_uuid]
3385libfdisk_tests_ldadd_deps = [blkid_dep]
d4c880d5
ZJS
3386
3387exe = executable(
3388 'test_fdisk_ask',
3389 'libfdisk/src/ask.c',
3390 c_args : libfdisk_tests_cflags,
3391 include_directories : lib_fdisk_includes,
ba30b89c 3392 link_with : libfdisk_tests_ldadd,
a764efb5 3393 dependencies : libfdisk_tests_ldadd_deps,
ba30b89c 3394 build_by_default: program_tests)
d4c880d5
ZJS
3395if not is_disabler(exe)
3396 exes += exe
3397endif
3398
3399exe = executable(
3400 'test_fdisk_gpt',
3401 'libfdisk/src/gpt.c',
3402 c_args : libfdisk_tests_cflags,
3403 include_directories : lib_fdisk_includes,
ba30b89c 3404 link_with : libfdisk_tests_ldadd,
a764efb5 3405 dependencies : libfdisk_tests_ldadd_deps,
ba30b89c 3406 build_by_default: program_tests)
d4c880d5
ZJS
3407if not is_disabler(exe)
3408 exes += exe
3409endif
3410
3411exe = executable(
3412 'test_fdisk_utils',
3413 'libfdisk/src/utils.c',
3414 c_args : libfdisk_tests_cflags,
3415 include_directories : lib_fdisk_includes,
ba30b89c 3416 link_with : libfdisk_tests_ldadd,
a764efb5 3417 dependencies : libfdisk_tests_ldadd_deps,
ba30b89c 3418 build_by_default: program_tests)
d4c880d5
ZJS
3419if not is_disabler(exe)
3420 exes += exe
3421endif
3422
3423exe = executable(
3424 'test_fdisk_script',
3425 'libfdisk/src/script.c',
3426 c_args : libfdisk_tests_cflags,
3427 include_directories : lib_fdisk_includes,
ba30b89c 3428 link_with : libfdisk_tests_ldadd,
a764efb5 3429 dependencies : libfdisk_tests_ldadd_deps,
ba30b89c 3430 build_by_default: program_tests)
d4c880d5
ZJS
3431if not is_disabler(exe)
3432 exes += exe
3433endif
3434
3435exe = executable(
3436 'test_fdisk_version',
3437 'libfdisk/src/version.c',
3438 c_args : libfdisk_tests_cflags,
3439 include_directories : lib_fdisk_includes,
ba30b89c 3440 link_with : libfdisk_tests_ldadd,
a764efb5 3441 dependencies : libfdisk_tests_ldadd_deps,
ba30b89c 3442 build_by_default: program_tests)
d4c880d5
ZJS
3443if not is_disabler(exe)
3444 exes += exe
3445endif
3446
3447exe = executable(
3448 'test_fdisk_item',
3449 'libfdisk/src/item.c',
3450 c_args : libfdisk_tests_cflags,
3451 include_directories : lib_fdisk_includes,
ba30b89c 3452 link_with : libfdisk_tests_ldadd,
a764efb5 3453 dependencies : libfdisk_tests_ldadd_deps,
ba30b89c 3454 build_by_default: program_tests)
d4c880d5
ZJS
3455if not is_disabler(exe)
3456 exes += exe
3457endif
3458
d4c880d5
ZJS
3459sample_fdisk_ldadd = [lib_common, lib_fdisk]
3460
3461exe = executable(
3462 'sample-fdisk-mkpart',
3463 'libfdisk/samples/mkpart.c',
d4c880d5
ZJS
3464 include_directories : lib_fdisk_includes,
3465 link_with : sample_fdisk_ldadd)
3466if not is_disabler(exe)
3467 exes += exe
3468endif
3469
3470exe = executable(
3471 'sample-fdisk-mkpart-fullspec',
3472 'libfdisk/samples/mkpart-fullspec.c',
d4c880d5
ZJS
3473 include_directories : lib_fdisk_includes,
3474 link_with : sample_fdisk_ldadd)
3475if not is_disabler(exe)
3476 exes += exe
3477endif
3478
3479############################################################
3480
a76299c1
TW
3481exe = executable(
3482 'test_cap',
3483 'tests/helpers/test_cap.c',
3484 include_directories : includes,
3485 dependencies : [lib_cap_ng],
3486 build_by_default: program_tests)
512c91a6
TW
3487if not is_disabler(exe)
3488 exes += exe
3489endif
a76299c1 3490
d4c880d5
ZJS
3491exe = executable(
3492 'test_mbsencode',
3493 'tests/helpers/test_mbsencode.c',
3494 include_directories : includes,
ba30b89c 3495 link_with : lib_common,
3496 build_by_default: program_tests)
d4c880d5
ZJS
3497exes += exe
3498
3499exe = executable(
3500 'test_byteswap',
3501 'tests/helpers/test_byteswap.c',
ba30b89c 3502 include_directories : includes,
3503 build_by_default: program_tests)
d4c880d5
ZJS
3504exes += exe
3505
3506exe = executable(
3507 'test_md5',
3508 'tests/helpers/test_md5.c',
3509 md5_c,
ba30b89c 3510 include_directories : includes,
3511 build_by_default: program_tests)
d4c880d5
ZJS
3512exes += exe
3513
3514exe = executable(
3515 'test_sha1',
3516 'tests/helpers/test_sha1.c',
3517 sha1_c,
ba30b89c 3518 include_directories : includes,
3519 build_by_default: program_tests)
d4c880d5
ZJS
3520exes += exe
3521
3522exe = executable(
3523 'test_pathnames',
3524 'tests/helpers/test_pathnames.c',
ba30b89c 3525 include_directories : includes,
3526 build_by_default: program_tests)
d4c880d5
ZJS
3527exes += exe
3528
3529exe = executable(
3530 'test_strerror',
3531 'tests/helpers/test_strerror.c',
ba30b89c 3532 include_directories : includes,
3533 build_by_default: program_tests)
d4c880d5
ZJS
3534exes += exe
3535
3536exe = executable(
3537 'test_sysinfo',
3538 'tests/helpers/test_sysinfo.c',
ba30b89c 3539 include_directories : includes,
3540 build_by_default: program_tests)
d4c880d5
ZJS
3541exes += exe
3542
3543exe = executable(
3544 'test_sigreceive',
3545 'tests/helpers/test_sigreceive.c',
3546 include_directories : includes,
ba30b89c 3547 link_with : lib_common,
3548 build_by_default: program_tests)
d4c880d5
ZJS
3549exes += exe
3550
3551exe = executable(
3552 'test_tiocsti',
3553 'tests/helpers/test_tiocsti.c',
ba30b89c 3554 include_directories : includes,
3555 build_by_default: program_tests)
d4c880d5
ZJS
3556exes += exe
3557
3558exe = executable(
3559 'test_uuid_namespace',
3560 'tests/helpers/test_uuid_namespace.c',
3561 predefined_c,
3562 unpack_c,
3563 unparse_c,
ba30b89c 3564 include_directories : includes,
3565 build_by_default: program_tests)
d4c880d5
ZJS
3566exes += exe
3567
06b27058 3568if LINUX and lib_rt.found()
d6418774
ZJS
3569 exe = executable(
3570 'test_mkfds',
3571 'tests/helpers/test_mkfds.c',
b2033a32 3572 'tests/helpers/test_mkfds.h',
38ffd1e3 3573 'tests/helpers/test_mkfds_ppoll.c',
d6418774 3574 include_directories : includes,
06b27058 3575 dependencies : [lib_rt],
ba30b89c 3576 build_by_default: program_tests)
d6418774
ZJS
3577 exes += exe
3578endif
f7b41ef8 3579
42900563
TW
3580exe = executable(
3581 'test_enosys',
3582 'tests/helpers/test_enosys.c',
ba30b89c 3583 include_directories : includes,
3584 build_by_default: program_tests)
42900563
TW
3585exes += exe
3586
d4c880d5
ZJS
3587############################################################
3588
941e1d55 3589if conf.get('HAVE_OPENAT').to_string() == '1'
d6418774
ZJS
3590 exe = executable(
3591 'sample-scols-tree',
3592 'libsmartcols/samples/tree.c',
3593 include_directories : includes,
ba30b89c 3594 link_with : [lib_smartcols, lib_common],
3595 build_by_default: program_tests)
d6418774
ZJS
3596 if not is_disabler(exe)
3597 exes += exe
3598 endif
d4c880d5
ZJS
3599endif
3600
3601exe = executable(
3602 'sample-scols-title',
3603 'libsmartcols/samples/title.c',
3604 include_directories : includes,
3605 link_with : [lib_smartcols, lib_common])
3606if not is_disabler(exe)
3607 exes += exe
3608endif
3609
3610exe = executable(
3611 'sample-scols-wrap',
3612 'libsmartcols/samples/wrap.c',
3613 include_directories : includes,
3614 link_with : [lib_smartcols, lib_common])
3615if not is_disabler(exe)
3616 exes += exe
3617endif
3618
3619exe = executable(
3620 'sample-scols-continuous',
3621 'libsmartcols/samples/continuous.c',
3622 include_directories : includes,
3623 link_with : [lib_smartcols, lib_common])
3624if not is_disabler(exe)
3625 exes += exe
3626endif
3627
be597292
TW
3628exe = executable(
3629 'sample-scols-continuous-json',
3630 'libsmartcols/samples/continuous-json.c',
3631 include_directories : includes,
3632 link_with : [lib_smartcols, lib_common])
3633if not is_disabler(exe)
3634 exes += exe
3635endif
3636
d4c880d5
ZJS
3637exe = executable(
3638 'sample-scols-maxout',
3639 'libsmartcols/samples/maxout.c',
3640 include_directories : includes,
3641 link_with : [lib_smartcols, lib_common])
3642if not is_disabler(exe)
3643 exes += exe
3644endif
3645
3646exe = executable(
3647 'sample-scols-fromfile',
3648 'libsmartcols/samples/fromfile.c',
3649 include_directories : includes,
3650 link_with : [lib_smartcols, lib_common])
3651if not is_disabler(exe)
3652 exes += exe
3653endif
3654
3655exe = executable(
3656 'sample-scols-grouping-simple',
3657 'libsmartcols/samples/grouping-simple.c',
3658 include_directories : includes,
3659 link_with : [lib_smartcols, lib_common])
3660if not is_disabler(exe)
3661 exes += exe
3662endif
3663
3664exe = executable(
3665 'sample-scols-grouping-overlay',
3666 'libsmartcols/samples/grouping-overlay.c',
3667 include_directories : includes,
3668 link_with : [lib_smartcols, lib_common])
3669if not is_disabler(exe)
3670 exes += exe
3671endif
48afece8
TW
3672
3673exe = executable(
3674 'test_boilerplate',
3675 'Documentation/boilerplate.c',
3676 include_directories : includes,
3677 build_by_default: program_tests)
3678if not is_disabler(exe)
3679 exes += exe
3680endif
d4c880d5
ZJS
3681
3682############################################################
3683
3684# Let the test runner know whether we're running under asan and export
3685# some paths. We use a file on disk so that it is possible to run the
3686# test scripts from commandline without setting any variables.
3687configure_file(output : 'meson.conf',
3688 capture : true,
3689 command : ['echo',
3690 '''asan=@0@
3691PYTHON=@1@
3692'''.format(get_option('b_sanitize')=='address' ? 'yes' : '',
e2cd7446 3693 python.full_path())])
d4c880d5
ZJS
3694
3695run_sh = find_program('tests/run.sh')
3696run_target(
3697 'check',
3698 command : [run_sh,
3699 '--srcdir=' + meson.current_source_dir(),
3700 '--builddir=' + meson.current_build_dir(),
3701 '--parallel',
3702 '--nonroot'],
3703 depends : exes)
53b37016
KZ
3704
3705
3706manadocs += ['lib/terminal-colors.d.5.adoc']
3707manadocs += ['libblkid/libblkid.3.adoc']
3708
3709if build_libuuid
3710 manadocs += [
3711 'libuuid/man/uuid.3.adoc',
3712 'libuuid/man/uuid_clear.3.adoc',
3713 'libuuid/man/uuid_compare.3.adoc',
3714 'libuuid/man/uuid_copy.3.adoc',
3715 'libuuid/man/uuid_generate.3.adoc',
3716 'libuuid/man/uuid_is_null.3.adoc',
3717 'libuuid/man/uuid_parse.3.adoc',
3718 'libuuid/man/uuid_time.3.adoc',
3719 'libuuid/man/uuid_unparse.3.adoc']
38bb89ee
TW
3720 manlinks += {
3721 'uuid_generate_random.3': 'uuid_generate.3',
3722 'uuid_generate_time.3': 'uuid_generate.3',
3723 'uuid_generate_time_safe.3': 'uuid_generate.3',
3724 }
53b37016
KZ
3725endif
3726
00b8a51f 3727asciidoctor = find_program('asciidoctor', required : false)
53b37016
KZ
3728if asciidoctor.found()
3729 foreach adoc : manadocs
3730 name = adoc.split('/')[-1]
3731 page = name.split('.adoc')[0]
3732 section = page.split('.')[-1]
3733 mandirn = join_paths(mandir, 'man' + section)
3734 input = adoc
3735
3736 custom_target(
3737 page,
3738 command : [ asciidoctor,
3739 '-b', 'manpage',
3740 '-a', 'VERSION=' + meson.project_version(),
38bb89ee 3741 '-a', 'release-version=' + meson.project_version(),
53b37016 3742 '-a', 'ADJTIME_PATH=/etc/adjtime',
38bb89ee 3743 '-a', 'package-docdir=' + docdir,
53b37016
KZ
3744 '--base-dir=' + meson.current_source_dir(),
3745 '--destination-dir=' + meson.current_build_dir(),
adcab835
TW
3746 '--load-path', '@SOURCE_ROOT@/tools',
3747 '--require', 'asciidoctor-includetracker',
53b37016
KZ
3748 '@INPUT@'],
3749 input : input,
3750 output : [page],
adcab835 3751 depfile : page + '.deps',
53b37016
KZ
3752 install: true,
3753 install_dir : mandirn)
3754 endforeach
38bb89ee
TW
3755
3756 foreach link_name, target : manlinks
3757 link_section = link_name.split('.')[-1]
3758 target_section = target.split('.')[-1]
3759 meson.add_install_script(meson_make_manpage_stub,
3760 join_paths('man' + target_section, target),
3761 join_paths(mandir, 'man' + link_section, link_name))
3762 endforeach
3763endif
3764
3765if bash_completion.found()
3766 foreach completion : bashcompletions
3767 install_data(
3768 join_paths('bash-completion', completion),
caa85688 3769 install_dir : bash_completion.get_variable(pkgconfig : 'completionsdir')
38bb89ee
TW
3770 )
3771 endforeach
aa519054
KZ
3772 foreach link_name, target : bashcompletionslinks
3773 meson.add_install_script(meson_make_symlink,
3774 target,
caa85688 3775 join_paths(bash_completion.get_variable(pkgconfig : 'completionsdir'), link_name))
aa519054 3776 endforeach
53b37016 3777endif