From: Fred Morcos Date: Mon, 27 Nov 2023 13:19:18 +0000 (+0100) Subject: Meson: Finish refactoring of how module dependencies are handled X-Git-Tag: rec-5.1.0-alpha1~80^2~33 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=24f709beb596958b9f477f6e69d4e12808228d2d;p=thirdparty%2Fpdns.git Meson: Finish refactoring of how module dependencies are handled --- diff --git a/meson.build b/meson.build index 3c04db684d..17aefe8592 100644 --- a/meson.build +++ b/meson.build @@ -75,6 +75,16 @@ subdir('meson' / 'various-headers') # Various Headers subdir('meson' / 'yaml-cpp') # YAML C++ subdir('meson' / 'sqlite3') # Sqlite3 subdir('meson' / 'lmdb') # LMDB +subdir('meson' / 'mysql') # MySQL +subdir('meson' / 'odbc') # ODBC +subdir('meson' / 'pgsql') # PostgreSQL +subdir('meson' / 'ldap') # LDAP +subdir('meson' / 'prog-curl') # cURL Program +subdir('meson' / 'zeromq') # ZeroMQ +subdir('meson' / 'cdb') # CDB +subdir('meson' / 'geoip') # GeoIP +subdir('meson' / 'mmdb') # MaxMindDB +subdir('meson' / 'cxx-fs') # C++ stdlib Filesystem Module # Manpages # if not fs.exists('docs' / 'pdns_server.1') and not python_have_venv @@ -128,55 +138,37 @@ deps = [ dep_sqlite3, dep_lmdb, dep_boost_serialization, + dep_mysql, + dep_odbc, + dep_pgsql, + dep_ldap, + dep_cdb, + dep_geoip, + dep_mmdb, + dep_cxx_fs, ] -# Modules -all_modules = { - 'bind': {'deps': [], }, - 'pipe': {'deps': [], }, - 'gmysql': {'deps': ['mysql'], }, - 'godbc': {'deps': ['odbc'], }, - 'gpgsql': {'deps': ['pgsql'], }, - 'ldap': {'deps': ['ldap'], }, - 'lua2': {'deps': [], }, - 'remote': {'deps': ['prog-curl', 'zeromq'], }, - 'tinydns': {'deps': ['cdb'], }, - 'geoip': {'deps': ['geoip', 'mmdb', 'cxx-fs'], }, - 'lmdb': {'deps': [],}, -} - -# Configure module dependencies -foreach module_name, module_props: all_modules - module_opt = get_option('module-' + module_name) - module_deps = module_props['deps'] - - if module_opt == 'disabled' - continue - endif - - foreach dep: module_deps - if module_name == 'remote' - if dep == 'prog-curl' - if not get_option('unit-tests') - continue # We only need cURL for unit tests. - endif - elif dep == 'zeromq' - if not get_option('module-remote-zeromq') - continue - endif - endif - endif - - subdir('meson' / dep) - endforeach -endforeach - subdir('pdns') +# Modules +all_modules = [ + 'bind', + 'pipe', + 'gmysql', + 'godbc', + 'gpgsql', + 'ldap', + 'lua2', + 'remote', + 'tinydns', + 'geoip', + 'lmdb', +] + selected_modules = [] selected_dyn_modules = [] dep_modules = [] -foreach module_name, module_props: all_modules +foreach module_name: all_modules module_backend_name = module_name + 'backend' module_opt = get_option('module-' + module_name) diff --git a/meson/cdb/meson.build b/meson/cdb/meson.build index 227b2b276f..72927edbee 100644 --- a/meson/cdb/meson.build +++ b/meson/cdb/meson.build @@ -1,9 +1,13 @@ -dep_cdb = dependency('libcdb', required: false) +dep_cdb = dependency('', required: false) -if not dep_cdb.found() - if cxx.has_header('cdb.h', required: true) - if cxx.has_function('cdb_find', args: ['-lcdb']) - dep_cdb = declare_dependency(link_args: ['-lcdb']) +if get_option('module-tinydns') != 'disabled' + dep_cdb = dependency('libcdb', required: false) + + if not dep_cdb.found() + if cxx.has_header('cdb.h', required: true) + if cxx.has_function('cdb_find', args: ['-lcdb']) + dep_cdb = declare_dependency(link_args: ['-lcdb']) + endif endif endif endif diff --git a/meson/cxx-fs/meson.build b/meson/cxx-fs/meson.build index 73c22bc9ad..38fdf963b5 100644 --- a/meson/cxx-fs/meson.build +++ b/meson/cxx-fs/meson.build @@ -1,33 +1,36 @@ dep_cxx_fs = dependency('', required: false) -need_cxx_fs = false -prog = fs.read('cxx-fs.cc') -if not cxx.links(prog, name: '-lstdc++fs and -lc++fs are not needed') - lib_cxx_fs = cxx.find_library('stdc++fs', disabler: true, required: false) - if lib_cxx_fs.found() - if cxx.links(prog, name: '-lstdc++fs is needed', dependencies: lib_cxx_fs) - need_cxx_fs = '-lstdc++fs' - dep_cxx_fs = declare_dependency(dependencies: lib_cxx_fs) - summary('Filesystem library', lib_cxx_fs, section: 'System') - endif - endif +if get_option('module-geoip') != 'disabled' + need_cxx_fs = false - if need_cxx_fs == false - lib_cxx_fs = cxx.find_library('c++fs', disabler: true, required: false) + prog = fs.read('cxx-fs.cc') + if not cxx.links(prog, name: '-lstdc++fs and -lc++fs are not needed') + lib_cxx_fs = cxx.find_library('stdc++fs', disabler: true, required: false) if lib_cxx_fs.found() - if cxx.links(prog, name: '-lc++fs is needed', dependencies: lib_cxx_fs) - need_cxx_fs = '-lc++fs' + if cxx.links(prog, name: '-lstdc++fs is needed', dependencies: lib_cxx_fs) + need_cxx_fs = '-lstdc++fs' dep_cxx_fs = declare_dependency(dependencies: lib_cxx_fs) summary('Filesystem library', lib_cxx_fs, section: 'System') + endif + endif + + if need_cxx_fs == false + lib_cxx_fs = cxx.find_library('c++fs', disabler: true, required: false) + if lib_cxx_fs.found() + if cxx.links(prog, name: '-lc++fs is needed', dependencies: lib_cxx_fs) + need_cxx_fs = '-lc++fs' + dep_cxx_fs = declare_dependency(dependencies: lib_cxx_fs) + summary('Filesystem library', lib_cxx_fs, section: 'System') + else + error('C++ Filesystem library was found but linking against it failed') + endif else - error('C++ Filesystem library was found but linking against it failed') + error('C++ Filesystem library is needed but could not be found') endif - else - error('C++ Filesystem library is needed but could not be found') endif + else + dep_cxx_fs = declare_dependency() endif -else - dep_cxx_fs = declare_dependency() -endif -summary('Need -lstdc++fs or -lc++fs', need_cxx_fs, bool_yn: true, section: 'System') + summary('Need -lstdc++fs/-lc++fs', need_cxx_fs, bool_yn: true, section: 'System') +endif diff --git a/meson/geoip/meson.build b/meson/geoip/meson.build index bcbeb2cf1a..97259c7a91 100644 --- a/meson/geoip/meson.build +++ b/meson/geoip/meson.build @@ -1,8 +1,13 @@ +dep_geoip = dependency('', required: false) + +if get_option('module-geoip') != 'disabled' dep_geoip = dependency('geoip', required: false) +endif conf.set('HAVE_GEOIP', dep_geoip.found(), description: 'GeoIP') summary('GeoIP', dep_geoip.found(), bool_yn: true, section: 'GeoIP Backend') + if dep_geoip.found() summary('GeoIP Name', dep_geoip.name(), section: 'GeoIP Backend') summary('GeoIP Version', dep_geoip.version(), section: 'GeoIP Backend') diff --git a/meson/ldap/meson.build b/meson/ldap/meson.build index 8924a44776..220fa1ee73 100644 --- a/meson/ldap/meson.build +++ b/meson/ldap/meson.build @@ -1,50 +1,59 @@ -dep_ldap = dependency('ldap', required: true) -dep_lber = dependency('lber', required: true) -dep_krb5 = dependency('krb5', required: true) - -conf.set('HAVE_LIBLDAP', dep_ldap.found(), description: 'Have libldap') - -have_ldap_initialize = cxx.has_function('ldap_initialize', dependencies: dep_ldap) -conf.set( - 'HAVE_LDAP_INITIALIZE', - have_ldap_initialize, - description: 'Have ldap_initialize', -) - -have_ldap_sasl_bind = cxx.has_function('ldap_sasl_bind', dependencies: dep_ldap) -conf.set( - 'HAVE_LDAP_SASL_BIND', - have_ldap_initialize, - description: 'Have ldap_sasl_bind', -) - -summary('LDAP', dep_ldap.found(), bool_yn: true, section: 'LDAP') -summary('LDAP Name', dep_ldap.name(), section: 'LDAP') -summary('LDAP Version', dep_ldap.version(), section: 'LDAP') - -summary('LBER', dep_lber.found(), bool_yn: true, section: 'LDAP') -summary('LBER Name', dep_lber.name(), section: 'LDAP') -summary('LBER Version', dep_lber.version(), section: 'LDAP') - -summary('Krb5', dep_krb5.found(), bool_yn: true, section: 'LDAP') -summary('Krb5 Name', dep_krb5.name(), section: 'LDAP') -summary('Krb5 Version', dep_krb5.version(), section: 'LDAP') - -have_krb5_get_init_creds_opt_set_default_flags = \ - cxx.has_function( +dep_ldap = dependency('', required: false) + +if get_option('module-ldap') != 'disabled' + dep_ldap_internal = dependency('ldap', required: true) + dep_lber_internal = dependency('lber', required: true) + dep_krb5_internal = dependency('krb5', required: true) + + conf.set('HAVE_LIBLDAP', dep_ldap_internal.found(), description: 'Have libldap') + + have_ldap_initialize = cxx.has_function('ldap_initialize', dependencies: dep_ldap_internal) + conf.set( + 'HAVE_LDAP_INITIALIZE', + have_ldap_initialize, + description: 'Have ldap_initialize', + ) + + have_ldap_sasl_bind = cxx.has_function('ldap_sasl_bind', dependencies: dep_ldap_internal) + conf.set( + 'HAVE_LDAP_SASL_BIND', + have_ldap_initialize, + description: 'Have ldap_sasl_bind', + ) + + have_krb5_get_init_creds_opt_set_default_flags = cxx.has_function( 'krb5_get_init_creds_opt_set_default_flags', - dependencies: dep_krb5, + dependencies: dep_krb5_internal, + ) + conf.set( + 'HAVE_KRB5_GET_INIT_CREDS_OPT_SET_DEFAULT_FLAGS', + have_krb5_get_init_creds_opt_set_default_flags, + description: 'Have krb5_get_init_creds_opt_set_default_flags', + ) + + dep_ldap = declare_dependency( + dependencies: [ + dep_ldap_internal, + dep_lber_internal, + dep_krb5_internal, + ], ) -conf.set( - 'HAVE_KRB5_GET_INIT_CREDS_OPT_SET_DEFAULT_FLAGS', - have_krb5_get_init_creds_opt_set_default_flags, - description: 'Have krb5_get_init_creds_opt_set_default_flags', -) - -dep_ldap = declare_dependency( - dependencies: [ - dep_ldap, - dep_lber, - dep_krb5, - ], -) +endif + +summary('LDAP', dep_ldap_internal.found(), bool_yn: true, section: 'LDAP') +if dep_ldap_internal.found() + summary('LDAP Name', dep_ldap_internal.name(), section: 'LDAP') + summary('LDAP Version', dep_ldap_internal.version(), section: 'LDAP') +endif + +summary('LBER', dep_lber_internal.found(), bool_yn: true, section: 'LDAP') +if dep_lber_internal.found() + summary('LBER Name', dep_lber_internal.name(), section: 'LDAP') + summary('LBER Version', dep_lber_internal.version(), section: 'LDAP') +endif + +summary('Krb5', dep_krb5_internal.found(), bool_yn: true, section: 'LDAP') +if dep_krb5_internal.found() + summary('Krb5 Name', dep_krb5_internal.name(), section: 'LDAP') + summary('Krb5 Version', dep_krb5_internal.version(), section: 'LDAP') +endif diff --git a/meson/mmdb/meson.build b/meson/mmdb/meson.build index 3873b27388..448bb8d01f 100644 --- a/meson/mmdb/meson.build +++ b/meson/mmdb/meson.build @@ -1,8 +1,13 @@ -dep_mmdb = dependency('libmaxminddb', required: false) +dep_mmdb = dependency('', required: false) + +if get_option('module-geoip') != 'disabled' + dep_mmdb = dependency('libmaxminddb', required: false) +endif conf.set('HAVE_MMDB', dep_mmdb.found(), description: 'MaxMindDB') summary('MaxMindDB', dep_mmdb.found(), bool_yn: true, section: 'GeoIP Backend') + if dep_mmdb.found() summary('MaxMindDB Name', dep_mmdb.name(), section: 'GeoIP Backend') summary('MaxMindDB Version', dep_mmdb.version(), section: 'GeoIP Backend') diff --git a/meson/mysql/meson.build b/meson/mysql/meson.build index e57c164f71..b4eceb0e81 100644 --- a/meson/mysql/meson.build +++ b/meson/mysql/meson.build @@ -1,28 +1,32 @@ -dep_mysql = dependency('libmysql', required: false) -if not dep_mysql.found() - dep_mysql = dependency('libmariadb', required: false) -endif +dep_mysql = dependency('', required: false) -if not dep_mysql.found() - mysql_config = find_program('mysql_config', required: false) - if not mysql_config.found() - mysql_config = find_program('mariadb_config', required: true) +if get_option('module-gmysql') != 'disabled' + dep_mysql = dependency('libmysql', required: false) + if not dep_mysql.found() + dep_mysql = dependency('libmariadb', required: false) endif - mysql_cflags_res = run_command(mysql_config, '--cflags', check: true) - mysql_cflags = mysql_cflags_res.stdout().strip().split() + if not dep_mysql.found() + mysql_config = find_program('mysql_config', required: false) + if not mysql_config.found() + mysql_config = find_program('mariadb_config', required: true) + endif + + mysql_cflags_res = run_command(mysql_config, '--cflags', check: true) + mysql_cflags = mysql_cflags_res.stdout().strip().split() - mysql_ldflags_res = run_command(mysql_config, '--libs', check: true) - mysql_ldflags = mysql_ldflags_res.stdout().strip().split() + mysql_ldflags_res = run_command(mysql_config, '--libs', check: true) + mysql_ldflags = mysql_ldflags_res.stdout().strip().split() - mysql_version_res = run_command(mysql_config, '--version', check: false) - mysql_version = mysql_version_res.stdout().strip() + mysql_version_res = run_command(mysql_config, '--version', check: false) + mysql_version = mysql_version_res.stdout().strip() - dep_mysql = declare_dependency( - compile_args: mysql_cflags, - link_args: mysql_ldflags, - version: mysql_version, - ) + dep_mysql = declare_dependency( + compile_args: mysql_cflags, + link_args: mysql_ldflags, + version: mysql_version, + ) + endif endif summary('MySQL/MariaDB', dep_mysql.found(), bool_yn: true, section: 'MySQL') diff --git a/meson/odbc/meson.build b/meson/odbc/meson.build index 6f16477993..d43befdca6 100644 --- a/meson/odbc/meson.build +++ b/meson/odbc/meson.build @@ -1,22 +1,26 @@ -dep_odbc = dependency('odbc', required: false) +dep_odbc = dependency('', required: false) -if not dep_odbc.found() - odbc_config = find_program('odbc_config', required: true) +if get_option('module-godbc') != 'disabled' + dep_odbc = dependency('odbc', required: false) - odbc_cflags_res = run_command(odbc_config, '--cflags', check: true) - odbc_cflags = odbc_cflags_res.stdout().strip().split() + if not dep_odbc.found() + odbc_config = find_program('odbc_config', required: true) - odbc_ldflags_res = run_command(odbc_config, '--libs', check: true) - odbc_ldflags = odbc_ldflags_res.stdout().strip().split() + odbc_cflags_res = run_command(odbc_config, '--cflags', check: true) + odbc_cflags = odbc_cflags_res.stdout().strip().split() - odbc_version_res = run_command(odbc_config, '--version', check: true) - odbc_version = odbc_version_res.stdout().strip() + odbc_ldflags_res = run_command(odbc_config, '--libs', check: true) + odbc_ldflags = odbc_ldflags_res.stdout().strip().split() - dep_odbc = declare_dependency( - compile_args: odbc_cflags, - link_args: odbc_ldflags, - version: odbc_version, - ) + odbc_version_res = run_command(odbc_config, '--version', check: true) + odbc_version = odbc_version_res.stdout().strip() + + dep_odbc = declare_dependency( + compile_args: odbc_cflags, + link_args: odbc_ldflags, + version: odbc_version, + ) + endif endif summary('ODBC', dep_odbc.found(), bool_yn: true, section: 'ODBC') diff --git a/meson/pgsql/meson.build b/meson/pgsql/meson.build index 0374c3d400..b8659da1b2 100644 --- a/meson/pgsql/meson.build +++ b/meson/pgsql/meson.build @@ -1,36 +1,40 @@ -dep_pgsql = dependency('libpq', required: false) +dep_pgsql = dependency('', required: false) -if not dep_pgsql.found() - pg_config = find_program('pg_config', required: true) +if get_option('module-gpgsql') != 'disabled' + dep_pgsql = dependency('libpq', required: false) - pg_includedir_res = run_command(pg_config, '--includedir', check: true) - pg_includedir = pg_includedir_res.stdout().strip() + if not dep_pgsql.found() + pg_config = find_program('pg_config', required: true) - # pg_cflags_res = run_command(pg_config, '--cflags', check: true) - # pg_cflags = pg_cflags_res.stdout().strip().split() + pg_includedir_res = run_command(pg_config, '--includedir', check: true) + pg_includedir = pg_includedir_res.stdout().strip() - # pg_cppflags_res = run_command(pg_config, '--cppflags', check: true) - # pg_cppflags = pg_cppflags_res.stdout().strip().split() + # pg_cflags_res = run_command(pg_config, '--cflags', check: true) + # pg_cflags = pg_cflags_res.stdout().strip().split() - # pg_ldflags_res = run_command(pg_config, '--libs', check: true) - # pg_ldflags = pg_ldflags_res.stdout().strip().split() + # pg_cppflags_res = run_command(pg_config, '--cppflags', check: true) + # pg_cppflags = pg_cppflags_res.stdout().strip().split() - pg_libdir_res = run_command(pg_config, '--libdir', check: true) - pg_libdir = pg_libdir_res.stdout().strip() + # pg_ldflags_res = run_command(pg_config, '--libs', check: true) + # pg_ldflags = pg_ldflags_res.stdout().strip().split() - # pg_libs_res = run_command(pg_config, '--libs', check: true) - # pg_libs = pg_libs_res.stdout().strip().split() + pg_libdir_res = run_command(pg_config, '--libdir', check: true) + pg_libdir = pg_libdir_res.stdout().strip() - pg_version_res = run_command(pg_config, '--version', check: true) - pg_version = pg_version_res.stdout().strip().split()[1] + # pg_libs_res = run_command(pg_config, '--libs', check: true) + # pg_libs = pg_libs_res.stdout().strip().split() - dep_pgsql = declare_dependency( - # compile_args: pg_cflags + pg_cppflags, - # link_args: pg_ldflags, - compile_args: '-I' + pg_includedir, - link_args: ['-L' + pg_libdir, '-lpq'], - version: pg_version, - ) + pg_version_res = run_command(pg_config, '--version', check: true) + pg_version = pg_version_res.stdout().strip().split()[1] + + dep_pgsql = declare_dependency( + # compile_args: pg_cflags + pg_cppflags, + # link_args: pg_ldflags, + compile_args: '-I' + pg_includedir, + link_args: ['-L' + pg_libdir, '-lpq'], + version: pg_version, + ) + endif endif summary('PostgreSQL', dep_pgsql.found(), bool_yn: true, section: 'PostgreSQL') diff --git a/meson/prog-curl/meson.build b/meson/prog-curl/meson.build index f836c63fed..93e8595c23 100644 --- a/meson/prog-curl/meson.build +++ b/meson/prog-curl/meson.build @@ -1,6 +1,7 @@ -# Find cURL -# Outputs: curl +curl = find_program('', required: false) -curl = find_program('curl', required: true) +if get_option('module-remote') != 'disabled' and get_option('unit-tests-backends') + curl = find_program('curl', required: true) +endif summary('cURL', curl.found(), bool_yn: true, section: 'Programs') diff --git a/meson/zeromq/meson.build b/meson/zeromq/meson.build index 45a23a65d1..21674e5195 100644 --- a/meson/zeromq/meson.build +++ b/meson/zeromq/meson.build @@ -1,8 +1,7 @@ -opt_zeromq = get_option('module-remote-zeromq') - dep_zeromq = dependency('', required: false) -if opt_zeromq - dep_zeromq = dependency('libzmq', required: opt_zeromq) + +if get_option('module-remote') != 'disabled' and get_option('module-remote-zeromq') + dep_zeromq = dependency('libzmq', required: true) endif conf.set('HAVE_LIBZMQ', dep_zeromq.found(), description: 'Have libzmq') diff --git a/pdns/meson.build b/pdns/meson.build index dd62220c1a..f9cc1b5c72 100644 --- a/pdns/meson.build +++ b/pdns/meson.build @@ -1,6 +1,5 @@ fs = import('fs') -dep_cdb = get_variable('dep_cdb', dependency('', required: false)) libpdns_cdb = dependency('', required: false) if dep_cdb.found() libpdns_cdb = declare_dependency(