Skip to content
Snippets Groups Projects
Verified Commit 8e14fd72 authored by Tomas Krizek's avatar Tomas Krizek
Browse files

meson: systemd - simplify detection

parent 3efdebfb
Branches
Tags
1 merge request!771meson build system
......@@ -35,12 +35,9 @@ kresd_deps = [
libuv,
luajit,
gnutls,
libsystemd,
]
if systemd
kresd_deps += libsystemd
endif
subdir('lua')
......
......@@ -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',
......
# 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
......
......@@ -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
......
......@@ -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',
)
......
......@@ -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
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment