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