]> git.ipfire.org Git - thirdparty/knot-resolver.git/commitdiff
meson: build daemon in a subdir
authorTomas Krizek <tomas.krizek@nic.cz>
Thu, 24 Jan 2019 15:00:21 +0000 (16:00 +0100)
committerTomas Krizek <tomas.krizek@nic.cz>
Tue, 12 Mar 2019 09:41:48 +0000 (10:41 +0100)
daemon/meson.build [new file with mode: 0644]
meson.build

diff --git a/daemon/meson.build b/daemon/meson.build
new file mode 100644 (file)
index 0000000..915ffdb
--- /dev/null
@@ -0,0 +1,107 @@
+kresd_sources = [
+  'bindings.c',
+  'engine.c',
+  'ffimodule.c',
+  'io.c',
+  'main.c',
+  'network.c',
+  'session.c',
+  'tls.c',
+  'tls_ephemeral_credentials.c',
+  'tls_session_ticket-srv.c',
+  'worker.c',
+  'zimport.c',
+]
+
+embed_lua = generator(
+  find_program('../scripts/embed-lua.sh'),
+  arguments: ['@INPUT@'],
+  output: '@BASENAME@.inc',
+  capture: true,
+)
+
+kresd_lua = embed_lua.process(
+  'lua/sandbox.lua',
+  'lua/config.lua',
+  preserve_path_from: meson.current_source_dir(),  # TODO is this necessary?
+)
+
+
+luajit_has_setfuncs = run_command(
+  'pkg-config', ['luajit', '--atleast-version', '2.1.0-beta3']
+  ).returncode() == 0 ? '1' : '0'
+
+lib_suffix = '.so'
+# TODO seek&destroy LIBEXT
+if host_machine.system() == 'darwin'
+  lib_suffix = '.dylib'
+endif
+
+# daemon CFLAGS
+c_args = [
+  '-fPIE',  # TODO pie=true since 0.49.0
+  '-DROOTHINTS="@0@/root.hints"'.format(
+      join_paths(get_option('prefix'), get_option('sysconfdir'))),
+  '-DLIBEXT="@0@"'.format(lib_suffix),
+  '-Dlibzscanner_SONAME="@0@"'.format(libzscanner.get_pkgconfig_variable('soname')),
+  '-Dlibknot_SONAME="@0@"'.format(libknot.get_pkgconfig_variable('soname')),
+  '-DLUA_HAS_SETFUNCS=@0@'.format(luajit_has_setfuncs),
+]
+
+if host_machine.system() == 'darwin'
+  # luajit workaround for OS X  https://luajit.org/install.html#embed
+  c_args += ['-pagezero_size', '10000', '-image_base', '100000000']
+endif
+
+
+# daemon dependencies
+skip_daemon = false
+
+luajit = dependency('luajit', required: false)
+if not luajit.found()
+  skip_daemon = true
+  message('kresd daemon: luajit not found')
+endif
+
+xxd = find_program('xxd', required: false)
+if not xxd.found()
+  hexdump = find_program('hexdump', required: false)
+  if not hexdump.found()
+    skip_daemon = true
+    message('kresd daemon: neither xxd nor hexdump found')
+  endif
+endif
+
+
+# optional dependencies
+
+## systemd socket activation
+libsystemd = dependency('libsystemd', version: '>=227', required: false)
+if libsystemd.found()
+  c_args += ['-DHAS_SYSTEMD']
+endif
+
+
+# build
+if skip_daemon
+  warning('kresd daemon: skipping build')
+else
+  kresd = executable(
+    'kresd',
+    kresd_sources, kresd_lua,
+    dependencies: [
+      contrib_dep,
+      libkres_dep,
+      libknot,
+      libzscanner,
+      libdnssec,
+      libuv,
+      luajit,
+      gnutls,
+      libsystemd,
+    ],
+    c_args: c_args,
+    install: true,
+    install_dir: 'sbin',
+  )
+endif
index 23213d3b1a3ca321d0db36b08c5db874dc643530..12d2fbd487c48256ea082d64865bf87254a80674 100644 (file)
@@ -19,19 +19,9 @@ libzscanner = dependency('libzscanner', version: knot_version)
 libuv = dependency('libuv', version: '>=1.7')
 lmdb = dependency('lmdb')
 gnutls = dependency('gnutls')
