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