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