]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
Meson: Finish refactoring of how module dependencies are handled
authorFred Morcos <fred.morcos@open-xchange.com>
Mon, 27 Nov 2023 13:19:18 +0000 (14:19 +0100)
committerFred Morcos <fred.morcos@open-xchange.com>
Wed, 20 Mar 2024 12:28:58 +0000 (13:28 +0100)
12 files changed:
meson.build
meson/cdb/meson.build
meson/cxx-fs/meson.build
meson/geoip/meson.build
meson/ldap/meson.build
meson/mmdb/meson.build
meson/mysql/meson.build
meson/odbc/meson.build
meson/pgsql/meson.build
meson/prog-curl/meson.build
meson/zeromq/meson.build
pdns/meson.build

index 3c04db684de57be8909f35616c23c79fdc59929c..17aefe8592583238029093df1dc5d842f3b8c008 100644 (file)
@@ -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)
 
index 227b2b276fc92f14f2f2d45886ca3c262a5ebcb3..72927edbeee70d69ea6b5c88b4b283c1b42cec84 100644 (file)
@@ -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
index 73c22bc9ade1b78971595491892bb0a459213349..38fdf963b565167dc5e4cfebb9fb3fd5258c3031 100644 (file)
@@ -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
index bcbeb2cf1aa20cbbb0f3c83c49a32ed57de24e31..97259c7a915c43070f6e78b4647dc06d91fba16e 100644 (file)
@@ -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')
index 8924a44776939a17d158fd85d021ef710b9ab125..220fa1ee732601146e550c98fed4d5d6167dcf62 100644 (file)
@@ -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
index 3873b27388e2778f0d3d0ae39cf01ee357146849..448bb8d01f917c050d9a673b13e4ac2527f033b8 100644 (file)
@@ -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')
index e57c164f713fcb04950f72aaa710abe18da7fa62..b4eceb0e812319da4094334f54a6166e8163cf18 100644 (file)
@@ -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')
index 6f1647799338437d7d46bf4233584ee209f8c819..d43befdca6436e1967c34cacacae36cb31daf068 100644 (file)
@@ -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')
index 0374c3d4009565e4b401a8161a9da8fed206da2b..b8659da1b2f528ef68e1f6374d1bd1c85275761d 100644 (file)
@@ -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')
index f836c63fedffb7851f730bb6ce86a74acc807011..93e8595c23cd7aa64235afbed9814ca77f31f2ac 100644 (file)
@@ -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')
index 45a23a65d138b5b73d760dd81bd0feabfa103f99..21674e5195b90085d06e86299e47210671a0cbeb 100644 (file)
@@ -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')
index dd62220c1a7dec6c3cf3ad199a147546ae01406a..f9cc1b5c72e58d6debd6197bed67f51170af989f 100644 (file)
@@ -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(