This repository was archived by the owner on Aug 13, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 171
Expand file tree
/
Copy pathmeson.build
More file actions
1876 lines (1643 loc) · 44.7 KB
/
meson.build
File metadata and controls
1876 lines (1643 loc) · 44.7 KB
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
# Copyright (C) Internet Systems Consortium, Inc. ("ISC")
#
# SPDX-License-Identifier: MPL-2.0
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, you can obtain one at https://mozilla.org/MPL/2.0/.
#
# See the COPYRIGHT file distributed with this work for additional
# information regarding copyright ownership.
project(
'bind',
['c'],
version: '9.21.11-dev',
meson_version: '>=0.61',
license: 'MPL-2.0',
default_options: [
'b_asneeded=true',
'b_pch=false',
'b_pie=true',
'c_std=gnu11',
'default_library=shared',
'localstatedir=/var',
'strip=false',
'warning_level=2',
'werror=false',
'wrap_mode=nodownload',
],
)
fs = import('fs')
ss = import('sourceset')
cc = meson.get_compiler('c')
### Check if autoconf is mixed
if fs.exists(meson.project_source_root() / 'config.h')
error('in-place autoconf detected! please run `make distclean`!')
endif
### Build Options
developer_mode = get_option('developer').enabled()
c_std = get_option('c_std')
optimization = get_option('optimization')
sanitizer = get_option('b_sanitize')
trace_logging = get_option('trace-logging')
rcu_flavor = get_option('rcu-flavor')
cap_opt = get_option('cap')
cmocka_opt = get_option('cmocka')
dnstap_opt = get_option('dnstap')
doc_opt = get_option('doc')
doh_opt = get_option('doh')
fips_opt = get_option('fips')
fuzz_opt = get_option('fuzzing')
geoip_opt = get_option('geoip')
gssapi_opt = get_option('gssapi')
idn_opt = get_option('idn')
jemalloc_opt = get_option('jemalloc').disable_auto_if(sanitizer != 'none')
leak_opt = get_option('leak-detection')
line_opt = get_option('line')
lmdb_opt = get_option('lmdb')
locktype_opt = get_option('locktype')
stats_json_opt = get_option('stats-json')
stats_xml_opt = get_option('stats-xml')
tracing_opt = get_option('tracing')
zlib_opt = get_option('zlib')
if meson.version().version_compare('>=1.1.0')
build_options = meson.build_options()
if build_options == ''
build_options = 'default'
endif
else
build_options = 'unprobed'
endif
### External commands
dtrace_shim = meson.project_source_root() / 'util' / 'dtrace.sh'
if tracing_opt.disabled()
meson.override_find_program('dtrace', find_program(dtrace_shim))
endif
## Required
perl = find_program(['perl', 'perl5'])
sh = find_program('sh')
## Feature gated
krb5_config = find_program('krb5-config', required: gssapi_opt)
protoc = find_program(['protoc-c', 'protoc'], required: dnstap_opt)
dtrace = find_program(['dtrace', dtrace_shim], required: false)
## Testing
curl = find_program('curl', required: false)
fstrm_capture = find_program('fstrm_capture', required: false)
git = find_program('git', required: false)
nc = find_program('nc', required: false)
python = find_program(['python3', 'python'], required: false)
xsltproc = find_program('xsltproc', required: false)
pytest = find_program(
['pytest-3', 'py.test-3', 'pytest', 'py.test', 'pytest-pypy'],
required: false,
)
## Documentation
sphinx_build = find_program('sphinx-build', required: doc_opt)
### Install information
prefix = get_option('prefix')
bindir = prefix / get_option('bindir')
datadir = prefix / get_option('datadir')
libdir = prefix / get_option('libdir')
localstatedir = prefix / get_option('localstatedir')
mandir = prefix / get_option('mandir')
runstatedir = localstatedir / 'run'
sbindir = prefix / get_option('sbindir')
sysconfdir = prefix / get_option('sysconfdir')
src_id = ''
if fs.is_file('srcid')
src_id = fs.read('srcid', encoding: 'utf-8').strip()
elif git.found()
src_id = run_command(git, 'rev-parse', '--short', 'HEAD', check: true).stdout().substring(0, 7)
meson.add_dist_script('util' / 'meson-dist-package.sh', 'srcid', src_id)
endif
### Compiler
add_project_arguments(
cc.get_supported_arguments(
'-Wformat',
'-Wno-missing-field-initializers',
'-Wpointer-arith',
'-Wshadow',
'-Wwrite-strings',
'-Werror=alloca',
'-Werror=cpp',
'-Werror=flex-array-member-not-at-end',
'-Werror=format-security',
'-Werror=implicit',
'-Werror=implicit-function-declaration',
'-Werror=missing-prototypes',
'-Werror=parentheses',
'-Werror=strict-prototypes',
'-Werror=vla',
'-fdiagnostics-show-option',
'-fno-delete-null-pointer-checks',
'-fno-strict-aliasing',
'-fstrict-flex-arrays=3',
),
language: 'c',
)
if developer_mode
add_project_arguments('-Werror', language: 'c')
endif
fortify_test = '''
#include <stdio.h>
#include <stdlib.h>
int main(void) {
void *x = malloc(10);
printf("%p\n", x);
}
'''
if optimization != 'plain'
if optimization != '0'
if cc.compiles(
fortify_test,
args: ['-Werror=cpp', '-U_FORTIFY_SOURCE', '-D_FORTIFY_SOURCE=3'],
name: 'usage of _FORTIFY_SOURCE=3',
)
add_project_arguments('-U_FORTIFY_SOURCE', '-D_FORTIFY_SOURCE=3', language: 'c')
else
add_project_arguments('-U_FORTIFY_SOURCE', '-D_FORTIFY_SOURCE=2', language: 'c')
endif
endif
add_project_arguments(
cc.get_supported_arguments(
'-fcf-protection=full',
'-fstack-clash-protection',
'-fstack-protector-strong',
'-mbranch-protection=standard',
),
language: 'c',
)
add_project_link_arguments(
cc.get_supported_link_arguments(
'-Wl,-z,noexecstack',
'-Wl,-z,now',
'-Wl,-z,relro',
'-Wl,-z,separate-code',
),
language: 'c',
)
endif
if host_machine.cpu_family() == 'x86'
add_project_arguments(
cc.get_supported_arguments(
'-Wno-psabi',
),
language: 'c',
)
endif
isdarwin = host_machine.system() == 'darwin'
if isdarwin
add_project_arguments(
cc.get_supported_arguments(
'-Wno-deprecated-declarations', # For GSS.Framework
'-Wno-unknown-attributes', # For _Noreturn in urcu
),
language: 'c',
)
add_project_link_arguments(
cc.get_supported_link_arguments(
'-Wl,-flat_namespace',
'-Wl,-no_warn_duplicate_libraries', # for krb5
),
language: 'c',
)
endif
sys_defines = [
'-D_BSD_SOURCE',
'-D_DARWIN_C_SOURCE',
'-D_DEFAULT_SOURCE',
'-D_FILE_OFFSET_BITS=64',
'-D_GNU_SOURCE',
'-D_LARGE_FILES',
'-D_TIME_BITS=64',
'-D__APPLE_USE_RFC_3542=1',
]
add_project_arguments(sys_defines, language: 'c')
### Environment
env = environment(
{
'BIND_PROJECT_VERSION': meson.project_version(),
'BIND_BUILD_ROOT': meson.project_build_root(),
'BIND_SOURCE_ROOT': meson.project_source_root(),
},
)
### Configuration
config = configuration_data()
config.set_quoted('PACKAGE_NAME', 'BIND')
config.set_quoted('PACKAGE_DESCRIPTION', 'Development Release')
config.set_quoted('PACKAGE_VERSION', meson.project_version())
config.set_quoted('PACKAGE_STRING', 'BIND ' + meson.project_version())
config.set_quoted('PACKAGE_BUILDER', 'meson')
config.set_quoted('PACKAGE_SRCID', src_id)
config.set_quoted('PACKAGE_CONFIGARGS', build_options)
if get_option('auto-validation').allowed()
config.set_quoted('VALIDATION_DEFAULT', 'auto')
else
config.set_quoted('VALIDATION_DEFAULT', 'no')
endif
config.set_quoted('SESSION_KEYFILE', localstatedir / 'run' / 'named' / 'session.key')
config.set_quoted('RNDC_CONFFILE', sysconfdir / 'rndc.conf')
config.set_quoted('RNDC_KEYFILE', sysconfdir / 'rndc.key')
config.set_quoted('NAMED_PLUGINDIR', libdir / 'bind')
if isdarwin
# Plugin extensions - macOS is the only specific case
config.set_quoted('NAMED_PLUGINEXT', '.dylib')
else
config.set_quoted('NAMED_PLUGINEXT', '.so')
endif
config.set_quoted('NAMED_LOCALSTATEDIR', localstatedir)
config.set_quoted('NAMED_SYSCONFDIR', sysconfdir)
config.set_quoted('NAMED_CONFFILE', sysconfdir / 'named.conf')
config.set_quoted('CACHEDB_DEFAULT', get_option('cachedb'))
config.set_quoted('ZONEDB_DEFAULT', get_option('zonedb'))
# Shim constexpr for pre-C23
# "ne" => "none"
if c_std.substring(-2) in ['ne', '89', '99', '11', '17', '18']
config.set('constexpr', 'static const')
endif
if developer_mode
config.set('ISC_LIST_CHECKINIT', 1)
config.set('ISC_MEM_DEFAULTFILL', 1)
config.set('ISC_MEM_TRACKLINES', 1)
config.set('ISC_MUTEX_ERROR_CHECK', 1)
config.set('ISC_SOCKET_DETAILS', 1)
config.set('ISC_STATS_CHECKUNDERFLOW', 1)
endif
foreach fn : [
'__builtin_add_overflow',
'__builtin_clz',
'__builtin_mul_overflow',
'__builtin_sub_overflow',
'__builtin_unreachable',
]
if cc.has_function(fn)
config.set('HAVE_@0@'.format(fn.substring(2).to_upper()), 1)
endif
endforeach
foreach attr : ['malloc', 'returns_nonnull']
if cc.has_function_attribute(attr)
config.set('HAVE_FUNC_ATTRIBUTE_@0@'.format(attr.to_upper()), 1)
endif
endforeach
malloc_ext_test = '''
#include <stddef.h>
#include <stdlib.h>
__attribute__ ((malloc, malloc(free, 1))
void * xmalloc(size_t sz) {
return malloc(sz);
}
void main(void) {
return xmalloc(8) != NULL;
}
'''
if cc.compiles(malloc_ext_test, name: 'usage of extended malloc attribute')
config.set('HAVE_MALLOC_EXT_ATTR', 1)
endif
## Fuzzing
config.set_quoted('FUZZDIR', meson.project_source_root() / 'fuzz')
fuzz_link_args = []
if fuzz_opt != 'none'
if get_option('b_lundef') != false
warning('fuzzing will fail to build properly without -Db_lundef=false')
endif
if fuzz_opt == 'afl'
elif fuzz_opt == 'libfuzzer'
config.set('FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION', 1)
fuzz_link_args += '-fsanitize=fuzzer,address,undefined'
add_project_link_arguments('-fsanitize=address,undefined', language: 'c')
add_project_arguments('-fsanitize=fuzzer-no-link,address,undefined', language: 'c')
endif
endif
## Architecture
if host_machine.endian() == 'big'
config.set('WORDS_BIGENDIAN', 1)
endif
instruction_test = '''
int main(void) {
__asm__ __volatile__ ("@0@");
return 0;
}
'''
cpu_family = host_machine.cpu_family()
if cpu_family in ['arm', 'aarch64']
if cc.compiles(
instruction_test.format('yield'),
name: 'usage of yield instruction',
)
config.set('HAVE_SPARC_PAUSE', 1)
endif
elif cpu_family in ['sparc', 'sparc64']
if cc.compiles(
instruction_test.format('pause'),
name: 'usage of pause instruction',
)
config.set('HAVE_SPARC_PAUSE', 1)
endif
endif
atomic_test = '''
#include <stdatomic.h>
int main(void) {
atomic_int_fast64_t val = 0;
atomic_fetch_add_explicit(&val, 1, memory_order_relaxed);
return 0;
}
'''
# meson_version (>=1.7.0) : new custom dependency for atomic
if not cc.links(atomic_test, name: 'usage of atomics without -latomic')
atomic_dep = declare_dependency(link_args: '-latomic')
if not cc.links(
atomic_test,
dependencies: atomic_dep,
name: 'usage of atomics with -latomic',
)
error(
'libatomic needed, but linking with -latomic failed, please fix your toolchain',
)
endif
add_project_link_arguments('-latomic', language: 'c')
endif
## OS
config.set10('USE_PTHREAD_RWLOCK', locktype_opt == 'system')
if host_machine.system() == 'sunos' and cc.get_id() == 'gcc'
add_project_link_arguments('-zrelax=transtls', language: 'c')
warning(
'When using GNU C Compiler on Solaris, -zrelax=transtls linker flag is used to fix bug in Thread Local Storage',
)
endif
if cc.has_header_symbol('pthread.h', 'PTHREAD_MUTEX_ADAPTIVE_NP')
config.set('HAVE_PTHREAD_MUTEX_ADAPTIVE_NP', 1)
endif
foreach fn, header : {
# Better strings
'strlcpy': '#include <string.h>',
'strlcat': '#include <string.h>',
'strnstr': '#include <string.h>',
# Kernel information
'uname': '#include <sys/utsname.h>',
# Backtrace
'backtrace_symbols': '#include <execinfo.h>',
# Timezone
'tzset': '#include <time.h>',
# Check for if_nametoindex() for IPv6 scoped addresses support
'if_nametoindex': '#include <net/if.h>',
# FILE locking
'flockfile': '#include <stdio.h>',
'getc_unlocked': '#include <stdio.h>',
# Processor control
'cpuset_getaffinity': '#include <sys/cpuset.h>',
'sched_getaffinity': '#include <sched.h>',
'sched_yield': '#include <sched.h>',
# Misc.
'clock_gettime': '#include <time.h>',
'sysctlbyname': '#include <sys/sysctl.h>',
}
if cc.has_function(fn, prefix: header, args: sys_defines)
config.set('HAVE_@0@'.format(fn.to_upper()), 1)
endif
endforeach
# Check for nanoseconds in file stats
if cc.has_member('struct stat', 'st_mtim.tv_nsec', prefix: '#include <sys/stat.h>')
config.set('HAVE_STAT_NSEC', 1)
endif
foreach h : [
'fcntl.h',
'linux/netlink.h',
'linux/rtnetlink.h',
'malloc_np.h',
'net/if6.h',
'net/route.h',
'regex.h',
'sys/mman.h',
'sys/select.h',
'sys/sockio.h',
'sys/sysctl.h',
'sys/time.h',
'unistd.h',
]
if cc.has_header(h)
config.set('HAVE_@0@'.format(h.underscorify().to_upper()), 1)
endif
endforeach
## Leak detection in external libraries
config.set10('ENABLE_LEAK_DETECTION', leak_opt.enabled())
## Query Tracing
# meson_version (>=1.1.0) : enable_if in feature object
query_trace_opt = 'query' in trace_logging
single_trace_opt = 'single' in trace_logging
if query_trace_opt or developer_mode
config.set('WANT_QUERYTRACE', 1)
if single_trace_opt
config.set('WANT_SINGLETRACE', 1)
endif
elif single_trace_opt
error('single trace logging requires query trace logging')
endif
###
### Dependencies
###
null_dep = dependency('', required: false)
m_dep = cc.find_library('m', required: false)
## Threads
thread_dep = dependency('threads')
foreach fn : [
'pthread_attr_getstacksize',
'pthread_attr_setstacksize',
'pthread_barrier_init',
'pthread_set_name_np',
'pthread_setname_np',
'pthread_spin_init',
'pthread_yield',
'pthread_yield_np',
]
if cc.has_function(
fn,
prefix: '#include <pthread.h>',
args: sys_defines,
dependencies: thread_dep,
)
config.set('HAVE_@0@'.format(fn.to_upper()), 1)
endif
endforeach
## OpenSSL
openssl_dep = [
dependency('libcrypto', version: '>=1.1.1'),
dependency('libssl', version: '>=1.1.1'),
]
foreach fn, header : {
'EVP_default_properties_enable_fips': '#include <openssl/evp.h>',
'FIPS_mode': '#include <openssl/crypto.h>',
}
if cc.has_function(fn, prefix: header, dependencies: openssl_dep)
config.set('HAVE_OPENSSL_FIPS_TOGGLE', 1)
config.set('HAVE_@0@'.format(fn.to_upper()), 1)
endif
endforeach
fips_opt.require(
config.has('HAVE_OPENSSL_FIPS_TOGGLE'),
error_message: 'OpenSSL FIPS mode requested but not available',
)
# Hash and curve probe
if cc.has_header_symbol('openssl/evp.h', 'NID_ED448', dependencies: openssl_dep)
config.set('HAVE_OPENSSL_ED448', 1)
endif
foreach fn, header : {
'ERR_get_error_all': '#include <openssl/err.h>',
'BIO_read_ex': '#include <openssl/bio.h>',
'BIO_write_ex': '#include <openssl/bio.h>',
'EVP_MD_CTX_get0_md': '#include <openssl/evp.h>',
'EVP_PKEY_eq': '#include <openssl/evp.h>',
'SSL_CTX_set1_cert_store': '#include <openssl/ssl.h>',
}
config.set10(
'HAVE_@0@'.format(fn.to_upper()),
cc.has_function(fn, dependencies: openssl_dep, prefix: header),
)
endforeach
## libuv
uv_dep = dependency('libuv', version: '>=1.34.0')
if uv_dep.version().version_compare('<1.40.0')
warning('libuv version 1.40.0 or greater is highly recommended')
endif
foreach sym : ['UV_UDP_LINUX_RECVERR', 'UV_UDP_MMSG_CHUNK', 'UV_UDP_MMSG_FREE']
if cc.has_header_symbol('uv.h', sym, dependencies: uv_dep)
config.set('HAVE_DECL_@0@'.format(sym), 1)
endif
endforeach
if not cc.has_members('struct msghdr', '__pad1', '__pad2', prefix: '#include <sys/socket.h>')
if cc.has_header_symbol('uv.h', 'UV_UDP_RECVMMSG', dependencies: uv_dep)
config.set('HAVE_DECL_UV_UDP_RECVMMSG', 1)
endif
else
message('likely non-glibc on linux, disabling recvmmsg')
endif
## userspace-rcu
urcu_dep = [dependency('liburcu-cds', version: '>=0.10.0')]
if rcu_flavor == 'membarrier'
config.set('RCU_MEMBARRIER', true)
urcu_dep += dependency('liburcu', version: '>=0.10.0')
elif not developer_mode
error('Changing Userspace-RCU flavor is allowed only in development mode')
elif rcu_flavor == 'bp'
config.set('RCU_BP', true)
urcu_dep += dependency('liburcu-bp', version: '>=0.10.0')
elif rcu_flavor == 'mb'
config.set('RCU_MB', true)
urcu_dep += dependency('liburcu-mb', version: '>=0.10.0')
elif rcu_flavor == 'qsbr'
config.set('RCU_QSBR', true)
urcu_dep += dependency('liburcu-qsbr', version: '>=0.10.0')
endif
# liburcu << v0.13.0 didn't add -lurcu-common and some toolchains would
# not add it automatically - we need to add it explicitly in such case.
if urcu_dep[1].version().version_compare('<0.13.0')
urcu_dep += cc.find_library('liburcu-common')
endif
config.set_quoted('RCU_FLAVOR', f'liburcu-@rcu_flavor@')
config.set_quoted('RCU_VERSION', urcu_dep[0].version())
urcu_inline_test = '''
#define URCU_INLINE_SMALL_FUNCTIONS 1
#include <urcu.h>
int main(void) {
struct opaque *a = malloc(1);
struct opaque *b = rcu_dereference(a);
return b != NULL;
}
'''
if cc.compiles(
urcu_inline_test,
dependencies: urcu_dep,
name: 'usage of opaque urcu inlining',
)
config.set('URCU_INLINE_SMALL_FUNCTIONS', 1)
endif
## jemalloc
jemalloc_dep = null_dep
if jemalloc_opt.allowed()
jemalloc_dep = dependency('jemalloc', required: jemalloc_opt)
if jemalloc_dep.found()
config.set('HAVE_JEMALLOC', 1)
endif
endif
## dnstap
dnstap_dep = null_dep # Will be filled later
fstrm_dep = null_dep
proto_dep = null_dep
if dnstap_opt.allowed()
fstrm_dep = dependency('libfstrm', required: dnstap_opt)
proto_dep = dependency('libprotobuf-c', required: dnstap_opt)
if protoc.found() and fstrm_dep.found() and proto_dep.found()
config.set('HAVE_DNSTAP', 1)
endif
endif
## JSON
json_c_dep = null_dep
if stats_json_opt.allowed()
json_c_dep = dependency('json-c', version: '>=0.11', required: stats_json_opt)
if json_c_dep.found()
config.set('HAVE_JSON_C', 1)
endif
endif
## XML
xml2_dep = null_dep
if stats_xml_opt.allowed()
xml2_dep = dependency('libxml-2.0', version: '>=2.6.0', required: stats_xml_opt)
if xml2_dep.found()
config.set('HAVE_LIBXML2', 1)
endif
endif
## DNS-over-HTTP (DoH)
nghttp2_dep = null_dep
if doh_opt.allowed()
nghttp2_dep = dependency('libnghttp2', version: '>=1.6.0', required: doh_opt)
if nghttp2_dep.found()
config.set('HAVE_LIBNGHTTP2', 1)
endif
endif
## GeoIP
maxminddb_dep = null_dep
if geoip_opt.allowed()
maxminddb_dep = dependency('libmaxminddb', required: geoip_opt)
if maxminddb_dep.found()
config.set('HAVE_GEOIP2', 1)
config.set_quoted('MAXMINDDB_PREFIX', maxminddb_dep.get_variable('prefix'))
endif
endif
## GSSAPI
gssapi_dep = null_dep
krb5_dep = null_dep
if gssapi_opt.allowed() and krb5_config.found()
krb5_dep = declare_dependency(
compile_args: run_command(krb5_config, ['krb5', '--cflags'], check: true).stdout().strip().split(),
link_args: run_command(krb5_config, ['krb5', '--libs'], check: true).stdout().strip().split(),
version: run_command(krb5_config, ['--version'], check: true).stdout().strip(),
)
if cc.has_header('krb5/krb5.h', dependencies: krb5_dep)
config.set('HAVE_KRB5_KRB5_H', 1)
elif cc.has_header('krb5.h', dependencies: krb5_dep)
config.set('HAVE_KRB5_H', 1)
elif krb5_dep.found()
error('neither krb5/krb5.h nor krb5 found')
endif
if krb5_dep.found() and not cc.has_function('krb5_init_context', dependencies: krb5_dep)
error('KRB5 does not work')
endif
gssapi_dep = declare_dependency(
compile_args: run_command(krb5_config, ['gssapi', '--cflags'], check: true).stdout().strip().split(),
link_args: run_command(krb5_config, ['gssapi', '--libs'], check: true).stdout().strip().split(),
version: krb5_dep.version(),
)
if cc.has_header('gssapi/gssapi.h', dependencies: gssapi_dep)
config.set('HAVE_GSSAPI_GSSAPI_H', 1)
elif cc.has_header('gssapi.h', dependencies: gssapi_dep)
config.set('HAVE_GSSAPI_H', 1)
elif gssapi_dep.found()
error('neither gssapi/gssapi.h nor gssapi.h found')
endif
if cc.has_header('gssapi/gssapi_krb5.h', dependencies: gssapi_dep)
config.set('HAVE_GSSAPI_GSSAPI_KRB5_H', 1)
elif cc.has_header('gssapi_krb5.h', dependencies: gssapi_dep)
config.set('HAVE_GSSAPI_KRB5_H', 1)
elif gssapi_dep.found()
error('neither gssapi/gssapi_krb5.h nor gssapi_krb5.h found')
endif
if krb5_dep.found() and gssapi_dep.found()
config.set('HAVE_GSSAPI', 1)
endif
endif
## libcap
cap_dep = null_dep
if cap_opt.allowed()
cap_dep = dependency('libcap', required: cap_opt)
if cap_dep.found()
config.set('HAVE_LIBCAP', 1)
endif
endif
## IDN
idn2_dep = null_dep
if idn_opt.allowed()
idn2_dep = dependency('libidn2', required: idn_opt)
if idn2_dep.found()
config.set('HAVE_LIBIDN2', 1)
endif
endif
## LMDB
lmdb_dep = null_dep
if lmdb_opt.allowed()
lmdb_dep = dependency('lmdb', required: lmdb_opt)
if lmdb_dep.found()
config.set('HAVE_LMDB', 1)
endif
endif
## zlib
# meson_version (>=1.1.0) : enable_if in feature object
zlib_dep = null_dep
if zlib_opt.allowed() or developer_mode
zlib_dep = dependency('zlib', required: zlib_opt.enabled() or developer_mode)
if zlib_dep.found()
config.set('HAVE_ZLIB', 1)
endif
endif
## libedit
edit_dep = null_dep
if line_opt.allowed()
edit_dep = dependency('libedit', required: line_opt)
if edit_dep.found()
config.set('HAVE_LIBEDIT', 1)
endif
endif
## cmocka
cmocka_dep = null_dep
# meson_version (>=1.1.0) : enable_if in feature object
if cmocka_opt.allowed() or developer_mode
cmocka_dep = dependency(
'cmocka',
version: '>=1.1.3',
required: cmocka_opt.enabled() or developer_mode,
)
if cmocka_dep.found()
config.set('HAVE_CMOCKA', 1)
endif
endif
## DTrace
dtrace_header = generator(
dtrace,
output: '@BASENAME@.h',
arguments: ['-s', '@INPUT@', '-h', '-o', '@OUTPUT@'],
)
# Acutally, dtrace probes are still built with macOS.
# macOS flavored dtrace doesn't recognize the -G option and
# only uses headers.
#
# Since the binary is in the base system, there isn't much reason
# to be able to disable it. You can just not use the probes.
config.set(
'HAVE_DTRACE',
dtrace.full_path() != dtrace_shim
and build_machine.system() != 'darwin',
)
cc.has_header('sys/sdt.h', required: tracing_opt)
assert(
dtrace.full_path() != dtrace_shim or not tracing_opt.enabled(),
'tracing is requested but dtrace is not found',
)
### Finalize configuration
configure_file(output: 'config.h', configuration: config)
add_project_arguments('-include', meson.project_build_root() / 'config.h', language: 'c')
### Build dnstap if necessary, needs configuration
if config.has('HAVE_DNSTAP')
dnstap_schema_src = custom_target(
'dnstap-protobuf',
input: ['dnstap.proto'],
output: ['dnstap.pb-c.c', 'dnstap.pb-c.h'],
command: [
protoc,
'--proto_path=@CURRENT_SOURCE_DIR@',
'--c_out=@OUTDIR@',
'@INPUT@',
],
)
dnstap = static_library(
'dnstap',
dnstap_schema_src,
implicit_include_directories: false,
dependencies: proto_dep,
)
dnstap_dep = declare_dependency(
link_with: dnstap,
sources: dnstap_schema_src[1],
dependencies: [
fstrm_dep,
proto_dep,
],
)
endif
###
### Compile Targets
###
bind_keys = custom_target(
'bind-keys',
output: 'bind.keys.h',
depend_files: files('bind.keys', 'util' / 'bindkeys.pl'),
capture: true,
command: [
perl,
meson.project_source_root() / 'util' / 'bindkeys.pl',
meson.project_source_root() / 'bind.keys',
],
)
# Headers
dns_inc = include_directories('lib' / 'dns' / 'include')
isc_inc = include_directories('lib' / 'isc' / 'include')
isccc_inc = include_directories('lib' / 'isccc' / 'include')
isccfg_inc = include_directories('lib' / 'isccfg' / 'include')
ns_inc = include_directories('lib' / 'ns' / 'include')
dns_inc_p = []
isc_inc_p = []
named_inc_p = []
confgen_inc_p = []
# USDT Probes
dns_probe_objects = []
isc_probe_objects = []
ns_probe_objects = []
# Use sourceset to add conditional files
# https://mesonbuild.com/SourceSet-module.html
dns_srcset = ss.source_set()
isc_srcset = ss.source_set()
isccc_srcset = ss.source_set()
isccfg_srcset = ss.source_set()
ns_srcset = ss.source_set()
named_srcset = ss.source_set()
arm_srcset = ss.source_set()
man_srcset = ss.source_set()
manrst_srcset = ss.source_set()
doc_misc_targets = []
man_pages = []
arpaname_src = []
delv_src = []
dig_src = []
dnssec_cds_src = []
dnssec_dsfromkey_src = []
dnssec_importkey_src = []
dnssec_keyfromlabel_src = []
dnssec_keygen_src = []
dnssec_ksr_src = []
dnssec_revoke_src = []
dnssec_settime_src = []
dnssec_signzone_src = []
dnssec_verify_src = []
dnstap_read_src = []
host_src = []
mdig_src = []
named_checkconf_src = []
named_checkzone_src = []
named_journalprint_src = []
named_makejournal_src = []
named_nzd2nzf_src = []
named_rrchecker_src = []
nsec3hash_src = []
nslookup_src = []
nsupdate_src = []
rndc_confgen_src = []
rndc_src = []
tsig_keygen_src = []
filter_a_src = []
filter_aaaa_src = []
fuzz_binaries = {}
system_test_binaries = {}
system_test_libraries = {}
system_test_targets = []
subdir('bin')
subdir('fuzz')
subdir('lib')
subdir('util')
###
### Libraries & Binaries
###
# libisc
isc_srcconf = isc_srcset.apply(config, strict: false)
libisc = library(
'isc',
isc_srcconf.sources(),
objects: isc_probe_objects,
install: true,
install_rpath: libdir,
implicit_include_directories: false,
include_directories: [isc_inc, isc_inc_p],
dependencies: isc_srcconf.dependencies(),
)
libisc_dep = declare_dependency(
link_with: libisc,
include_directories: isc_inc,
dependencies: [
openssl_dep,
thread_dep,
urcu_dep,
uv_dep,
jemalloc_dep,
],