meson.build 29.4 KB
Newer Older
Peter Hutterer's avatar
Peter Hutterer committed
1
project('libinput', 'c', 'cpp',
Peter Hutterer's avatar
Peter Hutterer committed
2
	version : '1.11.901',
3
	license : 'MIT/Expat',
Peter Hutterer's avatar
Peter Hutterer committed
4
5
6
7
8
	default_options : [ 'c_std=gnu99', 'warning_level=2' ],
	meson_version : '>= 0.40.0')

libinput_version = meson.project_version().split('.')

9
10
11
12
13
14
dir_data        = join_paths(get_option('prefix'), get_option('datadir'), 'libinput')
dir_sysconf     = join_paths(get_option('prefix'), get_option('sysconfdir'), 'libinput')
dir_libexec     = join_paths(get_option('prefix'), get_option('libexecdir'), 'libinput')
dir_lib         = join_paths(get_option('prefix'), get_option('libdir'))
dir_man1        = join_paths(get_option('prefix'), get_option('mandir'), 'man1')
dir_system_udev = join_paths(get_option('prefix'), 'lib', 'udev')
Peter Hutterer's avatar
Peter Hutterer committed
15
dir_src_quirks  = join_paths(meson.source_root(), 'quirks')
16
17
18
19
20
21
22
23
24
25
26
27
dir_src_test    = join_paths(meson.source_root(), 'test')
dir_src         = join_paths(meson.source_root(), 'src')

dir_udev = get_option('udev-dir')
if dir_udev == ''
	dir_udev = dir_system_udev
endif
dir_udev_callouts = dir_udev
dir_udev_rules    = join_paths(dir_udev, 'rules.d')
dir_udev_hwdb     = join_paths(dir_udev, 'hwdb.d')


Peter Hutterer's avatar
Peter Hutterer committed
28
29
30
31
32
33
34
35
# We use libtool-version numbers because it's easier to understand.
# Before making a release, the libinput_so_*
# numbers should be modified. The components are of the form C:R:A.
# a) If binary compatibility has been broken (eg removed or changed interfaces)
#    change to C+1:0:0.
# b) If interfaces have been changed or added, but binary compatibility has
#    been preserved, change to C+1:0:A+1
# c) If the interface is the same as the previous version, change to C:R+1:A
36
37
38
libinput_lt_c=23
libinput_lt_r=0
libinput_lt_a=13
Peter Hutterer's avatar
Peter Hutterer committed
39
40
41
42
43
44
45
46
47

# convert to soname
libinput_so_version = '@0@.@1@.@2@'.format((libinput_lt_c - libinput_lt_a),
                                            libinput_lt_a, libinput_lt_r)

# Compiler setup
cc = meson.get_compiler('c')
cppflags = ['-Wno-unused-parameter', '-g', '-fvisibility=hidden']
cflags = cppflags + ['-Wmissing-prototypes', '-Wstrict-prototypes']
48
49
add_project_arguments(cflags, language : 'c')
add_project_arguments(cppflags, language : 'cpp')
Peter Hutterer's avatar
Peter Hutterer committed
50

51
# config.h
Peter Hutterer's avatar
Peter Hutterer committed
52
53
config_h = configuration_data()
config_h.set('_GNU_SOURCE', '1')
54
55
56
57
58
if get_option('buildtype') == 'debug' or get_option('buildtype') == 'debugoptimized'
	config_h.set_quoted('MESON_BUILD_ROOT', meson.build_root())
else
	config_h.set_quoted('MESON_BUILD_ROOT', '')
endif
Peter Hutterer's avatar
Peter Hutterer committed
59
60
61
62
63
64
65
66

prefix = '''#define _GNU_SOURCE 1
#include <assert.h>
'''
if cc.get_define('static_assert', prefix : prefix) == ''
	config_h.set('static_assert(...)', '/* */')
endif

67
68
69
70
71
72
73
74
75
76
77
78
79
# Coverity breaks because it doesn't define _Float128 correctly, you'll end
# up with a bunch of messages in the form:
# "/usr/include/stdlib.h", line 133: error #20: identifier "_Float128" is
#           undefined
#   extern _Float128 strtof128 (const char *__restrict __nptr,
#          ^
# We don't use float128 ourselves, it gets pulled in from math.h or
# something, so let's just define it as uint128 and move on.
# Unfortunately we can't detect the coverity build at meson configure
# time, we only know it fails at runtime. So make this an option instead, to
# be removed when coverity fixes this again.
if get_option('coverity')
	config_h.set('_Float128', '__uint128_t')
80
81
82
83
	config_h.set('_Float32', 'int')
	config_h.set('_Float32x', 'int')
	config_h.set('_Float64', 'long')
	config_h.set('_Float64x', 'long')
84
85
endif

86
87
88
89
if cc.has_header_symbol('dirent.h', 'versionsort', prefix : prefix)
	config_h.set('HAVE_VERSIONSORT', '1')
endif

90
91
92
93
94
95
if not cc.has_header_symbol('errno.h', 'program_invocation_short_name', prefix : prefix)
	if cc.has_header_symbol('stdlib.h', 'getprogname')
		config_h.set('program_invocation_short_name', 'getprogname()')
	endif
endif

96
97
98
99
if cc.has_header('xlocale.h')
	config_h.set('HAVE_XLOCALE_H', '1')
endif

100
101
102
103
104
105
if not cc.has_header_symbol('sys/ptrace.h', 'PTRACE_ATTACH', prefix : prefix)
	config_h.set('PTRACE_ATTACH', 'PT_ATTACH')
	config_h.set('PTRACE_CONT', 'PT_CONTINUE')
	config_h.set('PTRACE_DETACH', 'PT_DETACH')
endif

Peter Hutterer's avatar
Peter Hutterer committed
106
107
108
# Dependencies
pkgconfig = import('pkgconfig')
dep_udev = dependency('libudev')
109
110
dep_mtdev = dependency('mtdev', version : '>= 1.1.0')
dep_libevdev = dependency('libevdev', version : '>= 0.4')
Peter Hutterer's avatar
Peter Hutterer committed
111
112
113
dep_lm = cc.find_library('m', required : false)
dep_rt = cc.find_library('rt', required : false)

114
115
116
117
# Include directories
includes_include = include_directories('include')
includes_src = include_directories('src')

Peter Hutterer's avatar
Peter Hutterer committed
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
############ libwacom configuration ############

have_libwacom = get_option('libwacom')
config_h.set10('HAVE_LIBWACOM', have_libwacom)
if have_libwacom
	dep_libwacom = dependency('libwacom', version : '>= 0.20')

	code = '''
	#include <libwacom/libwacom.h>
	int main(void) { libwacom_get_paired_device(NULL); }
	'''
	result = cc.links(code,
			  name : 'libwacom_get_paired_device check',
			  dependencies : dep_libwacom)
	config_h.set10('HAVE_LIBWACOM_GET_PAIRED_DEVICE', result)
133
134
135
136
137
138
139
140
141

	code = '''
	#include <libwacom/libwacom.h>
	int main(void) { libwacom_get_button_evdev_code(NULL, 'A'); }
	'''
	result = cc.links(code,
			  name : 'libwacom_get_button_evdev_code check',
			  dependencies : dep_libwacom)
	config_h.set10('HAVE_LIBWACOM_GET_BUTTON_EVDEV_CODE', result)
142
143
else
	dep_libwacom = declare_dependency()
Peter Hutterer's avatar
Peter Hutterer committed
144
145
146
147
148
149
150
endif

############ udev bits ############

executable('libinput-device-group',
	   'udev/libinput-device-group.c',
	   dependencies : [dep_udev, dep_libwacom],
151
	   include_directories : [includes_src, includes_include],
Peter Hutterer's avatar
Peter Hutterer committed
152
	   install : true,
153
	   install_dir : dir_udev_callouts)
Peter Hutterer's avatar
Peter Hutterer committed
154
155
executable('libinput-model-quirks',
	   'udev/libinput-model-quirks.c',
156
	   dependencies : [dep_udev, dep_libevdev],
157
	   include_directories : [includes_src, includes_include],
Peter Hutterer's avatar
Peter Hutterer committed
158
	   install : true,
159
	   install_dir : dir_udev_callouts)
Peter Hutterer's avatar
Peter Hutterer committed
160
161
162
163
164
165

udev_rules_config = configuration_data()
udev_rules_config.set('UDEV_TEST_PATH', '')
configure_file(input : 'udev/80-libinput-device-groups.rules.in',
	       output : '80-libinput-device-groups.rules',
	       install : true,
166
	       install_dir : dir_udev_rules,
Peter Hutterer's avatar
Peter Hutterer committed
167
168
169
	       configuration : udev_rules_config)

litest_udev_rules_config = configuration_data()
170
litest_udev_rules_config.set('UDEV_TEST_PATH', meson.build_root() + '/')
Peter Hutterer's avatar
Peter Hutterer committed
171
172
173
174
175
litest_groups_rules_file = configure_file(input : 'udev/80-libinput-device-groups.rules.in',
	       output : '80-libinput-device-groups-litest.rules',
	       install : false,
	       configuration : litest_udev_rules_config)

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
############ libepoll-shim (BSD) ############

if cc.has_header_symbol('sys/epoll.h', 'epoll_create1', prefix : prefix)
	# epoll is built-in (Linux, illumos)
	dep_libepoll = declare_dependency()
else
	# epoll is implemented in userspace by libepoll-shim (FreeBSD)
	dir_libepoll = get_option('epoll-dir')
	if dir_libepoll == ''
		dir_libepoll = get_option('prefix')
	endif
	includes_epoll = include_directories(join_paths(dir_libepoll, 'include/libepoll-shim'))
	dep_libepoll = cc.find_library('epoll-shim', dirs : join_paths(dir_libepoll, 'lib'))
	code = '''
	#include <sys/epoll.h>
	int main(void) { epoll_create1(0); }
	'''
	if not cc.links(code,
		name : 'libepoll-shim check',
		dependencies : [dep_libepoll, dep_rt],
		include_directories : includes_epoll) # note: wants an include_directories object
		error('No built-in epoll or libepoll-shim found.')
	endif
	dep_libepoll = declare_dependency(
		include_directories : includes_epoll,
		dependencies : [dep_libepoll, dep_rt])
endif

Peter Hutterer's avatar
Peter Hutterer committed
204
205
206
207
208
209
210
############ libinput-util.a ############
src_libinput_util = [
		'src/libinput-util.c',
		'src/libinput-util.h'
]
libinput_util = static_library('libinput-util',
			       src_libinput_util,
211
212
			       dependencies : dep_udev,
			       include_directories : includes_include)
