]> git.ipfire.org Git - thirdparty/pdns.git/blame - meson.build
Meson: Build remotebackend tests
[thirdparty/pdns.git] / meson.build
CommitLineData
5c68e442
FM
1project(
2 'pdns',
3 ['c', 'cpp'],
5c7f7b58 4 version: run_command('builder-support' / 'gen-version', check: true).stdout().strip(),
e6366c2d
FM
5 license: 'GPLv2',
6 license_files: 'NOTICE',
d7390f70 7 meson_version: '>= 1.2.1',
5c68e442
FM
8 default_options: [
9 'buildtype=debugoptimized',
40cbb4b5 10 'warning_level=2', # TODO Move this to 3 to enable -Wpedantic
5c68e442
FM
11 'cpp_std=c++17',
12 ],
13)
14
0fd9a8b4
FM
15product_source_dir = meson.current_source_dir()
16product_build_dir = meson.current_build_dir()
17summary('Source Dir', product_source_dir, section: 'Build')
18summary('Build Dir', product_build_dir, section: 'Build')
9c9daf0d 19
762296f8 20# Create the configuration object and dependencies list.
5c68e442 21conf = configuration_data()
e79e8538 22
057c30b2 23# Feature detection and system configuration
935ec14d
FM
24subdir('meson' / 'config') # Config
25subdir('meson' / 'version') # Generate version define
26subdir('meson' / 'compiler-setup') # Common compiler setup
27subdir('meson' / 'summary') # Print a system/project summary
6803f671 28subdir('meson' / 'sysconfdir') # Sysconfdir
d07827ea 29subdir('meson' / 'libdir') # Libdir
960b3dbb 30subdir('meson' / 'platform') # Platform detection
935ec14d
FM
31subdir('meson' / 'timet-size') # Check the size of time_t
32subdir('meson' / 'timet-sign') # Check the sign of time_t
935ec14d
FM
33subdir('meson' / 'atomics') # Check atomics support
34subdir('meson' / 'pthread-headers') # Check pthread headers
35subdir('meson' / 'pthread-setname') # Pthread setname madness
36subdir('meson' / 'strerror') # Strerror_r
37subdir('meson' / 'lua') # Lua
4f5c1414 38subdir('meson' / 'lua-records') # Lua-based Records
935ec14d
FM
39subdir('meson' / 'hardening') # Hardening
40subdir('meson' / 'kiss-rng') # Unsafe KISS RNG
41subdir('meson' / 'net-libs') # Network Libraries
111d721e 42subdir('meson' / 'tm-gmtoff') # Check for tm_gmtoff field in struct tm
b2a221f3 43subdir('meson' / 'mmap') # Check for mmap
935ec14d
FM
44subdir('meson' / 'libsodium') # Libsodium-based signers
45subdir('meson' / 'libdecaf') # Libdecaf-based signers
46subdir('meson' / 'libcrypto') # OpenSSL-based signers
47subdir('meson' / 'libssl') # OpenSSL libssl
48subdir('meson' / 'gnutls') # GnuTLS
49subdir('meson' / 'dot') # DNS over TLS
50subdir('meson' / 'ipcipher') # IPCipher
935ec14d
FM
51subdir('meson' / 'clock-gettime') # Clock_gettime
52subdir('meson' / 'boost') # Boost
53subdir('meson' / 'boost-program-options') # Boost Program Options Library
a1bc1ce4 54subdir('meson' / 'boost-test') # Boost Testing Library
2d4c0b49 55subdir('meson' / 'boost-serialization') # Boost Serialization Library
935ec14d 56subdir('meson' / 'reproducible') # Reproducible Builds
935ec14d
FM
57subdir('meson' / 'dlopen') # dlopen
58subdir('meson' / 'verbose-logging') # Verbose Logging
59subdir('meson' / 'pkcs11') # PKCS11
60subdir('meson' / 'gss-tsig') # GSS-TSIG
935ec14d
FM
61subdir('meson' / 'systemd') # Systemd and unit file handling
62subdir('meson' / 'code-coverage') # Code coverage
63subdir('meson' / 'auto-var-init') # Automatic Variable Initialization
64subdir('meson' / 'sanitizers') # Sanitizers
65subdir('meson' / 'malloc-trace') # Malloc-trace
86d2bb0e 66subdir('meson' / 'socket-dir') # Socket Dir
8a629261 67subdir('meson' / 'various-functions') # Various Functions
57376991 68subdir('meson' / 'various-headers') # Various Headers
9078074a 69subdir('meson' / 'yaml-cpp') # YAML C++
04c9ac7d 70subdir('meson' / 'sqlite3') # Sqlite3
2d4c0b49 71subdir('meson' / 'lmdb') # LMDB
24f709be
FM
72subdir('meson' / 'mysql') # MySQL
73subdir('meson' / 'odbc') # ODBC
74subdir('meson' / 'pgsql') # PostgreSQL
75subdir('meson' / 'ldap') # LDAP
76subdir('meson' / 'prog-curl') # cURL Program
77subdir('meson' / 'zeromq') # ZeroMQ
78subdir('meson' / 'cdb') # CDB
79subdir('meson' / 'geoip') # GeoIP
80subdir('meson' / 'mmdb') # MaxMindDB
81subdir('meson' / 'cxx-fs') # C++ stdlib Filesystem Module
fcbbf383 82
007f8b5e 83# Manpages
1062e0ba
FM
84# if not fs.exists('docs' / 'pdns_server.1') and not python_have_venv
85# warning('Python3 and/or its venv module is not available and ' +
86# '`docs/pdns_server.1` cannot be found. ' +
87# 'Documentation will not be built.')
88# endif
007f8b5e
FM
89# TODO Generate pdns_server.1 manpage
90
5ff791ec
FM
91common_sources = []
92
93fs = import('fs')
94src_dir = fs.is_dir('pdns') ? 'pdns' : ''
95# Toplevel includes
96dep_pdns = declare_dependency(include_directories: include_directories('.', src_dir))
97
0f02790d 98# Ext
a0a6b9ac
FM
99subdir('ext' / 'arc4random')
100subdir('ext' / 'ipcrypt')
101subdir('ext' / 'json11')
102subdir('ext' / 'luawrapper')
103subdir('ext' / 'protozero')
104subdir('ext' / 'yahttp')
2d4c0b49 105if get_option('module-lmdb') != 'disabled'
a0a6b9ac 106 subdir('ext' / 'lmdb-safe')
2d4c0b49 107endif
0f02790d 108
5ff791ec
FM
109libpdns_bindlexer_source = src_dir / 'bindlexer.l'
110libpdns_bindlexer_gen = src_dir / 'bindlexer.c'
111if not fs.is_file(libpdns_bindlexer_gen)
112 flex = find_program('flex', required: true)
113
114 summary('Flex', flex.found(), bool_yn: true, section: 'BIND Parser')
115 summary('Flex Path', flex.full_path(), section: 'BIND Parser')
116 summary('Flex Version', flex.version(), section: 'BIND Parser')
117
118 flex_generator = generator(
119 flex,
120 output: '@BASENAME@.c',
121 arguments: ['--case-insensitive', '--outfile=@OUTPUT@', '@INPUT@'],
122 )
123
124 libpdns_bindlexer_gen = flex_generator.process(libpdns_bindlexer_source)
125endif
126
127libpdns_bindparser_source = src_dir / 'bindparser.yy'
128libpdns_bindparser_gen = src_dir / 'bindparser.cc'
129libpdns_bindparser_gen_header = src_dir / 'bindparser.hh'
130if not fs.is_file(libpdns_bindparser_gen) and not fs.is_file(libpdns_bindparser_gen_header)
131 bison = find_program('bison', required: false)
132 if not bison.found()
133 bison = find_program('yacc', required: true)
134 endif
135
136 summary('Bison/YACC', bison.found(), bool_yn: true, section: 'BIND Parser')
137 summary('Bison/YACC Path', bison.full_path(), section: 'BIND Parser')
138 summary('Bison/YACC Version', bison.version(), section: 'BIND Parser')
139
140 bison_generator = generator(
141 bison,
142 output: ['@BASENAME@.cc', '@BASENAME@.hh', '@BASENAME@.output'],
143 arguments: ['-d', '--verbose', '--debug', '--output=@OUTPUT0@', '@INPUT@'],
144 )
145
146 libpdns_bindparser_gen = bison_generator.process(libpdns_bindparser_source)
147endif
148
149libpdns_dnslabeltext_source = src_dir / 'dnslabeltext.rl'
150libpdns_dnslabeltext_gen = src_dir / 'dnslabeltext.cc'
151if not fs.is_file(libpdns_dnslabeltext_gen)
152 ragel = find_program('ragel', required: true)
153 ragel_generator = generator(
154 ragel,
155 output: '@BASENAME@.cc',
156 arguments: ['@INPUT@', '-o', '@OUTPUT@'],
157 )
158
159 summary('Ragel', ragel.found(), bool_yn: ragel.found(), section: 'DNS Labels')
160 summary('Ragel Path', ragel.full_path(), section: 'DNS Labels')
161 summary('Ragel Version', ragel.version(), section: 'DNS Labels')
162
163 libpdns_dnslabeltext_gen = ragel_generator.process(libpdns_dnslabeltext_source)
164endif
5ff791ec
FM
165
166libpdns_apidocfiles_source = 'docs' / 'http-api' / 'swagger' / 'authoritative-api-swagger.yaml'
167libpdns_apidocfiles_gen = src_dir / 'apidocfiles.h'
168generate_api_swagger_py = src_dir / 'generate-api-swagger.py'
169if not fs.is_file(libpdns_apidocfiles_gen)
170 py = import('python')
171 python = py.find_installation('python3', modules: 'yaml', required: true)
172
173 summary('Python', python.found(), bool_yn: true, section: 'Swagger API')
174 summary('Path', python.full_path(), section: 'Swagger API')
175 summary('Version', python.version(), section: 'Swagger API')
176
177 libpdns_apidocfiles_gen = custom_target(
178 'pdns-apidocfiles-h',
179 command: [python, '@INPUT0@', '@INPUT1@'],
180 input: [generate_api_swagger_py, libpdns_apidocfiles_source],
181 output: 'apidocfiles.h',
182 capture: true,
183 )
184endif
185common_sources += libpdns_apidocfiles_gen
a1dc8cc7 186
5ff791ec
FM
187libpdns_bind_dnssec_schema_source = src_dir / 'bind-dnssec.schema.sqlite3.sql'
188libpdns_bind_dnssec_schema_gen = src_dir / 'bind-dnssec.schema.sqlite3.sql.h'
189generate_bind_dnssec_schema_py = src_dir / 'generate-bind-dnssec-schema.py'
190if not fs.is_file(libpdns_bind_dnssec_schema_gen)
191 py = import('python')
192 python = py.find_installation('python3', required: true)
193
194 summary('Python', python.found(), bool_yn: true, section: 'BIND DNSSEC Schema')
195 summary('Path', python.full_path(), section: 'BIND DNSSEC Schema')
196 summary('Version', python.version(), section: 'BIND DNSSEC Schema')
197
198 libpdns_bind_dnssec_schema_gen = custom_target(
199 'pdns-bind-dnssec-schema',
200 command: [python, '@INPUT0@', '@INPUT1@'],
201 input: [generate_bind_dnssec_schema_py, libpdns_bind_dnssec_schema_source],
202 output: 'bind-dnssec.schema.sqlite3.sql.h',
203 capture: true,
204 )
205endif
206common_sources += libpdns_bind_dnssec_schema_gen
207
208conditional_sources = {
209 'mplexer-sunos-devpoll': {
210 'sources': [
211 src_dir / 'devpollmplexer.cc',
212 src_dir / 'portsmplexer.cc',
213 ],
214 'condition': have_sunos,
215 },
216 'mplexer-linux-epoll': {
217 'sources': [src_dir / 'epollmplexer.cc'],
218 'condition': have_linux,
219 },
220 'mplexer-bsd-kqueue': {
221 'sources': [src_dir / 'kqueuemplexer.cc'],
222 'condition': have_openbsd or have_freebsd,
223 },
224 'minicurl': {
225 'sources': [
226 src_dir / 'minicurl.cc',
227 src_dir / 'minicurl.hh',
228 ],
229 'condition': dep_lua_records.found() or dep_libcurl.found(),
230 },
231 'lua-record': {
232 'sources': [src_dir / 'lua-record.cc'],
233 'condition': dep_lua_records.found(),
234 },
235 'signers-sodium': {
236 'sources': [src_dir / 'sodiumsigners.cc'],
237 'condition': dep_libsodium.found(),
238 },
239 'signers-decaf': {
240 'sources': [src_dir / 'decafsigners.cc'],
241 'condition': dep_libdecaf.found(),
242 },
5ff791ec
FM
243 'standalone-fuzz-target-runner': {
244 'sources': [src_dir / 'standalone_fuzz_target_runner.cc'],
245 'condition': get_option('fuzz-targets'),
246 },
247}
248
249foreach name, info: conditional_sources
250 if info['condition']
251 common_sources += files(info['sources'])
252 endif
253endforeach
254
bee5878d
FM
255# Conditional sources that need to be separated into standalone libraries.
256libpdns_signers_pkcs11 = dependency('', required: false)
257if dep_pkcs11.found()
258 libpdns_signers_pkcs11 = declare_dependency(
259 link_whole: static_library(
260 'pdns-signers-pkcs11',
261 sources: files(src_dir / 'pkcs11signers.cc', src_dir / 'pkcs11signers.hh'),
262 dependencies: dep_pkcs11,
263 )
264 )
265endif
266
5ff791ec
FM
267# This needs to be link_whole'd because it's needed by auth backends.
268libpdns_ssqlite3 = dependency('', required: false)
269if dep_sqlite3.found()
270 libpdns_ssqlite3 = declare_dependency(
271 link_whole: static_library(
272 'pdns-ssqlite3',
273 sources: files(src_dir / 'ssqlite3.cc', src_dir / 'ssqlite3.hh'),
274 dependencies: dep_sqlite3,
275 )
276 )
277endif
278
279libpdns_gettime = static_library(
280 'pdns-gettime',
281 src_dir / 'gettime.cc',
282 src_dir / 'gettime.hh',
9ab6b583 283 dependencies: dep_rt,
5ff791ec
FM
284)
285
286common_sources += files(
287 src_dir / 'arguments.cc',
288 src_dir / 'arguments.hh',
289 src_dir / 'auth-caches.cc',
290 src_dir / 'auth-caches.hh',
291 src_dir / 'auth-carbon.cc',
292 src_dir / 'auth-catalogzone.cc',
293 src_dir / 'auth-catalogzone.hh',
294 src_dir / 'auth-main.hh',
295 src_dir / 'auth-packetcache.cc',
296 src_dir / 'auth-packetcache.hh',
297 src_dir / 'auth-primarycommunicator.cc',
298 src_dir / 'auth-querycache.cc',
299 src_dir / 'auth-querycache.hh',
300 src_dir / 'auth-secondarycommunicator.cc',
301 src_dir / 'auth-zonecache.cc',
302 src_dir / 'auth-zonecache.hh',
303 src_dir / 'axfr-retriever.cc',
304 src_dir / 'axfr-retriever.hh',
305 src_dir / 'backends' / 'gsql' / 'gsqlbackend.cc', # TODO Move to a separate module.
306 src_dir / 'backends' / 'gsql' / 'gsqlbackend.hh', # TODO Move to a separate module.
307 src_dir / 'backends' / 'gsql' / 'ssql.hh', # TODO Move to a separate module.
308 src_dir / 'base32.cc',
309 src_dir / 'base32.hh',
310 src_dir / 'base64.cc',
311 src_dir / 'base64.hh',
312 src_dir / 'bindparserclasses.hh',
313 src_dir / 'burtle.hh',
314 src_dir / 'cachecleaner.hh',
315 src_dir / 'circular_buffer.hh',
316 src_dir / 'comment.hh',
317 src_dir / 'communicator.cc',
318 src_dir / 'communicator.hh',
319 src_dir / 'coverage.cc',
320 src_dir / 'coverage.hh',
321 src_dir / 'credentials.cc',
322 src_dir / 'credentials.hh',
323 src_dir / 'dbdnsseckeeper.cc',
324 src_dir / 'digests.hh',
325 src_dir / 'distributor.hh',
326 src_dir / 'dns.cc',
327 src_dir / 'dns.hh',
328 src_dir / 'dns_random.hh',
329 src_dir / 'dnsbackend.cc',
330 src_dir / 'dnsbackend.hh',
331 src_dir / 'dnsname.cc',
332 src_dir / 'dnsname.hh',
333 src_dir / 'dnspacket.cc',
334 src_dir / 'dnspacket.hh',
335 src_dir / 'dnsparser.cc',
336 src_dir / 'dnsparser.hh',
337 src_dir / 'dnsproxy.cc',
338 src_dir / 'dnsproxy.hh',
339 src_dir / 'dnsrecords.cc',
340 src_dir / 'dnsrecords.hh',
341 src_dir / 'dnssecinfra.cc',
342 src_dir / 'dnssecinfra.hh',
343 src_dir / 'dnsseckeeper.hh',
344 src_dir / 'dnssecsigner.cc',
345 src_dir / 'dnswriter.cc',
346 src_dir / 'dnswriter.hh',
347 src_dir / 'dynhandler.cc',
348 src_dir / 'dynhandler.hh',
349 src_dir / 'dynlistener.cc',
350 src_dir / 'dynlistener.hh',
351 src_dir / 'dynmessenger.cc',
352 src_dir / 'dynmessenger.hh',
353 src_dir / 'ednscookies.cc',
354 src_dir / 'ednscookies.hh',
355 src_dir / 'ednsoptions.cc',
356 src_dir / 'ednsoptions.hh',
357 src_dir / 'ednssubnet.cc',
358 src_dir / 'ednssubnet.hh',
359 src_dir / 'gss_context.cc',
360 src_dir / 'gss_context.hh',
361 src_dir / 'histogram.hh',
362 src_dir / 'ipcipher.cc',
363 src_dir / 'ipcipher.hh',
364 src_dir / 'iputils.cc',
365 src_dir / 'iputils.hh',
366 src_dir / 'ixfr.cc',
367 src_dir / 'ixfr.hh',
368 src_dir / 'json.cc',
369 src_dir / 'json.hh',
370 src_dir / 'lock.hh',
371 src_dir / 'logger.cc',
372 src_dir / 'logger.hh',
373 src_dir / 'logging.hh',
374 src_dir / 'lua-auth4.cc',
375 src_dir / 'lua-auth4.hh',
376 src_dir / 'lua-base4.cc',
377 src_dir / 'lua-base4.hh',
378 src_dir / 'misc.cc',
379 src_dir / 'misc.hh',
380 src_dir / 'nameserver.cc',
381 src_dir / 'nameserver.hh',
382 src_dir / 'namespaces.hh',
383 src_dir / 'noinitvector.hh',
384 src_dir / 'nsecrecords.cc',
385 src_dir / 'opensslsigners.cc',
386 src_dir / 'opensslsigners.hh',
387 src_dir / 'packetcache.hh',
388 src_dir / 'packethandler.cc',
389 src_dir / 'packethandler.hh',
390 src_dir / 'pdnsexception.hh',
391 src_dir / 'proxy-protocol.cc',
392 src_dir / 'proxy-protocol.hh',
393 src_dir / 'qtype.cc',
394 src_dir / 'qtype.hh',
395 src_dir / 'query-local-address.cc',
396 src_dir / 'query-local-address.hh',
397 src_dir / 'rcpgenerator.cc',
398 src_dir / 'rcpgenerator.hh',
399 src_dir / 'resolver.cc',
400 src_dir / 'resolver.hh',
401 src_dir / 'responsestats-auth.cc',
402 src_dir / 'responsestats.cc',
403 src_dir / 'responsestats.hh',
404 src_dir / 'rfc2136handler.cc',
405 src_dir / 'secpoll-auth.cc',
406 src_dir / 'secpoll-auth.hh',
407 src_dir / 'secpoll.cc',
408 src_dir / 'secpoll.hh',
409 src_dir / 'serialtweaker.cc',
410 src_dir / 'sha.hh',
411 src_dir / 'shuffle.cc',
412 src_dir / 'shuffle.hh',
413 src_dir / 'signingpipe.cc',
414 src_dir / 'signingpipe.hh',
415 src_dir / 'sillyrecords.cc',
416 src_dir / 'sstuff.hh',
417 src_dir / 'stat_t.hh',
418 src_dir / 'statbag.cc',
419 src_dir / 'statbag.hh',
420 src_dir / 'stubresolver.cc',
421 src_dir / 'stubresolver.hh',
422 src_dir / 'svc-records.cc',
423 src_dir / 'svc-records.hh',
424 src_dir / 'tcpreceiver.cc',
425 src_dir / 'tcpreceiver.hh',
426 src_dir / 'threadname.cc',
427 src_dir / 'threadname.hh',
428 src_dir / 'tkey.cc',
429 src_dir / 'trusted-notification-proxy.cc',
430 src_dir / 'trusted-notification-proxy.hh',
431 src_dir / 'tsigutils.cc',
432 src_dir / 'tsigutils.hh',
433 src_dir / 'tsigverifier.cc',
434 src_dir / 'tsigverifier.hh',
435 src_dir / 'ueberbackend.cc',
436 src_dir / 'ueberbackend.hh',
437 src_dir / 'unix_semaphore.cc',
438 src_dir / 'unix_utility.cc',
439 src_dir / 'utility.hh',
440 src_dir / 'uuid-utils.cc',
441 src_dir / 'uuid-utils.hh',
442 src_dir / 'validate.hh',
443 src_dir / 'version.cc',
444 src_dir / 'version.hh',
445 src_dir / 'webserver.cc',
446 src_dir / 'webserver.hh',
447 src_dir / 'ws-api.cc',
448 src_dir / 'ws-api.hh',
449 src_dir / 'ws-auth.cc',
450 src_dir / 'ws-auth.hh',
451 src_dir / 'zonemd.cc',
452 src_dir / 'zonemd.hh',
453 src_dir / 'zoneparser-tng.cc',
454 src_dir / 'zoneparser-tng.hh',
455)
a1dc8cc7 456
a611c863
FM
457deps = [
458 dep_pdns,
459 dep_platform,
460 dep_atomics,
461 dep_threads,
462 dep_lua,
463 dep_lua_records,
464 dep_netlibs,
465 dep_libsodium,
466 dep_libdecaf,
467 dep_libcrypto,
468 dep_libssl,
469 dep_gnutls,
a611c863
FM
470 dep_boost,
471 dep_boost_program_options,
a611c863
FM
472 dep_dlopen,
473 dep_pkcs11,
474 dep_gss_tsig,
03c20e2c
FM
475 dep_systemd,
476 dep_arc4random,
a611c863
FM
477 dep_ipcrypt,
478 dep_json11,
03c20e2c 479 dep_luawrapper,
f47bda90 480 dep_protozero,
03c20e2c 481 dep_yahttp,
9078074a 482 dep_yaml_cpp,
04c9ac7d 483 dep_sqlite3,
2d4c0b49
FM
484 dep_lmdb,
485 dep_boost_serialization,
24f709be
FM
486 dep_mysql,
487 dep_odbc,
488 dep_pgsql,
489 dep_ldap,
490 dep_cdb,
491 dep_geoip,
492 dep_mmdb,
493 dep_cxx_fs,
ca603a4d 494 dep_boost_test,
a611c863
FM
495]
496
5ff791ec
FM
497libpdns_bindparser = static_library(
498 'pdns-bindparser',
499 libpdns_bindlexer_gen,
500 libpdns_bindparser_gen,
501 cpp_args: '-Wno-redundant-decls',
502 dependencies: deps,
503)
80769082 504
80603578
FM
505libpdns_dnslabeltext = static_library(
506 'pdns-dnslabeltext',
507 libpdns_dnslabeltext_gen,
508 dependencies: deps,
509)
510
ca603a4d
FM
511libpdns_cdb = dependency('', required: false)
512if dep_cdb.found()
513 libpdns_cdb = declare_dependency(
514 link_whole: static_library(
515 'libpdns-cdb',
5ff791ec 516 sources: files(src_dir / 'cdb.cc', src_dir / 'cdb.hh'),
ca603a4d
FM
517 dependencies: deps,
518 )
519 )
520endif
521
24f709be
FM
522# Modules
523all_modules = [
524 'bind',
525 'pipe',
526 'gmysql',
527 'godbc',
528 'gpgsql',
5ff791ec 529 'gsqlite3',
24f709be
FM
530 'ldap',
531 'lua2',
532 'remote',
533 'tinydns',
534 'geoip',
535 'lmdb',
536]
537
80769082
FM
538selected_modules = []
539selected_dyn_modules = []
540dep_modules = []
24f709be 541foreach module_name: all_modules
80769082
FM
542 module_backend_name = module_name + 'backend'
543 module_opt = get_option('module-' + module_name)
80769082
FM
544
545 if module_opt == 'disabled'
546 continue
547 elif module_opt == 'static'
548 selected_modules += module_name
549 else
550 selected_dyn_modules += module_name
551 endif
7843c3e4 552
b74bcc28 553 subdir('modules' / module_backend_name)
70e1b8f2 554 dep_modules += get_variable('dep_' + module_backend_name)
7e83417e 555endforeach
7843c3e4 556
d07258db
FM
557conf.set_quoted('PDNS_MODULES', ' '.join(selected_modules), description: 'Built-in modules')
558conf.set_quoted('PDNS_DYN_MODULES', ' '.join(selected_dyn_modules), description: 'Loadable modules')
7e83417e 559
d38f2e9f 560# Generate config.h
1a4c8264 561config_h = configure_file(configuration: conf, output: 'config.h')
1a4c8264 562
5ff791ec
FM
563tools = {
564 'pdns-auth' : {
565 'main': src_dir / 'auth-main.cc',
566 'export-dynamic': true,
567 'deps-extra': [dep_modules, libpdns_ssqlite3],
568 'link-whole-extra': [libpdns_gettime],
569 },
ca603a4d 570
5ff791ec
FM
571 'pdns-auth-util' : {
572 'main': src_dir / 'pdnsutil.cc',
573 'deps-extra': libpdns_ssqlite3,
574 },
575 'pdns-auth-control' : { 'main': src_dir / 'dynloader.cc' },
576 'pdns-zone2sql' : { 'main': src_dir / 'zone2sql.cc' },
577 'pdns-zone2json' : { 'main': src_dir / 'zone2json.cc' },
578}
d0d30e9e 579
51929c8e 580if get_option('module-ldap') != 'disabled'
5ff791ec 581 tools += { 'pdns-zone2ldap' : { 'main': src_dir / 'zone2ldap.cc' } }
51929c8e 582endif
cd407269 583
51929c8e 584if get_option('tools')
5ff791ec
FM
585 tools += {
586 'pdns-auth-notify' : { 'main': src_dir / 'notify.cc' },
587 'sdig' : { 'main': src_dir / 'sdig.cc' },
588 'calidns' : { 'main': src_dir / 'calidns.cc' },
589 'dnsdemog' : { 'main': src_dir / 'dnsdemog.cc' },
590 'dnsgram' : { 'main': src_dir / 'dnsgram.cc' },
591 'dnspcap2calidns' : { 'main': src_dir / 'dnspcap2calidns.cc' },
592 'dnspcap2protobuf' : {
593 'main': src_dir / 'dnspcap2protobuf.cc',
594 'link-with-extra': libpdns_gettime,
595 },
596 'dnsreplay' : { 'main': src_dir / 'dnsreplay.cc' },
597 'dnsscan' : { 'main': src_dir / 'dnsscan.cc' },
598 'dnsscope' : { 'main': src_dir / 'dnsscope.cc' },
599 'dnswasher' : { 'main': src_dir / 'dnswasher.cc' },
600 'nproxy' : { 'main': src_dir / 'nproxy.cc' },
601 'nsec3dig' : { 'main': src_dir / 'nsec3dig.cc' },
602 'dumresp' : { 'main': src_dir / 'dumresp.cc' },
603 'kvresp' : { 'main': src_dir / 'kvresp.cc' },
604 'stubquery' : { 'main': src_dir / 'stubquery.cc' },
605 'saxfr' : { 'main': src_dir / 'saxfr.cc' },
606 'ixplore' : { 'main': src_dir / 'ixplore.cc' },
607 # 'comfun' : { 'main': src_dir / 'comfun.cc' }, # Broken
608 }
609
610 common_sources += files(
611 src_dir / 'anadns.hh',
612 src_dir / 'dnspcap.cc',
613 src_dir / 'dnspcap.hh',
614 src_dir / 'dolog.hh',
615 src_dir / 'ednsextendederror.cc',
616 src_dir / 'ednsextendederror.hh',
617 src_dir / 'histog.hh',
618 src_dir / 'ixfrutils.cc',
619 src_dir / 'ixfrutils.hh',
620 src_dir / 'libssl.cc',
621 src_dir / 'libssl.hh',
622 src_dir / 'mplexer.hh',
623 src_dir / 'pollmplexer.cc',
624 src_dir / 'protozero.cc',
625 src_dir / 'protozero.hh',
626 src_dir / 'statnode.cc',
627 src_dir / 'statnode.hh',
628 src_dir / 'tcpiohandler.cc',
629 src_dir / 'tcpiohandler.hh',
630 )
1df6c540
FM
631
632 if have_boost_1_48_0
5ff791ec
FM
633 tools += {
634 'dnstcpbench': { 'main': src_dir / 'dnstcpbench.cc' },
635 'dnsbulktest': { 'main': src_dir / 'dnsbulktest.cc' },
636 }
1df6c540 637 endif
5d890a28 638endif
0b25f764 639
1df6c540 640if get_option('tools-ixfrdist')
5ff791ec
FM
641 tools += {
642 'ixfrdist': {'main': src_dir / 'ixfrdist.cc' },
643 }
644
645 common_sources += files(
646 src_dir / 'ixfrdist-stats.cc',
647 src_dir / 'ixfrdist-stats.hh',
648 src_dir / 'ixfrdist-web.cc',
649 src_dir / 'ixfrdist-web.hh',
650 src_dir / 'ixfrutils.cc',
651 src_dir / 'ixfrutils.hh',
652 src_dir / 'mplexer.hh',
653 src_dir / 'pollmplexer.cc',
654 )
1df6c540 655endif
47bbdc4a 656
7838ce03 657if get_option('unit-tests')
5ff791ec
FM
658 tools += {
659 # TODO: NOINSTALL speedtest and pdns-auth-testrunner
660 'pdns-auth-testrunner': { 'main': src_dir / 'testrunner.cc' },
661 'speedtest' : { 'main': src_dir / 'speedtest.cc' },
662 'tsig-tests' : { 'main': src_dir / 'tsig-tests.cc' },
663 }
664
665 common_sources += files(
666 src_dir / 'channel.cc',
667 src_dir / 'channel.hh',
668 src_dir / 'pollmplexer.cc',
669 src_dir / 'test-arguments_cc.cc',
670 src_dir / 'test-auth-zonecache_cc.cc',
671 src_dir / 'test-base32_cc.cc',
672 src_dir / 'test-base64_cc.cc',
673 src_dir / 'test-bindparser_cc.cc',
674 src_dir / 'test-channel.cc',
675 src_dir / 'test-common.hh',
676 src_dir / 'test-communicator_hh.cc',
677 src_dir / 'test-credentials_cc.cc',
678 src_dir / 'test-digests_hh.cc',
679 src_dir / 'test-distributor_hh.cc',
680 src_dir / 'test-dns_random_hh.cc',
681 src_dir / 'test-dnsname_cc.cc',
682 src_dir / 'test-dnsparser_cc.cc',
683 src_dir / 'test-dnsparser_hh.cc',
684 src_dir / 'test-dnsrecordcontent.cc',
685 src_dir / 'test-dnsrecords_cc.cc',
686 src_dir / 'test-dnswriter_cc.cc',
687 src_dir / 'test-ednscookie_cc.cc',
688 src_dir / 'test-ipcrypt_cc.cc',
689 src_dir / 'test-iputils_hh.cc',
690 src_dir / 'test-ixfr_cc.cc',
691 src_dir / 'test-lock_hh.cc',
692 src_dir / 'test-lua_auth4_cc.cc',
693 src_dir / 'test-luawrapper.cc',
694 src_dir / 'test-misc_hh.cc',
695 src_dir / 'test-mplexer.cc',
696 src_dir / 'test-nameserver_cc.cc',
697 src_dir / 'test-packetcache_cc.cc',
698 src_dir / 'test-packetcache_hh.cc',
699 src_dir / 'test-proxy_protocol_cc.cc',
700 src_dir / 'test-rcpgenerator_cc.cc',
701 src_dir / 'test-sha_hh.cc',
702 src_dir / 'test-signers.cc',
703 src_dir / 'test-statbag_cc.cc',
704 src_dir / 'test-svc_records_cc.cc',
705 src_dir / 'test-trusted-notification-proxy_cc.cc',
706 src_dir / 'test-tsig.cc',
707 src_dir / 'test-ueberbackend_cc.cc',
708 src_dir / 'test-webserver_cc.cc',
709 src_dir / 'test-zonemd_cc.cc',
710 src_dir / 'test-zoneparser_tng_cc.cc',
711 src_dir / 'zoneparser-tng.hh',
712 )
1df6c540 713endif
90cd47f9 714
1df6c540 715if get_option('fuzz-targets')
5ff791ec
FM
716 tools += {
717 'fuzz-target-moadnsparser' : { 'main': src_dir / 'fuzz_moadnsparser.cc' },
718 'fuzz-target-packetcache' : { 'main': src_dir / 'fuzz_packetcache.cc' },
719 'fuzz-target-proxyprotocol' : { 'main': src_dir / 'fuzz_proxyprotocol.cc' },
720 'fuzz-target-dnslabeltext-parseRFC1035CharString' : { 'main': src_dir / 'fuzz_dnslabeltext_parseRFC1035CharString.cc' },
721 'fuzz-target-yahttp' : { 'main': src_dir / 'fuzz_yahttp.cc' },
722 'fuzz-target-zoneparsertng' : { 'main': src_dir / 'fuzz_zoneparsertng.cc' },
723 }
1df6c540 724endif
3de26691 725
5ff791ec
FM
726libpdns_common = static_library(
727 'pdns-common',
728 common_sources,
729 config_h,
bee5878d 730 dependencies: [deps, libpdns_signers_pkcs11],
80603578 731 link_with: [libpdns_bindparser, libpdns_dnslabeltext],
5ff791ec
FM
732)
733
734foreach tool, info: tools
ca603a4d 735 var_name = tool.underscorify()
5ff791ec
FM
736 main = files(info['main'])
737
738 export_dynamic = 'export-dynamic' in info ? info['export-dynamic'] : false
739 deps_extra = 'deps-extra' in info ? info['deps-extra'] : []
740 link_with_extra = 'link-with-extra' in info ? info['link-with-extra'] : []
741 link_whole_extra = 'link-whole-extra' in info ? info['link-whole-extra'] : []
742
68867bd2 743 set_variable(
ca603a4d 744 var_name,
68867bd2
FM
745 executable(
746 tool,
5ff791ec 747 main,
ca603a4d 748 config_h,
5ff791ec
FM
749 export_dynamic: export_dynamic,
750 dependencies: deps + deps_extra,
751 link_with: [libpdns_common] + link_with_extra,
752 link_whole: link_whole_extra,
68867bd2 753 )
3de26691 754 )
51929c8e 755endforeach
68bf2d10
FM
756
757if get_option('unit-tests')
758 test('PDNS Auth Testrunner', pdns_auth_testrunner, verbose: true)
759endif
760
761if get_option('unit-tests-backends')
762 libpdns_module_remotebackend_test_common = static_library(
763 'pdns-test-remotebackend',
764 module_remotebackend_test_sources_common,
765 link_with: [libpdns_common, libpdns_dnslabeltext],
766 dependencies: [
767 deps,
768 libpdns_signers_pkcs11,
769 ],
770 extra_files: module_remotebackend_test_sources_extra,
771 )
772
773 env = {
774 'BOOST_TEST_LOG_LEVEL': 'message',
775 'REMOTEBACKEND_ZEROMQ': get_option('module-remote-zeromq') ? '1' : '0',
776 }
777
778 foreach test_binary, test_source: module_remotebackend_test_sources_binaries
779 var_name = test_binary.underscorify()
780
781 set_variable(
782 var_name,
783 executable(
784 test_binary,
785 test_source,
786 dependencies: [
787 deps,
788 dep_boost_test,
789 dep_zeromq,
790 libpdns_module_remotebackend_test_common,
791 ],
792 )
793 )
794
795 test('PDNS Auth ' + test_binary, get_variable(var_name), verbose: true, env: env)
796 endforeach
797endif