-
Notifications
You must be signed in to change notification settings - Fork 19
/
meson.build
217 lines (186 loc) · 6.52 KB
/
meson.build
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
project(
'linux-driver-management',
['c'],
version: '1.0.3',
license: [
'LGPL-2.1',
],
default_options: [
'c_std=c11',
'prefix=/usr',
'sysconfdir=/etc',
'localstatedir=/var',
],
)
am_cflags = [
'-fstack-protector',
'-Wall',
'-pedantic',
'-Wstrict-prototypes',
'-Wundef',
'-fno-common',
'-Werror-implicit-function-declaration',
'-Wformat',
'-Wformat-security',
'-Werror=format-security',
'-Wconversion',
'-Wunused-variable',
'-Wunreachable-code',
'-W',
]
# Add our main flags
add_global_arguments(am_cflags, language: 'c')
path_prefix = get_option('prefix')
path_sysconfdir = join_paths(path_prefix, get_option('sysconfdir'))
path_libdir = join_paths(path_prefix, get_option('libdir'))
path_mandir = join_paths(path_prefix, get_option('mandir'))
path_datadir = join_paths(path_prefix, get_option('datadir'))
path_bindir = join_paths(path_prefix, get_option('bindir'))
path_vardir = join_paths(path_prefix, get_option('localstatedir'), 'lib', meson.project_name())
# For stateless distros this is changed to /usr/share/xdg/autostart
path_autostartdir = get_option('with-autostart-dir')
if path_autostartdir == ''
path_autostartdir = join_paths(path_sysconfdir, 'xdg', 'autostart')
endif
warn_modalias = false
with_modalias_dir = get_option('with-modalias-dir')
if with_modalias_dir != ''
path_modalias_dir = join_paths(path_prefix, with_modalias_dir)
else
path_modalias_dir = join_paths(path_datadir, meson.project_name(), 'modaliases')
warn_modalias = true
endif
# Find out where xorg modules are installed to
dep_xorg = dependency('xorg-server', required: false)
if dep_xorg.found()
xorg_module_dir = dep_xorg.get_pkgconfig_variable('moduledir')
else
xorg_module_dir = join_paths(path_libdir, 'xorg', 'modules')
message('Warning: Guessing xorg module directory! @0@'.format(xorg_module_dir))
message('Rebuild with pkgconfig(xorg-server) to ensure real path is used')
endif
# Get configuration bits together
cdata = configuration_data()
cdata.set_quoted('PACKAGE_VERSION', meson.project_version())
cdata.set_quoted('PACKAGE_NAME', meson.project_name())
cdata.set_quoted('LIBDIR', path_libdir)
cdata.set_quoted('SYSCONFDIR', path_sysconfdir)
cdata.set_quoted('XORG_MODULE_DIRECTORY', xorg_module_dir)
cdata.set_quoted('MODALIAS_DIR', path_modalias_dir)
with_glx_configuration = get_option('with-glx-configuration')
# Track dirs
cdata.set_quoted('LDM_TRACK_DIR', path_vardir)
with_hybrid_file = join_paths(path_vardir, 'hybrid')
cdata.set_quoted('LDM_HYBRID_FILE', with_hybrid_file)
if with_glx_configuration == true
cdata.set('WITH_GLX_CONFIGURATION', '1')
endif
# Write config.h now
config_h = configure_file(
configuration: cdata,
output: 'config.h',
)
config_h_dir = include_directories('.')
# Required dependencies
dep_usb = dependency('libusb-1.0', version: '>= 1.0.21')
glib_min_version = '>= 2.54.0'
dep_glib2 = dependency('glib-2.0', version: glib_min_version)
dep_gobject = dependency('gobject-2.0', version: glib_min_version)
dep_udev = dependency('libudev', version: '>= 215')
with_tests = get_option('with-tests')
enable_tests = false
if with_tests != 'no'
required_test = false
if with_tests == 'yes'
required_test = true
endif
dep_check = dependency('check', version: '>= 0.11.0', required: required_test)
dep_umockdev = dependency('umockdev-1.0', version: '>= 0.9.0', required: required_test)
run_umockdev = find_program('umockdev-wrapper', required: required_test)
if dep_check.found() and dep_umockdev.found() and run_umockdev.found()
enable_tests = true
endif
endif
enable_vapigen = true
run_vapigen = find_program('vapigen', required: false)
if not run_vapigen.found()
message('Disabling vala binding generation as vapigen is not installed')
enable_vapigen = false
endif
# If we have kmod, enable tooling
with_tools = get_option('with-tools')
enable_tools = false
if with_tools != 'no'
required_tools = false
if with_tools == 'yes'
required_tools = true
endif
dep_kmod = dependency('libkmod', version: '>= 24', required: required_tools)
if dep_kmod.found()
enable_tools = true
endif
endif
# Sort out compatibility stuff
with_gl_driver_switch_compat = get_option('with-gl-driver-switch-compat')
with_docs = get_option('with-docs')
# Define our ABI
abi_major_version = '1'
abi_minor_version = '0'
abi_micro_version = '2'
abi_version = '@0@.@1@.@2@'.format(
abi_major_version,
abi_minor_version,
abi_micro_version,
)
# Maybe build compat
subdir('compat')
# Always build data
subdir('data')
# Now go build the source
subdir('src')
# Maybe test, maybe not.
if enable_tests == true
subdir('tests')
endif
if with_docs == true
subdir('docs')
endif
subdir('man')
report = [
' Build configuration:',
' ====================',
'',
' prefix: @0@'.format(path_prefix),
' datadir: @0@'.format(path_datadir),
' sysconfdir: @0@'.format(path_sysconfdir),
' mandir: @0@'.format(path_mandir),
' bindir: @0@'.format(path_bindir),
' modaliasdir: @0@'.format(path_modalias_dir),
' xorg module directory: @0@'.format(xorg_module_dir),
' XDG autostart directory: @0@'.format(path_autostartdir),
' status directory: @0@'.format(path_vardir),
'',
' Extra modules:',
' ==============',
'',
' gl-driver-switch-compat: @0@'.format(with_gl_driver_switch_compat),
' GLX configuration: @0@'.format(with_glx_configuration),
' tools: @0@'.format(enable_tools),
' vala bindings: @0@'.format(enable_vapigen),
'',
' enable tests: @0@'.format(enable_tests),
' enable documentation: @0@'.format(with_docs),
]
if warn_modalias == true
report += [
'', '',
' Warning:',
' ========',
' default modalias directory selected. Verify this is correct.',
' The modalias directory contains modalias definitions required',
' for driver detection and should be provided by the driver',
' packages in your distribution.',
]
endif
# Output some stuff to validate the build config
message('\n\n\n' + '\n'.join(report) + '\n\n')