213
dep_libinput_util = declare_dependency(link_with : libinput_util)
Peter Hutterer's avatar
Peter Hutterer committed
214
215
216
217

############ libfilter.a ############
src_libfilter = [
		'src/filter.c',
218
		'src/filter-flat.c',
219
		'src/filter-low-dpi.c',
220
		'src/filter-mouse.c',
221
		'src/filter-touchpad.c',
222
		'src/filter-touchpad-x230.c',
223
		'src/filter-tablet.c',
224
		'src/filter-trackpoint.c',
Peter Hutterer's avatar
Peter Hutterer committed
225
226
227
		'src/filter.h',
		'src/filter-private.h'
]
228
229
230
libfilter = static_library('filter', src_libfilter,
			   dependencies : dep_udev,
			   include_directories : includes_include)
231
dep_libfilter = declare_dependency(link_with : libfilter)
Peter Hutterer's avatar
Peter Hutterer committed
232

233
############ libquirks.a #############
234
235
libinput_data_path = dir_data
libinput_data_override_path = join_paths(dir_sysconf, 'local-overrides.quirks')
Peter Hutterer's avatar
Peter Hutterer committed
236
237
config_h.set_quoted('LIBINPUT_QUIRKS_DIR', dir_data)
config_h.set_quoted('LIBINPUT_QUIRKS_OVERRIDE_FILE', libinput_data_override_path)
238
239

quirks_data = [
Peter Hutterer's avatar
Peter Hutterer committed
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
	'quirks/10-generic-keyboard.quirks',
	'quirks/10-generic-lid.quirks',
	'quirks/10-generic-trackball.quirks',
	'quirks/30-vendor-aiptek.quirks',
	'quirks/30-vendor-alps.quirks',
	'quirks/30-vendor-cyapa.quirks',
	'quirks/30-vendor-elantech.quirks',
	'quirks/30-vendor-huion.quirks',
	'quirks/30-vendor-ibm.quirks',
	'quirks/30-vendor-logitech.quirks',
	'quirks/30-vendor-microsoft.quirks',
	'quirks/30-vendor-razer.quirks',
	'quirks/30-vendor-synaptics.quirks',
	'quirks/30-vendor-wacom.quirks',
	'quirks/50-system-apple.quirks',
	'quirks/50-system-asus.quirks',
	'quirks/50-system-chicony.quirks',
	'quirks/50-system-cyborg.quirks',
	'quirks/50-system-dell.quirks',
	'quirks/50-system-google.quirks',
	'quirks/50-system-hp.quirks',
	'quirks/50-system-lenovo.quirks',
	'quirks/50-system-system76.quirks',
263
264
]

Peter Hutterer's avatar
Peter Hutterer committed
265
266
config_h.set_quoted('LIBINPUT_QUIRKS_FILES', ':'.join(quirks_data))
config_h.set_quoted('LIBINPUT_QUIRKS_SRCDIR', dir_src_quirks)
267

268
install_data(quirks_data, install_dir : dir_data)
269
270
271
272
273
274
275
276
277
278
279
280

src_libquirks = [
	'src/quirks.c',
	'src/quirks.h',
]

deps_libquirks = [dep_udev, dep_libinput_util]
libquirks = static_library('quirks', src_libquirks,
			   dependencies : deps_libquirks,
			   include_directories : includes_include)
dep_libquirks = declare_dependency(link_with : libquirks)

Peter Hutterer's avatar
Peter Hutterer committed
281
282
############ libinput.so ############
install_headers('src/libinput.h')
283
src_libinput = src_libfilter + [
Peter Hutterer's avatar
Peter Hutterer committed
284
285
286
287
288
	'src/libinput.c',
	'src/libinput.h',
	'src/libinput-private.h',
	'src/evdev.c',
	'src/evdev.h',
289
	'src/evdev-debounce.c',
290
	'src/evdev-fallback.c',
291
	'src/evdev-fallback.h',
Peter Hutterer's avatar
Peter Hutterer committed
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
	'src/evdev-middle-button.c',
	'src/evdev-mt-touchpad.c',
	'src/evdev-mt-touchpad.h',
	'src/evdev-mt-touchpad-tap.c',
	'src/evdev-mt-touchpad-buttons.c',
	'src/evdev-mt-touchpad-edge-scroll.c',
	'src/evdev-mt-touchpad-gestures.c',
	'src/evdev-tablet.c',
	'src/evdev-tablet.h',
	'src/evdev-tablet-pad.c',
	'src/evdev-tablet-pad.h',
	'src/evdev-tablet-pad-leds.c',
	'src/path-seat.h',
	'src/path-seat.c',
	'src/udev-seat.c',
	'src/udev-seat.h',
	'src/timer.c',
	'src/timer.h',
	'include/linux/input.h'
]
312

Peter Hutterer's avatar
Peter Hutterer committed
313
314
315
316
deps_libinput = [
	dep_mtdev,
	dep_udev,
	dep_libevdev,
317
	dep_libepoll,
Peter Hutterer's avatar
Peter Hutterer committed
318
319
320
	dep_lm,
	dep_rt,
	dep_libwacom,
321
322
	dep_libinput_util,
	dep_libquirks
Peter Hutterer's avatar
Peter Hutterer committed
323
324
325
326
327
328
329
330
331
332
333
334
]

libinput_version_h_config = configuration_data()
libinput_version_h_config.set('LIBINPUT_VERSION_MAJOR', libinput_version[0])
libinput_version_h_config.set('LIBINPUT_VERSION_MINOR', libinput_version[1])
libinput_version_h_config.set('LIBINPUT_VERSION_MICRO', libinput_version[2])
libinput_version_h_config.set('LIBINPUT_VERSION', meson.project_version())

libinput_version_h = configure_file(
		input : 'src/libinput-version.h.in',
		output : 'libinput-version.h',
		configuration : libinput_version_h_config,
335
		install : false,
Peter Hutterer's avatar
Peter Hutterer committed
336
337
)

338
mapfile = join_paths(dir_src, 'libinput.sym')
Peter Hutterer's avatar
Peter Hutterer committed
339
340
341
version_flag = '-Wl,--version-script,@0@'.format(mapfile)
lib_libinput = shared_library('input',
		src_libinput,
342
		include_directories : [include_directories('.'), includes_include],
Peter Hutterer's avatar
Peter Hutterer committed
343
344
345
346
347
348
349
350
351
352
353
354
		dependencies : deps_libinput,
		version : libinput_so_version,
		link_args : version_flag,
		link_depends : mapfile,
		install : true
		)

dep_libinput = declare_dependency(
		link_with : lib_libinput,
		dependencies : deps_libinput)

pkgconfig.generate(
355
356
357
358
359
	filebase : 'libinput',
	name : 'Libinput',
	description : 'Input device library',
	version : meson.project_version(),
	libraries : lib_libinput
Peter Hutterer's avatar
Peter Hutterer committed
360
361
)

362
363
git_version_h = vcs_tag(command : ['git', 'describe'],
			fallback : 'unknown',
364
365
			input : 'src/libinput-git-version.h.in',
			output :'libinput-git-version.h')
366

367
if meson.version().version_compare('<0.43.0')
368
369
370
	# Restore the SELinux context for the libinput.so.a.b.c on install
	# meson bug https://github.com/mesonbuild/meson/issues/1967
	meson.add_install_script('src/libinput-restore-selinux-context.sh',
371
				 dir_lib, lib_libinput.full_path())
372
endif
373

Peter Hutterer's avatar
Peter Hutterer committed
374
375
############ documentation ############

376
if get_option('documentation')
377
378
	subdir('doc/api')
	subdir('doc/user')
Peter Hutterer's avatar
Peter Hutterer committed
379
380
381
endif

############ tools ############
382
libinput_tool_path = dir_libexec
383
config_h.set_quoted('LIBINPUT_TOOL_PATH', libinput_tool_path)
Peter Hutterer's avatar
Peter Hutterer committed
384
385
tools_shared_sources = [ 'tools/shared.c',
			 'tools/shared.h' ]
386
387
388
deps_tools_shared = [ dep_libinput, dep_libevdev ]
lib_tools_shared = static_library('tools_shared',
				  tools_shared_sources,
389
				  include_directories : [includes_src, includes_include],
390
391
392
393
				  dependencies : deps_tools_shared)
dep_tools_shared = declare_dependency(link_with : lib_tools_shared,
				      dependencies : deps_tools_shared)

394
395
396
man_config = configuration_data()
man_config.set('LIBINPUT_VERSION', meson.project_version())

397
deps_tools = [ dep_tools_shared, dep_libinput ]
398
libinput_debug_events_sources = [ 'tools/libinput-debug-events.c' ]
Peter Hutterer's avatar
Peter Hutterer committed
399
400
executable('libinput-debug-events',
	   libinput_debug_events_sources,
401
	   dependencies : deps_tools,
402
	   include_directories : [includes_src, includes_include],
403
	   install_dir : libinput_tool_path,
Peter Hutterer's avatar
Peter Hutterer committed
404
405
	   install : true
	   )
406
407
408
409
configure_file(input : 'tools/libinput-debug-events.man',
	       output : 'libinput-debug-events.1',
	       configuration : man_config,
	       install : true,
410
	       install_dir : dir_man1,
411
	       )
Peter Hutterer's avatar
Peter Hutterer committed
412

413
414
415
416
417
418
419
420
libinput_quirks_sources = [ 'tools/libinput-quirks.c' ]
libinput_quirks = executable('libinput-quirks',
			     libinput_quirks_sources,
			     dependencies : [dep_libquirks, dep_tools_shared, dep_libinput],
			     include_directories : [includes_src, includes_include],
			     install_dir : libinput_tool_path,
			     install : true
			    )
421
test('validate-quirks',
422
     libinput_quirks,
423
     args: ['validate', '--data-dir=@0@'.format(dir_src_quirks)]
424
     )
425

426
427
428
429
configure_file(input : 'tools/libinput-quirks.man',
	       output : 'libinput-quirks.1',
	       configuration : man_config,
	       install : true,
430
	       install_dir : dir_man1,
431
432
433
434
435
436
	       )
# Same man page for the subtools to stay consistent with the other tools
configure_file(input : 'tools/libinput-quirks.man',
	       output : 'libinput-quirks-list.1',
	       configuration : man_config,
	       install : true,
437
	       install_dir : dir_man1,
438
439
440
	       )
