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 = [ ...@@ -35,12 +35,9 @@ kresd_deps = [
libuv, libuv,
luajit, luajit,
gnutls, gnutls,
libsystemd,
] ]
if systemd
kresd_deps += libsystemd
endif
subdir('lua') subdir('lua')
......
...@@ -5,7 +5,8 @@ man_config = configuration_data() ...@@ -5,7 +5,8 @@ man_config = configuration_data()
man_config.set('version', meson.project_version()) man_config.set('version', meson.project_version())
man_config.set('date', run_command('../scripts/get-date.sh', check: true).stdout()) man_config.set('date', run_command('../scripts/get-date.sh', check: true).stdout())
man_config.set('keyfile_default', keyfile_default) 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( man_kresd = configure_file(
input: 'kresd.8.in', input: 'kresd.8.in',
......
# etc: config examples # etc: config examples
# Config snippets (build-dependant) # Config snippets (build-dependant)
if systemd_socket if systemd_unit_files == 'enabled'
config_defaults = ''' config_defaults = '''
-- Network interface configuration: see kresd.systemd(7)''' -- Network interface configuration: see kresd.systemd(7)'''
else else
......
...@@ -77,30 +77,16 @@ user = get_option('user') ...@@ -77,30 +77,16 @@ user = get_option('user')
group = get_option('group') group = get_option('group')
## Systemd ## Systemd
opt_systemd = get_option('systemd') message('--- systemd socket activation ---')
systemd = false libsystemd = dependency('libsystemd', version: '>=227', required: false)
systemd_socket = false systemd_unit_files = get_option('systemd_unit_files')
if opt_systemd != 'disabled' if systemd_unit_files == 'enabled' and not libsystemd.found()
message('--- systemd integration ---') error('systemd_unit_files=enabled requires libsystemd >= 227')
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('---------------------------')
endif endif
message('---------------------------')
## Compiler args
c_args = [ c_args = [
'-D_GNU_SOURCE', '-D_GNU_SOURCE',
'-Wtype-limits', '-Wtype-limits',
...@@ -151,7 +137,7 @@ conf_data.set_quoted('libzscanner_SONAME', ...@@ -151,7 +137,7 @@ conf_data.set_quoted('libzscanner_SONAME',
libzscanner.get_pkgconfig_variable('soname')) libzscanner.get_pkgconfig_variable('soname'))
conf_data.set_quoted('libknot_SONAME', conf_data.set_quoted('libknot_SONAME',
libknot.get_pkgconfig_variable('soname')) libknot.get_pkgconfig_variable('soname'))
conf_data.set('HAS_SYSTEMD', systemd) conf_data.set('HAS_SYSTEMD', libsystemd.found())
kresconfig = configure_file( kresconfig = configure_file(
output: 'kresconfig.h', output: 'kresconfig.h',
...@@ -182,7 +168,7 @@ subdir('doc') ...@@ -182,7 +168,7 @@ subdir('doc')
subdir('etc') subdir('etc')
# systemd integration # systemd integration
if systemd if systemd_unit_files != 'disabled'
subdir('systemd') subdir('systemd')
endif endif
...@@ -191,8 +177,7 @@ endif ...@@ -191,8 +177,7 @@ endif
# NOTE: ternary operator in format() not supported # NOTE: ternary operator in format() not supported
# https://github.com/mesonbuild/meson/issues/2404 # https://github.com/mesonbuild/meson/issues/2404
summary_managed_ta = managed_ta ? 'enabled' : 'disabled' summary_managed_ta = managed_ta ? 'enabled' : 'disabled'
summary_systemd = systemd ? 'enabled' : 'disabled' summary_systemd_socket = libsystemd.found() ? 'enabled' : 'disabled'
summary_systemd_socket = systemd_socket ? 'enabled' : 'disabled'
summary_build_client = build_client ? 'enabled' : 'disabled' summary_build_client = build_client ? 'enabled' : 'disabled'
summary_build_doc = build_doc ? 'enabled' : 'disabled' summary_build_doc = build_doc ? 'enabled' : 'disabled'
summary_build_extra_tests = build_extra_tests ? 'enabled' : 'disabled' summary_build_extra_tests = build_extra_tests ? 'enabled' : 'disabled'
...@@ -213,8 +198,9 @@ message(''' ...@@ -213,8 +198,9 @@ message('''
keyfile_default: @0@'''.format(keyfile_default) + ''' keyfile_default: @0@'''.format(keyfile_default) + '''
managed_ta: @0@'''.format(summary_managed_ta) + ''' managed_ta: @0@'''.format(summary_managed_ta) + '''
systemd: @0@'''.format(summary_systemd) + ''' systemd:
socket activation: @0@'''.format(summary_systemd_socket) + ''' socket activation: @0@'''.format(summary_systemd_socket) + '''
unit_files: @0@'''.format(systemd_unit_files) + '''
work_dir: @0@'''.format(systemd_work_dir) + ''' work_dir: @0@'''.format(systemd_work_dir) + '''
optional components optional components
......
...@@ -41,18 +41,17 @@ option( ...@@ -41,18 +41,17 @@ option(
description: 'group which is used for kresd', description: 'group which is used for kresd',
) )
## Systemd integration ## Systemd
option( option(
'systemd', 'systemd_unit_files',
type: 'combo', type: 'combo',
choices: [ choices: [
'auto', 'disabled',
'enabled', 'enabled',
'nosocket', 'nosocket',
'disabled',
], ],
value: 'auto', value: 'disabled',
description: 'create systemd unit files', description: 'install systemd unit files',
) )
......
...@@ -4,8 +4,8 @@ ...@@ -4,8 +4,8 @@
systemd_work_dir = join_paths( systemd_work_dir = join_paths(
prefix, get_option('localstatedir'), 'cache', 'knot-resolver') prefix, get_option('localstatedir'), 'cache', 'knot-resolver')
run_dir = join_paths('/run', 'knot-resolver') run_dir = join_paths('/run', 'knot-resolver')
systemd_unit_dir = pkgconf_systemd.get_pkgconfig_variable('systemdsystemunitdir') systemd_unit_dir = join_paths(prefix, 'lib', 'systemd', 'system')
systemd_tmpfiles_dir = pkgconf_systemd.get_pkgconfig_variable('tmpfilesdir') systemd_tmpfiles_dir = join_paths(prefix, 'lib', 'tmpfiles.d')
## configuration ## configuration
systemd_config = configuration_data() systemd_config = configuration_data()
...@@ -16,9 +16,7 @@ systemd_config.set('sbin_dir', sbin_dir) ...@@ -16,9 +16,7 @@ systemd_config.set('sbin_dir', sbin_dir)
systemd_config.set('etc_dir', etc_dir) systemd_config.set('etc_dir', etc_dir)
systemd_config.set('run_dir', run_dir) systemd_config.set('run_dir', run_dir)
# TODO Restart=on-abnormal if systemd_unit_files == 'enabled'
if systemd_socket
## unit files ## unit files
kresd_service = configure_file( kresd_service = configure_file(
input: 'kresd@.service.in', input: 'kresd@.service.in',
...@@ -72,6 +70,6 @@ if systemd_socket ...@@ -72,6 +70,6 @@ if systemd_socket
], ],
install_dir: join_paths(examples_dir, 'kresd-tls.socket.d'), install_dir: join_paths(examples_dir, 'kresd-tls.socket.d'),
) )
else else if systemd_unit_files == 'nosocket'
subdir('nosocket') subdir('nosocket')
endif 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