meson.build: add the valgrind test setup, exclude python tests
[platform/upstream/libxkbcommon.git] / meson.build
1 project(
2     'libxkbcommon',
3     'c',
4     version: '0.10.0',
5     default_options: [
6         'c_std=c99',
7         'warning_level=2',
8         'b_lundef=true',
9     ],
10     meson_version : '>= 0.49.0',
11 )
12 pkgconfig = import('pkgconfig')
13 cc = meson.get_compiler('c')
14
15
16 # Compiler flags.
17 foreach cflag: [
18     '-fvisibility=hidden',
19     '-fno-strict-aliasing',
20     '-fsanitize-undefined-trap-on-error',
21     '-Wextra',
22     '-Wno-unused-parameter',
23     '-Wno-missing-field-initializers',
24     '-Wpointer-arith',
25     '-Wmissing-declarations',
26     '-Wformat=2',
27     '-Wstrict-prototypes',
28     '-Wmissing-prototypes',
29     '-Wnested-externs',
30     '-Wbad-function-cast',
31     '-Wshadow',
32     '-Wlogical-op',
33     '-Wdate-time',
34     '-Wwrite-strings',
35     '-Wno-documentation-deprecated-sync',
36 ]
37     if cc.has_argument(cflag)
38         add_project_arguments(cflag, language: 'c')
39     endif
40 endforeach
41
42
43 # The XKB config root.
44 XKBCONFIGROOT = get_option('xkb-config-root')
45 if XKBCONFIGROOT == ''
46     xkeyboard_config_dep = dependency('xkeyboard-config', required: false)
47     if xkeyboard_config_dep.found()
48         XKBCONFIGROOT = xkeyboard_config_dep.get_pkgconfig_variable('xkb_base')
49     else
50         XKBCONFIGROOT = join_paths(get_option('prefix'), get_option('datadir'), 'X11', 'xkb')
51   endif
52 endif
53
54
55 # The X locale directory for compose.
56 XLOCALEDIR = get_option('x-locale-root')
57 if XLOCALEDIR == ''
58     XLOCALEDIR = join_paths(get_option('prefix'), get_option('datadir'), 'X11', 'locale')
59 endif
60
61
62 # config.h.
63 configh_data = configuration_data()
64 # Like AC_USE_SYSTEM_EXTENSIONS, what #define to use to get extensions
65 # beyond the base POSIX function set.
66 if host_machine.system() == 'sunos'
67   system_extensions = '__EXTENSIONS__'
68 else
69   system_extensions = '_GNU_SOURCE'
70 endif
71 configh_data.set(system_extensions, 1)
72 system_ext_define = '#define ' + system_extensions
73 configh_data.set_quoted('DFLT_XKB_CONFIG_ROOT', XKBCONFIGROOT)
74 configh_data.set_quoted('XLOCALEDIR', XLOCALEDIR)
75 configh_data.set_quoted('DEFAULT_XKB_RULES', get_option('default-rules'))
76 configh_data.set_quoted('DEFAULT_XKB_MODEL', get_option('default-model'))
77 configh_data.set_quoted('DEFAULT_XKB_LAYOUT', get_option('default-layout'))
78 if get_option('default-variant') != ''
79     configh_data.set_quoted('DEFAULT_XKB_VARIANT', get_option('default-variant'))
80 else
81     configh_data.set('DEFAULT_XKB_VARIANT', 'NULL')
82 endif
83 if get_option('default-options') != ''
84     configh_data.set_quoted('DEFAULT_XKB_OPTIONS', get_option('default-options'))
85 else
86     configh_data.set('DEFAULT_XKB_OPTIONS', 'NULL')
87 endif
88 if cc.links('int main(){if(__builtin_expect(1<0,0)){}}', name: '__builtin_expect')
89     configh_data.set('HAVE___BUILTIN_EXPECT', 1)
90 endif
91 if cc.has_header_symbol('unistd.h', 'eaccess', prefix: system_ext_define)
92     configh_data.set('HAVE_EACCESS', 1)
93 endif
94 if cc.has_header_symbol('unistd.h', 'euidaccess', prefix: system_ext_define)
95     configh_data.set('HAVE_EUIDACCESS', 1)
96 endif
97 if cc.has_header_symbol('sys/mman.h', 'mmap')
98     configh_data.set('HAVE_MMAP', 1)
99 endif
100 if cc.has_header_symbol('stdlib.h', 'mkostemp', prefix: system_ext_define)
101     configh_data.set('HAVE_MKOSTEMP', 1)
102 endif
103 if cc.has_header_symbol('fcntl.h', 'posix_fallocate', prefix: system_ext_define)
104     configh_data.set('HAVE_POSIX_FALLOCATE', 1)
105 endif
106 if cc.has_header_symbol('string.h', 'strndup', prefix: system_ext_define)
107     configh_data.set('HAVE_STRNDUP', 1)
108 endif
109 if cc.has_header_symbol('stdio.h', 'asprintf', prefix: system_ext_define)
110     configh_data.set('HAVE_ASPRINTF', 1)
111 elif cc.has_header_symbol('stdio.h', 'vasprintf', prefix: system_ext_define)
112     configh_data.set('HAVE_VASPRINTF', 1)
113 endif
114 if cc.has_header_symbol('stdlib.h', 'secure_getenv', prefix: system_ext_define)
115     configh_data.set('HAVE_SECURE_GETENV', 1)
116 elif cc.has_header_symbol('stdlib.h', '__secure_getenv', prefix: system_ext_define)
117     configh_data.set('HAVE___SECURE_GETENV', 1)
118 else
119     message('C library does not support secure_getenv, using getenv instead')
120 endif
121 # Silence some security & deprecation warnings on MSVC
122 # for some unix/C functions we use.
123 # https://docs.microsoft.com/en-us/cpp/error-messages/compiler-warnings/compiler-warning-level-3-c4996?view=vs-2019
124 configh_data.set('_CRT_SECURE_NO_WARNINGS', 1)
125 configh_data.set('_CRT_NONSTDC_NO_WARNINGS', 1)
126 configh_data.set('_CRT_NONSTDC_NO_DEPRECATE', 1)
127 # Reduce unnecessary includes on MSVC.
128 configh_data.set('WIN32_LEAN_AND_MEAN', 1)
129 configure_file(output: 'config.h', configuration: configh_data)
130
131
132 # Supports -Wl,--version-script?
133 have_version_script = cc.links(
134     'int main(){}',
135     args: '-Wl,--version-script=' + join_paths(meson.source_root(), 'xkbcommon.map'),
136     name: '-Wl,--version-script',
137 )
138
139
140 # libxkbcommon.
141 # Note: we use some yacc extensions, which work with either GNU bison
142 # (preferred) or byacc (with backtracking enabled).
143 bison = find_program('bison', 'win_bison', required: false)
144 if bison.found()
145     yacc_gen = generator(
146         bison,
147         output: ['@BASENAME@.c', '@BASENAME@.h'],
148         arguments: ['@INPUT@', '--defines=@OUTPUT1@', '--output=@OUTPUT0@', '-p _xkbcommon_'],
149     )
150 else
151     byacc = find_program('byacc', required: false)
152     if byacc.found()
153         yacc_gen = generator(
154             byacc,
155             output: ['@BASENAME@.c', '@BASENAME@.h'],
156             arguments: ['@INPUT@', '-H', '@OUTPUT1@', '-o', '@OUTPUT0@', '-p _xkbcommon_'],
157         )
158     else
159         error('Could not find a compatible YACC program (bison or byacc)')
160     endif
161 endif
162 libxkbcommon_sources = [
163     'src/compose/parser.c',
164     'src/compose/parser.h',
165     'src/compose/paths.c',
166     'src/compose/paths.h',
167     'src/compose/state.c',
168     'src/compose/table.c',
169     'src/compose/table.h',
170     'src/xkbcomp/action.c',
171     'src/xkbcomp/action.h',
172     'src/xkbcomp/ast.h',
173     'src/xkbcomp/ast-build.c',
174     'src/xkbcomp/ast-build.h',
175     'src/xkbcomp/compat.c',
176     'src/xkbcomp/expr.c',
177     'src/xkbcomp/expr.h',
178     'src/xkbcomp/include.c',
179     'src/xkbcomp/include.h',
180     'src/xkbcomp/keycodes.c',
181     'src/xkbcomp/keymap.c',
182     'src/xkbcomp/keymap-dump.c',
183     'src/xkbcomp/keywords.c',
184     yacc_gen.process('src/xkbcomp/parser.y'),
185     'src/xkbcomp/parser-priv.h',
186     'src/xkbcomp/rules.c',
187     'src/xkbcomp/rules.h',
188     'src/xkbcomp/scanner.c',
189     'src/xkbcomp/symbols.c',
190     'src/xkbcomp/types.c',
191     'src/xkbcomp/vmod.c',
192     'src/xkbcomp/vmod.h',
193     'src/xkbcomp/xkbcomp.c',
194     'src/xkbcomp/xkbcomp-priv.h',
195     'src/atom.c',
196     'src/atom.h',
197     'src/context.c',
198     'src/context.h',
199     'src/context-priv.c',
200     'src/darray.h',
201     'src/keysym.c',
202     'src/keysym.h',
203     'src/keysym-utf.c',
204     'src/ks_tables.h',
205     'src/keymap.c',
206     'src/keymap.h',
207     'src/keymap-priv.c',
208     'src/scanner-utils.h',
209     'src/state.c',
210     'src/text.c',
211     'src/text.h',
212     'src/utf8.c',
213     'src/utf8.h',
214     'src/utils.c',
215     'src/utils.h',
216 ]
217 libxkbcommon_link_args = []
218 if have_version_script
219     libxkbcommon_link_args += '-Wl,--version-script=' + join_paths(meson.source_root(), 'xkbcommon.map')
220 endif
221 libxkbcommon = library(
222     'xkbcommon',
223     'xkbcommon/xkbcommon.h',
224     libxkbcommon_sources,
225     link_args: libxkbcommon_link_args,
226     link_depends: 'xkbcommon.map',
227     version: '0.0.0',
228     install: true,
229     include_directories: include_directories('src'),
230 )
231 install_headers(
232     'xkbcommon/xkbcommon.h',
233     'xkbcommon/xkbcommon-compat.h',
234     'xkbcommon/xkbcommon-compose.h',
235     'xkbcommon/xkbcommon-keysyms.h',
236     'xkbcommon/xkbcommon-names.h',
237     subdir: 'xkbcommon',
238 )
239 pkgconfig.generate(
240     libxkbcommon,
241     name: 'xkbcommon',
242     filebase: 'xkbcommon',
243     version: meson.project_version(),
244     description: 'XKB API common to servers and clients',
245 )
246
247
248 # libxkbcommon-x11.
249 if get_option('enable-x11')
250     xcb_dep = dependency('xcb', version: '>=1.10', required: false)
251     xcb_xkb_dep = dependency('xcb-xkb', version: '>=1.10', required: false)
252     if not xcb_dep.found() or not xcb_xkb_dep.found()
253         error('''X11 support requires xcb-xkb >= 1.10 which was not found.
254 You can disable X11 support with -Denable-x11=false.''')
255     endif
256
257     libxkbcommon_x11_sources = [
258         'src/x11/keymap.c',
259         'src/x11/state.c',
260         'src/x11/util.c',
261         'src/x11/x11-priv.h',
262         'src/context.h',
263         'src/context-priv.c',
264         'src/keymap.h',
265         'src/keymap-priv.c',
266         'src/atom.h',
267         'src/atom.c',
268     ]
269     libxkbcommon_x11_link_args = []
270     if have_version_script
271         libxkbcommon_x11_link_args += '-Wl,--version-script=' + join_paths(meson.source_root(), 'xkbcommon-x11.map')
272     endif
273     libxkbcommon_x11 = library(
274         'xkbcommon-x11',
275         'xkbcommon/xkbcommon-x11.h',
276         libxkbcommon_x11_sources,
277         link_args: libxkbcommon_x11_link_args,
278         link_depends: 'xkbcommon-x11.map',
279         version: '0.0.0',
280         install: true,
281         include_directories: include_directories('src'),
282         link_with: libxkbcommon,
283         dependencies: [
284             xcb_dep,
285             xcb_xkb_dep,
286         ],
287     )
288     install_headers(
289         'xkbcommon/xkbcommon-x11.h',
290         subdir: 'xkbcommon',
291     )
292     pkgconfig.generate(
293         libxkbcommon_x11,
294         name: 'xkbcommon-x11',
295         filebase: 'xkbcommon-x11',
296         version: meson.project_version(),
297         description: 'XKB API common to servers and clients - X11 support',
298         requires: ['xkbcommon'],
299         requires_private: ['xcb>=1.10', 'xcb-xkb>=1.10'],
300     )
301 endif
302
303 # libxkbregistry
304 if get_option('enable-xkbregistry')
305     dep_libxml = dependency('libxml-2.0')
306     deps_libxkbregistry = [dep_libxml]
307     libxkbregistry_sources = [
308         'src/registry.c',
309         'src/utils.h',
310         'src/utils.c',
311         'src/util-list.h',
312         'src/util-list.c',
313     ]
314     libxkbregistry_link_args = []
315     if have_version_script
316         libxkbregistry_link_args += '-Wl,--version-script=' + join_paths(meson.source_root(), 'xkbregistry.map')
317     endif
318     libxkbregistry = library(
319         'xkbregistry',
320         'xkbcommon/xkbregistry.h',
321         libxkbregistry_sources,
322         link_args: libxkbregistry_link_args,
323         link_depends: 'xkbregistry.map',
324         dependencies: deps_libxkbregistry,
325         version: '0.0.0',
326         install: true,
327         include_directories: include_directories('src'),
328     )
329     install_headers(
330         'xkbcommon/xkbregistry.h',
331         subdir: 'xkbcommon',
332     )
333     pkgconfig.generate(
334         libxkbregistry,
335         name: 'xkbregistry',
336         filebase: 'xkbregistry',
337         version: meson.project_version(),
338         description: 'XKB API to query available rules, models, layouts, variants and options',
339     )
340
341     dep_libxkbregistry = declare_dependency(
342                                 include_directories: include_directories('xkbcommon'),
343                                 link_with: libxkbregistry
344                                 )
345     executable('xkbcommon-registry-list',
346                'tools/registry-list.c',
347                dependencies: dep_libxkbregistry,
348                install: false)
349 endif
350
351 # Tests
352 test_env = environment()
353 test_env.set('XKB_LOG_LEVEL', 'debug')
354 test_env.set('XKB_LOG_VERBOSITY', '10')
355 test_env.set('top_srcdir', meson.source_root())
356 test_env.set('top_builddir', meson.build_root())
357
358 test_configh_data = configuration_data()
359 test_configh_data.set_quoted('TEST_XKB_CONFIG_ROOT', join_paths(meson.source_root(), 'test', 'data'))
360 configure_file(output: 'test-config.h', configuration: test_configh_data)
361
362 # Some tests need to use unexported symbols, so we link them against
363 # an internal copy of libxkbcommon with all symbols exposed.
364 libxkbcommon_test_internal = static_library(
365     'xkbcommon-test-internal',
366     'test/common.c',
367     'test/test.h',
368     'test/evdev-scancodes.h',
369     libxkbcommon_sources,
370     include_directories: include_directories('src'),
371 )
372 test_dep = declare_dependency(
373     include_directories: include_directories('src'),
374     link_with: libxkbcommon_test_internal,
375 )
376 if get_option('enable-x11')
377     libxkbcommon_x11_internal = static_library(
378         'xkbcommon-x11-internal',
379         libxkbcommon_x11_sources,
380         include_directories: include_directories('src'),
381         link_with: libxkbcommon_test_internal,
382         dependencies: [
383             xcb_dep,
384             xcb_xkb_dep,
385         ],
386     )
387     x11_test_dep = declare_dependency(
388         link_with: libxkbcommon_x11_internal,
389         dependencies: [
390             test_dep,
391             xcb_dep,
392             xcb_xkb_dep,
393         ],
394     )
395 endif
396 test(
397     'keysym',
398     executable('test-keysym', 'test/keysym.c', dependencies: test_dep),
399     env: test_env,
400 )
401 test(
402     'keymap',
403     executable('test-keymap', 'test/keymap.c', dependencies: test_dep),
404     env: test_env,
405 )
406 test(
407     'filecomp',
408     executable('test-filecomp', 'test/filecomp.c', dependencies: test_dep),
409     env: test_env,
410 )
411 # TODO: This test currently uses some functions that don't exist on Windows.
412 if cc.get_id() != 'msvc'
413   test(
414       'context',
415       executable('test-context', 'test/context.c', dependencies: test_dep),
416       env: test_env,
417   )
418 endif
419 test(
420     'rules-file',
421     executable('test-rules-file', 'test/rules-file.c', dependencies: test_dep),
422     env: test_env,
423 )
424 test(
425     'rules-file-includes',
426     executable('test-rules-file-includes', 'test/rules-file-includes.c', dependencies: test_dep),
427     env: test_env,
428 )
429 test(
430     'stringcomp',
431     executable('test-stringcomp', 'test/stringcomp.c', dependencies: test_dep),
432     env: test_env,
433 )
434 test(
435     'buffercomp',
436     executable('test-buffercomp', 'test/buffercomp.c', dependencies: test_dep),
437     env: test_env,
438 )
439 test(
440     'log',
441     executable('test-log', 'test/log.c', dependencies: test_dep),
442     env: test_env,
443 )
444 test(
445     'atom',
446     executable('test-atom', 'test/atom.c', dependencies: test_dep),
447     env: test_env,
448 )
449 test(
450     'utf8',
451     executable('test-utf8', 'test/utf8.c', dependencies: test_dep),
452     env: test_env,
453 )
454 test(
455     'state',
456     executable('test-state', 'test/state.c', dependencies: test_dep),
457     env: test_env,
458 )
459 test(
460     'keyseq',
461     executable('test-keyseq', 'test/keyseq.c', dependencies: test_dep),
462     env: test_env,
463 )
464 test(
465     'rulescomp',
466     executable('test-rulescomp', 'test/rulescomp.c', dependencies: test_dep),
467     env: test_env,
468 )
469 test(
470     'compose',
471     executable('test-compose', 'test/compose.c', dependencies: test_dep),
472     env: test_env,
473 )
474 test(
475     'utils',
476     executable('test-utils', 'test/utils.c', dependencies: test_dep),
477     env: test_env,
478 )
479 test(
480     'symbols-leak-test',
481     find_program('test/symbols-leak-test.py'),
482     env: test_env,
483     suite: ['python-tests'],
484 )
485 if get_option('enable-x11')
486     test(
487         'x11',
488         executable('test-x11', 'test/x11.c', dependencies: x11_test_dep),
489         env: test_env,
490     )
491     # test/x11comp is meant to be run, but it is (temporarily?) disabled.
492     # See: https://github.com/xkbcommon/libxkbcommon/issues/30
493     executable('test-x11comp', 'test/x11comp.c', dependencies: x11_test_dep)
494 endif
495 if get_option('enable-xkbregistry')
496     test(
497         'registry',
498         executable('test-registry', 'test/registry.c',
499                    include_directories: include_directories('src'),
500                    dependencies: dep_libxkbregistry),
501         env: test_env,
502     )
503 endif
504
505 valgrind = find_program('valgrind', required: false)
506 if valgrind.found()
507     add_test_setup('valgrind',
508         exe_wrapper: [valgrind,
509                        '--leak-check=full',
510                        '--track-origins=yes',
511                        '--gen-suppressions=all',
512                        '--error-exitcode=99'],
513         timeout_multiplier : 10)
514 else
515     message('valgrind not found, disabling valgrind test setup')
516 endif
517
518
519 # Fuzzing target programs.
520 executable('fuzz-keymap', 'fuzz/keymap/target.c', dependencies: test_dep)
521 executable('fuzz-compose', 'fuzz/compose/target.c', dependencies: test_dep)
522
523
524 # Demo programs.
525 libxkbcommon_tools_internal = static_library(
526     'tools-internal',
527     'tools/tools-common.h',
528     'tools/tools-common.c',
529     libxkbcommon_sources,
530     include_directories: include_directories('src'),
531 )
532 tools_dep = declare_dependency(
533     include_directories: [include_directories('src'), include_directories('tools')],
534     link_with: libxkbcommon_tools_internal,
535 )
536
537 if cc.has_header_symbol('getopt.h', 'getopt_long', prefix: '#define _GNU_SOURCE')
538     executable('xkbcommon-rmlvo-to-keymap', 'tools/rmlvo-to-keymap.c', dependencies: tools_dep)
539     executable('xkbcommon-how-to-type', 'tools/how-to-type.c', dependencies: tools_dep)
540 endif
541 if cc.has_header('linux/input.h')
542     executable('xkbcommon-interactive-evdev', 'tools/interactive-evdev.c', dependencies: tools_dep)
543 endif
544 if get_option('enable-x11')
545     x11_tools_dep = declare_dependency(
546         link_with: libxkbcommon_x11_internal,
547         dependencies: [
548             tools_dep,
549             xcb_dep,
550             xcb_xkb_dep,
551         ],
552     )
553     executable('xkbcommon-interactive-x11', 'tools/interactive-x11.c', dependencies: x11_tools_dep)
554 endif
555 if get_option('enable-wayland')
556     wayland_client_dep = dependency('wayland-client', version: '>=1.2.0', required: false)
557     wayland_protocols_dep = dependency('wayland-protocols', version: '>=1.12', required: false)
558     wayland_scanner_dep = dependency('wayland-scanner', required: false, native: true)
559     if not wayland_client_dep.found() or not wayland_protocols_dep.found() or not wayland_scanner_dep.found()
560         error('''The Wayland demo programs require wayland-client >= 1.2.0, wayland-protocols >= 1.7 which were not found.
561 You can disable the Wayland demo programs with -Denable-wayland=false.''')
562     endif
563
564     wayland_scanner = find_program(wayland_scanner_dep.get_pkgconfig_variable('wayland_scanner'))
565     wayland_scanner_code_gen = generator(
566         wayland_scanner,
567         output: '@BASENAME@-protocol.c',
568         arguments: ['code', '@INPUT@', '@OUTPUT@'],
569     )
570     wayland_scanner_client_header_gen = generator(
571         wayland_scanner,
572         output: '@BASENAME@-client-protocol.h',
573         arguments: ['client-header', '@INPUT@', '@OUTPUT@'],
574     )
575     wayland_protocols_datadir = wayland_protocols_dep.get_pkgconfig_variable('pkgdatadir')
576     xdg_shell_xml = join_paths(wayland_protocols_datadir, 'stable/xdg-shell/xdg-shell.xml')
577     xdg_shell_sources = [
578         wayland_scanner_code_gen.process(xdg_shell_xml),
579         wayland_scanner_client_header_gen.process(xdg_shell_xml),
580     ]
581     executable('xkbcommon-interactive-wayland',
582                'tools/interactive-wayland.c',
583                xdg_shell_sources,
584                dependencies: [tools_dep, wayland_client_dep])
585 endif
586
587 # xkeyboard-config "verifier"
588 xkct_config = configuration_data()
589 xkct_config.set('MESON_BUILD_ROOT', meson.build_root())
590 xkct_config.set('XKB_CONFIG_ROOT', XKBCONFIGROOT)
591 configure_file(input: 'test/xkeyboard-config-test.py.in',
592                output: 'xkeyboard-config-test',
593                configuration: xkct_config,
594                install: false)
595
596
597 # Benchmarks.
598 libxkbcommon_bench_internal = static_library(
599     'xkbcommon-bench-internal',
600     'bench/bench.c',
601     'bench/bench.h',
602     link_with: libxkbcommon_test_internal,
603 )
604 bench_dep = declare_dependency(
605     include_directories: include_directories('src'),
606     link_with: libxkbcommon_bench_internal,
607 )
608 bench_env = environment()
609 bench_env.set('top_srcdir', meson.source_root())
610 benchmark(
611     'key-proc',
612     executable('bench-key-proc', 'bench/key-proc.c', dependencies: bench_dep),
613     env: bench_env,
614 )
615 benchmark(
616     'rules',
617     executable('bench-rules', 'bench/rules.c', dependencies: bench_dep),
618     env: bench_env,
619 )
620 benchmark(
621     'rulescomp',
622     executable('bench-rulescomp', 'bench/rulescomp.c', dependencies: bench_dep),
623     env: bench_env,
624 )
625 benchmark(
626     'compose',
627     executable('bench-compose', 'bench/compose.c', dependencies: bench_dep),
628     env: bench_env,
629 )
630
631
632 # Documentation.
633 if get_option('enable-docs')
634     doxygen = find_program('doxygen', required: false)
635     if not doxygen.found()
636         error('''Documentation requires doxygen which was not found.
637 You can disable the documentation with -Denable-docs=false.''')
638     endif
639     doxygen_wrapper = find_program('scripts/doxygen-wrapper')
640
641     doxygen_input = [
642         'README.md',
643         'doc/doxygen-extra.css',
644         'doc/quick-guide.md',
645         'doc/compat.md',
646         'doc/user-configuration.md',
647         'doc/rules-format.md',
648         'xkbcommon/xkbcommon.h',
649         'xkbcommon/xkbcommon-names.h',
650         'xkbcommon/xkbcommon-x11.h',
651         'xkbcommon/xkbcommon-compose.h',
652         'xkbcommon/xkbregistry.h',
653     ]
654     doxygen_data = configuration_data()
655     doxygen_data.set('PACKAGE_NAME', meson.project_name())
656     doxygen_data.set('PACKAGE_VERSION', meson.project_version())
657     doxygen_data.set('INPUT', ' '.join(doxygen_input))
658     doxygen_data.set('OUTPUT_DIRECTORY', meson.build_root())
659     doxyfile = configure_file(
660         input: 'doc/Doxyfile.in',
661         output: 'Doxyfile',
662         configuration: doxygen_data,
663     )
664     # TODO: Meson should provide this.
665     docdir = join_paths(get_option('datadir'), 'doc', meson.project_name())
666     custom_target(
667         'doc',
668         input: [doxyfile] + doxygen_input,
669         output: 'html',
670         command: [doxygen_wrapper, doxygen.path(), join_paths(meson.build_root(), 'Doxyfile'), meson.source_root()],
671         install: true,
672         install_dir: docdir,
673         build_by_default: true,
674     )
675 endif