configure_file(input : 'tools/libinput-quirks.man',
	       output : 'libinput-quirks-validate.1',
441
442
	       configuration : man_config,
	       install : true,
443
	       install_dir : dir_man1,
444
445
	       )

446
libinput_list_devices_sources = [ 'tools/libinput-list-devices.c' ]
447
448
449
450
451
452
453
454
455
libinput_list_devices = executable('libinput-list-devices',
				   libinput_list_devices_sources,
				   dependencies : deps_tools,
				   include_directories : [includes_src, includes_include],
				   install_dir : libinput_tool_path,
				   install : true,
				  )
test('list-devices', libinput_list_devices)

456
457
458
459
configure_file(input : 'tools/libinput-list-devices.man',
	       output : 'libinput-list-devices.1',
	       configuration : man_config,
	       install : true,
460
	       install_dir : dir_man1,
461
	       )
Peter Hutterer's avatar
Peter Hutterer committed
462

463
464
465
466
libinput_measure_sources = [ 'tools/libinput-measure.c' ]
executable('libinput-measure',
	   libinput_measure_sources,
	   dependencies : deps_tools,
467
	   include_directories : [includes_src, includes_include],
468
469
470
	   install_dir : libinput_tool_path,
	   install : true,
	   )
471
472
473
474
configure_file(input : 'tools/libinput-measure.man',
	       output : 'libinput-measure.1',
	       configuration : man_config,
	       install : true,
475
	       install_dir : dir_man1,
476
	       )
477

478
config_noop = configuration_data()
479
480
481
482
483
484
# Set a dummy replacement to silence meson warnings:
# meson.build:487: WARNING: Got an empty configuration_data() object and
# 		   found no substitutions in the input file 'foo'. If you
# 		   want to copy a file to the build dir, use the 'copy:'
# 		   keyword argument added in 0.47.0
config_noop.set('dummy', 'dummy')
485
486
487
488
489
490
configure_file(input: 'tools/libinput-measure-fuzz.py',
	       output: 'libinput-measure-fuzz',
	       configuration : config_noop,
	       install : true,
	       install_dir : libinput_tool_path
	       )
491
492
493
494
configure_file(input : 'tools/libinput-measure-fuzz.man',
	       output : 'libinput-measure-fuzz.1',
	       configuration : man_config,
	       install : true,
495
	       install_dir : dir_man1,
496
	       )
497

498
configure_file(input: 'tools/libinput-measure-touchpad-tap.py',
499
	       output: 'libinput-measure-touchpad-tap',
500
501
502
503
	       configuration : config_noop,
	       install : true,
	       install_dir : libinput_tool_path
	       )
504
505
506
507
configure_file(input : 'tools/libinput-measure-touchpad-tap.man',
	       output : 'libinput-measure-touchpad-tap.1',
	       configuration : man_config,
	       install : true,
508
	       install_dir : dir_man1,
509
	       )
510

511
configure_file(input: 'tools/libinput-measure-touchpad-pressure.py',
512
	       output: 'libinput-measure-touchpad-pressure',
513
514
515
	       configuration : config_noop,
	       install : true,
	       install_dir : libinput_tool_path
516
517
	       )

518
519
520
521
configure_file(input : 'tools/libinput-measure-touchpad-pressure.man',
	       output : 'libinput-measure-touchpad-pressure.1',
	       configuration : man_config,
	       install : true,
522
	       install_dir : dir_man1,
523
	       )
524
configure_file(input: 'tools/libinput-measure-touch-size.py',
525
	       output: 'libinput-measure-touch-size',
526
527
528
	       configuration : config_noop,
	       install : true,
	       install_dir : libinput_tool_path
529
530
	       )

531
532
533
534
configure_file(input : 'tools/libinput-measure-touch-size.man',
	       output : 'libinput-measure-touch-size.1',
	       configuration : man_config,
	       install : true,
535
	       install_dir : dir_man1,
536
	       )
537

538
539
540
541
542
543
configure_file(input: 'tools/libinput-measure-trackpoint-range.py',
	       output: 'libinput-measure-trackpoint-range',
	       configuration : config_noop,
	       install : true,
	       install_dir : libinput_tool_path
	       )
544
545
546
547
configure_file(input : 'tools/libinput-measure-trackpoint-range.man',
	       output : 'libinput-measure-trackpoint-range.1',
	       configuration : man_config,
	       install : true,
548
	       install_dir : dir_man1,
549
550
	       )

551
libinput_record_sources = [ 'tools/libinput-record.c', git_version_h ]
552
553
executable('libinput-record',
	   libinput_record_sources,
554
	   dependencies : deps_tools + [dep_udev],
555
556
557
558
559
560
561
562
	   include_directories : [includes_src, includes_include],
	   install_dir : libinput_tool_path,
	   install : true,
	   )
configure_file(input : 'tools/libinput-record.man',
	       output : 'libinput-record.1',
	       configuration : man_config,
	       install : true,
563
	       install_dir : dir_man1,
564
565
	       )

566
567
568
569
570
571
install_data('tools/libinput-replay',
	     install_dir : libinput_tool_path)
configure_file(input : 'tools/libinput-replay.man',
	       output : 'libinput-replay.1',
	       configuration : man_config,
	       install : true,
572
	       install_dir : dir_man1,
573
574
	       )

