Skip to content

Commit 4b75174

Browse files
committed
build-sys: Add meson files
1 parent f6af965 commit 4b75174

File tree

4 files changed

+181
-0
lines changed

4 files changed

+181
-0
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@
88
/Makefile.in
99
/aclocal.m4
1010
/build-aux/
11+
/build/
1112
/compile
13+
/compile_commands.json
1214
/config.guess
1315
/config.h
1416
/config.h.in

config.h.meson

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#ifndef fooconfighfoo
2+
#define fooconfighfoo
3+
4+
#mesondefine PACKAGE_VERSION
5+
6+
#endif

meson.build

Lines changed: 137 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,137 @@
1+
project(
2+
'rtkit', 'c',
3+
version: '0.12',
4+
license: 'GPL3',
5+
meson_version: '>=0.49.0',
6+
default_options: ['c_std=c99', 'warning_level=2'],
7+
)
8+
9+
add_project_arguments(
10+
'-D_GNU_SOURCE', '-DHAVE_CONFIG_H',
11+
language: 'c'
12+
)
13+
14+
cc = meson.get_compiler('c')
15+
sh = find_program('sh')
16+
xxd = find_program('xxd')
17+
18+
dbus_dep = dependency('dbus-1')
19+
libcap_dep = dependency('libcap')
20+
libsystemd_dep = dependency('libsystemd')
21+
polkit_dep = dependency('polkit-gobject-1', required: false)
22+
systemd_dep = dependency('systemd', required: false)
23+
thread_dep = dependency('threads')
24+
25+
librt_dep = cc.find_library('z')
26+
cc.check_header('sched.h', dependencies: librt_dep)
27+
cc.has_function('sched_setscheduler', dependencies: librt_dep)
28+
29+
libexecdir = get_option('libexecdir')
30+
testsdir = get_option('libexecdir') / 'installed-tests' / meson.project_name()
31+
32+
busservicedir = get_option('dbus_systemservicedir')
33+
if busservicedir == ''
34+
busservicedir = dbus_dep.get_pkgconfig_variable(
35+
'system_bus_services_dir',
36+
default: get_option('datadir') / 'dbus-1' / 'system-services',
37+
)
38+
endif
39+
40+
interfacedir = get_option('dbus_interfacedir')
41+
if interfacedir == ''
42+
interfacedir = dbus_dep.get_pkgconfig_variable(
43+
'interfaces_dir',
44+
default: get_option('datadir') / 'dbus-1' / 'interfaces',
45+
)
46+
endif
47+
48+
rulesdir = get_option('dbus_rulesdir')
49+
if rulesdir == ''
50+
rulesdir = get_option('datadir') / 'dbus-1' / 'system.d'
51+
endif
52+
53+
policydir = get_option('polkit_actiondir')
54+
if policydir == '' and polkit_dep.found()
55+
policydir = polkit_dep.get_pkgconfig_variable('actiondir', default: '')
56+
endif
57+
if policydir == ''
58+
policydir = get_option('datadir') / 'polkit-1' / 'actions'
59+
endif
60+
61+
systemunitdir = ''
62+
if systemunitdir == '' and systemd_dep.found()
63+
systemunitdir = systemd_dep.get_pkgconfig_variable(
64+
'systemdsystemunitdir',
65+
default: '',
66+
)
67+
endif
68+
if systemunitdir == ''
69+
systemunitdir = get_option('libdir') / 'systemd' / 'system'
70+
endif
71+
72+
config = configuration_data()
73+
config.set('LIBEXECDIR', get_option('prefix') / libexecdir)
74+
config.set_quoted('PACKAGE_VERSION', meson.project_version())
75+
76+
config_h = configure_file(
77+
input: 'config.h.meson',
78+
output: 'config.h',
79+
configuration: config,
80+
)
81+
82+
xml_introspection_h = configure_file(
83+
input: 'org.freedesktop.RealtimeKit1.xml',
84+
output: 'xml-introspection.h',
85+
command: [
86+
sh, '-c', '"$1" -i < "$2" > "$3"', sh,
87+
xxd, '@INPUT@', '@OUTPUT@'
88+
],
89+
)
90+
91+
executable(
92+
'rtkit-daemon',
93+
'rtkit-daemon.c', 'rtkit.c', 'rtkit.h', config_h, xml_introspection_h,
94+
dependencies: [
95+
dbus_dep,
96+
libcap_dep,
97+
librt_dep,
98+
libsystemd_dep,
99+
thread_dep
100+
],
101+
install: true,
102+
install_dir: libexecdir,
103+
)
104+
105+
executable(
106+
'rtkit-test',
107+
'rtkit-test.c', 'rtkit.c', 'rtkit.h', config_h,
108+
dependencies: [dbus_dep, librt_dep],
109+
install: get_option('installed_tests'),
110+
install_dir: testsdir,
111+
)
112+
113+
executable(
114+
'rtkitctl',
115+
'rtkitctl.c', 'rtkit.h', config_h,
116+
install: true,
117+
dependencies: [dbus_dep],
118+
)
119+
120+
install_man('rtkitctl.8')
121+
install_data('org.freedesktop.RealtimeKit1.xml', install_dir: interfacedir)
122+
install_data('org.freedesktop.RealtimeKit1.conf', install_dir: rulesdir)
123+
install_data('org.freedesktop.RealtimeKit1.policy', install_dir: policydir)
124+
125+
configure_file(
126+
input: 'org.freedesktop.RealtimeKit1.service.in',
127+
output: 'org.freedesktop.RealtimeKit1.service',
128+
configuration: config,
129+
install_dir: busservicedir,
130+
)
131+
132+
configure_file(
133+
input: 'rtkit-daemon.service.in',
134+
output: 'rtkit-daemon.service',
135+
configuration: config,
136+
install_dir: systemunitdir,
137+
)

meson_options.txt

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
option(
2+
'dbus_interfacedir',
3+
type: 'string',
4+
value: '',
5+
description: 'Directory for D-Bus interface definitions',
6+
)
7+
option(
8+
'dbus_rulesdir',
9+
type: 'string',
10+
value: '',
11+
description: 'Directory for D-Bus system bus policy rules',
12+
)
13+
option(
14+
'dbus_systemservicedir',
15+
type: 'string',
16+
value: '',
17+
description: 'Directory for D-Bus system services',
18+
)
19+
option(
20+
'polkit_actiondir',
21+
type: 'string',
22+
value: '',
23+
description: 'Directory for Polkit actions',
24+
)
25+
option(
26+
'systemd_systemunitdir',
27+
type: 'string',
28+
value: '',
29+
description: 'Directory for systemd system units',
30+
)
31+
option(
32+
'installed_tests',
33+
type: 'boolean',
34+
value: true,
35+
description: 'Install tests'
36+
)

0 commit comments

Comments
 (0)