forked from util-linux/util-linux
-
Notifications
You must be signed in to change notification settings - Fork 0
/
meson.build
3334 lines (3018 loc) · 81.1 KB
/
meson.build
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
project('util-linux', 'c',
version : run_command('tools/git-version-gen', check: true).stdout(),
meson_version: '>=0.53.0',
license : 'GPLv2+')
pkgconfig = import('pkgconfig')
libblkid_version = '1.1.0'
libblkid_date = '01-Jun-2021'
libuuid_version = '1.3.0'
libmount_version = '1.1.0'
libsmartcols_version = '1.1.0'
libfdisk_version = '1.1.0'
prefixdir = get_option('prefix')
if not prefixdir.startswith('/')
error('Prefix is not absolute: "@0@"'.format(prefixdir))
endif
bindir = join_paths(prefixdir, get_option('bindir'))
sbindir = join_paths(prefixdir, get_option('sbindir'))
sysconfstaticdir = join_paths(prefixdir, 'lib')
docdir = join_paths(prefixdir, get_option('datadir'), 'doc', 'util-linux')
mandir = join_paths(prefixdir, get_option('mandir'))
runstatedir = '/run'
execprefixdir = prefixdir
usrbin_exec_dir = join_paths(execprefixdir, bindir)
usrsbin_exec_dir = join_paths(execprefixdir, sbindir)
bash_completion = dependency('bash-completion', required : get_option('build-bash-completion'))
vendordir = get_option('vendordir')
add_project_arguments('-D_GNU_SOURCE', language : 'c')
cc = meson.get_compiler('c')
conf = configuration_data()
conf.set_quoted('PACKAGE', meson.project_name())
conf.set_quoted('PACKAGE_VERSION', meson.project_version())
package_string = '@0@ @1@'.format(meson.project_name(), meson.project_version())
conf.set_quoted('PACKAGE_STRING', package_string)
codes = [''' {print $1} ''',
''' {sub("-.*","",$2); print $2} ''',
''' {sub("-.*","",$3); print $3 ~ /^[0-9]+$/ ? $3 : 0} ''']
pc_version = []
foreach code : codes
res = run_command('bash', '-c',
'''echo '@0@' | awk -F. '@1@' '''.format(
meson.project_version(), code), check: true)
pc_version += res.stdout().strip()
endforeach
pc_version = '.'.join(pc_version)
conf.set_quoted('LIBBLKID_VERSION', libblkid_version)
conf.set_quoted('LIBBLKID_DATE', libblkid_date)
conf.set('bindir', bindir)
conf.set('sbindir', sbindir)
conf.set('runstatedir', runstatedir)
conf.set('usrsbin_execdir', usrsbin_exec_dir)
conf.set('docdir', docdir)
conf.set_quoted('_PATH_SYSCONFSTATICDIR', sysconfstaticdir)
conf.set_quoted('_PATH_RUNSTATEDIR', runstatedir)
conf.set_quoted('CONFIG_ADJTIME_PATH', '/etc/adjtime')
conf.set_quoted('ADJTIME_PATH', '/etc/adjtime') # yes, both are used :(
conf.set_quoted('_PATH_VENDORDIR', vendordir)
conf.set('USE_VENDORDIR', vendordir == '' ? false : 1)
build_libblkid = not get_option('build-libblkid').disabled()
conf.set('HAVE_LIBBLKID', build_libblkid ? 1 : false)
summary('libblkid', build_libblkid ? 'enabled' : 'disabled', section : 'components')
build_libuuid = not get_option('build-libuuid').disabled()
conf.set('HAVE_LIBUUID', build_libuuid ? 1 : false)
summary('libuuid', build_libuuid ? 'enabled' : 'disabled', section : 'components')
build_libmount = not get_option('build-libmount').disabled()
conf.set('HAVE_LIBMOUNT', build_libmount ? 1 : false)
conf.set('USE_LIBMOUNT_SUPPORT_NAMESPACES', 1)
summary('libmount', build_libmount ? 'enabled' : 'disabled', section : 'components')
build_libsmartcols = not get_option('build-libsmartcols').disabled()
conf.set('HAVE_LIBSMARTCOLS', build_libsmartcols ? 1 : false)
summary('libsmartcols', build_libsmartcols ? 'enabled' : 'disabled', section : 'components')
build_libfdisk = not get_option('build-libfdisk').disabled()
conf.set('HAVE_LIBFDISK', build_libfdisk ? 1 : false)
summary('libfdisk', build_libfdisk ? 'enabled' : 'disabled', section : 'components')
build_uuidd = not get_option('build-uuidd').disabled()
conf.set('HAVE_UUIDD', build_uuidd ? 1 : false)
summary('uuidd', build_uuidd ? 'enabled' : 'disabled', section : 'components')
static_programs = get_option('static-programs')
need_static_libs = static_programs.length() > 0 # a rough estimate...
summary('static programs', static_programs)
LINUX = host_machine.system() in ['linux']
BSD = host_machine.system() in ['dragonfly', 'freebsd', 'netbsd', 'openbsd']
############################################################
code = '''
#include <wchar.h>
#include <wctype.h>
#include <stdio.h>
#include <stdlib.h>
int main(void) {
wchar_t wc;
wint_t w;
w = fgetwc(stdin);
if (w == WEOF)
return 1;
wc = w;
fputwc(wc,stdout);
return 0;
}
'''
have = cc.compiles(code, name : 'wchar_t support')
if not have and get_option('widechar').enabled()
error('widechar support requested but unavailable')
endif
if get_option('ncurses').enabled() and get_option('widechar').enabled()
error('widechar support is incompatible with non-wide ncurses')
endif
conf.set('HAVE_WIDECHAR', have ? 1 : false)
headers = '''
byteswap.h
crypt.h
endian.h
err.h
errno.h
fcntl.h
getopt.h
inttypes.h
langinfo.h
lastlog.h
libutil.h
locale.h
mntent.h
paths.h
pty.h
shadow.h
stdint.h
stdio_ext.h
stdlib.h
string.h
strings.h
unistd.h
utmp.h
utmpx.h
asm-generic/fcntl.h
asm/fcntl.h
asm/io.h
linux/blkzoned.h
linux/capability.h
linux/cdrom.h
linux/compiler.h
linux/falloc.h
linux/fd.h
linux/fiemap.h
linux/gsmmux.h
linux/net_namespace.h
linux/nsfs.h
linux/securebits.h
linux/tiocl.h
linux/version.h
linux/watchdog.h
net/if.h
net/if_dl.h
netinet/in.h
security/openpam.h
security/pam_appl.h
security/pam_misc.h
sys/disk.h
sys/disklabel.h
sys/endian.h
sys/file.h
sys/io.h
sys/ioccom.h
sys/ioctl.h
sys/mkdev.h
sys/mount.h
sys/param.h
sys/pidfd.h
sys/prctl.h
sys/resource.h
sys/sendfile.h
sys/signalfd.h
sys/socket.h
sys/sockio.h
sys/stat.h
sys/swap.h
sys/syscall.h
sys/sysmacros.h
sys/time.h
sys/timex.h
sys/ttydefaults.h
sys/types.h
sys/ucred.h
sys/un.h
sys/xattr.h
'''.split()
lib_m = cc.find_library('m')
lib_tinfo = dependency(
'tinfo',
required : get_option('tinfo'))
lib_ncursesw = dependency(
'ncursesw',
required : get_option('ncursesw'))
if lib_ncursesw.found()
headers += ['ncursesw/ncurses.h',
'ncursesw/term.h',
'ncurses.h',
'term.h']
lib_ncurses = disabler()
else
lib_ncurses = dependency(
'ncurses',
required : get_option('ncurses'))
headers += ['ncurses.h',
'term.h']
endif
conf.set('HAVE_LIBNCURSESW', lib_ncursesw.found())
conf.set('HAVE_LIBNCURSES', lib_ncurses.found())
conf.set('HAVE_NCURSES', lib_ncursesw.found() or lib_ncurses.found())
lib_slang = dependency(
'slang',
required : get_option('slang'))
if lib_slang.found()
headers += ['slang.h',
'slang/slang.h',
'slcurses.h',
'slang/slcurses.h']
endif
conf.set('HAVE_SLANG', lib_slang.found())
foreach curses_libs : [lib_slang, lib_ncursesw, lib_ncurses]
if curses_libs.found()
have = cc.has_function('use_default_colors', dependencies : curses_libs)
conf.set('HAVE_USE_DEFAULT_COLORS', have ? 1 : false)
have = cc.has_function('resizeterm', dependencies : curses_libs)
conf.set('HAVE_RESIZETERM', have ? 1 : false)
break
endif
endforeach
lib_z = dependency(
'zlib',
required : get_option('zlib'))
lib_readline = dependency(
'readline',
required : get_option('readline'))
conf.set('HAVE_LIBREADLINE', lib_readline.found() ? 1 : false)
lib_readline_static = dependency(
'readline',
static : true,
required : need_static_libs ? get_option('readline') : disabler())
if meson.version().version_compare('>= 0.59.0')
lib_intl = dependency(
'intl',
required : get_option('nls'))
conf.set('ENABLE_NLS', lib_intl.found() ? 1 : false)
else
if get_option('nls').enabled()
error('nls is not supported with meson before 0.59.0')
endif
lib_intl = dependency('', required : false)
endif
lib_user = dependency(
'libuser',
version : '>= 0.58',
required : get_option('libuser'))
conf.set('HAVE_LIBUSER', lib_user.found() ? 1 : false)
lib_util = cc.find_library(
'util',
required : get_option('libutil'))
conf.set('HAVE_LIBUTIL', lib_util.found() ? 1 : false)
lib_utempter = cc.find_library(
'utempter',
required : get_option('libutempter'))
conf.set('HAVE_LIBUTEMPTER', lib_utempter.found() ? 1 : false)
systemd = dependency(
'systemd',
required : get_option('systemd'))
lib_systemd = dependency(
'libsystemd',
required : get_option('systemd'))
conf.set('HAVE_LIBSYSTEMD', lib_systemd.found() ? 1 : false)
lib_udev = dependency(
'libudev',
required : get_option('systemd'))
conf.set('HAVE_LIBUDEV', lib_udev.found() ? 1 : false)
lib_crypt = cc.find_library('crypt')
lib_pam = cc.find_library('pam', required : get_option('build-login'))
if not lib_pam.found()
lib_pam = cc.find_library('pam', required : get_option('build-chfn-chsh'))
endif
if not lib_pam.found()
lib_pam = cc.find_library('pam', required : get_option('build-su'))
endif
if not lib_pam.found()
lib_pam = cc.find_library('pam', required : get_option('build-runuser'))
endif
if lib_pam.found()
lib_pam_misc = cc.find_library('pam_misc')
lib_pam = [lib_pam, lib_pam_misc]
else
lib_pam_misc = declare_dependency()
endif
lib_cryptsetup = dependency(
'libcryptsetup',
required : get_option('cryptsetup'))
conf.set('HAVE_CRYPTSETUP', lib_cryptsetup.found() ? 1 : false)
if not get_option('cryptsetup').disabled() and get_option('cryptsetup-dlopen').enabled()
if meson.version().version_compare('>= 0.62.0')
lib_dl = dependency('dl')
else
lib_dl = cc.find_library('dl')
endif
conf.set('CRYPTSETUP_VIA_DLOPEN', 1)
summary('cryptsetup support (dlopen)',
'enabled',
section : 'components')
else
summary('cryptsetup support',
lib_cryptsetup.found() ? 'enabled' : 'disabled',
section : 'components')
endif
have = cc.has_function(
'crypt_activate_by_signed_key',
dependencies : lib_cryptsetup)
conf.set('HAVE_CRYPT_ACTIVATE_BY_SIGNED_KEY', have ? 1 : false)
lib_cap_ng = dependency(
'libcap-ng',
required : get_option('build-setpriv'))
lib_selinux = dependency(
'libselinux',
version : '>= 2.5',
required : get_option('selinux'))
conf.set('HAVE_LIBSELINUX', lib_selinux.found() ? 1 : false)
lib_magic = dependency(
'libmagic',
required : get_option('magic'))
conf.set('HAVE_MAGIC', lib_magic.found() ? 1 : false)
lib_econf = dependency(
'libeconf',
required : get_option('econf'))
conf.set('HAVE_LIBECONF', lib_econf.found() ? 1 : false)
lib_audit = dependency(
'libaudit',
required : get_option('audit'))
conf.set('HAVE_LIBAUDIT', lib_audit.found() ? 1 : false)
conf.set('HAVE_SMACK', not get_option('smack').disabled())
foreach header : headers
have = cc.has_header(header)
conf.set('HAVE_' + header.underscorify().to_upper(), have ? 1 : false)
endforeach
header = 'linux/btrfs.h'
enable_btrfs = cc.has_header(header,
required : get_option('btrfs'))
conf.set('HAVE_' + header.underscorify().to_upper(), enable_btrfs ? 1 : false)
conf.set('HAVE_BTRFS_SUPPORT', enable_btrfs ? 1 : false)
prefix = conf.get('HAVE_LINUX_COMPILER_H') ? '#include <linux/compiler.h>' : ''
foreach header : [
'linux/blkpg.h',
'linux/major.h',
]
have = cc.has_header(header,
prefix : prefix)
conf.set('HAVE_' + header.underscorify().to_upper(), have ? 1 : false)
endforeach
have = cc.has_header('sched.h')
conf.set10('HAVE_DECL_CPU_ALLOC', have)
# We get -1 if the size cannot be determined
have_cpu_set_t = cc.sizeof('cpu_set_t', prefix : '#define _GNU_SOURCE\n#include <sched.h>') > 0
conf.set('HAVE_CPU_SET_T', have_cpu_set_t ? 1 : false)
have = cc.has_header_symbol('unistd.h', 'environ', args : '-D_GNU_SOURCE')
conf.set10('HAVE_ENVIRON_DECL', have)
have = cc.has_header_symbol('signal.h', 'sighandler_t', args : '-D_GNU_SOURCE')
conf.set('HAVE_SIGHANDLER_T', have ? 1 : false)
have = cc.has_function('strsignal')
conf.set10('HAVE_STRSIGNAL_DECL', have)
have = cc.sizeof('union semun', prefix : '#include <sys/sem.h>') > 0
conf.set('HAVE_UNION_SEMUN', have ? 1 : false)
have = cc.compiles('''
#define _GNU_SOURCE 1
#include <langinfo.h>
int main(void) {
char *str;
str = nl_langinfo (ALTMON_1);
str = nl_langinfo (ALTMON_2);
str = nl_langinfo (ALTMON_3);
str = nl_langinfo (ALTMON_4);
str = nl_langinfo (ALTMON_5);
str = nl_langinfo (ALTMON_6);
str = nl_langinfo (ALTMON_7);
str = nl_langinfo (ALTMON_8);
str = nl_langinfo (ALTMON_9);
str = nl_langinfo (ALTMON_10);
str = nl_langinfo (ALTMON_11);
str = nl_langinfo (ALTMON_12);
return 0;
}
''',
name : 'langinfo.h defines ALTMON_x constants')
conf.set('HAVE_LANGINFO_ALTMON', have ? 1 : false)
have = cc.compiles('''
#define _GNU_SOURCE 1
#include <langinfo.h>
int main(void) {
char *str;
str = nl_langinfo (_NL_ABALTMON_1);
str = nl_langinfo (_NL_ABALTMON_2);
str = nl_langinfo (_NL_ABALTMON_3);
str = nl_langinfo (_NL_ABALTMON_4);
str = nl_langinfo (_NL_ABALTMON_5);
str = nl_langinfo (_NL_ABALTMON_6);
str = nl_langinfo (_NL_ABALTMON_7);
str = nl_langinfo (_NL_ABALTMON_8);
str = nl_langinfo (_NL_ABALTMON_9);
str = nl_langinfo (_NL_ABALTMON_10);
str = nl_langinfo (_NL_ABALTMON_11);
str = nl_langinfo (_NL_ABALTMON_12);
return 0;
}
''',
name : 'langinfo.h defines _NL_ABALTMON_x constants')
conf.set('HAVE_LANGINFO_NL_ABALTMON', have ? 1 : false)
funcs = '''
clearenv
close_range
__fpurge
fpurge
__fpending
secure_getenv
__secure_getenv
eaccess
err
errx
explicit_bzero
fmemopen
fseeko
fsync
utimensat
getdomainname
getdtablesize
getexecname
getmntinfo
getrandom
getrlimit
getsgnam
inotify_init
jrand48
lchown
lgetxattr
llistxattr
llseek
newlocale
mempcpy
mkostemp
nanosleep
ntp_gettime
personality
pidfd_open
pidfd_send_signal
posix_fadvise
prctl
qsort_r
rpmatch
scandirat
setprogname
sendfile
setns
setresgid
setresuid
sched_setattr
sched_setscheduler
sigqueue
srandom
strnchr
strndup
strnlen
strtod_l
sysconf
sysinfo
swapon
swapoff
timegm
unshare
usleep
uselocale
utimensat
vwarnx
warn
warnx
prlimit
openat
fstatat
unlinkat
ioperm
iopl
futimens
inotify_init1
open_memstream
reboot
getusershell
'''.split()
foreach func: funcs
have = cc.has_function(func)
# For autotools compatibility, use either #define FOO 1 or #undef FOO.
# This makes little sense, but is necessary to avoid warnings about
# redefined macros from Python.h, which uses this convention.
conf.set('HAVE_' + func.to_upper(), have ? 1 : false)
endforeach
have = conf.get('HAVE_FUTIMENS') in [1] and conf.get('HAVE_INOTIFY_INIT1') in [1]
conf.set('AGETTY_RELOAD', have ? 1 : false)
if not have
warning('futimens or inotify_init1 not found; agetty(8) will not provide --reload functionality')
endif
have_dirfd = (cc.has_function('dirfd') or
cc.has_header_symbol('dirent.h', 'dirfd',
prefix : '#include <sys/types.h>'))
conf.set('HAVE_DIRFD', have_dirfd ? 1 : false)
have_ddfd = cc.has_member('DIR', 'dd_fd',
prefix : '''
#include <sys/types.h>
#include <dirent.h>
''')
conf.set('HAVE_DECL_DDFD', have_ddfd ? 1 : false)
have = cc.has_member('struct tm', 'tm_gmtoff',
prefix : '''
#include <time.h>
#include <unistd.h>
''')
conf.set('HAVE_TM_GMTOFF', have ? 1 : false)
have = cc.has_member('struct termios', 'c_line',
prefix : '#include <termios.h>')
conf.set('HAVE_STRUCT_TERMIOS_C_LINE', have ? 1 : false)
have = cc.has_member('struct stat', 'st_mtim.tv_nsec',
prefix : '#include <sys/stat.h>')
conf.set('HAVE_STRUCT_STAT_ST_MTIM_TV_NSEC', have ? 1 : false)
# replacement for AC_STRUCT_TIMEZONE
have = cc.has_member('struct tm', 'tm_zone',
prefix : '#include <time.h>')
conf.set('HAVE_STRUCT_TM_TM_ZONE', have ? 1 : false)
have = cc.has_header_symbol('time.h', 'tzname', args: '-D_GNU_SOURCE')
conf.set('HAVE_DECL_TZNAME', have ? 1 : false)
code = '''
#include <time.h>
#if !@0@
extern char *tzname[];
#endif
int main(void) {
return tzname ? 0 : 1;
}
'''.format(have ? 1 : 0)
have = cc.compiles(code, name : 'using tzname[]')
conf.set('HAVE_TZNAME', have ? 1 : false)
socket_libs = []
if not cc.has_function('socket')
socket_libs += cc.find_library('socket', required : true)
have = cc.has_function('socket',
dependencies : socket_libs)
if not have
error('socket() function not available')
endif
endif
realtime_libs = []
have = cc.has_function('clock_gettime')
if not have
realtime_libs += cc.find_library('rt', required : true)
have = cc.has_function('clock_gettime',
dependencies : realtime_libs)
endif
conf.set('HAVE_CLOCK_GETTIME', have ? 1 : false)
thread_libs = dependency('threads')
have = cc.has_function('timer_create')
if not have
realtime_libs = [cc.find_library('rt', required : true)]
have = cc.has_function('timer_create',
dependencies : realtime_libs)
if not have
realtime_libs += thread_libs
have = cc.has_function('timer_create',
dependencies : realtime_libs)
endif
endif
conf.set('HAVE_TIMER_CREATE', have ? 1 : false)
if not have
have = cc.has_function('setitimer')
conf.set('HAVE_SETITIMER', have ? 1 : false)
endif
rtas_libs = cc.find_library('rtas', required : false)
conf.set('HAVE_LIBRTAS', rtas_libs.found() ? 1 : false)
math_libs = []
if not cc.has_header_symbol('math.h', 'isnan')
lib = cc.find_library('m', required : true)
if (cc.has_function('isnan', dependencies : lib) and
cc.has_function('__isnan', dependencies : lib))
math_libs += lib
endif
endif
have = cc.has_header_symbol('errno.h', 'program_invocation_short_name',
args : '-D_GNU_SOURCE')
conf.set('HAVE_PROGRAM_INVOCATION_SHORT_NAME', have ? 1 : false)
code = '''
extern char *__progname;
int main(void) {
return (*__progname != 0);
}
'''
have = cc.compiles(code, name : 'using __progname')
conf.set('HAVE___PROGNAME', have ? 1 : false)
build_plymouth_support = get_option('build-plymouth-support')
have_tiocglcktrmios = cc.has_header_symbol(
'sys/ioctl.h', 'TIOCGLCKTRMIOS',
required : build_plymouth_support.enabled())
have_sock_cloexec = cc.has_header_symbol(
'sys/socket.h', 'SOCK_CLOEXEC',
prefix : '#include <sys/types.h>',
required : build_plymouth_support.enabled())
have_sock_nonblock = cc.has_header_symbol(
'sys/socket.h', 'SOCK_NONBLOCK',
prefix : '#include <sys/types.h>',
required : build_plymouth_support.enabled())
have_so_passcred = cc.has_header_symbol(
'sys/socket.h', 'SO_PASSCRED',
prefix : '#include <sys/types.h>',
required : build_plymouth_support.enabled())
build_plymouth_support = (not build_plymouth_support.disabled() and
have_tiocglcktrmios and
have_sock_cloexec and
have_sock_nonblock and
have_so_passcred)
conf.set('ENABLE_PLYMOUTH_SUPPORT', build_plymouth_support ? 1 : false)
summary('plymouth support',
build_plymouth_support ? 'enabled' : 'disabled',
section : 'components')
# check for valid fallocate() function
# with 32 bits glibc 2.10, fallocate() exists but not fallocate64()
# when _FILE_OFFSET_BITS==64, fallocate() is redirect to fallocate64()
# and program can't be linked.
code = '''
#define _GNU_SOURCE
#include <unistd.h>
#include <fcntl.h>
int main(void) {
long ret;
ret = fallocate(0, FALLOC_FL_KEEP_SIZE, 0xfffffffful, 0xfffffffful);
return ret == 0 ? 0 : 1;
}
'''
have = cc.links(code, name : 'fallocate() function')
conf.set('HAVE_FALLOCATE', have ? 1 : false)
code = '''
#include <unistd.h>
#include <fcntl.h>
int main(void) {
long ret;
ret = posix_fallocate(0, 0xfffffffful, 0xfffffffful);
return ret == 0 ? 0 : 1;
}
'''
have = cc.links(code, name : 'posix_fallocate() function')
conf.set('HAVE_POSIX_FALLOCATE', have ? 1 : false)
use_hwclock_cmos = host_machine.cpu_family() in ['x86', 'x86_64']
message('Use CMOS clock: @0@'.format(use_hwclock_cmos))
conf.set('USE_HWCLOCK_CMOS', use_hwclock_cmos ? 1 : false)
conf.set('HAVE_TLS', get_option('use-tls') ? 1 : false)
conf.set('PG_BELL', get_option('pg-bell') ? 1 : false)
conf.set('USE_COLORS_BY_DEFAULT', get_option('colors-default') ? 1 : false)
############################################################
fs_search_path = get_option('fs-search-path')
fs_search_path_extra = get_option('fs-search-path-extra')
if fs_search_path_extra != ''
fs_search_path = ':'.join(fs_search_path, fs_search_path_extra)
endif
conf.set_quoted('FS_SEARCH_PATH', fs_search_path)
systemdsystemunitdir = ''
if systemd.found()
systemdsystemunitdir = systemd.get_variable(pkgconfig : 'systemdsystemunitdir')
endif
chfn_chsh_password = get_option('chfn-chsh-password') or lib_user.found()
conf.set('CHFN_CHSH_PASSWORD', chfn_chsh_password ? 1 : false)
have = get_option('chsh-only-listed')
conf.set('ONLY_LISTED_SHELLS', have ? 1 : false)
have = get_option('use-tty-group')
conf.set('USE_TTY_GROUP', have ? 1 : false)
build_hwclock = not get_option('build-hwclock').disabled()
bison = find_program('bison', required: build_hwclock)
bison_gen = generator(
bison,
output : ['@BASENAME@.tab.c', '@BASENAME@.tab.h'],
arguments : ['@INPUT@', '--defines=@OUTPUT1@', '--output=@OUTPUT0@'])
meson_make_symlink = meson.current_source_dir() + '/tools/meson-make-symlink.sh'
meson_make_manpage_stub = meson.current_source_dir() + '/tools/meson-make-manpage-stub.sh'
configure_file(
output : 'config.h',
configuration : conf)
add_project_arguments('-include', meson.current_build_dir() / 'config.h', language : 'c')
compiler_flags = [
'-fno-common',
'-Waddress-of-packed-member',
'-Wdiscarded-qualifiers',
'-Wembedded-directive',
'-Wextra-semi',
'-Wformat-security',
'-Wimplicit-function-declaration',
'-Wmissing-declarations',
'-Wmissing-parameter-type',
'-Wmissing-prototypes',
'-Wnested-externs',
'-Wno-missing-field-initializers',
'-Wpointer-arith',
'-Wredundant-decls',
'-Wsign-compare',
'-Wstrict-prototypes',
'-Wtype-limits',
'-Wuninitialized',
'-Wunused-but-set-parameter',
'-Wunused-but-set-variable',
'-Wunused-parameter',
'-Wunused-result',
'-Wunused-variable',
]
foreach compiler_flag : compiler_flags
if cc.has_argument(compiler_flag)
add_project_arguments(compiler_flag, language : 'c')
endif
endforeach
manadocs = []
manlinks = {}
bashcompletions = []
bashcompletionslinks = {}
subdir('include')
subdir('lib')
subdir('libblkid')
subdir('libmount')
subdir('libsmartcols')
subdir('libuuid')
subdir('libfdisk')
subdir('login-utils')
subdir('sys-utils')
subdir('disk-utils')
subdir('misc-utils')
subdir('text-utils')
subdir('term-utils')
subdir('po')
includes = [dir_include,
dir_libblkid,
dir_libsmartcols,
dir_libmount,
dir_libfdisk,
dir_libuuid,
dir_sys_utils]
exes = []
opt = not get_option('build-chfn-chsh').disabled()
exe = executable(
'chfn',
chfn_sources,
chfn_chsh_sources,
include_directories : includes,
link_with : [lib_common, logindefs_c],
dependencies : chfn_chsh_deps,
install_dir : usrbin_exec_dir,
install : opt,
build_by_default : opt)
exe2 = executable(
'chsh',
'login-utils/chsh.c',
chfn_chsh_sources,
include_directories : includes,
link_with : lib_common,
dependencies : chfn_chsh_deps,
install_dir : usrbin_exec_dir,
install : opt,
build_by_default : opt)
if opt and not is_disabler(exe)
exes += [exe, exe2]
manadocs += ['login-utils/chfn.1.adoc', 'login-utils/chsh.1.adoc']
bashcompletions += ['chfn', 'chsh']
endif
exe = executable(
'test_islocal',
test_islocal_sources,
include_directories : includes,
c_args : '-DTEST_PROGRAM')
exes += exe
exe = executable(
'test-consoles',
test_consoles_sources,
c_args : ['-DTEST_PROGRAM'],
include_directories : includes,
link_with : lib_common)
exes += exe
opt = not get_option('build-last').disabled()
exe = executable(
'last',
last_sources,
include_directories : includes,
link_with : [lib_common],
install_dir : usrbin_exec_dir,
install : opt,
build_by_default : opt)
if opt and not is_disabler(exe)
exes += exe
meson.add_install_script(meson_make_symlink,
'last',
join_paths(usrbin_exec_dir, 'lastb'))
manadocs += ['login-utils/last.1.adoc']
manlinks += {'lastb.1': 'last.1'}
bashcompletions += ['last']
bashcompletionslinks += {'lastb': 'last'}
endif
opt = not get_option('build-nologin').disabled()
exe = executable(
'nologin',
'login-utils/nologin.c',
include_directories : includes,
install_dir : sbindir,
link_with : [lib_common],
install : opt,
build_by_default : opt)
if opt and not is_disabler(exe)
exes += exe
manadocs += ['login-utils/nologin.8.adoc']
endif
opt = not get_option('build-utmpdump').disabled()
exe = executable(
'utmpdump',
'login-utils/utmpdump.c',
include_directories : includes,
link_with : [lib_common],
install_dir : usrbin_exec_dir,
install : opt,
build_by_default : opt)
if opt and not is_disabler(exe)
exes += exe
manadocs += ['login-utils/utmpdump.1.adoc']
bashcompletions += ['utmpdump']
endif
opt = not get_option('build-su').disabled()
exe = executable(
'su',
'login-utils/su.c',
'login-utils/su-common.c',
'login-utils/su-common.h',
'lib/logindefs.c',
pty_session_c,
monotonic_c,
include_directories : includes,
link_with : [lib_common, logindefs_c],
dependencies : [lib_pam,
lib_pam_misc,
lib_util,
realtime_libs],
install : opt,
build_by_default : opt)
if opt and not is_disabler(exe)
exes += exe
manadocs += ['login-utils/su.1.adoc']
bashcompletions += ['su']
endif
opt = not get_option('build-newgrp').disabled()
exe = executable(
'newgrp',
'login-utils/newgrp.c',
include_directories : includes,
dependencies : [lib_crypt],
install_dir : usrbin_exec_dir,
install : opt,
build_by_default : opt)
if opt and not is_disabler(exe)
exes += exe
manadocs += ['login-utils/newgrp.1.adoc']
endif
opt = not get_option('build-lslogins').disabled()
exe = executable(
'lslogins',
'login-utils/lslogins.c',
'lib/logindefs.c',
include_directories : includes,
link_with : [lib_common,
lib_smartcols,
logindefs_c],
dependencies : [lib_selinux,
lib_systemd],
install_dir : usrbin_exec_dir,
install : opt,
build_by_default : opt)
if opt and not is_disabler(exe)
exes += exe
manadocs += ['login-utils/lslogins.1.adoc']
bashcompletions += ['lslogins']
endif
opt = not get_option('build-vipw').disabled()
exe = executable(
'vipw',
'login-utils/vipw.c',
'login-utils/setpwnam.h',
include_directories : includes,
link_with : [lib_common],
dependencies : [lib_selinux],