575
if get_option('debug-gui')
Peter Hutterer's avatar
Peter Hutterer committed
576
	dep_gtk = dependency('gtk+-3.0', version : '>= 3.20')
Peter Hutterer's avatar
Peter Hutterer committed
577
578
579
	dep_cairo = dependency('cairo')
	dep_glib = dependency('glib-2.0')

580
	debug_gui_sources = [ 'tools/libinput-debug-gui.c' ]
581
	deps_debug_gui = [
Peter Hutterer's avatar
Peter Hutterer committed
582
583
584
			dep_gtk,
			dep_cairo,
			dep_glib,
585
			] + deps_tools
586
587
588
	executable('libinput-debug-gui',
		   debug_gui_sources,
		   dependencies : deps_debug_gui,
589
		   include_directories : [includes_src, includes_include],
590
		   install_dir : libinput_tool_path,
591
		   install : true
Peter Hutterer's avatar
Peter Hutterer committed
592
		   )
593
594
595
596
	configure_file(input : 'tools/libinput-debug-gui.man',
		       output : 'libinput-debug-gui.1',
		       configuration : man_config,
		       install : true,
597
		       install_dir : dir_man1,
598
		       )
Peter Hutterer's avatar
Peter Hutterer committed
599
600
endif

601
602
603
604
libinput_sources = [ 'tools/libinput-tool.c' ]

executable('libinput',
	   libinput_sources,
605
	   dependencies : deps_tools,
606
	   include_directories : [includes_src, includes_include],
607
608
	   install : true
	   )
609
610
611
612
configure_file(input : 'tools/libinput.man',
	       output : 'libinput.1',
	       configuration : man_config,
	       install : true,
613
	       install_dir : dir_man1,
614
	       )
615
616
617
618
619

ptraccel_debug_sources = [ 'tools/ptraccel-debug.c' ]
executable('ptraccel-debug',
	   ptraccel_debug_sources,
	   dependencies : [ dep_libfilter, dep_libinput ],
620
	   include_directories : [includes_src, includes_include],
621
622
623
	   install : false
	   )

624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
# the libinput tools check whether we execute from the builddir, this is
# the test to verify that lookup. We test twice, once as normal test
# run from the builddir, once after copying to /tmp
test_builddir_lookup = executable('test-builddir-lookup',
				  'tools/test-builddir-lookup.c',
				  dependencies : [ dep_tools_shared],
				  include_directories : [includes_src, includes_include],
				  install : false)
test('tools-builddir-lookup',
     test_builddir_lookup,
     args : ['--builddir-is-set'])
test('tools-builddir-lookup-installed',
     find_program('tools/helper-copy-and-exec-from-tmp.sh'),
     args : [test_builddir_lookup.full_path(), '--builddir-is-null'],
     env : ['LD_LIBRARY_PATH=@0@'.format(meson.build_root())],
     workdir : '/tmp')

Peter Hutterer's avatar
Peter Hutterer committed
641
642
############ tests ############

643
test('symbols-leak-test',
644
645
     find_program('test/symbols-leak-test'),
     args : [ join_paths(dir_src, 'libinput.sym'), dir_src])
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675

# build-test only
executable('test-build-pedantic',
	   'test/build-pedantic.c',
	   dependencies : [dep_udev],
	   include_directories : [includes_src, includes_include],
	   c_args : ['-std=c99', '-pedantic', '-Werror'],
	   install : false)
# build-test only
executable('test-build-std-gnuc90',
	   'test/build-pedantic.c',
	   dependencies : [dep_udev],
	   include_directories : [includes_src, includes_include],
	   c_args : ['-std=gnu90', '-Werror'],
	   install : false)
# test for linking with the minimal linker flags
executable('test-build-linker',
	   'test/build-pedantic.c',
	   include_directories : [includes_src, includes_include],
	   dependencies : [ dep_libinput, dep_libinput_util ],
	   install : false)
# test including from C++
executable('test-build-cxx',
	   'test/build-cxx.cc',
	   dependencies : [dep_udev],
	   include_directories : [includes_src, includes_include],
	   install : false)

# This is the test suite runner, we allow disabling that one because of
# dependencies
676
if get_option('tests')
Peter Hutterer's avatar
Peter Hutterer committed
677
678
679
680
681
682
683
684
685
	dep_check = dependency('check', version : '>= 0.9.10')
	valgrind = find_program('valgrind')
	addr2line = find_program('addr2line')

	if addr2line.found()
		config_h.set('HAVE_ADDR2LINE', '1')
		config_h.set_quoted('ADDR2LINE', addr2line.path())
	endif

686
687
688
	leftover_rules = find_program('test/check-leftover-udev-rules.sh')
	test('leftover-rules', leftover_rules, is_parallel : false)

689
	dep_libunwind = dependency('libunwind', required : false)
Peter Hutterer's avatar
Peter Hutterer committed
690
691
	config_h.set10('HAVE_LIBUNWIND', dep_libunwind.found())

692
	# for inhibit support during test run
693
	dep_libsystemd = dependency('libsystemd', version : '>= 221', required : false)
694
695
	config_h.set10('HAVE_LIBSYSTEMD', dep_libsystemd.found())

