aboutsummaryrefslogtreecommitdiff
path: root/meson.build
diff options
context:
space:
mode:
authorDaniel Eklöf <daniel@ekloef.se>2023-05-17 18:51:40 +0000
committerDaniel Eklöf <daniel@ekloef.se>2023-05-22 16:47:25 +0000
commite78319fccd2b8c057deff4b1937b325be1d35140 (patch)
tree493ce56bf9ffe7b00386108d89869b8998f2ea6f /meson.build
parentslave: unset TERM_PROGRAM{,_VERSION} (diff)
utmp: rewrite utmp logging
This patch generalizes the utmp support, to not only support libutempter, but also ulog (and in the future, even more interfaces). * Rename config option main.utempter to main.utmp-helper * Add meson option -Dutmp-backend=none|libutempter|ulog|auto * Rename meson option -Ddefault-utempter-path to -Dutmp-default-helper-path * utmp is no longer detected at compile time, but at runtime instead. Meson will configure the following pre-processor macros, based on the selected utmp backend: * UTMP_ADD - argument to pass to utmp helper when adding a record (starting foot) * UTMP_DEL - argument to pass to utmp helper when removing a record (exiting foot) * UTMP_DEL_HAVE_ARGUMENT - if defined, UTMP_DEL expects an extra argument ($WAYLAND_DISPLAY) * UTMP_DEFAULT_HELPER_PATH - path to the default utmp helper binary The documentation has been updated to mention which arguments are passed to the helper binary. Closes #1314
Diffstat (limited to 'meson.build')
-rw-r--r--meson.build63
1 files changed, 44 insertions, 19 deletions
diff --git a/meson.build b/meson.build
index a6892cc4..c5ef1928 100644
--- a/meson.build
+++ b/meson.build
@@ -16,30 +16,54 @@ if cc.has_function('memfd_create')
add_project_arguments('-DMEMFD_CREATE', language: 'c')
endif
-utempter_path = get_option('default-utempter-path')
-if utempter_path == ''
- utempter = find_program(
- 'utempter',
- required: false,
- dirs: [join_paths(get_option('prefix'), get_option('libdir'), 'utempter'),
- join_paths(get_option('prefix'), get_option('libexecdir'), 'utempter'),
- '/usr/lib/utempter',
- '/usr/libexec/utempter',
- '/lib/utempter']
- )
- if utempter.found()
- utempter_path = utempter.full_path()
+utmp_backend = get_option('utmp-backend')
+if utmp_backend == 'auto'
+ host_os = host_machine.system()
+ if host_os == 'linux'
+ utmp_backend = 'libutempter'
+ elif host_os == 'freebsd'
+ utmp_backend = 'ulog'
else
- utempter_path = ''
+ utmp_backend = 'none'
endif
-elif utempter_path == 'none'
- utempter_path = ''
+endif
+
+utmp_default_helper_path = get_option('utmp-default-helper-path')
+
+if utmp_backend == 'none'
+ utmp_add = ''
+ utmp_del = ''
+ utmp_del_have_argument = false
+ utmp_default_helper_path = ''
+elif utmp_backend == 'libutempter'
+ utmp_add = 'add'
+ utmp_del = 'del'
+ utmp_del_have_argument = true
+ if utmp_default_helper_path == 'auto'
+ utmp_default_helper_path = join_paths('/usr', get_option('libdir'), 'utempter', 'utempter')
+ endif
+elif utmp_backend == 'ulog'
+ utmp_add = 'login'
+ utmp_del = 'logout'
+ utmp_del_have_argument = false
+ if utmp_default_helper_path == 'auto'
+ utmp_default_helper_path = join_paths('/usr', get_option('libexecdir'), 'ulog-helper')
+ endif
+else
+ error('invalid utmp backend')
endif
add_project_arguments(
['-D_GNU_SOURCE=200809L',
- '-DFOOT_DEFAULT_TERM="@0@"'.format(get_option('default-terminfo')),
- '-DFOOT_DEFAULT_UTEMPTER_PATH="@0@"'.format(utempter_path)] +
+ '-DFOOT_DEFAULT_TERM="@0@"'.format(get_option('default-terminfo'))] +
+ (utmp_backend != 'none'
+ ? ['-DUTMP_ADD="@0@"'.format(utmp_add),
+ '-DUTMP_DEL="@0@"'.format(utmp_del),
+ '-DUTMP_DEFAULT_HELPER_PATH="@0@"'.format(utmp_default_helper_path)]
+ : []) +
+ (utmp_del_have_argument
+ ? ['-DUTMP_DEL_HAVE_ARGUMENT=1']
+ : []) +
(is_debug_build
? ['-D_DEBUG']
: [cc.get_supported_arguments('-fno-asynchronous-unwind-tables')]) +
@@ -343,7 +367,8 @@ summary(
'Themes': get_option('themes'),
'IME': get_option('ime'),
'Grapheme clustering': utf8proc.found(),
- 'Utempter path': utempter_path,
+ 'utmp backend': utmp_backend,
+ 'utmp helper default path': utmp_default_helper_path,
'Build terminfo': tic.found(),
'Terminfo install location': terminfo_install_location,
'Default TERM': get_option('default-terminfo'),