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