Peter Hutterer's avatar
Peter Hutterer committed
696
697
698
699
700
	lib_litest_sources = [
		'test/litest.h',
		'test/litest-int.h',
		'test/litest-device-acer-hawaii-keyboard.c',
		'test/litest-device-acer-hawaii-touchpad.c',
701
		'test/litest-device-aiptek-tablet.c',
Peter Hutterer's avatar
Peter Hutterer committed
702
703
704
705
706
707
708
709
710
711
712
713
714
		'test/litest-device-alps-semi-mt.c',
		'test/litest-device-alps-dualpoint.c',
		'test/litest-device-anker-mouse-kbd.c',
		'test/litest-device-apple-appletouch.c',
		'test/litest-device-apple-internal-keyboard.c',
		'test/litest-device-apple-magicmouse.c',
		'test/litest-device-asus-rog-gladius.c',
		'test/litest-device-atmel-hover.c',
		'test/litest-device-bcm5974.c',
		'test/litest-device-calibrated-touchscreen.c',
		'test/litest-device-cyborg-rat-5.c',
		'test/litest-device-elantech-touchpad.c',
		'test/litest-device-generic-singletouch.c',
715
		'test/litest-device-gpio-keys.c',
Peter Hutterer's avatar
Peter Hutterer committed
716
		'test/litest-device-huion-pentablet.c',
717
		'test/litest-device-hp-wmi-hotkeys.c',
718
		'test/litest-device-ignored-mouse.c',
Peter Hutterer's avatar
Peter Hutterer committed
719
720
721
		'test/litest-device-keyboard.c',
		'test/litest-device-keyboard-all-codes.c',
		'test/litest-device-keyboard-razer-blackwidow.c',
722
723
		'test/litest-device-keyboard-razer-blade-stealth.c',
		'test/litest-device-keyboard-razer-blade-stealth-videoswitch.c',
Peter Hutterer's avatar
Peter Hutterer committed
724
725
726
727
728
729
730
731
732
733
734
		'test/litest-device-lid-switch.c',
		'test/litest-device-lid-switch-surface3.c',
		'test/litest-device-logitech-trackball.c',
		'test/litest-device-nexus4-touch-screen.c',
		'test/litest-device-magic-trackpad.c',
		'test/litest-device-mouse.c',
		'test/litest-device-mouse-wheel-tilt.c',
		'test/litest-device-mouse-roccat.c',
		'test/litest-device-mouse-low-dpi.c',
		'test/litest-device-mouse-wheel-click-angle.c',
		'test/litest-device-mouse-wheel-click-count.c',
735
		'test/litest-device-ms-nano-transceiver-mouse.c',
Peter Hutterer's avatar
Peter Hutterer committed
736
737
738
		'test/litest-device-ms-surface-cover.c',
		'test/litest-device-protocol-a-touch-screen.c',
		'test/litest-device-qemu-usb-tablet.c',
739
		'test/litest-device-synaptics-x220.c',
Peter Hutterer's avatar
Peter Hutterer committed
740
741
742
743
744
745
		'test/litest-device-synaptics-hover.c',
		'test/litest-device-synaptics-i2c.c',
		'test/litest-device-synaptics-rmi4.c',
		'test/litest-device-synaptics-st.c',
		'test/litest-device-synaptics-t440.c',
		'test/litest-device-synaptics-x1-carbon-3rd.c',
746
		'test/litest-device-thinkpad-extrabuttons.c',
Peter Hutterer's avatar
Peter Hutterer committed
747
748
		'test/litest-device-trackpoint.c',
		'test/litest-device-touch-screen.c',
749
		'test/litest-device-touchscreen-invalid-range.c',
Peter Hutterer's avatar
Peter Hutterer committed
750
		'test/litest-device-touchscreen-fuzz.c',
751
		'test/litest-device-touchscreen-mt-tool.c',
752
		'test/litest-device-uclogic-tablet.c',
753
754
755
		'test/litest-device-wacom-bamboo-2fg-finger.c',
		'test/litest-device-wacom-bamboo-2fg-pad.c',
		'test/litest-device-wacom-bamboo-2fg-pen.c',
Peter Hutterer's avatar
Peter Hutterer committed
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
		'test/litest-device-wacom-bamboo-16fg-pen.c',
		'test/litest-device-wacom-cintiq-12wx-pen.c',
		'test/litest-device-wacom-cintiq-13hdt-finger.c',
		'test/litest-device-wacom-cintiq-13hdt-pad.c',
		'test/litest-device-wacom-cintiq-13hdt-pen.c',
		'test/litest-device-wacom-cintiq-24hd-pen.c',
		'test/litest-device-wacom-cintiq-24hdt-pad.c',
		'test/litest-device-wacom-ekr.c',
		'test/litest-device-wacom-hid4800-pen.c',
		'test/litest-device-wacom-intuos3-pad.c',
		'test/litest-device-wacom-intuos5-finger.c',
		'test/litest-device-wacom-intuos5-pad.c',
		'test/litest-device-wacom-intuos5-pen.c',
		'test/litest-device-wacom-isdv4-e6-pen.c',
		'test/litest-device-wacom-isdv4-e6-finger.c',
771
		'test/litest-device-wacom-mobilestudio-pro-pad.c',
Peter Hutterer's avatar
Peter Hutterer committed
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
		'test/litest-device-waltop-tablet.c',
		'test/litest-device-wheel-only.c',
		'test/litest-device-xen-virtual-pointer.c',
		'test/litest-device-vmware-virtual-usb-mouse.c',
		'test/litest-device-yubikey.c',
		'test/litest.c'
	]

	dep_dl = cc.find_library('dl')
	deps_litest = [
		dep_libinput,
		dep_check,
		dep_libunwind,
		dep_udev,
		dep_libevdev,
		dep_dl,
788
789
		dep_lm,
		dep_libsystemd,
790
		dep_libquirks,
Peter Hutterer's avatar
Peter Hutterer committed
791
792
	]

