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