-luajit = dependency('luajit')
-
-xxd = find_program('xxd', required: false)
-if not xxd.found()
-  hexdump = find_program('hexdump')
-endif
-
 
 # Optional dependencies
 
-## systemd socket activation
-libsystemd = dependency('libsystemd', version: '>=227', required: false)
-
 ## documentation
 doxygen = find_program('doxygen', required: false)
 sphinx_build = find_program('sphinx-build', required: false)
@@ -76,18 +66,8 @@ endif
 
 # Variables
 
-luajit_has_setfuncs = run_command(
-  'pkg-config', ['luajit', '--atleast-version', '2.1.0-beta3']
-  ).returncode() == 0 ? '1' : '0'
-
 # TODO @DATE@. @VERSION@, ...
 
-lib_suffix = '.so'
-# TODO seek&destroy LIBEXT
-if host_machine.system() == 'darwin'
-  lib_suffix = '.dylib'
-endif
-
 add_global_arguments(
   '-D_GNU_SOURCE',
 #  '-Wtype-limits',
@@ -109,80 +89,15 @@ add_global_link_arguments(
   language: 'c',
 )
 
-c_args = [
-  '-fPIE',  # TODO pie=true since 0.49.0
-  '-DROOTHINTS="@0@/root.hints"'.format(
-      join_paths(get_option('prefix'), get_option('sysconfdir'))),
-  '-DLIBEXT="@0@"'.format(lib_suffix),
-  '-Dlibzscanner_SONAME="@0@"'.format(libzscanner.get_pkgconfig_variable('soname')),
-  '-Dlibknot_SONAME="@0@"'.format(libknot.get_pkgconfig_variable('soname')),
-  '-DLUA_HAS_SETFUNCS=@0@'.format(luajit_has_setfuncs),
-]
-
-if libsystemd.found()
-  c_args += ['-DHAS_SYSTEMD']
-endif
-
-if host_machine.system() == 'darwin'
-  # luajit workaround for OS X  https://luajit.org/install.html#embed
-  c_args += ['-pagezero_size', '10000', '-image_base', '100000000']
-endif
-
 
 subdir('contrib')
 subdir('lib')
 subdir('client')
+subdir('daemon')
 
 
 ## kresd
 
-embed_lua = generator(
-  find_program('scripts/embed-lua.sh'),
-  arguments: ['@INPUT@'],
-  output: '@BASENAME@.inc',
-  capture: true,
-)
-
-kresd_lua = embed_lua.process(
-  'daemon/lua/sandbox.lua',
-  'daemon/lua/config.lua',
-  preserve_path_from: meson.current_source_dir(),  # TODO is this necessary?
-)
-
-kresd_sources = [
-  'daemon/bindings.c',
-  'daemon/engine.c',
-  'daemon/ffimodule.c',
-  'daemon/io.c',
-  'daemon/main.c',
-  'daemon/network.c',
-  'daemon/session.c',
-  'daemon/tls.c',
-  'daemon/tls_ephemeral_credentials.c',
-  'daemon/tls_session_ticket-srv.c',
-  'daemon/worker.c',
-  'daemon/zimport.c',
-]
-
-kresd = executable(
-  'kresd',
-  kresd_sources, kresd_lua,
-  include_directories: include_directories('daemon'),
-  dependencies: [
-    contrib_dep,
-    libkres_dep,
-    libknot,
-    libzscanner,
-    libdnssec,
-    libuv,
-    luajit,
-    gnutls,
-    libsystemd,
-  ],
-  c_args: c_args,
-  install: true,
-  install_dir: 'sbin',
-)
 
 # TODO install man