]> git.ipfire.org Git - thirdparty/pdns.git/blob - meson.build
Merge pull request #14078 from rgacogne/ddist-harvest-quic
[thirdparty/pdns.git] / meson.build
1 project(
2 'pdns',
3 ['c', 'cpp'],
4 version: run_command('builder-support' / 'gen-version', check: true).stdout().strip(),
5 license: 'GPLv2',
6 license_files: 'NOTICE',
7 meson_version: '>= 1.2.1',
8 default_options: [
9 'buildtype=debugoptimized',
10 'warning_level=2', # TODO Move this to 3 to enable -Wpedantic
11 'cpp_std=c++17',
12 ],
13 )
14
15 product_source_dir = meson.current_source_dir()
16 product_build_dir = meson.current_build_dir()
17 summary('Source Dir', product_source_dir, section: 'Build')
18 summary('Build Dir', product_build_dir, section: 'Build')
19
20 # Create the configuration object and dependencies list.
21 conf = configuration_data()
22
23 # Feature detection and system configuration
24 subdir('meson' / 'config') # Config
25 subdir('meson' / 'version') # Generate version define
26 subdir('meson' / 'compiler-setup') # Common compiler setup
27 subdir('meson' / 'summary') # Print a system/project summary
28 subdir('meson' / 'sysconfdir') # Sysconfdir
29 subdir('meson' / 'libdir') # Libdir
30 subdir('meson' / 'platform') # Platform detection
31 subdir('meson' / 'timet-size') # Check the size of time_t
32 subdir('meson' / 'timet-sign') # Check the sign of time_t
33 subdir('meson' / 'atomics') # Check atomics support
34 subdir('meson' / 'pthread-headers') # Check pthread headers
35 subdir('meson' / 'pthread-setname') # Pthread setname madness
36 subdir('meson' / 'strerror') # Strerror_r
37 subdir('meson' / 'lua') # Lua
38 subdir('meson' / 'lua-records') # Lua-based Records
39 subdir('meson' / 'hardening') # Hardening
40 subdir('meson' / 'kiss-rng') # Unsafe KISS RNG
41 subdir('meson' / 'net-libs') # Network Libraries
42 subdir('meson' / 'tm-gmtoff') # Check for tm_gmtoff field in struct tm
43 subdir('meson' / 'mmap') # Check for mmap
44 subdir('meson' / 'libsodium') # Libsodium-based signers
45 subdir('meson' / 'libdecaf') # Libdecaf-based signers
46 subdir('meson' / 'libcrypto') # OpenSSL-based signers
47 subdir('meson' / 'libssl') # OpenSSL libssl
48 subdir('meson' / 'gnutls') # GnuTLS
49 subdir('meson' / 'dot') # DNS over TLS
50 subdir('meson' / 'ipcipher') # IPCipher
51 subdir('meson' / 'clock-gettime') # Clock_gettime
52 subdir('meson' / 'boost') # Boost
53 subdir('meson' / 'boost-program-options') # Boost Program Options Library
54 subdir('meson' / 'boost-test') # Boost Testing Library
55 subdir('meson' / 'boost-serialization') # Boost Serialization Library
56 subdir('meson' / 'reproducible') # Reproducible Builds
57 subdir('meson' / 'dlopen') # dlopen
58 subdir('meson' / 'verbose-logging') # Verbose Logging
59 subdir('meson' / 'pkcs11') # PKCS11
60 subdir('meson' / 'gss-tsig') # GSS-TSIG
61 subdir('meson' / 'libsystemd') # Systemd notification
62 subdir('meson' / 'systemd') # Systemd and unit file handling
63 subdir('meson' / 'code-coverage') # Code coverage
64 subdir('meson' / 'auto-var-init') # Automatic Variable Initialization
65 subdir('meson' / 'sanitizers') # Sanitizers
66 subdir('meson' / 'malloc-trace') # Malloc-trace
67 subdir('meson' / 'socket-dir') # Socket Dir
68 subdir('meson' / 'various-functions') # Various Functions
69 subdir('meson' / 'various-headers') # Various Headers
70 subdir('meson' / 'yaml-cpp') # YAML C++
71 subdir('meson' / 'sqlite3') # Sqlite3
72 subdir('meson' / 'lmdb') # LMDB
73 subdir('meson' / 'mysql') # MySQL
74 subdir('meson' / 'odbc') # ODBC
75 subdir('meson' / 'pgsql') # PostgreSQL
76 subdir('meson' / 'ldap') # LDAP
77 subdir('meson' / 'prog-curl') # cURL Program
78 subdir('meson' / 'zeromq') # ZeroMQ
79 subdir('meson' / 'cdb') # CDB
80 subdir('meson' / 'geoip') # GeoIP
81 subdir('meson' / 'mmdb') # MaxMindDB
82 subdir('meson' / 'cxx-fs') # C++ stdlib Filesystem Module
83
84 common_sources = []
85
86 fs = import('fs')
87 src_dir = fs.is_dir('pdns') ? 'pdns' : ''
88 docs_dir = 'docs'
89 # Toplevel includes
90 dep_pdns = declare_dependency(include_directories: include_directories('.', src_dir))
91
92 # Ext
93 subdir('ext' / 'arc4random')
94 subdir('ext' / 'ipcrypt')
95 subdir('ext' / 'json11')
96 subdir('ext' / 'luawrapper')
97 subdir('ext' / 'protozero')
98 subdir('ext' / 'yahttp')
99
100 libpdns_gettime = declare_dependency(
101 link_whole: static_library(
102 'pdns-gettime',
103 src_dir / 'gettime.cc',
104 src_dir / 'gettime.hh',
105 dependencies: dep_rt,
106 )
107 )
108
109 if get_option('module-lmdb') != 'disabled'
110 subdir('ext' / 'lmdb-safe')
111 endif
112
113 deps = [
114 dep_pdns,
115 dep_platform,
116 dep_atomics,
117 dep_threads,
118 dep_lua,
119 dep_lua_records,
120 dep_netlibs,
121 dep_libsodium,
122 dep_libdecaf,
123 dep_libcrypto,
124 dep_libssl,
125 dep_gnutls,
126 dep_boost,
127 dep_boost_program_options,
128 dep_dlopen,
129 dep_pkcs11,
130 dep_gss_tsig,
131 dep_systemd,
132 dep_arc4random,
133 dep_ipcrypt,
134 dep_json11,
135 dep_luawrapper,
136 dep_protozero,
137 dep_yahttp,
138 dep_yaml_cpp,
139 dep_sqlite3,
140 dep_lmdb,
141 dep_boost_serialization,
142 dep_mysql,
143 dep_odbc,
144 dep_pgsql,
145 dep_ldap,
146 dep_cdb,
147 dep_geoip,
148 dep_mmdb,
149 dep_cxx_fs,
150 dep_boost_test,
151 ]
152
153 if dep_systemd.found()
154 systemd_service_conf = configuration_data()
155 systemd_service_conf.set('BinDir', get_option('bindir'))
156 systemd_service_conf.set('StaticBinDir', get_option('sbindir'))
157 systemd_service_user = get_option('systemd-service-user')
158 systemd_service_group = get_option('systemd-service-group')
159 systemd_service_conf.set('ServiceUser', systemd_service_user)
160 systemd_service_conf.set('ServiceGroup', systemd_service_group)
161 summary('Service User', systemd_service_user, section: 'Systemd')
162 summary('Service Group', systemd_service_group, section: 'Systemd')
163
164 # ProtectSystem=full will disallow write access to /etc and /usr, possibly not being
165 # able to write slaved-zones into sqlite3 or zonefiles.
166 systemd_service_conf.set(
167 'ProtectSystem', have_systemd_protect_system ? 'ProtectSystem=full' : '',
168 )
169 systemd_service_conf.set(
170 'SystemCallArchitectures',
171 have_systemd_system_call_architectures ? 'SystemCallArchitectures=native' : '',
172 )
173 systemd_system_call_filter = '~ @clock @debug @module @mount @raw-io @reboot @swap @cpu-emulation @obsolete'
174 systemd_service_conf.set(
175 'SystemCallFilter',
176 have_systemd_system_call_filter ? 'SystemCallFilter=' + systemd_system_call_filter : '',
177 )
178 systemd_service_conf.set(
179 'ProtectProc',
180 have_systemd_protect_proc ? 'ProtectProc=invisible' : '',
181 )
182
183 systemd_features = {
184 'LockPersonality': have_systemd_lock_personality,
185 'PrivateDevices': have_systemd_private_devices,
186 'PrivateTmp': have_systemd_private_tmp,
187 'PrivateUsers': false, # Setting it to true prevents us from opening our sockets.
188 'ProtectClock': have_systemd_protect_clock,
189 'ProtectControlGroups': have_systemd_protect_control_groups,
190 'ProtectHome': have_systemd_protect_home,
191 'ProtectHostname': have_systemd_protect_hostname,
192 'ProtectKernelLogs': have_systemd_protect_kernel_logs,
193 'ProtectKernelModules': have_systemd_protect_kernel_modules,
194 'ProtectKernelTunables': have_systemd_protect_kernel_tunables,
195 'RestrictNamespaces': have_systemd_restrict_namespaces,
196 'RestrictRealtime': have_systemd_restrict_realtime,
197 'RestrictSUIDSGID': have_systemd_restrict_suidsgid,
198 'PrivateIPC': have_systemd_private_ipc,
199 'RemoveIPC': have_systemd_remove_ipc,
200 }
201
202 foreach feature, enable_it: systemd_features
203 systemd_service_conf.set(feature, enable_it ? feature + '=true': '')
204 endforeach
205
206 auth_service_conf = configuration_data()
207 auth_service_conf.merge_from(systemd_service_conf)
208 # Disabled, it breaks LuaJIT.
209 auth_service_conf.set(
210 'MemoryDenyWriteExecute',
211 have_systemd_memory_deny_write_execute ? 'MemoryDenyWriteExecute=false' : '',
212 )
213 auth_service_conf.set(
214 'RestrictAddressFamilies',
215 have_systemd_restrict_address_families ? 'RestrictAddressFamilies=AF_UNIX AF_INET AF_INET6' : '',
216 )
217
218 enable_socket_dir = (not have_systemd_with_runtime_dir_env) and have_systemd_percent_t
219
220 auth_service_conf_general = configuration_data()
221 auth_service_conf_general.merge_from(auth_service_conf)
222 auth_service_conf_general.set('Description', 'PowerDNS Authoritative Server')
223 auth_service_conf_general.set('SocketDir', enable_socket_dir ? '--socket-dir=%t/pdns-auth' : '')
224 auth_service_conf_general.set('SyslogIdentifier', 'pdns-auth')
225 auth_service_conf_general.set('RuntimeDirectory', 'pdns-auth')
226
227 configure_file(
228 input: 'auth' / 'systemd' / 'pdns-auth.service.in',
229 output: 'pdns-auth.service',
230 configuration: auth_service_conf_general,
231 )
232
233 auth_service_conf_instance = configuration_data()
234 auth_service_conf_instance.merge_from(auth_service_conf)
235 auth_service_conf_instance.set('Description', 'PowerDNS Authoritative Server %i')
236 auth_service_conf_instance.set('ConfigName', '--config-name=%i')
237 auth_service_conf_instance.set('SocketDir', enable_socket_dir ? '--socket-dir=%t/pdns-auth-%i' : '')
238 auth_service_conf_instance.set('SyslogIdentifier', 'pdns-auth-%i')
239 auth_service_conf_instance.set('RuntimeDirectory', have_systemd_percent_t ? 'pdns-auth-%i' : 'pdns-auth')
240
241 configure_file(
242 input: 'auth' / 'systemd' / 'pdns-auth.service.in',
243 output: 'pdns-auth@.service',
244 configuration: auth_service_conf_instance,
245 )
246
247 if get_option('tools-ixfrdist')
248 ixfrdist_service_conf = configuration_data()
249 ixfrdist_service_conf.merge_from(systemd_service_conf)
250 ixfrdist_service_conf.set(
251 'MemoryDenyWriteExecute',
252 have_systemd_memory_deny_write_execute ? 'MemoryDenyWriteExecute=true' : '',
253 )
254 ixfrdist_service_conf.set(
255 'RestrictAddressFamilies',
256 have_systemd_restrict_address_families ? 'RestrictAddressFamilies=AF_INET AF_INET6' : '',
257 )
258
259 ixfrdist_service_conf_general = configuration_data()
260 ixfrdist_service_conf_general.merge_from(ixfrdist_service_conf)
261 ixfrdist_service_conf_general.set('Description', 'PowerDNS IXFR Distributor')
262
263 configure_file(
264 input: 'auth' / 'systemd' / 'ixfrdist.service.in',
265 output: 'ixfrdist.service',
266 configuration: ixfrdist_service_conf_general,
267 )
268
269 ixfrdist_service_conf_instance = configuration_data()
270 ixfrdist_service_conf_instance.merge_from(ixfrdist_service_conf)
271 ixfrdist_service_conf_instance.set('Description', 'PowerDNS IXFR Distributor %i')
272 ixfrdist_service_conf_instance.set('Config', '--config=' + get_option('sysconfdir') + '/ixfrdist-%.ymli')
273
274 configure_file(
275 input: 'auth' / 'systemd' / 'ixfrdist.service.in',
276 output: 'ixfrdist@.service',
277 configuration: ixfrdist_service_conf_instance,
278 )
279 endif
280 endif
281
282 libpdns_bindlexer_source = src_dir / 'bindlexer.l'
283 libpdns_bindlexer_gen = src_dir / 'bindlexer.c'
284 if not fs.is_file(libpdns_bindlexer_gen)
285 flex = find_program('flex', required: true)
286
287 summary('Flex', flex.found(), bool_yn: true, section: 'BIND Parser')
288 summary('Flex Path', flex.full_path(), section: 'BIND Parser')
289 summary('Flex Version', flex.version(), section: 'BIND Parser')
290
291 flex_generator = generator(
292 flex,
293 output: '@BASENAME@.c',
294 arguments: ['--case-insensitive', '--outfile=@OUTPUT@', '@INPUT@'],
295 )
296
297 libpdns_bindlexer_gen = flex_generator.process(libpdns_bindlexer_source)
298 endif
299
300 libpdns_bindparser_source = src_dir / 'bindparser.yy'
301 libpdns_bindparser_gen = src_dir / 'bindparser.cc'
302 libpdns_bindparser_gen_header = src_dir / 'bindparser.hh'
303 if not fs.is_file(libpdns_bindparser_gen) and not fs.is_file(libpdns_bindparser_gen_header)
304 bison = find_program('bison', required: false)
305 if not bison.found()
306 bison = find_program('yacc', required: true)
307 endif
308
309 summary('Bison/YACC', bison.found(), bool_yn: true, section: 'BIND Parser')
310 summary('Bison/YACC Path', bison.full_path(), section: 'BIND Parser')
311 summary('Bison/YACC Version', bison.version(), section: 'BIND Parser')
312
313 bison_generator = generator(
314 bison,
315 output: ['@BASENAME@.cc', '@BASENAME@.hh', '@BASENAME@.output'],
316 arguments: ['-d', '--verbose', '--debug', '--output=@OUTPUT0@', '@INPUT@'],
317 )
318
319 libpdns_bindparser_gen = bison_generator.process(libpdns_bindparser_source)
320 endif
321
322 libpdns_dnslabeltext_source = src_dir / 'dnslabeltext.rl'
323 libpdns_dnslabeltext_gen = src_dir / 'dnslabeltext.cc'
324 if not fs.is_file(libpdns_dnslabeltext_gen)
325 ragel = find_program('ragel', required: true)
326
327 summary('Ragel', ragel.found(), bool_yn: ragel.found(), section: 'DNS Labels')
328 summary('Ragel Path', ragel.full_path(), section: 'DNS Labels')
329 summary('Ragel Version', ragel.version(), section: 'DNS Labels')
330
331 ragel_generator = generator(
332 ragel,
333 output: '@BASENAME@.cc',
334 arguments: ['@INPUT@', '-o', '@OUTPUT@'],
335 )
336
337 libpdns_dnslabeltext_gen = ragel_generator.process(libpdns_dnslabeltext_source)
338 endif
339
340 libpdns_apidocfiles_source = 'docs' / 'http-api' / 'swagger' / 'authoritative-api-swagger.yaml'
341 libpdns_apidocfiles_gen = src_dir / 'apidocfiles.h'
342 generate_api_swagger_py = src_dir / 'generate-api-swagger.py'
343 if not fs.is_file(libpdns_apidocfiles_gen)
344 py = import('python')
345 python = py.find_installation('python3', modules: 'yaml', required: true)
346
347 summary('Python', python.found(), bool_yn: true, section: 'Swagger API')
348 summary('Path', python.full_path(), section: 'Swagger API')
349 summary('Version', python.version(), section: 'Swagger API')
350
351 libpdns_apidocfiles_gen = custom_target(
352 'pdns-apidocfiles-h',
353 command: [python, '@INPUT0@', '@INPUT1@'],
354 input: [generate_api_swagger_py, libpdns_apidocfiles_source],
355 output: 'apidocfiles.h',
356 capture: true,
357 )
358 endif
359
360 libpdns_bind_dnssec_schema_source = src_dir / 'bind-dnssec.schema.sqlite3.sql'
361 libpdns_bind_dnssec_schema_gen = src_dir / 'bind-dnssec.schema.sqlite3.sql.h'
362 generate_bind_dnssec_schema_py = src_dir / 'generate-bind-dnssec-schema.py'
363 if not fs.is_file(libpdns_bind_dnssec_schema_gen)
364 py = import('python')
365 python = py.find_installation('python3', required: true)
366
367 summary('Python', python.found(), bool_yn: true, section: 'BIND DNSSEC Schema')
368 summary('Path', python.full_path(), section: 'BIND DNSSEC Schema')
369 summary('Version', python.version(), section: 'BIND DNSSEC Schema')
370
371 libpdns_bind_dnssec_schema_gen = custom_target(
372 'pdns-bind-dnssec-schema',
373 command: [python, '@INPUT0@', '@INPUT1@'],
374 input: [generate_bind_dnssec_schema_py, libpdns_bind_dnssec_schema_source],
375 output: 'bind-dnssec.schema.sqlite3.sql.h',
376 capture: true,
377 )
378 endif
379
380 conditional_sources = {
381 'mplexer-sunos-devpoll': {
382 'sources': [
383 src_dir / 'devpollmplexer.cc',
384 src_dir / 'portsmplexer.cc',
385 ],
386 'condition': have_sunos,
387 },
388 'mplexer-linux-epoll': {
389 'sources': [src_dir / 'epollmplexer.cc'],
390 'condition': have_linux,
391 },
392 'mplexer-bsd-kqueue': {
393 'sources': [src_dir / 'kqueuemplexer.cc'],
394 'condition': have_openbsd or have_freebsd,
395 },
396 'minicurl': {
397 'sources': [
398 src_dir / 'minicurl.cc',
399 src_dir / 'minicurl.hh',
400 ],
401 'condition': dep_lua_records.found() or dep_libcurl.found(),
402 },
403 'lua-record': {
404 'sources': [src_dir / 'lua-record.cc'],
405 'condition': dep_lua_records.found(),
406 },
407 'standalone-fuzz-target-runner': {
408 'sources': [src_dir / 'standalone_fuzz_target_runner.cc'],
409 'condition': get_option('fuzz-targets'),
410 },
411 }
412
413 foreach name, info: conditional_sources
414 if info['condition']
415 common_sources += files(info['sources'])
416 endif
417 endforeach
418
419 # Conditional sources that need to be separated into standalone libraries for special
420 # linking without implicitly getting rid of symbols.
421 libpdns_signers_sodium = dependency('', required: false)
422 if dep_libsodium.found()
423 libpdns_signers_sodium = declare_dependency(
424 link_whole: static_library(
425 'pdns-signers-sodium',
426 sources: files(src_dir / 'sodiumsigners.cc'),
427 dependencies: deps,
428 )
429 )
430 endif
431
432 libpdns_signers_decaf = dependency('', required: false)
433 if dep_libdecaf.found()
434 libpdns_signers_decaf = declare_dependency(
435 link_whole: static_library(
436 'pdns-signers-decaf',
437 sources: files(src_dir / 'decafsigners.cc'),
438 dependencies: deps,
439 )
440 )
441 endif
442
443 libpdns_signers_pkcs11 = dependency('', required: false)
444 if dep_pkcs11.found()
445 libpdns_signers_pkcs11 = declare_dependency(
446 link_whole: static_library(
447 'pdns-signers-pkcs11',
448 sources: files(src_dir / 'pkcs11signers.cc', src_dir / 'pkcs11signers.hh'),
449 dependencies: dep_pkcs11,
450 )
451 )
452 endif
453
454 # This needs to be link_whole'd because it's needed by auth backends.
455 libpdns_ssqlite3 = dependency('', required: false)
456 if dep_sqlite3.found()
457 libpdns_ssqlite3 = declare_dependency(
458 link_whole: static_library(
459 'pdns-ssqlite3',
460 sources: files(src_dir / 'ssqlite3.cc', src_dir / 'ssqlite3.hh'),
461 dependencies: deps,
462 )
463 )
464 endif
465
466 libpdns_signers_openssl = declare_dependency(
467 link_whole: static_library(
468 'pdns-signers-openssl',
469 sources: files(src_dir / 'opensslsigners.cc', src_dir / 'opensslsigners.hh'),
470 dependencies: deps,
471 )
472 )
473
474 common_sources += files(
475 src_dir / 'arguments.cc',
476 src_dir / 'arguments.hh',
477 src_dir / 'auth-caches.cc',
478 src_dir / 'auth-caches.hh',
479 src_dir / 'auth-carbon.cc',
480 src_dir / 'auth-catalogzone.cc',
481 src_dir / 'auth-catalogzone.hh',
482 src_dir / 'auth-main.hh',
483 src_dir / 'auth-packetcache.cc',
484 src_dir / 'auth-packetcache.hh',
485 src_dir / 'auth-primarycommunicator.cc',
486 src_dir / 'auth-querycache.cc',
487 src_dir / 'auth-querycache.hh',
488 src_dir / 'auth-secondarycommunicator.cc',
489 src_dir / 'auth-zonecache.cc',
490 src_dir / 'auth-zonecache.hh',
491 src_dir / 'axfr-retriever.cc',
492 src_dir / 'axfr-retriever.hh',
493 src_dir / 'backends' / 'gsql' / 'gsqlbackend.cc', # TODO Move to a separate module.
494 src_dir / 'backends' / 'gsql' / 'gsqlbackend.hh', # TODO Move to a separate module.
495 src_dir / 'backends' / 'gsql' / 'ssql.hh', # TODO Move to a separate module.
496 src_dir / 'base32.cc',
497 src_dir / 'base32.hh',
498 src_dir / 'base64.cc',
499 src_dir / 'base64.hh',
500 src_dir / 'bindparserclasses.hh',
501 src_dir / 'burtle.hh',
502 src_dir / 'cachecleaner.hh',
503 src_dir / 'circular_buffer.hh',
504 src_dir / 'comment.hh',
505 src_dir / 'communicator.cc',
506 src_dir / 'communicator.hh',
507 src_dir / 'coverage.cc',
508 src_dir / 'coverage.hh',
509 src_dir / 'credentials.cc',
510 src_dir / 'credentials.hh',
511 src_dir / 'dbdnsseckeeper.cc',
512 src_dir / 'digests.hh',
513 src_dir / 'distributor.hh',
514 src_dir / 'dns.cc',
515 src_dir / 'dns.hh',
516 src_dir / 'dns_random.hh',
517 src_dir / 'dnsbackend.cc',
518 src_dir / 'dnsbackend.hh',
519 src_dir / 'dnsname.cc',
520 src_dir / 'dnsname.hh',
521 src_dir / 'dnspacket.cc',
522 src_dir / 'dnspacket.hh',
523 src_dir / 'dnsparser.cc',
524 src_dir / 'dnsparser.hh',
525 src_dir / 'dnsproxy.cc',
526 src_dir / 'dnsproxy.hh',
527 src_dir / 'dnsrecords.cc',
528 src_dir / 'dnsrecords.hh',
529 src_dir / 'dnssecinfra.cc',
530 src_dir / 'dnssecinfra.hh',
531 src_dir / 'dnsseckeeper.hh',
532 src_dir / 'dnssecsigner.cc',
533 src_dir / 'dnswriter.cc',
534 src_dir / 'dnswriter.hh',
535 src_dir / 'dynhandler.cc',
536 src_dir / 'dynhandler.hh',
537 src_dir / 'dynlistener.cc',
538 src_dir / 'dynlistener.hh',
539 src_dir / 'dynmessenger.cc',
540 src_dir / 'dynmessenger.hh',
541 src_dir / 'ednscookies.cc',
542 src_dir / 'ednscookies.hh',
543 src_dir / 'ednsoptions.cc',
544 src_dir / 'ednsoptions.hh',
545 src_dir / 'ednssubnet.cc',
546 src_dir / 'ednssubnet.hh',
547 src_dir / 'gss_context.cc',
548 src_dir / 'gss_context.hh',
549 src_dir / 'histogram.hh',
550 src_dir / 'ipcipher.cc',
551 src_dir / 'ipcipher.hh',
552 src_dir / 'iputils.cc',
553 src_dir / 'iputils.hh',
554 src_dir / 'ixfr.cc',
555 src_dir / 'ixfr.hh',
556 src_dir / 'json.cc',
557 src_dir / 'json.hh',
558 src_dir / 'lock.hh',
559 src_dir / 'logger.cc',
560 src_dir / 'logger.hh',
561 src_dir / 'logging.hh',
562 src_dir / 'lua-auth4.cc',
563 src_dir / 'lua-auth4.hh',
564 src_dir / 'lua-base4.cc',
565 src_dir / 'lua-base4.hh',
566 src_dir / 'misc.cc',
567 src_dir / 'misc.hh',
568 src_dir / 'nameserver.cc',
569 src_dir / 'nameserver.hh',
570 src_dir / 'namespaces.hh',
571 src_dir / 'noinitvector.hh',
572 src_dir / 'nsecrecords.cc',
573 src_dir / 'packetcache.hh',
574 src_dir / 'packethandler.cc',
575 src_dir / 'packethandler.hh',
576 src_dir / 'pdnsexception.hh',
577 src_dir / 'proxy-protocol.cc',
578 src_dir / 'proxy-protocol.hh',
579 src_dir / 'qtype.cc',
580 src_dir / 'qtype.hh',
581 src_dir / 'query-local-address.cc',
582 src_dir / 'query-local-address.hh',
583 src_dir / 'rcpgenerator.cc',
584 src_dir / 'rcpgenerator.hh',
585 src_dir / 'resolver.cc',
586 src_dir / 'resolver.hh',
587 src_dir / 'responsestats-auth.cc',
588 src_dir / 'responsestats.cc',
589 src_dir / 'responsestats.hh',
590 src_dir / 'rfc2136handler.cc',
591 src_dir / 'secpoll-auth.cc',
592 src_dir / 'secpoll-auth.hh',
593 src_dir / 'secpoll.cc',
594 src_dir / 'secpoll.hh',
595 src_dir / 'serialtweaker.cc',
596 src_dir / 'sha.hh',
597 src_dir / 'shuffle.cc',
598 src_dir / 'shuffle.hh',
599 src_dir / 'signingpipe.cc',
600 src_dir / 'signingpipe.hh',
601 src_dir / 'sillyrecords.cc',
602 src_dir / 'sstuff.hh',
603 src_dir / 'stat_t.hh',
604 src_dir / 'statbag.cc',
605 src_dir / 'statbag.hh',
606 src_dir / 'stubresolver.cc',
607 src_dir / 'stubresolver.hh',
608 src_dir / 'svc-records.cc',
609 src_dir / 'svc-records.hh',
610 src_dir / 'tcpreceiver.cc',
611 src_dir / 'tcpreceiver.hh',
612 src_dir / 'threadname.cc',
613 src_dir / 'threadname.hh',
614 src_dir / 'tkey.cc',
615 src_dir / 'trusted-notification-proxy.cc',
616 src_dir / 'trusted-notification-proxy.hh',
617 src_dir / 'tsigutils.cc',
618 src_dir / 'tsigutils.hh',
619 src_dir / 'tsigverifier.cc',
620 src_dir / 'tsigverifier.hh',
621 src_dir / 'ueberbackend.cc',
622 src_dir / 'ueberbackend.hh',
623 src_dir / 'unix_semaphore.cc',
624 src_dir / 'unix_utility.cc',
625 src_dir / 'utility.hh',
626 src_dir / 'uuid-utils.cc',
627 src_dir / 'uuid-utils.hh',
628 src_dir / 'validate.hh',
629 src_dir / 'version.cc',
630 src_dir / 'version.hh',
631 src_dir / 'webserver.cc',
632 src_dir / 'webserver.hh',
633 src_dir / 'ws-api.cc',
634 src_dir / 'ws-api.hh',
635 src_dir / 'ws-auth.cc',
636 src_dir / 'ws-auth.hh',
637 src_dir / 'zonemd.cc',
638 src_dir / 'zonemd.hh',
639 src_dir / 'zoneparser-tng.cc',
640 src_dir / 'zoneparser-tng.hh',
641 )
642
643 libpdns_bindparser = declare_dependency(
644 link_with: static_library(
645 'pdns-bindparser',
646 libpdns_bindlexer_gen,
647 libpdns_bindparser_gen,
648 cpp_args: ['-Wno-redundant-decls', '-Wno-sign-compare'],
649 dependencies: deps,
650 )
651 )
652
653 libpdns_dnslabeltext = declare_dependency(
654 link_with: static_library(
655 'pdns-dnslabeltext',
656 libpdns_dnslabeltext_gen,
657 dependencies: deps,
658 )
659 )
660
661 libpdns_cdb = dependency('', required: false)
662 if dep_cdb.found()
663 libpdns_cdb = declare_dependency(
664 link_whole: static_library(
665 'pdns-cdb',
666 sources: files(src_dir / 'cdb.cc', src_dir / 'cdb.hh'),
667 dependencies: deps,
668 )
669 )
670 endif
671
672 # Modules
673 all_modules = [
674 'bind',
675 'pipe',
676 'gmysql',
677 'godbc',
678 'gpgsql',
679 'gsqlite3',
680 'ldap',
681 'lua2',
682 'remote',
683 'tinydns',
684 'geoip',
685 'lmdb',
686 ]
687
688 selected_modules = []
689 selected_dyn_modules = []
690 dep_modules = []
691 foreach module_name: all_modules
692 module_backend_name = module_name + 'backend'
693 module_opt = get_option('module-' + module_name)
694
695 if module_opt == 'disabled'
696 continue
697 elif module_opt == 'static'
698 selected_modules += module_name
699 else
700 selected_dyn_modules += module_name
701 endif
702
703 subdir('modules' / module_backend_name)
704 dep_modules += get_variable('dep_' + module_backend_name)
705 endforeach
706
707 conf.set_quoted('PDNS_MODULES', ' '.join(selected_modules), description: 'Built-in modules')
708 conf.set_quoted('PDNS_DYN_MODULES', ' '.join(selected_dyn_modules), description: 'Loadable modules')
709
710 # Generate config.h
711 config_h = configure_file(configuration: conf, output: 'config.h')
712
713 tools = {
714 'pdns-auth': {
715 'main': src_dir / 'auth-main.cc',
716 'export-dynamic': true,
717 'deps-extra': [
718 dep_modules,
719 libpdns_ssqlite3,
720 libpdns_gettime,
721 libpdns_signers_openssl,
722 libpdns_signers_decaf,
723 libpdns_signers_sodium,
724 ],
725 'manpages': ['pdns_server.1'],
726 },
727 'pdns-auth-util': {
728 'main': src_dir / 'pdnsutil.cc',
729 'files-extra': libpdns_bind_dnssec_schema_gen,
730 'deps-extra': [
731 dep_modules,
732 libpdns_ssqlite3,
733 libpdns_signers_openssl,
734 libpdns_signers_decaf,
735 libpdns_signers_sodium,
736 ],
737 'manpages': ['pdnsutil.1'],
738 },
739 'pdns-auth-control': {
740 'main': src_dir / 'dynloader.cc',
741 'manpages': ['pdns_control.1'],
742 },
743 'pdns-zone2sql': {
744 'main': src_dir / 'zone2sql.cc',
745 'manpages': ['zone2sql.1'],
746 },
747 'pdns-zone2json': {
748 'main': src_dir / 'zone2json.cc',
749 'manpages': ['zone2json.1'],
750 },
751 }
752
753 if get_option('module-ldap') != 'disabled'
754 tools += {
755 'pdns-zone2ldap': {
756 'main': src_dir / 'zone2ldap.cc',
757 'manpages': ['zone2ldap.1'],
758 }
759 }
760 endif
761
762 if get_option('tools')
763 tools += {
764 'pdns-auth-notify': {
765 'main': src_dir / 'notify.cc',
766 'manpages': ['pdns_notify.1'],
767 },
768 'sdig': {
769 'main': src_dir / 'sdig.cc',
770 'manpages': ['sdig.1'],
771 },
772 'calidns': {
773 'main': src_dir / 'calidns.cc',
774 'manpages': ['calidns.1'],
775 },
776 'dnsdemog': {
777 'main': src_dir / 'dnsdemog.cc',
778 },
779 'dnsgram': {
780 'main': src_dir / 'dnsgram.cc',
781 'manpages': ['dnsgram.1'],
782 },
783 'dnspcap2calidns': {
784 'main': src_dir / 'dnspcap2calidns.cc',
785 'manpages': ['dnspcap2calidns.1'],
786 },
787 'dnspcap2protobuf' : {
788 'main': src_dir / 'dnspcap2protobuf.cc',
789 'deps-extra': libpdns_gettime,
790 'manpages': ['dnspcap2protobuf.1'],
791 },
792 'dnsreplay': {
793 'main': src_dir / 'dnsreplay.cc',
794 'manpages': ['dnsreplay.1'],
795 },
796 'dnsscan' : {
797 'main': src_dir / 'dnsscan.cc',
798 'manpages': ['dnsscan.1'],
799 },
800 'dnsscope' : {
801 'main': src_dir / 'dnsscope.cc',
802 'manpages': ['dnsscope.1'],
803 },
804 'dnswasher': {
805 'main': src_dir / 'dnswasher.cc',
806 'manpages': ['dnswasher.1'],
807 },
808 'nproxy' : {
809 'main': src_dir / 'nproxy.cc',
810 'manpages': ['nproxy.1'],
811 },
812 'nsec3dig' : {
813 'main': src_dir / 'nsec3dig.cc',
814 'manpages': ['nsec3dig.1'],
815 },
816 'dumresp' : {
817 'main': src_dir / 'dumresp.cc',
818 'manpages': ['dumresp.1'],
819 },
820 'kvresp' : {
821 'main': src_dir / 'kvresp.cc',
822 },
823 'stubquery': {
824 'main': src_dir / 'stubquery.cc',
825 },
826 'saxfr' : {
827 'main': src_dir / 'saxfr.cc',
828 'manpages': ['saxfr.1'],
829 },
830 'ixplore' : {
831 'main': src_dir / 'ixplore.cc',
832 'manpages': ['ixplore.1'],
833 },
834 # Broken
835 # 'comfun' : {
836 # 'main': src_dir / 'comfun.cc',
837 # },
838 }
839
840 common_sources += files(
841 src_dir / 'anadns.hh',
842 src_dir / 'dnspcap.cc',
843 src_dir / 'dnspcap.hh',
844 src_dir / 'dolog.hh',
845 src_dir / 'ednsextendederror.cc',
846 src_dir / 'ednsextendederror.hh',
847 src_dir / 'histog.hh',
848 src_dir / 'ixfrutils.cc',
849 src_dir / 'ixfrutils.hh',
850 src_dir / 'libssl.cc',
851 src_dir / 'libssl.hh',
852 src_dir / 'mplexer.hh',
853 src_dir / 'pollmplexer.cc',
854 src_dir / 'protozero.cc',
855 src_dir / 'protozero.hh',
856 src_dir / 'statnode.cc',
857 src_dir / 'statnode.hh',
858 src_dir / 'tcpiohandler.cc',
859 src_dir / 'tcpiohandler.hh',
860 )
861
862 if have_boost_1_48_0
863 tools += {
864 'dnstcpbench': {
865 'main': src_dir / 'dnstcpbench.cc',
866 'manpages': ['dnstcpbench.1'],
867 },
868 'dnsbulktest': {
869 'main': src_dir / 'dnsbulktest.cc',
870 'manpages': ['dnsbulktest.1'],
871 },
872 }
873 endif
874 endif
875
876 if get_option('tools-ixfrdist')
877 tools += {
878 'ixfrdist': {
879 'main': src_dir / 'ixfrdist.cc',
880 'manpages': [
881 'ixfrdist.1',
882 'ixfrdist.yml.5',
883 ],
884 },
885 }
886
887 common_sources += files(
888 src_dir / 'ixfrdist-stats.cc',
889 src_dir / 'ixfrdist-stats.hh',
890 src_dir / 'ixfrdist-web.cc',
891 src_dir / 'ixfrdist-web.hh',
892 src_dir / 'ixfrutils.cc',
893 src_dir / 'ixfrutils.hh',
894 src_dir / 'mplexer.hh',
895 src_dir / 'pollmplexer.cc',
896 )
897 endif
898
899 if get_option('unit-tests')
900 libpdns_test = declare_dependency(
901 link_whole: static_library(
902 'pdns-test',
903 config_h,
904 src_dir / 'channel.cc',
905 src_dir / 'channel.hh',
906 src_dir / 'pollmplexer.cc',
907 src_dir / 'test-arguments_cc.cc',
908 src_dir / 'test-auth-zonecache_cc.cc',
909 src_dir / 'test-base32_cc.cc',
910 src_dir / 'test-base64_cc.cc',
911 src_dir / 'test-bindparser_cc.cc',
912 src_dir / 'test-channel.cc',
913 src_dir / 'test-common.hh',
914 src_dir / 'test-communicator_hh.cc',
915 src_dir / 'test-credentials_cc.cc',
916 src_dir / 'test-digests_hh.cc',
917 src_dir / 'test-distributor_hh.cc',
918 src_dir / 'test-dns_random_hh.cc',
919 src_dir / 'test-dnsname_cc.cc',
920 src_dir / 'test-dnsparser_cc.cc',
921 src_dir / 'test-dnsparser_hh.cc',
922 src_dir / 'test-dnsrecordcontent.cc',
923 src_dir / 'test-dnsrecords_cc.cc',
924 src_dir / 'test-dnswriter_cc.cc',
925 src_dir / 'test-ednscookie_cc.cc',
926 src_dir / 'test-ipcrypt_cc.cc',
927 src_dir / 'test-iputils_hh.cc',
928 src_dir / 'test-ixfr_cc.cc',
929 src_dir / 'test-lock_hh.cc',
930 src_dir / 'test-lua_auth4_cc.cc',
931 src_dir / 'test-luawrapper.cc',
932 src_dir / 'test-misc_hh.cc',
933 src_dir / 'test-mplexer.cc',
934 src_dir / 'test-nameserver_cc.cc',
935 src_dir / 'test-packetcache_cc.cc',
936 src_dir / 'test-packetcache_hh.cc',
937 src_dir / 'test-proxy_protocol_cc.cc',
938 src_dir / 'test-rcpgenerator_cc.cc',
939 src_dir / 'test-sha_hh.cc',
940 src_dir / 'test-signers.cc',
941 src_dir / 'test-statbag_cc.cc',
942 src_dir / 'test-svc_records_cc.cc',
943 src_dir / 'test-trusted-notification-proxy_cc.cc',
944 src_dir / 'test-tsig.cc',
945 src_dir / 'test-ueberbackend_cc.cc',
946 src_dir / 'test-webserver_cc.cc',
947 src_dir / 'test-zonemd_cc.cc',
948 src_dir / 'test-zoneparser_tng_cc.cc',
949 src_dir / 'zoneparser-tng.hh',
950 dependencies: [
951 deps,
952 ],
953 )
954 )
955
956 tools += {
957 # TODO: NOINSTALL speedtest and pdns-auth-testrunner
958 'pdns-auth-testrunner': {
959 'main': src_dir / 'testrunner.cc',
960 'deps-extra': [
961 libpdns_test,
962 libpdns_signers_openssl,
963 libpdns_signers_decaf,
964 libpdns_signers_sodium,
965 ],
966 },
967 'speedtest': {
968 'main': src_dir / 'speedtest.cc',
969 },
970 'tsig-tests': {
971 'main': src_dir / 'tsig-tests.cc',
972 },
973 }
974 endif
975
976 if get_option('fuzz-targets')
977 tools += {
978 'fuzz-target-moadnsparser' : { 'main': src_dir / 'fuzz_moadnsparser.cc' },
979 'fuzz-target-packetcache' : { 'main': src_dir / 'fuzz_packetcache.cc' },
980 'fuzz-target-proxyprotocol' : { 'main': src_dir / 'fuzz_proxyprotocol.cc' },
981 'fuzz-target-dnslabeltext-parseRFC1035CharString' : { 'main': src_dir / 'fuzz_dnslabeltext_parseRFC1035CharString.cc' },
982 'fuzz-target-yahttp' : { 'main': src_dir / 'fuzz_yahttp.cc' },
983 'fuzz-target-zoneparsertng' : { 'main': src_dir / 'fuzz_zoneparsertng.cc' },
984 }
985 endif
986
987 libpdns_common = declare_dependency(
988 link_with: static_library(
989 'pdns-common',
990 common_sources,
991 config_h,
992 libpdns_apidocfiles_gen,
993 dependencies: [
994 deps,
995 libpdns_signers_pkcs11,
996 libpdns_bindparser,
997 libpdns_dnslabeltext,
998 ],
999 )
1000 )
1001
1002 man_pages = []
1003 foreach tool, info: tools
1004 var_name = tool.underscorify()
1005 main = files(info['main'])
1006
1007 export_dynamic = 'export-dynamic' in info ? info['export-dynamic'] : false
1008 files_extra = 'files-extra' in info ? info['files-extra'] : []
1009 deps_extra = 'deps-extra' in info ? info['deps-extra'] : []
1010
1011 set_variable(
1012 var_name,
1013 executable(
1014 tool,
1015 main,
1016 config_h,
1017 files_extra,
1018 export_dynamic: export_dynamic,
1019 dependencies: [
1020 deps,
1021 libpdns_common,
1022 deps_extra,
1023 ],
1024 )
1025 )
1026
1027 if 'manpages' in info
1028 foreach man_page: info['manpages']
1029 man_pages += docs_dir / 'manpages' / (man_page + '.rst')
1030 endforeach
1031 endif
1032 endforeach
1033
1034 # Man-pages.
1035 py = import('python')
1036 python = py.find_installation('python3', modules: 'venv', required: false)
1037
1038 summary('Python', python.found(), bool_yn: true, section: 'Manual Pages')
1039 summary('Path', python.full_path(), section: 'Manual Pages')
1040 summary('Version', python.version(), section: 'Manual Pages')
1041
1042 if python.found()
1043 run_target(
1044 'man-pages',
1045 command: [
1046 python,
1047 docs_dir / 'generate-man-pages.py',
1048 '--venv-name', 'venv-auth-man-pages',
1049 '--requirements-file', docs_dir / 'requirements.txt',
1050 '--source-directory', docs_dir,
1051 '--target-directory', 'auth-man-pages',
1052 ] + man_pages,
1053 )
1054 endif
1055
1056 if get_option('unit-tests')
1057 test(
1058 'pdns-auth-testrunner',
1059 pdns_auth_testrunner,
1060 env: {
1061 'BOOST_TEST_LOG_LEVEL': 'message',
1062 },
1063 is_parallel: false,
1064 )
1065 endif
1066
1067 if get_option('module-remote') != 'disabled' and get_option('unit-tests-backends')
1068 libpdns_module_remotebackend_test_common = declare_dependency(
1069 link_whole: static_library(
1070 'pdns-test-remotebackend',
1071 module_remotebackend_test_sources_common,
1072 dependencies: [
1073 deps,
1074 module_remotebackend_lib,
1075 libpdns_signers_pkcs11,
1076 libpdns_common,
1077 libpdns_dnslabeltext,
1078 ],
1079 extra_files: module_remotebackend_test_sources_extra,
1080 )
1081 )
1082
1083 env = {
1084 'BOOST_TEST_LOG_LEVEL': 'message',
1085 'REMOTEBACKEND_ZEROMQ': get_option('module-remote-zeromq') ? 'yes' : 'no',
1086 }
1087
1088 foreach test_binary, test_source: module_remotebackend_test_sources_binaries
1089 exec_var_name = test_binary.underscorify()
1090
1091 set_variable(
1092 exec_var_name,
1093 executable(
1094 test_binary,
1095 test_source,
1096 dependencies: [
1097 deps,
1098 dep_boost_test,
1099 dep_zeromq,
1100 libpdns_module_remotebackend_test_common,
1101 ],
1102 )
1103 )
1104
1105 test(
1106 'pdns-auth-' + test_binary,
1107 module_remotebackend_testrunner,
1108 args: ['--', get_variable(exec_var_name).full_path()],
1109 env: env,
1110 workdir: product_source_dir / fs.parent(module_remotebackend_testrunner),
1111 is_parallel: false,
1112 )
1113 endforeach
1114 endif