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