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