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