2020-07-31 00:22:18 +02:00
|
|
|
project(
|
|
|
|
'seatd',
|
|
|
|
'c',
|
2021-03-15 20:32:27 +01:00
|
|
|
version: '0.5.0',
|
2020-08-22 21:36:15 +02:00
|
|
|
license: 'MIT',
|
2020-07-31 14:19:41 +02:00
|
|
|
meson_version: '>=0.53.0',
|
2020-07-31 00:22:18 +02:00
|
|
|
default_options: [
|
|
|
|
'c_std=c11',
|
|
|
|
'warning_level=3',
|
|
|
|
'werror=true',
|
|
|
|
],
|
|
|
|
)
|
|
|
|
|
2020-09-08 00:00:48 +02:00
|
|
|
# Bump whenever ABI-breaking changes occur.
|
|
|
|
libseat_soversion = 1
|
|
|
|
|
2020-09-22 01:12:33 +02:00
|
|
|
defaultpath = get_option('defaultpath')
|
|
|
|
if defaultpath == ''
|
2021-03-16 12:53:39 +01:00
|
|
|
defaultpath = '/var/run/seatd.sock'
|
|
|
|
if target_machine.system() == 'linux'
|
|
|
|
defaultpath = '/run/seatd.sock'
|
2020-09-22 01:12:33 +02:00
|
|
|
endif
|
|
|
|
endif
|
|
|
|
|
2020-07-31 00:22:18 +02:00
|
|
|
add_project_arguments(
|
|
|
|
[
|
|
|
|
'-Wundef',
|
|
|
|
'-Wunused',
|
|
|
|
'-Wlogical-op',
|
|
|
|
'-Wmissing-include-dirs',
|
|
|
|
'-Wold-style-definition', # nop
|
|
|
|
'-Wpointer-arith',
|
|
|
|
'-Wstrict-prototypes',
|
|
|
|
'-Wimplicit-fallthrough',
|
|
|
|
'-Wmissing-prototypes',
|
2020-08-01 00:31:42 +00:00
|
|
|
'-Wno-unknown-warning-option',
|
|
|
|
'-Wno-unused-command-line-argument',
|
2020-07-31 00:22:18 +02:00
|
|
|
'-Wvla',
|
|
|
|
'-Wl,--exclude-libs=ALL',
|
2020-07-31 15:58:45 +02:00
|
|
|
'-D_XOPEN_SOURCE=700',
|
2020-08-01 00:31:42 +00:00
|
|
|
'-D__BSD_VISIBLE',
|
2020-08-07 15:48:24 +02:00
|
|
|
'-DSEATD_VERSION="@0@"'.format(meson.project_version()),
|
2020-09-22 01:12:33 +02:00
|
|
|
'-DSEATD_DEFAULTPATH="@0@"'.format(defaultpath)
|
2020-07-31 00:22:18 +02:00
|
|
|
],
|
|
|
|
language: 'c',
|
|
|
|
)
|
|
|
|
|
2020-07-31 15:58:45 +02:00
|
|
|
if ['debugoptimized', 'release', 'minsize'].contains(get_option('buildtype'))
|
2021-03-15 20:26:06 +01:00
|
|
|
add_project_arguments('-D_FORTIFY_SOURCE=2', language: 'c')
|
2020-07-31 15:58:45 +02:00
|
|
|
endif
|
|
|
|
|
2021-03-16 12:53:39 +01:00
|
|
|
if get_option('buildtype').startswith('debug')
|
|
|
|
add_project_arguments('-DDEBUG', language : 'c')
|
|
|
|
endif
|
|
|
|
|
2020-07-31 00:22:18 +02:00
|
|
|
# Hacks
|
|
|
|
source_root = meson.current_source_dir().split('/')
|
|
|
|
build_root = meson.build_root().split('/')
|
|
|
|
relative_dir_parts = []
|
|
|
|
i = 0
|
|
|
|
in_prefix = true
|
|
|
|
foreach p : build_root
|
|
|
|
if i >= source_root.length() or not in_prefix or p != source_root[i]
|
|
|
|
in_prefix = false
|
|
|
|
relative_dir_parts += '..'
|
|
|
|
endif
|
|
|
|
i += 1
|
|
|
|
endforeach
|
|
|
|
i = 0
|
|
|
|
in_prefix = true
|
|
|
|
foreach p : source_root
|
|
|
|
if i >= build_root.length() or not in_prefix or build_root[i] != p
|
|
|
|
in_prefix = false
|
|
|
|
relative_dir_parts += p
|
|
|
|
endif
|
|
|
|
i += 1
|
|
|
|
endforeach
|
|
|
|
|
|
|
|
add_project_arguments(
|
2020-08-05 23:31:05 +02:00
|
|
|
'-DREL_SRC_DIR="@0@"'.format(join_paths(relative_dir_parts) + '/'),
|
2020-07-31 00:22:18 +02:00
|
|
|
language: 'c',
|
|
|
|
)
|
|
|
|
|
|
|
|
private_files = [
|
|
|
|
'common/connection.c',
|
2020-08-03 02:32:33 +02:00
|
|
|
'common/linked_list.c',
|
2020-07-31 00:22:18 +02:00
|
|
|
'common/log.c',
|
|
|
|
]
|
|
|
|
|
|
|
|
private_deps = []
|
|
|
|
|
|
|
|
server_files = [
|
|
|
|
'common/log.c',
|
2020-08-03 02:12:47 +02:00
|
|
|
'common/linked_list.c',
|
2020-07-31 00:22:18 +02:00
|
|
|
'common/terminal.c',
|
|
|
|
'common/connection.c',
|
|
|
|
'common/evdev.c',
|
|
|
|
'common/drm.c',
|
2020-08-03 01:15:20 +02:00
|
|
|
'seatd/poller.c',
|
2020-07-31 00:22:18 +02:00
|
|
|
'seatd/seat.c',
|
|
|
|
'seatd/client.c',
|
|
|
|
'seatd/server.c',
|
|
|
|
]
|
|
|
|
|
2021-04-07 14:30:04 +02:00
|
|
|
with_seatd = get_option('seatd') == 'enabled'
|
|
|
|
with_builtin = get_option('builtin') == 'enabled'
|
|
|
|
with_server = get_option('server') == 'enabled'
|
|
|
|
|
|
|
|
if with_seatd
|
2020-07-31 00:22:18 +02:00
|
|
|
private_files += 'libseat/backend/seatd.c'
|
|
|
|
add_project_arguments('-DSEATD_ENABLED=1', language: 'c')
|
|
|
|
endif
|
|
|
|
|
2021-04-08 23:00:13 +02:00
|
|
|
logind = disabler()
|
2020-07-31 14:19:41 +02:00
|
|
|
logind_provider = ''
|
2021-04-07 13:24:19 +02:00
|
|
|
if get_option('logind') != 'disabled'
|
|
|
|
if get_option('logind') == 'auto'
|
|
|
|
assert(get_option('auto_features').auto(), '-Dlogind must be set to systemd or elogind since auto_features != auto')
|
|
|
|
foreach logind_provider : ['elogind', 'systemd']
|
|
|
|
logind = dependency('lib@0@'.format(logind_provider), required: false)
|
|
|
|
if logind.found()
|
|
|
|
break
|
|
|
|
endif
|
|
|
|
endforeach
|
|
|
|
else
|
|
|
|
logind_provider = get_option('logind')
|
|
|
|
logind = dependency('lib@0@'.format(logind_provider))
|
|
|
|
endif
|
2021-03-16 12:52:31 +01:00
|
|
|
|
2020-07-31 00:22:18 +02:00
|
|
|
if logind.found()
|
2021-03-16 12:52:31 +01:00
|
|
|
add_project_arguments('-DLOGIND_ENABLED=1', language: 'c')
|
|
|
|
add_project_arguments('-DHAVE_@0@=1'.format(logind_provider.to_upper()), language: 'c')
|
|
|
|
private_files += [
|
|
|
|
'libseat/backend/logind.c',
|
|
|
|
'common/drm.c',
|
|
|
|
]
|
|
|
|
private_deps += logind
|
2020-07-31 00:22:18 +02:00
|
|
|
endif
|
|
|
|
endif
|
|
|
|
|
2021-04-07 14:30:04 +02:00
|
|
|
if with_builtin
|
2020-07-31 00:22:18 +02:00
|
|
|
add_project_arguments('-DBUILTIN_ENABLED=1', language: 'c')
|
|
|
|
private_files += server_files
|
|
|
|
endif
|
|
|
|
|
|
|
|
private_lib = static_library(
|
|
|
|
'seat-private',
|
|
|
|
private_files,
|
|
|
|
dependencies: private_deps,
|
|
|
|
include_directories: [include_directories('.', 'include')],
|
|
|
|
)
|
|
|
|
|
2020-08-03 00:54:43 +02:00
|
|
|
symbols_file = 'libseat/libseat.syms'
|
|
|
|
symbols_flag = '-Wl,--version-script,@0@/@1@'.format(meson.current_source_dir(), symbols_file)
|
2020-07-31 00:22:18 +02:00
|
|
|
lib = library(
|
|
|
|
'seat', # This results in the library being called 'libseat'
|
2021-03-26 10:05:12 +01:00
|
|
|
[ 'libseat/libseat.c', 'libseat/backend/noop.c' ],
|
2020-09-08 00:00:48 +02:00
|
|
|
soversion: libseat_soversion,
|
2020-07-31 00:22:18 +02:00
|
|
|
link_with: private_lib,
|
|
|
|
include_directories: [include_directories('.', 'include')],
|
|
|
|
install: true,
|
2020-08-03 00:54:43 +02:00
|
|
|
link_args: symbols_flag,
|
|
|
|
link_depends: symbols_file,
|
2020-07-31 00:22:18 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
install_headers('include/libseat.h')
|
|
|
|
|
|
|
|
pkgconfig = import('pkgconfig')
|
|
|
|
pkgconfig.generate(lib,
|
|
|
|
version: meson.project_version(),
|
|
|
|
filebase: 'libseat',
|
|
|
|
name: 'libseat',
|
|
|
|
description: 'Seat management library',
|
|
|
|
)
|
|
|
|
|
2021-03-26 10:07:00 +01:00
|
|
|
libseat = declare_dependency(
|
|
|
|
link_with: lib,
|
|
|
|
dependencies: private_deps,
|
|
|
|
include_directories: include_directories('include', is_system: true),
|
|
|
|
)
|
|
|
|
|
2021-04-07 14:30:04 +02:00
|
|
|
if with_server
|
2020-07-31 00:22:18 +02:00
|
|
|
executable(
|
|
|
|
'seatd',
|
|
|
|
[ server_files, 'seatd/seatd.c' ],
|
|
|
|
include_directories: [include_directories('.', 'include')],
|
|
|
|
install: true,
|
|
|
|
)
|
|
|
|
endif
|
|
|
|
|
2021-04-07 14:30:04 +02:00
|
|
|
if get_option('examples') == 'enabled'
|
2020-07-31 00:22:18 +02:00
|
|
|
executable(
|
|
|
|
'simpletest',
|
|
|
|
['examples/simpletest/main.c'],
|
|
|
|
link_with: [lib],
|
|
|
|
include_directories: [include_directories('.', 'include')],
|
|
|
|
install: false,
|
|
|
|
)
|
|
|
|
endif
|
2020-07-31 14:19:41 +02:00
|
|
|
|
2021-03-15 20:22:55 +01:00
|
|
|
tests = {
|
2021-03-15 20:26:06 +01:00
|
|
|
'linked_list': ['common/linked_list.c'],
|
|
|
|
'connection': ['common/connection.c'],
|
|
|
|
'poller': ['common/linked_list.c', 'seatd/poller.c'],
|
2021-03-15 20:22:55 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
foreach name, value : tests
|
2021-03-15 20:26:06 +01:00
|
|
|
test(name, executable(
|
|
|
|
'@0@_test'.format(name),
|
|
|
|
['tests/@0@.c'.format(name), value],
|
|
|
|
include_directories: [include_directories('.', 'include')]))
|
2021-03-15 20:22:55 +01:00
|
|
|
endforeach
|
2020-10-12 17:58:20 +02:00
|
|
|
|
2021-04-07 14:30:04 +02:00
|
|
|
if with_server
|
2021-03-15 20:26:06 +01:00
|
|
|
scdoc = dependency('scdoc', required: get_option('man-pages'), version: '>= 1.9.7', native: true)
|
2021-02-26 20:34:27 -08:00
|
|
|
else
|
2021-03-15 20:26:06 +01:00
|
|
|
scdoc = disabler()
|
2021-02-26 20:34:27 -08:00
|
|
|
endif
|
2020-08-08 14:54:25 +02:00
|
|
|
|
|
|
|
if scdoc.found()
|
2020-08-31 20:08:12 +02:00
|
|
|
scdoc_prog = find_program(scdoc.get_pkgconfig_variable('scdoc'), native: true)
|
2020-08-08 14:54:25 +02:00
|
|
|
mandir = get_option('mandir')
|
|
|
|
|
2021-03-16 12:53:39 +01:00
|
|
|
foreach src : ['seatd.1.scd']
|
2020-08-08 14:54:25 +02:00
|
|
|
topic = src.split('.')[0]
|
|
|
|
section = src.split('.')[1]
|
|
|
|
output = '@0@.@1@'.format(topic, section)
|
|
|
|
|
|
|
|
custom_target(
|
|
|
|
output,
|
|
|
|
input: 'man/' + src,
|
|
|
|
output: output,
|
|
|
|
command: [
|
2021-04-07 13:36:41 +02:00
|
|
|
'sh', '-c', '@0@ < @INPUT@ > @1@'.format(scdoc_prog.path(), output)
|
2020-08-08 14:54:25 +02:00
|
|
|
],
|
|
|
|
install: true,
|
|
|
|
install_dir: '@0@/man@1@'.format(mandir, section)
|
|
|
|
)
|
|
|
|
endforeach
|
|
|
|
endif
|
2020-08-06 13:14:38 +02:00
|
|
|
|
2020-07-31 14:19:41 +02:00
|
|
|
summary({
|
2021-04-07 14:30:04 +02:00
|
|
|
'seatd': with_seatd,
|
|
|
|
'builtin': with_builtin,
|
|
|
|
'server': with_server,
|
2021-04-07 13:30:18 +02:00
|
|
|
'systemd': logind.found() and logind_provider == 'systemd',
|
|
|
|
'elogind': logind.found() and logind_provider == 'elogind',
|
2021-03-15 20:23:09 +01:00
|
|
|
}, bool_yn: true)
|