forked from systemd/systemd
-
Notifications
You must be signed in to change notification settings - Fork 0
/
meson.build
2353 lines (2099 loc) · 89.4 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('systemd', 'c',
version : '233',
license : 'LGPLv2+',
default_options: [
'c_std=gnu99',
'prefix=/usr',
'sysconfdir=/etc',
'localstatedir=/var',
],
meson_version : '>= 0.40',
)
# We need the same data in three different formats, ugh!
# Also, for hysterical reasons, we use different variable
# names, sometimes. Not all variables are included in every
# set. Ugh, ugh, ugh!
conf = configuration_data()
conf.set_quoted('PACKAGE_STRING', meson.project_name() + ' ' + meson.project_version())
conf.set_quoted('PACKAGE_VERSION', meson.project_version())
substs = configuration_data()
substs.set('PACKAGE_URL', 'https://www.freedesktop.org/wiki/Software/systemd')
substs.set('PACKAGE_VERSION', meson.project_version())
m4_defines = []
#####################################################################
rootprefixdir = get_option('rootprefix')
if get_option('split-usr')
conf.set('HAVE_SPLIT_USR', 1)
rootprefixdir = rootprefixdir != '' ? rootprefixdir : '/'
else
rootprefixdir = rootprefixdir != '' ? rootprefixdir : '/usr'
endif
sysvinit_path = get_option('sysvinit-path')
sysvrcnd_path = get_option('sysvrcnd-path')
if sysvinit_path != '' or sysvrcnd_path != ''
conf.set('HAVE_SYSV_COMPAT', 1,
description : 'SysV init scripts and rcN.d links are supported')
m4_defines += ['-DHAVE_SYSV_COMPAT']
endif
# join_paths ignore the preceding arguments if an absolute component is
# encountered, so this should canonicalize various paths when they are
# absolute or relative.
prefixdir = get_option('prefix')
if not prefixdir.startswith('/')
error('Prefix is not absolute: "@0@"'.format(prefixdir))
endif
bindir = join_paths(prefixdir, get_option('bindir'))
libdir = join_paths(prefixdir, get_option('libdir'))
sysconfdir = join_paths(prefixdir, get_option('sysconfdir'))
includedir = join_paths(prefixdir, get_option('includedir'))
datadir = join_paths(prefixdir, get_option('datadir'))
localstatedir = join_paths('/', get_option('localstatedir'))
rootbindir = join_paths(rootprefixdir, 'bin')
rootlibexecdir = join_paths(rootprefixdir, 'lib/systemd')
rootlibdir = get_option('rootlibdir')
if rootlibdir == ''
rootlibdir = join_paths(rootprefixdir, libdir.split('/')[-1])
endif
# Dirs of external packages
pkgconfigdatadir = join_paths(datadir, 'pkgconfig')
pkgconfiglibdir = join_paths(libdir, 'pkgconfig')
polkitpolicydir = join_paths(datadir, 'polkit-1/actions')
polkitrulesdir = join_paths(datadir, 'polkit-1/rules.d')
polkitpkladir = join_paths(localstatedir, 'lib/polkit-1/localauthority/10-vendor.d')
varlogdir = join_paths(localstatedir, 'log')
xinitrcdir = join_paths(sysconfdir, 'X11/xinit/xinitrc.d')
rpmmacrosdir = get_option('rpmmacrosdir')
# Our own paths
pkgdatadir = join_paths(datadir, 'systemd')
environmentdir = join_paths(prefixdir, 'lib/environment.d')
pkgsysconfdir = join_paths(sysconfdir, 'systemd')
userunitdir = join_paths(prefixdir, 'lib/systemd/user')
userpresetdir = join_paths(prefixdir, 'lib/systemd/user-preset')
tmpfilesdir = join_paths(prefixdir, 'lib/tmpfiles.d')
sysusersdir = join_paths(prefixdir, 'lib/sysusers.d')
sysctldir = join_paths(prefixdir, 'lib/sysctl.d')
binfmtdir = join_paths(prefixdir, 'lib/binfmt.d')
modulesloaddir = join_paths(prefixdir, 'lib/modules-load.d')
networkdir = join_paths(rootprefixdir, 'lib/systemd/network')
pkgincludedir = join_paths(includedir, 'systemd')
systemgeneratordir = join_paths(rootlibexecdir, 'system-generators')
usergeneratordir = join_paths(prefixdir, 'lib/systemd/user-generators')
systemenvgeneratordir = join_paths(prefixdir, 'lib/systemd/system-environment-generators')
userenvgeneratordir = join_paths(prefixdir, 'lib/systemd/user-environment-generators')
systemshutdowndir = join_paths(rootlibexecdir, 'system-shutdown')
systemsleepdir = join_paths(rootlibexecdir, 'system-sleep')
systemunitdir = join_paths(rootprefixdir, 'lib/systemd/system')
systempresetdir = join_paths(rootprefixdir, 'lib/systemd/system-preset')
udevlibexecdir = join_paths(rootprefixdir, 'lib/udev')
udevhomedir = udevlibexecdir
udevrulesdir = join_paths(udevlibexecdir, 'rules.d')
udevhwdbdir = join_paths(udevlibexecdir, 'hwdb.d')
catalogdir = join_paths(prefixdir, 'lib/systemd/catalog')
kernelinstalldir = join_paths(prefixdir, 'lib/kernel/install.d')
factorydir = join_paths(datadir, 'factory')
docdir = join_paths(datadir, 'doc/systemd')
bootlibdir = join_paths(prefixdir, 'lib/systemd/boot/efi')
testsdir = join_paths(prefixdir, 'lib/systemd/tests')
systemdstatedir = join_paths(localstatedir, 'lib/systemd')
catalogstatedir = join_paths(systemdstatedir, 'catalog')
randomseeddir = join_paths(localstatedir, 'lib/systemd')
dbuspolicydir = get_option('dbuspolicydir')
if dbuspolicydir == ''
dbuspolicydir = join_paths(datadir, 'dbus-1/system.d')
endif
dbussessionservicedir = get_option('dbussessionservicedir')
if dbussessionservicedir == ''
dbussessionservicedir = join_paths(datadir, 'dbus-1/services')
endif
dbussystemservicedir = get_option('dbussystemservicedir')
if dbussystemservicedir == ''
dbussystemservicedir = join_paths(datadir, 'dbus-1/system-services')
endif
pamlibdir = get_option('pamlibdir')
if pamlibdir == ''
pamlibdir = join_paths(rootlibdir, 'security')
endif
pamconfdir = get_option('pamconfdir')
if pamconfdir == ''
pamconfdir = join_paths(sysconfdir, 'pam.d')
endif
conf.set_quoted('PKGSYSCONFDIR', pkgsysconfdir)
conf.set_quoted('SYSTEM_CONFIG_UNIT_PATH', join_paths(pkgsysconfdir, 'system'))
conf.set_quoted('SYSTEM_DATA_UNIT_PATH', systemunitdir)
conf.set_quoted('SYSTEM_SYSVINIT_PATH', sysvinit_path)
conf.set_quoted('SYSTEM_SYSVRCND_PATH', sysvrcnd_path)
conf.set_quoted('RC_LOCAL_SCRIPT_PATH_START', get_option('rc-local'))
conf.set_quoted('RC_LOCAL_SCRIPT_PATH_STOP', get_option('halt-local'))
conf.set_quoted('USER_CONFIG_UNIT_PATH', join_paths(pkgsysconfdir, 'user'))
conf.set_quoted('USER_DATA_UNIT_PATH', userunitdir)
conf.set_quoted('CERTIFICATE_ROOT', get_option('certificate-root'))
conf.set_quoted('CATALOG_DATABASE', join_paths(catalogstatedir, 'database'))
conf.set_quoted('SYSTEMD_CGROUP_AGENT_PATH', join_paths(rootlibexecdir, 'systemd-cgroups-agent'))
conf.set_quoted('SYSTEMD_BINARY_PATH', join_paths(rootlibexecdir, 'systemd'))
conf.set_quoted('SYSTEMD_FSCK_PATH', join_paths(rootlibexecdir, 'systemd-fsck'))
conf.set_quoted('SYSTEMD_SHUTDOWN_BINARY_PATH', join_paths(rootlibexecdir, 'systemd-shutdown'))
conf.set_quoted('SYSTEMD_SLEEP_BINARY_PATH', join_paths(rootlibexecdir, 'systemd-sleep'))
conf.set_quoted('SYSTEMCTL_BINARY_PATH', join_paths(rootbindir, 'systemctl'))
conf.set_quoted('SYSTEMD_TTY_ASK_PASSWORD_AGENT_BINARY_PATH', join_paths(rootbindir, 'systemd-tty-ask-password-agent'))
conf.set_quoted('SYSTEMD_STDIO_BRIDGE_BINARY_PATH', join_paths(bindir, 'systemd-stdio-bridge'))
conf.set_quoted('ROOTPREFIX', rootprefixdir)
conf.set_quoted('RANDOM_SEED_DIR', randomseeddir)
conf.set_quoted('RANDOM_SEED', join_paths(randomseeddir, 'random-seed'))
conf.set_quoted('SYSTEMD_CRYPTSETUP_PATH', join_paths(rootlibexecdir, 'systemd-cryptsetup'))
conf.set_quoted('SYSTEM_GENERATOR_PATH', systemgeneratordir)
conf.set_quoted('USER_GENERATOR_PATH', usergeneratordir)
conf.set_quoted('SYSTEM_ENV_GENERATOR_PATH', systemenvgeneratordir)
conf.set_quoted('USER_ENV_GENERATOR_PATH', userenvgeneratordir)
conf.set_quoted('SYSTEM_SHUTDOWN_PATH', systemshutdowndir)
conf.set_quoted('SYSTEM_SLEEP_PATH', systemsleepdir)
conf.set_quoted('SYSTEMD_KBD_MODEL_MAP', join_paths(pkgdatadir, 'kbd-model-map'))
conf.set_quoted('SYSTEMD_LANGUAGE_FALLBACK_MAP', join_paths(pkgdatadir, 'language-fallback-map'))
conf.set_quoted('UDEVLIBEXECDIR', udevlibexecdir)
conf.set_quoted('POLKIT_AGENT_BINARY_PATH', join_paths(bindir, 'pkttyagent'))
conf.set_quoted('LIBDIR', libdir)
conf.set_quoted('ROOTLIBDIR', rootlibdir)
conf.set_quoted('ROOTLIBEXECDIR', rootlibexecdir)
conf.set_quoted('BOOTLIBDIR', bootlibdir)
conf.set_quoted('SYSTEMD_PULL_PATH', join_paths(rootlibexecdir, 'systemd-pull'))
conf.set_quoted('SYSTEMD_IMPORT_PATH', join_paths(rootlibexecdir, 'systemd-import'))
conf.set_quoted('SYSTEMD_EXPORT_PATH', join_paths(rootlibexecdir, 'systemd-export'))
conf.set_quoted('VENDOR_KEYRING_PATH', join_paths(rootlibexecdir, 'import-pubring.gpg'))
conf.set_quoted('USER_KEYRING_PATH', join_paths(pkgsysconfdir, 'import-pubring.gpg'))
conf.set_quoted('DOCUMENT_ROOT', join_paths(pkgdatadir, 'gatewayd'))
conf.set_quoted('ABS_BUILD_DIR', meson.build_root())
conf.set_quoted('ABS_SRC_DIR', meson.source_root())
substs.set('prefix', prefixdir)
substs.set('exec_prefix', prefixdir)
substs.set('libdir', libdir)
substs.set('rootlibdir', rootlibdir)
substs.set('includedir', includedir)
substs.set('pkgsysconfdir', pkgsysconfdir)
substs.set('bindir', bindir)
substs.set('rootbindir', rootbindir)
substs.set('rootlibexecdir', rootlibexecdir)
substs.set('systemunitdir', systemunitdir)
substs.set('userunitdir', userunitdir)
substs.set('systempresetdir', systempresetdir)
substs.set('userpresetdir', userpresetdir)
substs.set('udevhwdbdir', udevhwdbdir)
substs.set('udevrulesdir', udevrulesdir)
substs.set('udevlibexecdir', udevlibexecdir)
substs.set('catalogdir', catalogdir)
substs.set('tmpfilesdir', tmpfilesdir)
substs.set('sysusersdir', sysusersdir)
substs.set('sysctldir', sysctldir)
substs.set('binfmtdir', binfmtdir)
substs.set('modulesloaddir', modulesloaddir)
substs.set('systemgeneratordir', systemgeneratordir)
substs.set('usergeneratordir', usergeneratordir)
substs.set('systemenvgeneratordir', systemenvgeneratordir)
substs.set('userenvgeneratordir', userenvgeneratordir)
substs.set('systemshutdowndir', systemshutdowndir)
substs.set('systemsleepdir', systemsleepdir)
substs.set('VARLOGDIR', varlogdir)
substs.set('CERTIFICATEROOT', get_option('certificate-root'))
substs.set('SYSTEMCTL', join_paths(rootbindir, 'systemctl'))
substs.set('RANDOM_SEED', join_paths(randomseeddir, 'random-seed'))
substs.set('SYSTEM_SYSVINIT_PATH', sysvinit_path)
substs.set('SYSTEM_SYSVRCND_PATH', sysvrcnd_path)
substs.set('RC_LOCAL_SCRIPT_PATH_START', get_option('rc-local'))
substs.set('RC_LOCAL_SCRIPT_PATH_STOP', get_option('halt-local'))
#####################################################################
cc = meson.get_compiler('c')
pkgconfig = import('pkgconfig')
check_compilation_sh = find_program('tools/meson-check-compilation.sh')
foreach arg : ['-Wundef',
'-Wlogical-op',
'-Wmissing-include-dirs',
'-Wold-style-definition',
'-Wpointer-arith',
'-Winit-self',
'-Wdeclaration-after-statement',
'-Wfloat-equal',
'-Wsuggest-attribute=noreturn',
'-Werror=missing-prototypes',
'-Werror=implicit-function-declaration',
'-Werror=missing-declarations',
'-Werror=return-type',
'-Werror=incompatible-pointer-types',
'-Werror=format=2',
'-Wstrict-prototypes',
'-Wredundant-decls',
'-Wmissing-noreturn',
'-Wshadow',
'-Wendif-labels',
'-Wstrict-aliasing=2',
'-Wwrite-strings',
'-Werror=overflow',
'-Wdate-time',
'-Wnested-externs',
'-ffast-math',
'-fno-common',
'-fdiagnostics-show-option',
'-fno-strict-aliasing',
'-fvisibility=hidden',
'-fstack-protector',
'-fstack-protector-strong',
'-fPIE',
'--param=ssp-buffer-size=4',
]
if cc.has_argument(arg)
add_project_arguments(arg, language : 'c')
endif
endforeach
# "negative" arguments: gcc on purpose does not return an error for "-Wno-"
# arguments, just emits a warnings. So test for the "positive" version instead.
foreach arg : ['unused-parameter',
'missing-field-initializers',
'unused-result',
'format-signedness']
if cc.has_argument('-W' + arg)
add_project_arguments('-Wno-' + arg, language : 'c')
endif
endforeach
if cc.compiles('
#include <time.h>
#include <inttypes.h>
typedef uint64_t usec_t;
usec_t now(clockid_t clock);
int main(void) {
struct timespec now;
return 0;
}
', name : '-Werror=shadow with local shadowing')
add_project_arguments('-Werror=shadow', language : 'c')
endif
if cc.get_id() == 'clang'
foreach arg : ['-Wno-typedef-redefinition',
'-Wno-gnu-variable-sized-type-not-at-end',
]
if cc.has_argument(arg,
name : '@0@ is supported'.format(arg))
add_project_arguments(arg, language : 'c')
endif
endforeach
endif
link_test_c = files('tools/meson-link-test.c')
# --as-needed and --no-undefined are provided by meson by default,
# run mesonconf to see what is enabled
foreach arg : ['-Wl,-z,relro',
'-Wl,-z,now',
'-pie',
'-Wl,-fuse-ld=gold',
]
have = run_command(check_compilation_sh,
cc.cmd_array(), '-x', 'c', arg,
'-include', link_test_c).returncode() == 0
message('Linking with @0@ supported: @1@'.format(arg, have ? 'yes' : 'no'))
if have
add_project_link_arguments(arg, language : 'c')
endif
endforeach
if get_option('buildtype') != 'debug'
foreach arg : ['-ffunction-sections',
'-fdata-sections']
if cc.has_argument(arg,
name : '@0@ is supported'.format(arg))
add_project_arguments(arg, language : 'c')
endif
endforeach
foreach arg : ['-Wl,--gc-sections']
have = run_command(check_compilation_sh,
cc.cmd_array(), '-x', 'c', arg,
'-include', link_test_c).returncode() == 0
message('Linking with @0@ supported: @1@'.format(arg, have ? 'yes' : 'no'))
if have
add_project_link_arguments(arg, language : 'c')
endif
endforeach
endif
cpp = ' '.join(cc.cmd_array()) + ' -E'
#####################################################################
# compilation result tests
conf.set('_GNU_SOURCE', 1)
conf.set('__SANE_USERSPACE_TYPES__', 1)
conf.set('SIZEOF_PID_T', cc.sizeof('pid_t', prefix : '#include <sys/types.h>'))
conf.set('SIZEOF_UID_T', cc.sizeof('uid_t', prefix : '#include <sys/types.h>'))
conf.set('SIZEOF_GID_T', cc.sizeof('gid_t', prefix : '#include <sys/types.h>'))
conf.set('SIZEOF_DEV_T', cc.sizeof('dev_t', prefix : '#include <sys/types.h>'))
conf.set('SIZEOF_INO_T', cc.sizeof('ino_t', prefix : '#include <sys/types.h>'))
conf.set('SIZEOF_TIME_T', cc.sizeof('time_t', prefix : '#include <sys/time.h>'))
conf.set('SIZEOF_RLIM_T', cc.sizeof('rlim_t', prefix : '#include <sys/resource.h>'))
decl_headers = '''
#include <uchar.h>
#include <linux/ethtool.h>
'''
# FIXME: key_serial_t is only defined in keyutils.h, this is bound to fail
foreach decl : ['char16_t',
'char32_t',
'key_serial_t',
'struct ethtool_link_settings',
]
if cc.sizeof(decl, prefix : decl_headers) > 0
# We get -1 if the size cannot be determined
conf.set('HAVE_' + decl.underscorify().to_upper(), 1)
endif
endforeach
foreach decl : [['IFLA_INET6_ADDR_GEN_MODE', 'linux/if_link.h'],
['IN6_ADDR_GEN_MODE_STABLE_PRIVACY', 'linux/if_link.h'],
['IFLA_VRF_TABLE', 'linux/if_link.h'],
['IFLA_MACVLAN_FLAGS', 'linux/if_link.h'],
['IFLA_IPVLAN_MODE', 'linux/if_link.h'],
['IFLA_PHYS_PORT_ID', 'linux/if_link.h'],
['IFLA_BOND_AD_INFO', 'linux/if_link.h'],
['IFLA_VLAN_PROTOCOL', 'linux/if_link.h'],
['IFLA_VXLAN_REMCSUM_NOPARTIAL', 'linux/if_link.h'],
['IFLA_VXLAN_GPE', 'linux/if_link.h'],
['IFLA_GENEVE_LABEL', 'linux/if_link.h'],
# if_tunnel.h is buggy and cannot be included on its own
['IFLA_VTI_REMOTE', 'linux/if_tunnel.h', '#include <net/if.h>'],
['IFLA_IPTUN_ENCAP_DPORT', 'linux/if_tunnel.h', '#include <net/if.h>'],
['IFLA_GRE_ENCAP_DPORT', 'linux/if_tunnel.h', '#include <net/if.h>'],
['IFLA_BRIDGE_VLAN_INFO', 'linux/if_bridge.h'],
['IFLA_BRPORT_PROXYARP', 'linux/if_link.h'],
['IFLA_BRPORT_LEARNING_SYNC', 'linux/if_link.h'],
['IFLA_BR_VLAN_DEFAULT_PVID', 'linux/if_link.h'],
['NDA_IFINDEX', 'linux/neighbour.h'],
['IFA_FLAGS', 'linux/if_addr.h'],
['LO_FLAGS_PARTSCAN', 'linux/loop.h'],
]
prefix = decl.length() > 2 ? decl[2] : ''
have = cc.has_header_symbol(decl[1], decl[0], prefix : prefix)
conf.set10('HAVE_DECL_' + decl[0], have)
endforeach
skip = false
foreach ident : ['secure_getenv', '__secure_getenv']
if not skip and cc.has_function(ident)
conf.set('HAVE_' + ident.to_upper(), 1)
skip = true
endif
endforeach
foreach ident : [
['memfd_create', '''#include <sys/memfd.h>'''],
['gettid', '''#include <sys/types.h>'''],
['pivot_root', '''#include <stdlib.h>'''], # no known header declares pivot_root
['name_to_handle_at', '''#define _GNU_SOURCE
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>'''],
['setns', '''#define _GNU_SOURCE
#include <sched.h>'''],
['renameat2', '''#include <stdio.h>'''],
['kcmp', '''#include <linux/kcmp.h>'''],
['keyctl', '''#include <sys/types.h>
#include <keyutils.h>'''],
['copy_file_range', '''#include <sys/syscall.h>
#include <unistd.h>'''],
['explicit_bzero' , '''#include <string.h>'''],
]
have = cc.has_function(ident[0], prefix : ident[1])
conf.set10('HAVE_DECL_' + ident[0].to_upper(), have)
endforeach
if cc.has_function('getrandom', prefix : '''#include <sys/random.h>''')
conf.set('USE_SYS_RANDOM_H', 1)
conf.set10('HAVE_DECL_GETRANDOM', 1)
else
have = cc.has_function('getrandom', prefix : '''#include <linux/random.h>''')
conf.set10('HAVE_DECL_GETRANDOM', have)
endif
#####################################################################
sed = find_program('sed')
grep = find_program('grep')
awk = find_program('awk')
m4 = find_program('m4')
stat = find_program('stat')
git = find_program('git', required : false)
etags = find_program('etags', required : false)
meson_make_symlink = meson.source_root() + '/tools/meson-make-symlink.sh'
mkdir_p = 'mkdir -p $DESTDIR/@0@'
test_efi_create_disk_sh = find_program('test/test-efi-create-disk.sh')
splash_bmp = files('test/splash.bmp')
# if -Dxxx-path option is found, use that. Otherwise, check in $PATH,
# /usr/sbin, /sbin, and fall back to the default from middle column.
progs = [['telinit', '/lib/sysvinit/telinit'],
['quotaon', '/usr/sbin/quotaon' ],
['quotacheck', '/usr/sbin/quotacheck' ],
['kill', '/usr/bin/kill' ],
['kmod', '/usr/bin/kmod' ],
['kexec', '/usr/sbin/kexec' ],
['sulogin', '/usr/sbin/sulogin' ],
['mount', '/usr/bin/mount', 'MOUNT_PATH'],
['umount', '/usr/bin/umount', 'UMOUNT_PATH'],
['loadkeys', '/usr/bin/loadkeys', 'KBD_LOADKEYS'],
['setfont', '/usr/bin/setfont', 'KBD_SETFONT'],
]
foreach prog : progs
path = get_option(prog[0] + '-path')
if path != ''
message('Using @1@ for @0@'.format(prog[0], path))
else
exe = find_program(prog[0],
'/usr/sbin/' + prog[0],
'/sbin/' + prog[0],
required: false)
path = exe.found() ? exe.path() : prog[1]
endif
name = prog.length() > 2 ? prog[2] : prog[0].to_upper()
conf.set_quoted(name, path)
substs.set(name, path)
endforeach
if run_command('ln', '--relative', '--help').returncode() != 0
error('ln does not support --relative')
endif
############################################################
gperf = find_program('gperf')
gperf_test_format = '''
#include <string.h>
const char * in_word_set(const char *, @0@);
@1@
'''
gperf_snippet_format = 'echo foo,bar | @0@ -L ANSI-C'
gperf_snippet = run_command('sh', '-c', gperf_snippet_format.format(gperf.path()))
gperf_test = gperf_test_format.format('size_t', gperf_snippet.stdout())
if cc.compiles(gperf_test)
gperf_len_type = 'size_t'
else
gperf_test = gperf_test_format.format('unsigned', gperf_snippet.stdout())
if cc.compiles(gperf_test)
gperf_len_type = 'unsigned'
else
error('unable to determine gperf len type')
endif
endif
message('gperf len type is @0@'.format(gperf_len_type))
conf.set('GPERF_LEN_TYPE', gperf_len_type,
description : 'The type of gperf "len" parameter')
############################################################
if not cc.has_header('sys/capability.h')
error('POSIX caps headers not found')
endif
foreach header : ['linux/btrfs.h',
'linux/memfd.h',
'linux/vm_sockets.h',
'valgrind/memcheck.h',
'valgrind/valgrind.h',
]
if cc.has_header(header)
conf.set('HAVE_' + header.underscorify().to_upper(), 1)
endif
endforeach
############################################################
conf.set_quoted('FALLBACK_HOSTNAME', get_option('fallback-hostname'))
default_hierarchy = get_option('default-hierarchy')
conf.set_quoted('DEFAULT_HIERARCHY_NAME', default_hierarchy,
description : 'default cgroup hierarchy as string')
if default_hierarchy == 'legacy'
conf.set('DEFAULT_HIERARCHY', 'CGROUP_UNIFIED_NONE')
elif default_hierarchy == 'hybrid'
conf.set('DEFAULT_HIERARCHY', 'CGROUP_UNIFIED_SYSTEMD')
else
conf.set('DEFAULT_HIERARCHY', 'CGROUP_UNIFIED_ALL')
endif
time_epoch = get_option('time-epoch')
if time_epoch == ''
NEWS = files('NEWS')
time_epoch = run_command(stat, '-c', '%Y', NEWS).stdout()
endif
time_epoch = time_epoch.to_int()
conf.set('TIME_EPOCH', time_epoch)
system_uid_max = get_option('system-uid-max')
if system_uid_max == ''
system_uid_max = run_command(
awk,
'BEGIN { uid=999 } /^\s*SYS_UID_MAX\s+/ { uid=$2 } END { print uid }',
'/etc/login.defs').stdout()
endif
system_uid_max = system_uid_max.to_int()
conf.set('SYSTEM_UID_MAX', system_uid_max)
substs.set('systemuidmax', system_uid_max)
message('maximum system UID is @0@'.format(system_uid_max))
conf.set_quoted('NOBODY_USER_NAME', get_option('nobody-user'))
conf.set_quoted('NOBODY_GROUP_NAME', get_option('nobody-group'))
system_gid_max = get_option('system-gid-max')
if system_gid_max == ''
system_gid_max = run_command(
awk,
'BEGIN { gid=999 } /^\s*SYS_GID_MAX\s+/ { gid=$2 } END { print gid }',
'/etc/login.defs').stdout()
endif
system_gid_max = system_gid_max.to_int()
conf.set('SYSTEM_GID_MAX', system_gid_max)
substs.set('systemgidmax', system_gid_max)
message('maximum system GID is @0@'.format(system_gid_max))
tty_gid = get_option('tty-gid')
conf.set('TTY_GID', tty_gid)
substs.set('TTY_GID', tty_gid)
if get_option('adm-group')
m4_defines += ['-DENABLE_ADM_GROUP']
endif
if get_option('wheel-group')
m4_defines += ['-DENABLE_WHEEL_GROUP']
endif
substs.set('DEV_KVM_MODE', get_option('dev-kvm-mode'))
kill_user_processes = get_option('default-kill-user-processes')
conf.set10('KILL_USER_PROCESSES', kill_user_processes)
substs.set('KILL_USER_PROCESSES', kill_user_processes ? 'yes' : 'no')
default_dnssec = get_option('default-dnssec')
conf.set('DEFAULT_DNSSEC_MODE',
'DNSSEC_' + default_dnssec.underscorify().to_upper())
substs.set('DEFAULT_DNSSEC_MODE', default_dnssec)
conf.set_quoted('DNS_SERVERS', get_option('dns-servers'))
substs.set('DNS_SERVERS', get_option('dns-servers'))
conf.set_quoted('NTP_SERVERS', get_option('ntp-servers'))
substs.set('NTP_SERVERS', get_option('ntp-servers'))
conf.set_quoted('GETTEXT_PACKAGE', meson.project_name())
substs.set('SUSHELL', get_option('debug-shell'))
substs.set('DEBUGTTY', get_option('debug-tty'))
#####################################################################
threads = dependency('threads')
librt = cc.find_library('rt')
libm = cc.find_library('m')
libdl = cc.find_library('dl')
libcrypt = cc.find_library('crypt')
libcap = dependency('libcap', required : false)
if not libcap.found()
# Compat with Ubuntu 14.04 which ships libcap w/o .pc file
libcap = cc.find_library('cap')
endif
libmount = dependency('mount',
version : '>= 2.27')
want_seccomp = get_option('seccomp')
if want_seccomp != 'false'
libseccomp = dependency('libseccomp',
version : '>= 2.3.1',
required : want_seccomp == 'true')
if libseccomp.found()
conf.set('HAVE_SECCOMP', 1)
m4_defines += ['-DHAVE_SECCOMP']
endif
else
libseccomp = []
endif
want_selinux = get_option('selinux')
if want_selinux != 'false'
libselinux = dependency('libselinux',
version : '>= 2.1.9',
required : want_selinux == 'true')
if libselinux.found()
conf.set('HAVE_SELINUX', 1)
m4_defines += ['-DHAVE_SELINUX']
endif
else
libselinux = []
endif
want_apparmor = get_option('apparmor')
if want_apparmor != 'false'
libapparmor = dependency('libapparmor',
required : want_apparmor == 'true')
if libapparmor.found()
conf.set('HAVE_APPARMOR', 1)
m4_defines += ['-DHAVE_APPARMOR']
endif
else
libapparmor = []
endif
smack_run_label = get_option('smack-run-label')
if smack_run_label != ''
conf.set_quoted('SMACK_RUN_LABEL', smack_run_label)
m4_defines += ['-DHAVE_SMACK_RUN_LABEL']
endif
want_polkit = get_option('polkit')
install_polkit = false
install_polkit_pkla = false
if want_polkit != 'false'
conf.set('ENABLE_POLKIT', 1)
install_polkit = true
libpolkit = dependency('polkit-gobject-1',
required : false)
if libpolkit.found() and libpolkit.version().version_compare('< 0.106')
message('Old polkit detected, will install pkla files')
install_polkit_pkla = true
endif
endif
want_acl = get_option('acl')
if want_acl != 'false'
libacl = cc.find_library('acl', required : want_acl == 'true')
if libacl.found()
conf.set('HAVE_ACL', 1)
m4_defines += ['-DHAVE_ACL']
endif
else
libacl = []
endif
want_audit = get_option('audit')
if want_audit != 'false'
libaudit = dependency('audit', required : want_audit == 'true')
if libaudit.found()
conf.set('HAVE_AUDIT', 1)
endif
else
libaudit = []
endif
want_blkid = get_option('blkid')
if want_blkid != 'false'
libblkid = dependency('blkid', required : want_blkid == 'true')
if libblkid.found()
conf.set('HAVE_BLKID', 1)
endif
else
libblkid = []
endif
want_kmod = get_option('kmod')
if want_kmod != 'false'
libkmod = dependency('libkmod',
version : '>= 15',
required : want_kmod == 'true')
if libkmod.found()
conf.set('HAVE_KMOD', 1)
endif
else
libkmod = []
endif
want_pam = get_option('pam')
if want_pam != 'false'
libpam = cc.find_library('pam', required : want_pam == 'true')
libpam_misc = cc.find_library('pam_misc', required : want_pam == 'true')
if libpam.found() and libpam_misc.found()
conf.set('HAVE_PAM', 1)
m4_defines += ['-DHAVE_PAM']
endif
else
libpam = []
libpam_misc = []
endif
want_microhttpd = get_option('microhttpd')
if want_microhttpd != 'false'
libmicrohttpd = dependency('libmicrohttpd',
version : '>= 0.9.33',
required : want_microhttpd == 'true')
if libmicrohttpd.found()
conf.set('HAVE_MICROHTTPD', 1)
m4_defines += ['-DHAVE_MICROHTTPD']
endif
else
libmicrohttpd = []
endif
want_libcryptsetup = get_option('libcryptsetup')
if want_libcryptsetup != 'false'
libcryptsetup = dependency('libcryptsetup',
version : '>= 1.6.0',
required : want_libcryptsetup == 'true')
if libcryptsetup.found()
conf.set('HAVE_LIBCRYPTSETUP', 1)
endif
else
libcryptsetup = []
endif
want_libcurl = get_option('libcurl')
if want_libcurl != 'false'
libcurl = dependency('libcurl',
version : '>= 7.32.0',
required : want_libcurl == 'true')
if libcurl.found()
conf.set('HAVE_LIBCURL', 1)
m4_defines += ['-DHAVE_LIBCURL']
endif
else
libcurl = []
endif
want_libidn = get_option('libidn')
if want_libidn != 'false'
libidn = dependency('libidn',
required : want_libidn == 'true')
if libidn.found()
conf.set('HAVE_LIBIDN', 1)
m4_defines += ['-DHAVE_LIBIDN']
endif
else
libidn = []
endif
want_libiptc = get_option('libiptc')
if want_libiptc != 'false'
libiptc = dependency('libiptc',
required : want_libiptc == 'true')
if libiptc.found()
conf.set('HAVE_LIBIPTC', 1)
m4_defines += ['-DHAVE_LIBIPTC']
endif
else
libiptc = []
endif
want_qrencode = get_option('qrencode')
if want_qrencode != 'false'
libqrencode = dependency('libqrencode',
required : want_qrencode == 'true')
if libqrencode.found()
conf.set('HAVE_QRENCODE', 1)
endif
else
libqrencode = []
endif
want_gnutls = get_option('gnutls')
if want_gnutls != 'false'
libgnutls = dependency('gnutls',
version : '>= 3.1.4',
required : want_gnutls == 'true')
if libgnutls.found()
conf.set('HAVE_GNUTLS', 1)
endif
else
libgnutls = []
endif
want_elfutils = get_option('elfutils')
if want_elfutils != 'false'
libdw = dependency('libdw',
required : want_elfutils == 'true')
if libdw.found()
conf.set('HAVE_ELFUTILS', 1)
endif
else
libdw = []
endif
want_zlib = get_option('zlib')
if want_zlib != 'false'
libz = dependency('zlib',
required : want_zlib == 'true')
if libz.found()
conf.set('HAVE_ZLIB', 1)
endif
else
libz = []
endif
want_bzip2 = get_option('bzip2')
if want_bzip2 != 'false'
libbzip2 = cc.find_library('bz2',
required : want_bzip2 == 'true')
if libbzip2.found()
conf.set('HAVE_BZIP2', 1)
endif
else
libbzip2 = []
endif
want_xz = get_option('xz')
if want_xz != 'false'
libxz = dependency('liblzma',
required : want_xz == 'true')
if libxz.found()
conf.set('HAVE_XZ', 1)
endif
else
libxz = []
endif
want_lz4 = get_option('lz4')
if want_lz4 != 'false'
liblz4 = dependency('liblz4',
required : want_lz4 == 'true')
if liblz4.found()
conf.set('HAVE_LZ4', 1)
endif
else
liblz4 = []
endif
want_glib = get_option('glib')
if want_glib != 'false'
libglib = dependency('glib-2.0',
version : '>= 2.22.0',
required : want_glib == 'true')
libgobject = dependency('gobject-2.0',
version : '>= 2.22.0',
required : want_glib == 'true')
libgio = dependency('gio-2.0',
required : want_glib == 'true')
if libglib.found() and libgobject.found() and libgio.found()
conf.set('HAVE_GLIB', 1)
endif
else
libglib = []
libgobject = []
libgio = []
endif
want_xkbcommon = get_option('xkbcommon')
if want_xkbcommon != 'false'
libxkbcommon = dependency('xkbcommon',
version : '>= 0.3.0',
required : want_xkbcommon == 'true')
if libxkbcommon.found()
conf.set('HAVE_XKBCOMMON', 1)
endif
else
libxkbcommon = []
endif
want_dbus = get_option('dbus')
if want_dbus != 'false'
libdbus = dependency('dbus-1',
version : '>= 1.3.2',
required : want_dbus == 'true')
if libdbus.found()
conf.set('HAVE_DBUS', 1)
endif
else
libdbus = []
endif
want_gcrypt = get_option('gcrypt')
if want_gcrypt != 'false'
libgcrypt = cc.find_library('gcrypt', required : want_gcrypt == 'true')
libgpg_error = cc.find_library('gpg-error', required : want_gcrypt == 'true')
if libgcrypt.found() and libgpg_error.found()
conf.set('HAVE_GCRYPT', 1)
else
# link to neither of the libs if one is not found
libgcrypt = []
libgpg_error = []
endif
else
libgcrypt = []
libgpg_error = []
endif
want_importd = get_option('importd')
if want_importd != 'false'
have_deps = (conf.get('HAVE_LIBCURL', 0) == 1 and
conf.get('HAVE_ZLIB', 0) == 1 and
conf.get('HAVE_BZIP2', 0) == 1 and
conf.get('HAVE_XZ', 0) == 1 and
conf.get('HAVE_GCRYPT', 0) == 1)
if have_deps
conf.set('ENABLE_IMPORTD', 1)
elif want_importd == 'true'
error('importd support was requested, but dependencies are not available')
endif
endif
want_remote = get_option('remote')
if want_remote != 'false'
have_deps = [conf.get('HAVE_MICROHTTPD', 0) == 1,
conf.get('HAVE_LIBCURL', 0) == 1]
# sd-j-remote requires µhttpd, and sd-j-upload requires libcurl, so
# it's possible to build one without the other. Complain only if
# support was explictly requested. The auxiliary files like sysusers
# config should be installed when any of the programs are built.
if want_remote == 'true' and not (have_deps[0] and have_deps[1])
error('remote support was requested, but dependencies are not available')
endif
if have_deps[0] or have_deps[1]
conf.set('ENABLE_REMOTE', 1)
endif
endif
foreach pair : [['utmp', 'HAVE_UTMP'],
['hibernate', 'ENABLE_HIBERNATE'],
['environment-d', 'ENABLE_ENVIRONMENT_D'],
['binfmt', 'ENABLE_BINFMT'],
['coredump', 'ENABLE_COREDUMP'],
['resolve', 'ENABLE_RESOLVED'],
['logind', 'ENABLE_LOGIND'],
['hostnamed', 'ENABLE_HOSTNAMED'],
['localed', 'ENABLE_LOCALED'],
['machined', 'ENABLE_MACHINED'],
['networkd', 'ENABLE_NETWORKD'],
['timedated', 'ENABLE_TIMEDATED'],
['timesyncd', 'ENABLE_TIMESYNCD'],
['myhostname', 'HAVE_MYHOSTNAME'],
['firstboot', 'ENABLE_FIRSTBOOT'],
['randomseed', 'ENABLE_RANDOMSEED'],
['backlight', 'ENABLE_BACKLIGHT'],
['vconsole', 'ENABLE_VCONSOLE'],
['quotacheck', 'ENABLE_QUOTACHECK'],
['sysusers', 'ENABLE_SYSUSERS'],
['tmpfiles', 'ENABLE_TMPFILES'],
['hwdb', 'ENABLE_HWDB'],
['rfkill', 'ENABLE_RFKILL'],