From 8e14fd72b68e0abab38ff85cb51967b97f01d005 Mon Sep 17 00:00:00 2001 From: Tomas Krizek <tomas.krizek@nic.cz> Date: Wed, 13 Feb 2019 13:30:23 +0100 Subject: [PATCH] meson: systemd - simplify detection --- daemon/meson.build | 5 +---- doc/meson.build | 3 ++- etc/config/meson.build | 2 +- meson.build | 40 +++++++++++++--------------------------- meson_options.txt | 11 +++++------ systemd/meson.build | 10 ++++------ 6 files changed, 26 insertions(+), 45 deletions(-) diff --git a/daemon/meson.build b/daemon/meson.build index 1fe62073a..0cde203ed 100644 --- a/daemon/meson.build +++ b/daemon/meson.build @@ -35,12 +35,9 @@ kresd_deps = [ libuv, luajit, gnutls, + libsystemd, ] -if systemd - kresd_deps += libsystemd -endif - subdir('lua') diff --git a/doc/meson.build b/doc/meson.build index 956c6872e..d803f0f45 100644 --- a/doc/meson.build +++ b/doc/meson.build @@ -5,7 +5,8 @@ man_config = configuration_data() man_config.set('version', meson.project_version()) man_config.set('date', run_command('../scripts/get-date.sh', check: true).stdout()) man_config.set('keyfile_default', keyfile_default) -man_config.set('man_seealso_systemd', systemd ? '\\fIkresd.systemd(7)\\fR, ' : '') +man_config.set('man_seealso_systemd', + libsystemd.found() ? '\\fIkresd.systemd(7)\\fR, ' : '') man_kresd = configure_file( input: 'kresd.8.in', diff --git a/etc/config/meson.build b/etc/config/meson.build index dcd08e7d0..b02e027fa 100644 --- a/etc/config/meson.build +++ b/etc/config/meson.build @@ -1,7 +1,7 @@ # etc: config examples # Config snippets (build-dependant) -if systemd_socket +if systemd_unit_files == 'enabled' config_defaults = ''' -- Network interface configuration: see kresd.systemd(7)''' else diff --git a/meson.build b/meson.build index 0d402db14..3f7080f74 100644 --- a/meson.build +++ b/meson.build @@ -77,30 +77,16 @@ user = get_option('user') group = get_option('group') ## Systemd -opt_systemd = get_option('systemd') -systemd = false -systemd_socket = false -if opt_systemd != 'disabled' - message('--- systemd integration ---') - libsystemd = dependency('libsystemd', version: '>=227', - required: opt_systemd == 'enabled') - if libsystemd.found() - systemd = true - systemd_socket = opt_systemd != 'nosocket' - else - libsystemd = dependency('libsystemd', version: '>=214', - required: opt_systemd == 'nosocket') - if libsystemd.found() - systemd = true - systemd_socket = false - endif - endif - if systemd - pkgconf_systemd = dependency('systemd') - endif - message('---------------------------') +message('--- systemd socket activation ---') +libsystemd = dependency('libsystemd', version: '>=227', required: false) +systemd_unit_files = get_option('systemd_unit_files') +if systemd_unit_files == 'enabled' and not libsystemd.found() + error('systemd_unit_files=enabled requires libsystemd >= 227') endif +message('---------------------------') + +## Compiler args c_args = [ '-D_GNU_SOURCE', '-Wtype-limits', @@ -151,7 +137,7 @@ conf_data.set_quoted('libzscanner_SONAME', libzscanner.get_pkgconfig_variable('soname')) conf_data.set_quoted('libknot_SONAME', libknot.get_pkgconfig_variable('soname')) -conf_data.set('HAS_SYSTEMD', systemd) +conf_data.set('HAS_SYSTEMD', libsystemd.found()) kresconfig = configure_file( output: 'kresconfig.h', @@ -182,7 +168,7 @@ subdir('doc') subdir('etc') # systemd integration -if systemd +if systemd_unit_files != 'disabled' subdir('systemd') endif @@ -191,8 +177,7 @@ endif # NOTE: ternary operator in format() not supported # https://github.com/mesonbuild/meson/issues/2404 summary_managed_ta = managed_ta ? 'enabled' : 'disabled' -summary_systemd = systemd ? 'enabled' : 'disabled' -summary_systemd_socket = systemd_socket ? 'enabled' : 'disabled' +summary_systemd_socket = libsystemd.found() ? 'enabled' : 'disabled' summary_build_client = build_client ? 'enabled' : 'disabled' summary_build_doc = build_doc ? 'enabled' : 'disabled' summary_build_extra_tests = build_extra_tests ? 'enabled' : 'disabled' @@ -213,8 +198,9 @@ message(''' keyfile_default: @0@'''.format(keyfile_default) + ''' managed_ta: @0@'''.format(summary_managed_ta) + ''' - systemd: @0@'''.format(summary_systemd) + ''' + systemd: socket activation: @0@'''.format(summary_systemd_socket) + ''' + unit_files: @0@'''.format(systemd_unit_files) + ''' work_dir: @0@'''.format(systemd_work_dir) + ''' optional components diff --git a/meson_options.txt b/meson_options.txt index 3540e446f..44531c281 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -41,18 +41,17 @@ option( description: 'group which is used for kresd', ) -## Systemd integration +## Systemd option( - 'systemd', + 'systemd_unit_files', type: 'combo', choices: [ - 'auto', + 'disabled', 'enabled', 'nosocket', - 'disabled', ], - value: 'auto', - description: 'create systemd unit files', + value: 'disabled', + description: 'install systemd unit files', ) diff --git a/systemd/meson.build b/systemd/meson.build index c252fd319..a3b9b40ee 100644 --- a/systemd/meson.build +++ b/systemd/meson.build @@ -4,8 +4,8 @@ systemd_work_dir = join_paths( prefix, get_option('localstatedir'), 'cache', 'knot-resolver') run_dir = join_paths('/run', 'knot-resolver') -systemd_unit_dir = pkgconf_systemd.get_pkgconfig_variable('systemdsystemunitdir') -systemd_tmpfiles_dir = pkgconf_systemd.get_pkgconfig_variable('tmpfilesdir') +systemd_unit_dir = join_paths(prefix, 'lib', 'systemd', 'system') +systemd_tmpfiles_dir = join_paths(prefix, 'lib', 'tmpfiles.d') ## configuration systemd_config = configuration_data() @@ -16,9 +16,7 @@ systemd_config.set('sbin_dir', sbin_dir) systemd_config.set('etc_dir', etc_dir) systemd_config.set('run_dir', run_dir) -# TODO Restart=on-abnormal - -if systemd_socket +if systemd_unit_files == 'enabled' ## unit files kresd_service = configure_file( input: 'kresd@.service.in', @@ -72,6 +70,6 @@ if systemd_socket ], install_dir: join_paths(examples_dir, 'kresd-tls.socket.d'), ) -else +else if systemd_unit_files == 'nosocket' subdir('nosocket') endif -- GitLab