793
794
795
796
797
798
799
800
801
	configure_file(input : 'udev/80-libinput-test-device.rules',
		       output : '80-libinput-test-device.rules',
		       install : false,
		       configuration : udev_rules_config)

	config_h.set_quoted('LIBINPUT_TEST_DEVICE_RULES_FILE',
			    join_paths(meson.build_root(), '80-libinput-test-device.rules'))
	config_h.set_quoted('LIBINPUT_DEVICE_GROUPS_RULES_FILE',
			    join_paths(meson.build_root(), '80-libinput-device-groups.rules'))
Peter Hutterer's avatar
Peter Hutterer committed
802
803
	lib_litest = static_library('litest',
				    lib_litest_sources,
804
				    include_directories : [includes_src, includes_include],
805
				    dependencies : deps_litest)
Peter Hutterer's avatar
Peter Hutterer committed
806
807
808
809
810
811
812
813
	dep_litest = declare_dependency(link_with : lib_litest,
					dependencies : deps_litest)

	def_no_main = '-DLITEST_NO_MAIN'
	def_disable_backtrace = '-DLITEST_DISABLE_BACKTRACE_LOGGING'
	defs_litest_selftest = [
		def_no_main,
		def_disable_backtrace
814
	]
815
	test_litest_selftest_sources = lib_litest_sources + [
Peter Hutterer's avatar
Peter Hutterer committed
816
817
818
819
820
821
822
		'test/litest-selftest.c',
		'test/litest.c',
		'test/litest-int.h',
		'test/litest.h'
	]
	test_litest_selftest = executable('test-litest-selftest',
					  test_litest_selftest_sources,
823
					  include_directories : [includes_src, includes_include],
824
					  dependencies : deps_litest,
Peter Hutterer's avatar
Peter Hutterer committed
825
826
827
828
					  c_args : defs_litest_selftest,
					  install : false)
	test('test-litest-selftest', test_litest_selftest)

829
	libinput_test_runner_sources = lib_litest_sources + [
Peter Hutterer's avatar
Peter Hutterer committed
830
831
		'src/libinput-util.h',
		'src/libinput-util.c',
Peter Hutterer's avatar
Peter Hutterer committed
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
		'test/test-udev.c',
		'test/test-path.c',
		'test/test-pointer.c',
		'test/test-touch.c',
		'test/test-log.c',
		'test/test-tablet.c',
		'test/test-pad.c',
		'test/test-touchpad.c',
		'test/test-touchpad-tap.c',
		'test/test-touchpad-buttons.c',
		'test/test-trackpoint.c',
		'test/test-trackball.c',
		'test/test-misc.c',
		'test/test-keyboard.c',
		'test/test-device.c',
		'test/test-gestures.c',
848
849
		'test/test-switch.c',
		'test/test-quirks.c',
Peter Hutterer's avatar
Peter Hutterer committed
850
851
852
853
	]
	def_LT_VERSION = '-DLIBINPUT_LT_VERSION="@0@:@1@:@2@"'.format(libinput_lt_c, libinput_lt_r, libinput_lt_a)
	libinput_test_runner = executable('libinput-test-suite-runner',
					  libinput_test_runner_sources,
854
					  include_directories : [includes_src, includes_include],
855
					  dependencies : deps_litest,
Peter Hutterer's avatar
Peter Hutterer committed
856
857
858
859
					  c_args : [ def_LT_VERSION ],
					  install : false)
	test('libinput-test-suite-runner',
	     libinput_test_runner,
860
	     timeout : 1200)
Peter Hutterer's avatar
Peter Hutterer committed
861

862
863
864
865
866
867
868
869
	libinput_test_deviceless = executable('libinput-test-deviceless',
					      libinput_test_runner_sources,
					      include_directories : [includes_src, includes_include],
					      dependencies : deps_litest,
					      c_args : [ def_LT_VERSION, '-DDISABLE_DEVICE_TESTS=1' ],
					      install : false)
	test('libinput-test-deviceless', libinput_test_deviceless)

870
871
872
	valgrind_env = environment()
	valgrind_env.set('CK_FORK', 'no')
	valgrind_env.set('USING_VALGRIND', '1')
873
	valgrind_suppressions_file = join_paths(dir_src_test, 'valgrind.suppressions')
874
875
876
	add_test_setup('valgrind',
			exe_wrapper : [ valgrind,
					'--leak-check=full',
877
					'--gen-suppressions=all',
878
879
880
881
					'--error-exitcode=3',
					'--suppressions=' + valgrind_suppressions_file ],
			env :  valgrind_env,
			timeout_multiplier : 100)
Peter Hutterer's avatar
Peter Hutterer committed
882
883
endif
############ output files ############
884
configure_file(output : 'config.h', install : false, configuration : config_h)