meson.build: only build the tools where getopt.h is available
[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 have_getopt = cc.has_header_symbol('getopt.h', 'getopt')
122 have_getopt_long = cc.has_header_symbol('getopt.h', 'getopt_long',
123                                         prefix: '#define _GNU_SOURCE')
124
125 # Silence some security & deprecation warnings on MSVC
126 # for some unix/C functions we use.
127 # https://docs.microsoft.com/en-us/cpp/error-messages/compiler-warnings/compiler-warning-level-3-c4996?view=vs-2019
128 configh_data.set('_CRT_SECURE_NO_WARNINGS', 1)
129 configh_data.set('_CRT_NONSTDC_NO_WARNINGS', 1)
130 configh_data.set('_CRT_NONSTDC_NO_DEPRECATE', 1)
131 # Reduce unnecessary includes on MSVC.
132 configh_data.set('WIN32_LEAN_AND_MEAN', 1)
133
134 # Supports -Wl,--version-script?
135 have_version_script = cc.links(
136     'int main(){}',
137     args: '-Wl,--version-script=' + join_paths(meson.source_root(), 'xkbcommon.map'),
138     name: '-Wl,--version-script',
139 )
140
141
142 # libxkbcommon.
143 # Note: we use some yacc extensions, which work with either GNU bison
144 # (preferred) or byacc (with backtracking enabled).
145 bison = find_program('bison', 'win_bison', required: false)
146 if bison.found()
147     yacc_gen = generator(
148         bison,
149         output: ['@BASENAME@.c', '@BASENAME@.h'],
150         arguments: ['@INPUT@', '--defines=@OUTPUT1@', '--output=@OUTPUT0@', '-p _xkbcommon_'],
151     )
152 else
153     byacc = find_program('byacc', required: false)
154     if byacc.found()
155         yacc_gen = generator(
156             byacc,
157             output: ['@BASENAME@.c', '@BASENAME@.h'],
158             arguments: ['@INPUT@', '-H', '@OUTPUT1@', '-o', '@OUTPUT0@', '-p _xkbcommon_'],
159         )
160     else
161         error('Could not find a compatible YACC program (bison or byacc)')
162     endif
163 endif
164 libxkbcommon_sources = [
165     'src/compose/parser.c',
166     'src/compose/parser.h',
167     'src/compose/paths.c',
168     'src/compose/paths.h',
169     'src/compose/state.c',
170     'src/compose/table.c',
171     'src/compose/table.h',
172     'src/xkbcomp/action.c',
173     'src/xkbcomp/action.h',
174     'src/xkbcomp/ast.h',
175     'src/xkbcomp/ast-build.c',
176     'src/xkbcomp/ast-build.h',
177     'src/xkbcomp/compat.c',
178     'src/xkbcomp/expr.c',
179     'src/xkbcomp/expr.h',
180     'src/xkbcomp/include.c',
181     'src/xkbcomp/include.h',
182     'src/xkbcomp/keycodes.c',
183     'src/xkbcomp/keymap.c',
184     'src/xkbcomp/keymap-dump.c',
185     'src/xkbcomp/keywords.c',
186     yacc_gen.process('src/xkbcomp/parser.y'),
187     'src/xkbcomp/parser-priv.h',
188     'src/xkbcomp/rules.c',
189     'src/xkbcomp/rules.h',
190     'src/xkbcomp/scanner.c',
191     'src/xkbcomp/symbols.c',
192     'src/xkbcomp/types.c',
193     'src/xkbcomp/vmod.c',
194     'src/xkbcomp/vmod.h',
195     'src/xkbcomp/xkbcomp.c',
196     'src/xkbcomp/xkbcomp-priv.h',
197     'src/atom.c',
198     'src/atom.h',
199     'src/context.c',
200     'src/context.h',
201     'src/context-priv.c',
202     'src/darray.h',
203     'src/keysym.c',
204     'src/keysym.h',
205     'src/keysym-utf.c',
206     'src/ks_tables.h',
207     'src/keymap.c',
208     'src/keymap.h',
209     'src/keymap-priv.c',
210     'src/scanner-utils.h',
211     'src/state.c',
212     'src/text.c',
213     'src/text.h',
214     'src/utf8.c',
215     'src/utf8.h',
216     'src/utils.c',
217     'src/utils.h',
218 ]
219 libxkbcommon_link_args = []
220 if have_version_script
221     libxkbcommon_link_args += '-Wl,--version-script=' + join_paths(meson.source_root(), 'xkbcommon.map')
222 endif
223 libxkbcommon = library(
224     'xkbcommon',
225     'xkbcommon/xkbcommon.h',
226     libxkbcommon_sources,
227     link_args: libxkbcommon_link_args,
228     link_depends: 'xkbcommon.map',
229     version: '0.0.0',
230     install: true,
231     include_directories: include_directories('src'),
232 )
233 install_headers(
234     'xkbcommon/xkbcommon.h',
235     'xkbcommon/xkbcommon-compat.h',
236     'xkbcommon/xkbcommon-compose.h',
237     'xkbcommon/xkbcommon-keysyms.h',
238     'xkbcommon/xkbcommon-names.h',
239     subdir: 'xkbcommon',
240 )
241 pkgconfig.generate(
242     libxkbcommon,
243     name: 'xkbcommon',
244     filebase: 'xkbcommon',
245     version: meson.project_version(),
246     description: 'XKB API common to servers and clients',
247 )
248
249
250 # libxkbcommon-x11.
251 if get_option('enable-x11')
252     xcb_dep = dependency('xcb', version: '>=1.10', required: false)
253     xcb_xkb_dep = dependency('xcb-xkb', version: '>=1.10', required: false)
254     if not xcb_dep.found() or not xcb_xkb_dep.found()
255         error('''X11 support requires xcb-xkb >= 1.10 which was not found.
256 You can disable X11 support with -Denable-x11=false.''')
257     endif
258
259     libxkbcommon_x11_sources = [
260         'src/x11/keymap.c',
261         'src/x11/state.c',
262         'src/x11/util.c',
263         'src/x11/x11-priv.h',
264         'src/context.h',
265         'src/context-priv.c',
266         'src/keymap.h',
267         'src/keymap-priv.c',
268         'src/atom.h',
269         'src/atom.c',
270     ]
271     libxkbcommon_x11_link_args = []
272     if have_version_script
273         libxkbcommon_x11_link_args += '-Wl,--version-script=' + join_paths(meson.source_root(), 'xkbcommon-x11.map')
274     endif
275     libxkbcommon_x11 = library(
276         'xkbcommon-x11',
277         'xkbcommon/xkbcommon-x11.h',
278         libxkbcommon_x11_sources,
279         link_args: libxkbcommon_x11_link_args,
280         link_depends: 'xkbcommon-x11.map',
281         version: '0.0.0',
282         install: true,
283         include_directories: include_directories('src'),
284         link_with: libxkbcommon,
285         dependencies: [
286             xcb_dep,
287             xcb_xkb_dep,
288         ],
289     )
290     install_headers(
291         'xkbcommon/xkbcommon-x11.h',
292         subdir: 'xkbcommon',
293     )
294     pkgconfig.generate(
295         libxkbcommon_x11,
296         name: 'xkbcommon-x11',
297         filebase: 'xkbcommon-x11',
298         version: meson.project_version(),
299         description: 'XKB API common to servers and clients - X11 support',
300         requires: ['xkbcommon'],
301         requires_private: ['xcb>=1.10', 'xcb-xkb>=1.10'],
302     )
303 endif
304
305 # libxkbregistry
306 if get_option('enable-xkbregistry')
307     dep_libxml = dependency('libxml-2.0')
308     deps_libxkbregistry = [dep_libxml]
309     libxkbregistry_sources = [
310         'src/registry.c',
311         'src/utils.h',
312         'src/utils.c',
313         'src/util-list.h',
314         'src/util-list.c',
315     ]
316     libxkbregistry_link_args = []
317     if have_version_script
318         libxkbregistry_link_args += '-Wl,--version-script=' + join_paths(meson.source_root(), 'xkbregistry.map')
319     endif
320     libxkbregistry = library(
321         'xkbregistry',
322         'xkbcommon/xkbregistry.h',
323         libxkbregistry_sources,
324         link_args: libxkbregistry_link_args,
325         link_depends: 'xkbregistry.map',
326         dependencies: deps_libxkbregistry,
327         version: '0.0.0',
328         install: true,
329         include_directories: include_directories('src'),
330     )
331     install_headers(
332         'xkbcommon/xkbregistry.h',
333         subdir: 'xkbcommon',
334     )
335     pkgconfig.generate(
336         libxkbregistry,
337         name: 'xkbregistry',
338         filebase: 'xkbregistry',
339         version: meson.project_version(),
340         description: 'XKB API to query available rules, models, layouts, variants and options',
341     )
342
343     dep_libxkbregistry = declare_dependency(
344                                 include_directories: include_directories('xkbcommon'),
345                                 link_with: libxkbregistry
346                                 )
347     if have_getopt_long
348         executable('xkbcommon-registry-list',
349                    'tools/registry-list.c',
350                    dependencies: dep_libxkbregistry,
351                    install: false)
352     endif
353 endif
354
355 # Tests
356 test_env = environment()
357 test_env.set('XKB_LOG_LEVEL', 'debug')
358 test_env.set('XKB_LOG_VERBOSITY', '10')
359 test_env.set('top_srcdir', meson.source_root())
360 test_env.set('top_builddir', meson.build_root())
361
362 test_configh_data = configuration_data()
363 test_configh_data.set_quoted('TEST_XKB_CONFIG_ROOT', join_paths(meson.source_root(), 'test', 'data'))
364 configure_file(output: 'test-config.h', configuration: test_configh_data)
365
366 # Some tests need to use unexported symbols, so we link them against
367 # an internal copy of libxkbcommon with all symbols exposed.
368 libxkbcommon_test_internal = static_library(
369     'xkbcommon-test-internal',
370     'test/common.c',
371     'test/test.h',
372     'test/evdev-scancodes.h',
373     libxkbcommon_sources,
374     include_directories: include_directories('src'),
375 )
376 test_dep = declare_dependency(
377     include_directories: include_directories('src'),
378     link_with: libxkbcommon_test_internal,
379 )
380 if get_option('enable-x11')
381     libxkbcommon_x11_internal = static_library(
382         'xkbcommon-x11-internal',
383         libxkbcommon_x11_sources,
384         include_directories: include_directories('src'),
385         link_with: libxkbcommon_test_internal,
386         dependencies: [
387             xcb_dep,
388             xcb_xkb_dep,
389         ],
390     )
391     x11_test_dep = declare_dependency(
392         link_with: libxkbcommon_x11_internal,
393         dependencies: [
394             test_dep,
395             xcb_dep,
396             xcb_xkb_dep,
397         ],
398     )
399 endif
400 test(
401     'keysym',
402     executable('test-keysym', 'test/keysym.c', dependencies: test_dep),
403     env: test_env,
404 )
405 test(
406     'keymap',
407     executable('test-keymap', 'test/keymap.c', dependencies: test_dep),
408     env: test_env,
409 )
410 test(
411     'filecomp',
412     executable('test-filecomp', 'test/filecomp.c', dependencies: test_dep),
413     env: test_env,
414 )
415 # TODO: This test currently uses some functions that don't exist on Windows.
416 if cc.get_id() != 'msvc'
417   test(
418       'context',
419       executable('test-context', 'test/context.c', dependencies: test_dep),
420       env: test_env,
421   )
422 endif
423 test(
424     'rules-file',
425     executable('test-rules-file', 'test/rules-file.c', dependencies: test_dep),
426     env: test_env,
427 )
428 test(
429     'rules-file-includes',
430     executable('test-rules-file-includes', 'test/rules-file-includes.c', dependencies: test_dep),
431     env: test_env,
432 )
433 test(
434     'stringcomp',
435     executable('test-stringcomp', 'test/stringcomp.c', dependencies: test_dep),
436     env: test_env,
437 )
438 test(
439     'buffercomp',
440     executable('test-buffercomp', 'test/buffercomp.c', dependencies: test_dep),
441     env: test_env,
442 )
443 test(
444     'log',
445     executable('test-log', 'test/log.c', dependencies: test_dep),
446     env: test_env,
447 )
448 test(
449     'atom',
450     executable('test-atom', 'test/atom.c', dependencies: test_dep),
451     env: test_env,
452 )
453 test(
454     'utf8',
455     executable('test-utf8', 'test/utf8.c', dependencies: test_dep),
456     env: test_env,
457 )
458 test(
459     'state',
460     executable('test-state', 'test/state.c', dependencies: test_dep),
461     env: test_env,
462 )
463 test(
464     'keyseq',
465     executable('test-keyseq', 'test/keyseq.c', dependencies: test_dep),
466     env: test_env,
467 )
468 test(
469     'rulescomp',
470     executable('test-rulescomp', 'test/rulescomp.c', dependencies: test_dep),
471     env: test_env,
472 )
473 test(
474     'compose',
475     executable('test-compose', 'test/compose.c', dependencies: test_dep),
476     env: test_env,
477 )
478 test(
479     'utils',
480     executable('test-utils', 'test/utils.c', dependencies: test_dep),
481     env: test_env,
482 )
483 test(
484     'symbols-leak-test',
485     find_program('test/symbols-leak-test.py'),
486     env: test_env,
487     suite: ['python-tests'],
488 )
489 if get_option('enable-x11')
490     test(
491         'x11',
492         executable('test-x11', 'test/x11.c', dependencies: x11_test_dep),
493         env: test_env,
494     )
495     # test/x11comp is meant to be run, but it is (temporarily?) disabled.
496     # See: https://github.com/xkbcommon/libxkbcommon/issues/30
497     executable('test-x11comp', 'test/x11comp.c', dependencies: x11_test_dep)
498 endif
499 if get_option('enable-xkbregistry')
500     test(
501         'registry',
502         executable('test-registry', 'test/registry.c',
503                    include_directories: include_directories('src'),
504                    dependencies: dep_libxkbregistry),
505         env: test_env,
506     )
507 endif
508
509 valgrind = find_program('valgrind', required: false)
510 if valgrind.found()
511     add_test_setup('valgrind',
512         exe_wrapper: [valgrind,
513                        '--leak-check=full',
514                        '--track-origins=yes',
515                        '--gen-suppressions=all',
516                        '--error-exitcode=99'],
517         timeout_multiplier : 10)
518 else
519     message('valgrind not found, disabling valgrind test setup')
520 endif
521
522
523 # Fuzzing target programs.
524 executable('fuzz-keymap', 'fuzz/keymap/target.c', dependencies: test_dep)
525 executable('fuzz-compose', 'fuzz/compose/target.c', dependencies: test_dep)
526
527
528 # Demo programs.
529 build_tools = have_getopt
530 if build_tools
531     libxkbcommon_tools_internal = static_library(
532         'tools-internal',
533         'tools/tools-common.h',
534         'tools/tools-common.c',
535         libxkbcommon_sources,
536         include_directories: include_directories('src'),
537     )
538     tools_dep = declare_dependency(
539         include_directories: [include_directories('src'), include_directories('tools')],
540         link_with: libxkbcommon_tools_internal,
541     )
542
543     if have_getopt_long
544         executable('xkbcommon-rmlvo-to-keymap', 'tools/rmlvo-to-keymap.c', dependencies: tools_dep)
545         executable('xkbcommon-how-to-type', 'tools/how-to-type.c', dependencies: tools_dep)
546     endif
547     if cc.has_header('linux/input.h')
548         executable('xkbcommon-interactive-evdev', 'tools/interactive-evdev.c', dependencies: tools_dep)
549     endif
550     if get_option('enable-x11')
551         x11_tools_dep = declare_dependency(
552             link_with: libxkbcommon_x11_internal,
553             dependencies: [
554                 tools_dep,
555                 xcb_dep,
556                 xcb_xkb_dep,
557             ],
558         )
559         executable('xkbcommon-interactive-x11', 'tools/interactive-x11.c', dependencies: x11_tools_dep)
560     endif
561     if get_option('enable-wayland')
562         wayland_client_dep = dependency('wayland-client', version: '>=1.2.0', required: false)
563         wayland_protocols_dep = dependency('wayland-protocols', version: '>=1.12', required: false)
564         wayland_scanner_dep = dependency('wayland-scanner', required: false, native: true)
565         if not wayland_client_dep.found() or not wayland_protocols_dep.found() or not wayland_scanner_dep.found()
566             error('''The Wayland demo programs require wayland-client >= 1.2.0, wayland-protocols >= 1.7 which were not found.
567     You can disable the Wayland demo programs with -Denable-wayland=false.''')
568         endif
569
570         wayland_scanner = find_program(wayland_scanner_dep.get_pkgconfig_variable('wayland_scanner'))
571         wayland_scanner_code_gen = generator(
572             wayland_scanner,
573             output: '@BASENAME@-protocol.c',
574             arguments: ['code', '@INPUT@', '@OUTPUT@'],
575         )
576         wayland_scanner_client_header_gen = generator(
577             wayland_scanner,
578             output: '@BASENAME@-client-protocol.h',
579             arguments: ['client-header', '@INPUT@', '@OUTPUT@'],
580         )
581         wayland_protocols_datadir = wayland_protocols_dep.get_pkgconfig_variable('pkgdatadir')
582         xdg_shell_xml = join_paths(wayland_protocols_datadir, 'stable/xdg-shell/xdg-shell.xml')
583         xdg_shell_sources = [
584             wayland_scanner_code_gen.process(xdg_shell_xml),
585             wayland_scanner_client_header_gen.process(xdg_shell_xml),
586         ]
587         executable('xkbcommon-interactive-wayland',
588                    'tools/interactive-wayland.c',
589                    xdg_shell_sources,
590                    dependencies: [tools_dep, wayland_client_dep])
591     endif
592 endif
593
594 # xkeyboard-config "verifier"
595 xkct_config = configuration_data()
596 xkct_config.set('MESON_BUILD_ROOT', meson.build_root())
597 xkct_config.set('XKB_CONFIG_ROOT', XKBCONFIGROOT)
598 configure_file(input: 'test/xkeyboard-config-test.py.in',
599                output: 'xkeyboard-config-test',
600                configuration: xkct_config)
601
602
603 # Benchmarks.
604 libxkbcommon_bench_internal = static_library(
605     'xkbcommon-bench-internal',
606     'bench/bench.c',
607     'bench/bench.h',
608     link_with: libxkbcommon_test_internal,
609 )
610 bench_dep = declare_dependency(
611     include_directories: include_directories('src'),
612     link_with: libxkbcommon_bench_internal,
613 )
614 bench_env = environment()
615 bench_env.set('top_srcdir', meson.source_root())
616 benchmark(
617     'key-proc',
618     executable('bench-key-proc', 'bench/key-proc.c', dependencies: bench_dep),
619     env: bench_env,
620 )
621 benchmark(
622     'rules',
623     executable('bench-rules', 'bench/rules.c', dependencies: bench_dep),
624     env: bench_env,
625 )
626 benchmark(
627     'rulescomp',
628     executable('bench-rulescomp', 'bench/rulescomp.c', dependencies: bench_dep),
629     env: bench_env,
630 )
631 benchmark(
632     'compose',
633     executable('bench-compose', 'bench/compose.c', dependencies: bench_dep),
634     env: bench_env,
635 )
636
637
638 # Documentation.
639 if get_option('enable-docs')
640     doxygen = find_program('doxygen', required: false)
641     if not doxygen.found()
642         error('''Documentation requires doxygen which was not found.
643 You can disable the documentation with -Denable-docs=false.''')
644     endif
645     doxygen_wrapper = find_program('scripts/doxygen-wrapper')
646
647     doxygen_input = [
648         'README.md',
649         'doc/doxygen-extra.css',
650         'doc/quick-guide.md',
651         'doc/compat.md',
652         'doc/user-configuration.md',
653         'doc/rules-format.md',
654         'xkbcommon/xkbcommon.h',
655         'xkbcommon/xkbcommon-names.h',
656         'xkbcommon/xkbcommon-x11.h',
657         'xkbcommon/xkbcommon-compose.h',
658         'xkbcommon/xkbregistry.h',
659     ]
660     doxygen_data = configuration_data()
661     doxygen_data.set('PACKAGE_NAME', meson.project_name())
662     doxygen_data.set('PACKAGE_VERSION', meson.project_version())
663     doxygen_data.set('INPUT', ' '.join(doxygen_input))
664     doxygen_data.set('OUTPUT_DIRECTORY', meson.build_root())
665     doxyfile = configure_file(
666         input: 'doc/Doxyfile.in',
667         output: 'Doxyfile',
668         configuration: doxygen_data,
669     )
670     # TODO: Meson should provide this.
671     docdir = join_paths(get_option('datadir'), 'doc', meson.project_name())
672     custom_target(
673         'doc',
674         input: [doxyfile] + doxygen_input,
675         output: 'html',
676         command: [doxygen_wrapper, doxygen.path(), join_paths(meson.build_root(), 'Doxyfile'), meson.source_root()],
677         install: true,
678         install_dir: docdir,
679         build_by_default: true,
680     )
681 endif
682
683 configure_file(output: 'config.h', configuration: configh_data)