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