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