]> git.ipfire.org Git - thirdparty/pdns.git/blob - meson.build
f617821c5d4e0438fe19c4f9192e0563cfe2dada
[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' / 'systemd') # Systemd and unit file handling
62 subdir('meson' / 'code-coverage') # Code coverage
63 subdir('meson' / 'auto-var-init') # Automatic Variable Initialization
64 subdir('meson' / 'sanitizers') # Sanitizers
65 subdir('meson' / 'malloc-trace') # Malloc-trace
66 subdir('meson' / 'socket-dir') # Socket Dir
67 subdir('meson' / 'various-functions') # Various Functions
68 subdir('meson' / 'various-headers') # Various Headers
69 subdir('meson' / 'yaml-cpp') # YAML C++
70 subdir('meson' / 'sqlite3') # Sqlite3
71 subdir('meson' / 'lmdb') # LMDB
72 subdir('meson' / 'mysql') # MySQL
73 subdir('meson' / 'odbc') # ODBC
74 subdir('meson' / 'pgsql') # PostgreSQL
75 subdir('meson' / 'ldap') # LDAP
76 subdir('meson' / 'prog-curl') # cURL Program
77 subdir('meson' / 'zeromq') # ZeroMQ
78 subdir('meson' / 'cdb') # CDB
79 subdir('meson' / 'geoip') # GeoIP
80 subdir('meson' / 'mmdb') # MaxMindDB
81 subdir('meson' / 'cxx-fs') # C++ stdlib Filesystem Module
82
83 common_sources = []
84
85 fs = import('fs')
86 src_dir = fs.is_dir('pdns') ? 'pdns' : ''
87 docs_dir = 'docs'
88 # Toplevel includes
89 dep_pdns = declare_dependency(include_directories: include_directories('.', src_dir))
90
91 # Ext
92 subdir('ext' / 'arc4random')
93 subdir('ext' / 'ipcrypt')
94 subdir('ext' / 'json11')
95 subdir('ext' / 'luawrapper')
96 subdir('ext' / 'protozero')
97 subdir('ext' / 'yahttp')
98 if get_option('module-lmdb') != 'disabled'
99 subdir('ext' / 'lmdb-safe')
100 endif
101
102 deps = [
103 dep_pdns,
104 dep_platform,
105 dep_atomics,
106 dep_threads,
107 dep_lua,
108 dep_lua_records,
109 dep_netlibs,
110 dep_libsodium,
111 dep_libdecaf,
112 dep_libcrypto,
113 dep_libssl,
114 dep_gnutls,
115 dep_boost,
116 dep_boost_program_options,
117 dep_dlopen,
118 dep_pkcs11,
119 dep_gss_tsig,
120 dep_systemd,
121 dep_arc4random,
122 dep_ipcrypt,
123 dep_json11,
124 dep_luawrapper,
125 dep_protozero,
126 dep_yahttp,
127 dep_yaml_cpp,
128 dep_sqlite3,
129 dep_lmdb,
130 dep_boost_serialization,
131 dep_mysql,
132 dep_odbc,
133 dep_pgsql,
134 dep_ldap,
135 dep_cdb,
136 dep_geoip,
137 dep_mmdb,
138 dep_cxx_fs,
139 dep_boost_test,
140 ]
141
142 libpdns_bindlexer_source = src_dir / 'bindlexer.l'
143 libpdns_bindlexer_gen = src_dir / 'bindlexer.c'
144 if not fs.is_file(libpdns_bindlexer_gen)
145 flex = find_program('flex', required: true)
146
147 summary('Flex', flex.found(), bool_yn: true, section: 'BIND Parser')
148 summary('Flex Path', flex.full_path(), section: 'BIND Parser')
149 summary('Flex Version', flex.version(), section: 'BIND Parser')
150
151 flex_generator = generator(
152 flex,
153 output: '@BASENAME@.c',
154 arguments: ['--case-insensitive', '--outfile=@OUTPUT@', '@INPUT@'],
155 )
156
157 libpdns_bindlexer_gen = flex_generator.process(libpdns_bindlexer_source)
158 endif
159
160 libpdns_bindparser_source = src_dir / 'bindparser.yy'
161 libpdns_bindparser_gen = src_dir / 'bindparser.cc'
162 libpdns_bindparser_gen_header = src_dir / 'bindparser.hh'
163 if not fs.is_file(libpdns_bindparser_gen) and not fs.is_file(libpdns_bindparser_gen_header)
164 bison = find_program('bison', required: false)
165 if not bison.found()
166 bison = find_program('yacc', required: true)
167 endif
168
169 summary('Bison/YACC', bison.found(), bool_yn: true, section: 'BIND Parser')
170 summary('Bison/YACC Path', bison.full_path(), section: 'BIND Parser')
171 summary('Bison/YACC Version', bison.version(), section: 'BIND Parser')
172
173 bison_generator = generator(
174 bison,
175 output: ['@BASENAME@.cc', '@BASENAME@.hh', '@BASENAME@.output'],
176 arguments: ['-d', '--verbose', '--debug', '--output=@OUTPUT0@', '@INPUT@'],
177 )
178
179 libpdns_bindparser_gen = bison_generator.process(libpdns_bindparser_source)
180 endif
181
182 libpdns_dnslabeltext_source = src_dir / 'dnslabeltext.rl'
183 libpdns_dnslabeltext_gen = src_dir / 'dnslabeltext.cc'
184 if not fs.is_file(libpdns_dnslabeltext_gen)
185 ragel = find_program('ragel', required: true)
186
187 summary('Ragel', ragel.found(), bool_yn: ragel.found(), section: 'DNS Labels')
188 summary('Ragel Path', ragel.full_path(), section: 'DNS Labels')
189 summary('Ragel Version', ragel.version(), section: 'DNS Labels')
190
191 ragel_generator = generator(
192 ragel,
193 output: '@BASENAME@.cc',
194 arguments: ['@INPUT@', '-o', '@OUTPUT@'],
195 )
196
197 libpdns_dnslabeltext_gen = ragel_generator.process(libpdns_dnslabeltext_source)
198 endif
199
200 libpdns_apidocfiles_source = 'docs' / 'http-api' / 'swagger' / 'authoritative-api-swagger.yaml'
201 libpdns_apidocfiles_gen = src_dir / 'apidocfiles.h'
202 generate_api_swagger_py = src_dir / 'generate-api-swagger.py'
203 if not fs.is_file(libpdns_apidocfiles_gen)
204 py = import('python')
205 python = py.find_installation('python3', modules: 'yaml', required: true)
206
207 summary('Python', python.found(), bool_yn: true, section: 'Swagger API')
208 summary('Path', python.full_path(), section: 'Swagger API')
209 summary('Version', python.version(), section: 'Swagger API')
210
211 libpdns_apidocfiles_gen = custom_target(
212 'pdns-apidocfiles-h',
213 command: [python, '@INPUT0@', '@INPUT1@'],
214 input: [generate_api_swagger_py, libpdns_apidocfiles_source],
215 output: 'apidocfiles.h',
216 capture: true,
217 )
218 endif
219
220 libpdns_bind_dnssec_schema_source = src_dir / 'bind-dnssec.schema.sqlite3.sql'
221 libpdns_bind_dnssec_schema_gen = src_dir / 'bind-dnssec.schema.sqlite3.sql.h'
222 generate_bind_dnssec_schema_py = src_dir / 'generate-bind-dnssec-schema.py'
223 if not fs.is_file(libpdns_bind_dnssec_schema_gen)
224 py = import('python')
225 python = py.find_installation('python3', required: true)
226
227 summary('Python', python.found(), bool_yn: true, section: 'BIND DNSSEC Schema')
228 summary('Path', python.full_path(), section: 'BIND DNSSEC Schema')
229 summary('Version', python.version(), section: 'BIND DNSSEC Schema')
230
231 libpdns_bind_dnssec_schema_gen = custom_target(
232 'pdns-bind-dnssec-schema',
233 command: [python, '@INPUT0@', '@INPUT1@'],
234 input: [generate_bind_dnssec_schema_py, libpdns_bind_dnssec_schema_source],
235 output: 'bind-dnssec.schema.sqlite3.sql.h',
236 capture: true,
237 )
238 endif
239
240 conditional_sources = {
241 'mplexer-sunos-devpoll': {
242 'sources': [
243 src_dir / 'devpollmplexer.cc',
244 src_dir / 'portsmplexer.cc',
245 ],
246 'condition': have_sunos,
247 },
248 'mplexer-linux-epoll': {
249 'sources': [src_dir / 'epollmplexer.cc'],
250 'condition': have_linux,
251 },
252 'mplexer-bsd-kqueue': {
253 'sources': [src_dir / 'kqueuemplexer.cc'],
254 'condition': have_openbsd or have_freebsd,
255 },
256 'minicurl': {
257 'sources': [
258 src_dir / 'minicurl.cc',
259 src_dir / 'minicurl.hh',
260 ],
261 'condition': dep_lua_records.found() or dep_libcurl.found(),
262 },
263 'lua-record': {
264 'sources': [src_dir / 'lua-record.cc'],
265 'condition': dep_lua_records.found(),
266 },
267 'standalone-fuzz-target-runner': {
268 'sources': [src_dir / 'standalone_fuzz_target_runner.cc'],
269 'condition': get_option('fuzz-targets'),
270 },
271 }
272
273 foreach name, info: conditional_sources
274 if info['condition']
275 common_sources += files(info['sources'])
276 endif
277 endforeach
278
279 # Conditional sources that need to be separated into standalone libraries for special
280 # linking without implicitly getting rid of symbols.
281 libpdns_signers_sodium = dependency('', required: false)
282 if dep_libsodium.found()
283 libpdns_signers_sodium = declare_dependency(
284 link_whole: static_library(
285 'pdns-signers-sodium',
286 sources: files(src_dir / 'sodiumsigners.cc'),
287 dependencies: deps,
288 )
289 )
290 endif
291
292 libpdns_signers_decaf = dependency('', required: false)
293 if dep_libdecaf.found()
294 libpdns_signers_decaf = declare_dependency(
295 link_whole: static_library(
296 'pdns-signers-decaf',
297 sources: files(src_dir / 'decafsigners.cc'),
298 dependencies: deps,
299 )
300 )
301 endif
302
303 libpdns_signers_pkcs11 = dependency('', required: false)
304 if dep_pkcs11.found()
305 libpdns_signers_pkcs11 = declare_dependency(
306 link_whole: static_library(
307 'pdns-signers-pkcs11',
308 sources: files(src_dir / 'pkcs11signers.cc', src_dir / 'pkcs11signers.hh'),
309 dependencies: dep_pkcs11,
310 )
311 )
312 endif
313
314 # This needs to be link_whole'd because it's needed by auth backends.
315 libpdns_ssqlite3 = dependency('', required: false)
316 if dep_sqlite3.found()
317 libpdns_ssqlite3 = declare_dependency(
318 link_whole: static_library(
319 'pdns-ssqlite3',
320 sources: files(src_dir / 'ssqlite3.cc', src_dir / 'ssqlite3.hh'),
321 dependencies: deps,
322 )
323 )
324 endif
325
326 libpdns_gettime = declare_dependency(
327 link_whole: static_library(
328 'pdns-gettime',
329 src_dir / 'gettime.cc',
330 src_dir / 'gettime.hh',
331 dependencies: dep_rt,
332 )
333 )
334
335 libpdns_signers_openssl = declare_dependency(
336 link_whole: static_library(
337 'pdns-signers-openssl',
338 sources: files(src_dir / 'opensslsigners.cc', src_dir / 'opensslsigners.hh'),
339 dependencies: deps,
340 )
341 )
342
343 common_sources += files(
344 src_dir / 'arguments.cc',
345 src_dir / 'arguments.hh',
346 src_dir / 'auth-caches.cc',
347 src_dir / 'auth-caches.hh',
348 src_dir / 'auth-carbon.cc',
349 src_dir / 'auth-catalogzone.cc',
350 src_dir / 'auth-catalogzone.hh',
351 src_dir / 'auth-main.hh',
352 src_dir / 'auth-packetcache.cc',
353 src_dir / 'auth-packetcache.hh',
354 src_dir / 'auth-primarycommunicator.cc',
355 src_dir / 'auth-querycache.cc',
356 src_dir / 'auth-querycache.hh',
357 src_dir / 'auth-secondarycommunicator.cc',
358 src_dir / 'auth-zonecache.cc',
359 src_dir / 'auth-zonecache.hh',
360 src_dir / 'axfr-retriever.cc',
361 src_dir / 'axfr-retriever.hh',
362 src_dir / 'backends' / 'gsql' / 'gsqlbackend.cc', # TODO Move to a separate module.
363 src_dir / 'backends' / 'gsql' / 'gsqlbackend.hh', # TODO Move to a separate module.
364 src_dir / 'backends' / 'gsql' / 'ssql.hh', # TODO Move to a separate module.
365 src_dir / 'base32.cc',
366 src_dir / 'base32.hh',
367 src_dir / 'base64.cc',
368 src_dir / 'base64.hh',
369 src_dir / 'bindparserclasses.hh',
370 src_dir / 'burtle.hh',
371 src_dir / 'cachecleaner.hh',
372 src_dir / 'circular_buffer.hh',
373 src_dir / 'comment.hh',
374 src_dir / 'communicator.cc',
375 src_dir / 'communicator.hh',
376 src_dir / 'coverage.cc',
377 src_dir / 'coverage.hh',
378 src_dir / 'credentials.cc',
379 src_dir / 'credentials.hh',
380 src_dir / 'dbdnsseckeeper.cc',
381 src_dir / 'digests.hh',
382 src_dir / 'distributor.hh',
383 src_dir / 'dns.cc',
384 src_dir / 'dns.hh',
385 src_dir / 'dns_random.hh',
386 src_dir / 'dnsbackend.cc',
387 src_dir / 'dnsbackend.hh',
388 src_dir / 'dnsname.cc',
389 src_dir / 'dnsname.hh',
390 src_dir / 'dnspacket.cc',
391 src_dir / 'dnspacket.hh',
392 src_dir / 'dnsparser.cc',
393 src_dir / 'dnsparser.hh',
394 src_dir / 'dnsproxy.cc',
395 src_dir / 'dnsproxy.hh',
396 src_dir / 'dnsrecords.cc',
397 src_dir / 'dnsrecords.hh',
398 src_dir / 'dnssecinfra.cc',
399 src_dir / 'dnssecinfra.hh',
400 src_dir / 'dnsseckeeper.hh',
401 src_dir / 'dnssecsigner.cc',
402 src_dir / 'dnswriter.cc',
403 src_dir / 'dnswriter.hh',
404 src_dir / 'dynhandler.cc',
405 src_dir / 'dynhandler.hh',
406 src_dir / 'dynlistener.cc',
407 src_dir / 'dynlistener.hh',
408 src_dir / 'dynmessenger.cc',
409 src_dir / 'dynmessenger.hh',
410 src_dir / 'ednscookies.cc',
411 src_dir / 'ednscookies.hh',
412 src_dir / 'ednsoptions.cc',
413 src_dir / 'ednsoptions.hh',
414 src_dir / 'ednssubnet.cc',
415 src_dir / 'ednssubnet.hh',
416 src_dir / 'gss_context.cc',
417 src_dir / 'gss_context.hh',
418 src_dir / 'histogram.hh',
419 src_dir / 'ipcipher.cc',
420 src_dir / 'ipcipher.hh',
421 src_dir / 'iputils.cc',
422 src_dir / 'iputils.hh',
423 src_dir / 'ixfr.cc',
424 src_dir / 'ixfr.hh',
425 src_dir / 'json.cc',
426 src_dir / 'json.hh',
427 src_dir / 'lock.hh',
428 src_dir / 'logger.cc',
429 src_dir / 'logger.hh',
430 src_dir / 'logging.hh',
431 src_dir / 'lua-auth4.cc',
432 src_dir / 'lua-auth4.hh',
433 src_dir / 'lua-base4.cc',
434 src_dir / 'lua-base4.hh',
435 src_dir / 'misc.cc',
436 src_dir / 'misc.hh',
437 src_dir / 'nameserver.cc',
438 src_dir / 'nameserver.hh',
439 src_dir / 'namespaces.hh',
440 src_dir / 'noinitvector.hh',
441 src_dir / 'nsecrecords.cc',
442 src_dir / 'packetcache.hh',
443 src_dir / 'packethandler.cc',
444 src_dir / 'packethandler.hh',
445 src_dir / 'pdnsexception.hh',
446 src_dir / 'proxy-protocol.cc',
447 src_dir / 'proxy-protocol.hh',
448 src_dir / 'qtype.cc',
449 src_dir / 'qtype.hh',
450 src_dir / 'query-local-address.cc',
451 src_dir / 'query-local-address.hh',
452 src_dir / 'rcpgenerator.cc',
453 src_dir / 'rcpgenerator.hh',
454 src_dir / 'resolver.cc',
455 src_dir / 'resolver.hh',
456 src_dir / 'responsestats-auth.cc',
457 src_dir / 'responsestats.cc',
458 src_dir / 'responsestats.hh',
459 src_dir / 'rfc2136handler.cc',
460 src_dir / 'secpoll-auth.cc',
461 src_dir / 'secpoll-auth.hh',
462 src_dir / 'secpoll.cc',
463 src_dir / 'secpoll.hh',
464 src_dir / 'serialtweaker.cc',
465 src_dir / 'sha.hh',
466 src_dir / 'shuffle.cc',
467 src_dir / 'shuffle.hh',
468 src_dir / 'signingpipe.cc',
469 src_dir / 'signingpipe.hh',
470 src_dir / 'sillyrecords.cc',
471 src_dir / 'sstuff.hh',
472 src_dir / 'stat_t.hh',
473 src_dir / 'statbag.cc',
474 src_dir / 'statbag.hh',
475 src_dir / 'stubresolver.cc',
476 src_dir / 'stubresolver.hh',
477 src_dir / 'svc-records.cc',
478 src_dir / 'svc-records.hh',
479 src_dir / 'tcpreceiver.cc',
480 src_dir / 'tcpreceiver.hh',
481 src_dir / 'threadname.cc',
482 src_dir / 'threadname.hh',
483 src_dir / 'tkey.cc',
484 src_dir / 'trusted-notification-proxy.cc',
485 src_dir / 'trusted-notification-proxy.hh',
486 src_dir / 'tsigutils.cc',
487 src_dir / 'tsigutils.hh',
488 src_dir / 'tsigverifier.cc',
489 src_dir / 'tsigverifier.hh',
490 src_dir / 'ueberbackend.cc',
491 src_dir / 'ueberbackend.hh',
492 src_dir / 'unix_semaphore.cc',
493 src_dir / 'unix_utility.cc',
494 src_dir / 'utility.hh',
495 src_dir / 'uuid-utils.cc',
496 src_dir / 'uuid-utils.hh',
497 src_dir / 'validate.hh',
498 src_dir / 'version.cc',
499 src_dir / 'version.hh',
500 src_dir / 'webserver.cc',
501 src_dir / 'webserver.hh',
502 src_dir / 'ws-api.cc',
503 src_dir / 'ws-api.hh',
504 src_dir / 'ws-auth.cc',
505 src_dir / 'ws-auth.hh',
506 src_dir / 'zonemd.cc',
507 src_dir / 'zonemd.hh',
508 src_dir / 'zoneparser-tng.cc',
509 src_dir / 'zoneparser-tng.hh',
510 )
511
512 libpdns_bindparser = declare_dependency(
513 link_with: static_library(
514 'pdns-bindparser',
515 libpdns_bindlexer_gen,
516 libpdns_bindparser_gen,
517 cpp_args: ['-Wno-redundant-decls', '-Wno-sign-compare'],
518 dependencies: deps,
519 )
520 )
521
522 libpdns_dnslabeltext = declare_dependency(
523 link_with: static_library(
524 'pdns-dnslabeltext',
525 libpdns_dnslabeltext_gen,
526 dependencies: deps,
527 )
528 )
529
530 libpdns_cdb = dependency('', required: false)
531 if dep_cdb.found()
532 libpdns_cdb = declare_dependency(
533 link_whole: static_library(
534 'pdns-cdb',
535 sources: files(src_dir / 'cdb.cc', src_dir / 'cdb.hh'),
536 dependencies: deps,
537 )
538 )
539 endif
540
541 # Modules
542 all_modules = [
543 'bind',
544 'pipe',
545 'gmysql',
546 'godbc',
547 'gpgsql',
548 'gsqlite3',
549 'ldap',
550 'lua2',
551 'remote',
552 'tinydns',
553 'geoip',
554 'lmdb',
555 ]
556
557 selected_modules = []
558 selected_dyn_modules = []
559 dep_modules = []
560 foreach module_name: all_modules
561 module_backend_name = module_name + 'backend'
562 module_opt = get_option('module-' + module_name)
563
564 if module_opt == 'disabled'
565 continue
566 elif module_opt == 'static'
567 selected_modules += module_name
568 else
569 selected_dyn_modules += module_name
570 endif
571
572 subdir('modules' / module_backend_name)
573 dep_modules += get_variable('dep_' + module_backend_name)
574 endforeach
575
576 conf.set_quoted('PDNS_MODULES', ' '.join(selected_modules), description: 'Built-in modules')
577 conf.set_quoted('PDNS_DYN_MODULES', ' '.join(selected_dyn_modules), description: 'Loadable modules')
578
579 # Generate config.h
580 config_h = configure_file(configuration: conf, output: 'config.h')
581
582 tools = {
583 'pdns-auth': {
584 'main': src_dir / 'auth-main.cc',
585 'export-dynamic': true,
586 'deps-extra': [
587 dep_modules,
588 libpdns_ssqlite3,
589 libpdns_gettime,
590 libpdns_signers_openssl,
591 libpdns_signers_decaf,
592 libpdns_signers_sodium,
593 ],
594 'manpages': ['pdns_server.1'],
595 },
596 'pdns-auth-util': {
597 'main': src_dir / 'pdnsutil.cc',
598 'files-extra': libpdns_bind_dnssec_schema_gen,
599 'deps-extra': [
600 dep_modules,
601 libpdns_ssqlite3,
602 libpdns_signers_openssl,
603 libpdns_signers_decaf,
604 libpdns_signers_sodium,
605 ],
606 'manpages': ['pdnsutil.1'],
607 },
608 'pdns-auth-control': {
609 'main': src_dir / 'dynloader.cc',
610 'manpages': ['pdns_control.1'],
611 },
612 'pdns-zone2sql': {
613 'main': src_dir / 'zone2sql.cc',
614 'manpages': ['zone2sql.1'],
615 },
616 'pdns-zone2json': {
617 'main': src_dir / 'zone2json.cc',
618 'manpages': ['zone2json.1'],
619 },
620 }
621
622 if get_option('module-ldap') != 'disabled'
623 tools += {
624 'pdns-zone2ldap': {
625 'main': src_dir / 'zone2ldap.cc',
626 'manpages': ['zone2ldap.1'],
627 }
628 }
629 endif
630
631 if get_option('tools')
632 tools += {
633 'pdns-auth-notify': {
634 'main': src_dir / 'notify.cc',
635 'manpages': ['pdns_notify.1'],
636 },
637 'sdig': {
638 'main': src_dir / 'sdig.cc',
639 'manpages': ['sdig.1'],
640 },
641 'calidns': {
642 'main': src_dir / 'calidns.cc',
643 'manpages': ['calidns.1'],
644 },
645 'dnsdemog': {
646 'main': src_dir / 'dnsdemog.cc',
647 },
648 'dnsgram': {
649 'main': src_dir / 'dnsgram.cc',
650 'manpages': ['dnsgram.1'],
651 },
652 'dnspcap2calidns': {
653 'main': src_dir / 'dnspcap2calidns.cc',
654 'manpages': ['dnspcap2calidns.1'],
655 },
656 'dnspcap2protobuf' : {
657 'main': src_dir / 'dnspcap2protobuf.cc',
658 'deps-extra': libpdns_gettime,
659 'manpages': ['dnspcap2protobuf.1'],
660 },
661 'dnsreplay': {
662 'main': src_dir / 'dnsreplay.cc',
663 'manpages': ['dnsreplay.1'],
664 },
665 'dnsscan' : {
666 'main': src_dir / 'dnsscan.cc',
667 'manpages': ['dnsscan.1'],
668 },
669 'dnsscope' : {
670 'main': src_dir / 'dnsscope.cc',
671 'manpages': ['dnsscope.1'],
672 },
673 'dnswasher': {
674 'main': src_dir / 'dnswasher.cc',
675 'manpages': ['dnswasher.1'],
676 },
677 'nproxy' : {
678 'main': src_dir / 'nproxy.cc',
679 'manpages': ['nproxy.1'],
680 },
681 'nsec3dig' : {
682 'main': src_dir / 'nsec3dig.cc',
683 'manpages': ['nsec3dig.1'],
684 },
685 'dumresp' : {
686 'main': src_dir / 'dumresp.cc',
687 'manpages': ['dumresp.1'],
688 },
689 'kvresp' : {
690 'main': src_dir / 'kvresp.cc',
691 },
692 'stubquery': {
693 'main': src_dir / 'stubquery.cc',
694 },
695 'saxfr' : {
696 'main': src_dir / 'saxfr.cc',
697 'manpages': ['saxfr.1'],
698 },
699 'ixplore' : {
700 'main': src_dir / 'ixplore.cc',
701 'manpages': ['ixplore.1'],
702 },
703 # Broken
704 # 'comfun' : {
705 # 'main': src_dir / 'comfun.cc',
706 # },
707 }
708
709 common_sources += files(
710 src_dir / 'anadns.hh',
711 src_dir / 'dnspcap.cc',
712 src_dir / 'dnspcap.hh',
713 src_dir / 'dolog.hh',
714 src_dir / 'ednsextendederror.cc',
715 src_dir / 'ednsextendederror.hh',
716 src_dir / 'histog.hh',
717 src_dir / 'ixfrutils.cc',
718 src_dir / 'ixfrutils.hh',
719 src_dir / 'libssl.cc',
720 src_dir / 'libssl.hh',
721 src_dir / 'mplexer.hh',
722 src_dir / 'pollmplexer.cc',
723 src_dir / 'protozero.cc',
724 src_dir / 'protozero.hh',
725 src_dir / 'statnode.cc',
726 src_dir / 'statnode.hh',
727 src_dir / 'tcpiohandler.cc',
728 src_dir / 'tcpiohandler.hh',
729 )
730
731 if have_boost_1_48_0
732 tools += {
733 'dnstcpbench': {
734 'main': src_dir / 'dnstcpbench.cc',
735 'manpages': ['dnstcpbench.1'],
736 },
737 'dnsbulktest': {
738 'main': src_dir / 'dnsbulktest.cc',
739 'manpages': ['dnsbulktest.1'],
740 },
741 }
742 endif
743 endif
744
745 if get_option('tools-ixfrdist')
746 tools += {
747 'ixfrdist': {
748 'main': src_dir / 'ixfrdist.cc',
749 'manpages': [
750 'ixfrdist.1',
751 'ixfrdist.yml.5',
752 ],
753 },
754 }
755
756 common_sources += files(
757 src_dir / 'ixfrdist-stats.cc',
758 src_dir / 'ixfrdist-stats.hh',
759 src_dir / 'ixfrdist-web.cc',
760 src_dir / 'ixfrdist-web.hh',
761 src_dir / 'ixfrutils.cc',
762 src_dir / 'ixfrutils.hh',
763 src_dir / 'mplexer.hh',
764 src_dir / 'pollmplexer.cc',
765 )
766 endif
767
768 if get_option('unit-tests')
769 libpdns_test = declare_dependency(
770 link_whole: static_library(
771 'pdns-test',
772 config_h,
773 src_dir / 'channel.cc',
774 src_dir / 'channel.hh',
775 src_dir / 'pollmplexer.cc',
776 src_dir / 'test-arguments_cc.cc',
777 src_dir / 'test-auth-zonecache_cc.cc',
778 src_dir / 'test-base32_cc.cc',
779 src_dir / 'test-base64_cc.cc',
780 src_dir / 'test-bindparser_cc.cc',
781 src_dir / 'test-channel.cc',
782 src_dir / 'test-common.hh',
783 src_dir / 'test-communicator_hh.cc',
784 src_dir / 'test-credentials_cc.cc',
785 src_dir / 'test-digests_hh.cc',
786 src_dir / 'test-distributor_hh.cc',
787 src_dir / 'test-dns_random_hh.cc',
788 src_dir / 'test-dnsname_cc.cc',
789 src_dir / 'test-dnsparser_cc.cc',
790 src_dir / 'test-dnsparser_hh.cc',
791 src_dir / 'test-dnsrecordcontent.cc',
792 src_dir / 'test-dnsrecords_cc.cc',
793 src_dir / 'test-dnswriter_cc.cc',
794 src_dir / 'test-ednscookie_cc.cc',
795 src_dir / 'test-ipcrypt_cc.cc',
796 src_dir / 'test-iputils_hh.cc',
797 src_dir / 'test-ixfr_cc.cc',
798 src_dir / 'test-lock_hh.cc',
799 src_dir / 'test-lua_auth4_cc.cc',
800 src_dir / 'test-luawrapper.cc',
801 src_dir / 'test-misc_hh.cc',
802 src_dir / 'test-mplexer.cc',
803 src_dir / 'test-nameserver_cc.cc',
804 src_dir / 'test-packetcache_cc.cc',
805 src_dir / 'test-packetcache_hh.cc',
806 src_dir / 'test-proxy_protocol_cc.cc',
807 src_dir / 'test-rcpgenerator_cc.cc',
808 src_dir / 'test-sha_hh.cc',
809 src_dir / 'test-signers.cc',
810 src_dir / 'test-statbag_cc.cc',
811 src_dir / 'test-svc_records_cc.cc',
812 src_dir / 'test-trusted-notification-proxy_cc.cc',
813 src_dir / 'test-tsig.cc',
814 src_dir / 'test-ueberbackend_cc.cc',
815 src_dir / 'test-webserver_cc.cc',
816 src_dir / 'test-zonemd_cc.cc',
817 src_dir / 'test-zoneparser_tng_cc.cc',
818 src_dir / 'zoneparser-tng.hh',
819 dependencies: [
820 deps,
821 ],
822 )
823 )
824
825 tools += {
826 # TODO: NOINSTALL speedtest and pdns-auth-testrunner
827 'pdns-auth-testrunner': {
828 'main': src_dir / 'testrunner.cc',
829 'deps-extra': [
830 libpdns_test,
831 libpdns_signers_openssl,
832 libpdns_signers_decaf,
833 libpdns_signers_sodium,
834 ],
835 },
836 'speedtest': {
837 'main': src_dir / 'speedtest.cc',
838 },
839 'tsig-tests': {
840 'main': src_dir / 'tsig-tests.cc',
841 },
842 }
843 endif
844
845 if get_option('fuzz-targets')
846 tools += {
847 'fuzz-target-moadnsparser' : { 'main': src_dir / 'fuzz_moadnsparser.cc' },
848 'fuzz-target-packetcache' : { 'main': src_dir / 'fuzz_packetcache.cc' },
849 'fuzz-target-proxyprotocol' : { 'main': src_dir / 'fuzz_proxyprotocol.cc' },
850 'fuzz-target-dnslabeltext-parseRFC1035CharString' : { 'main': src_dir / 'fuzz_dnslabeltext_parseRFC1035CharString.cc' },
851 'fuzz-target-yahttp' : { 'main': src_dir / 'fuzz_yahttp.cc' },
852 'fuzz-target-zoneparsertng' : { 'main': src_dir / 'fuzz_zoneparsertng.cc' },
853 }
854 endif
855
856 libpdns_common = declare_dependency(
857 link_with: static_library(
858 'pdns-common',
859 common_sources,
860 config_h,
861 libpdns_apidocfiles_gen,
862 dependencies: [
863 deps,
864 libpdns_signers_pkcs11,
865 libpdns_bindparser,
866 libpdns_dnslabeltext,
867 ],
868 )
869 )
870
871 man_pages = []
872 foreach tool, info: tools
873 var_name = tool.underscorify()
874 main = files(info['main'])
875
876 export_dynamic = 'export-dynamic' in info ? info['export-dynamic'] : false
877 files_extra = 'files-extra' in info ? info['files-extra'] : []
878 deps_extra = 'deps-extra' in info ? info['deps-extra'] : []
879
880 set_variable(
881 var_name,
882 executable(
883 tool,
884 main,
885 config_h,
886 files_extra,
887 export_dynamic: export_dynamic,
888 dependencies: [
889 deps,
890 libpdns_common,
891 deps_extra,
892 ],
893 )
894 )
895
896 if 'manpages' in info
897 foreach man_page: info['manpages']
898 man_pages += docs_dir / 'manpages' / (man_page + '.rst')
899 endforeach
900 endif
901 endforeach
902
903 # Man-pages.
904 py = import('python')
905 python = py.find_installation('python3', modules: 'venv', required: false)
906
907 summary('Python', python.found(), bool_yn: true, section: 'Manual Pages')
908 summary('Path', python.full_path(), section: 'Manual Pages')
909 summary('Version', python.version(), section: 'Manual Pages')
910
911 if python.found()
912 run_target(
913 'man-pages',
914 command: [
915 python,
916 docs_dir / 'generate-man-pages.py',
917 '--venv-name', 'venv-auth-man-pages',
918 '--requirements-file', docs_dir / 'requirements.txt',
919 '--source-directory', docs_dir,
920 '--target-directory', 'auth-man-pages',
921 ] + man_pages,
922 )
923 endif
924
925 if get_option('unit-tests')
926 test(
927 'pdns-auth-testrunner',
928 pdns_auth_testrunner,
929 env: {
930 'BOOST_TEST_LOG_LEVEL': 'message',
931 },
932 is_parallel: false,
933 )
934 endif
935
936 if get_option('module-remote') != 'disabled' and get_option('unit-tests-backends')
937 libpdns_module_remotebackend_test_common = declare_dependency(
938 link_whole: static_library(
939 'pdns-test-remotebackend',
940 module_remotebackend_test_sources_common,
941 dependencies: [
942 deps,
943 module_remotebackend_lib,
944 libpdns_signers_pkcs11,
945 libpdns_common,
946 libpdns_dnslabeltext,
947 ],
948 extra_files: module_remotebackend_test_sources_extra,
949 )
950 )
951
952 env = {
953 'BOOST_TEST_LOG_LEVEL': 'message',
954 'REMOTEBACKEND_ZEROMQ': get_option('module-remote-zeromq') ? 'yes' : 'no',
955 }
956
957 foreach test_binary, test_source: module_remotebackend_test_sources_binaries
958 exec_var_name = test_binary.underscorify()
959
960 set_variable(
961 exec_var_name,
962 executable(
963 test_binary,
964 test_source,
965 dependencies: [
966 deps,
967 dep_boost_test,
968 dep_zeromq,
969 libpdns_module_remotebackend_test_common,
970 ],
971 )
972 )
973
974 test(
975 'pdns-auth-' + test_binary,
976 module_remotebackend_testrunner,
977 args: ['--', get_variable(exec_var_name).full_path()],
978 env: env,
979 workdir: product_source_dir / fs.parent(module_remotebackend_testrunner),
980 is_parallel: false,
981 )
982 endforeach
983 endif