1# Here be dragons
2
3dot_gv = {
4	'wayland-architecture': files('dot/wayland-architecture.gv'),
5	'x-architecture': files('dot/x-architecture.gv'),
6}
7
8# This is a workaround for Meson's custom_target() directive, which
9# currently does not support outputs pointing to a sub-directory
10# XXX: try turning these into maps, so they can be indexed with picture name
11dot_png = []
12dot_map = []
13
14doxygen_conf = configuration_data()
15doxygen_conf.set('VERSION', meson.project_version())
16doxygen_conf.set('top_builddir', meson.build_root())
17wayland_doxygen = configure_file(
18	input: 'wayland.doxygen.in',
19	output: 'wayland.doxygen',
20	configuration: doxygen_conf,
21)
22
23shared_files = files([
24	'../../src/wayland-util.h',
25])
26
27client_files = files([
28	'../../src/wayland-client.c',
29	'../../src/wayland-client.h',
30	'../../src/wayland-client-core.h',
31])
32
33server_files = files([
34	'../../src/event-loop.c',
35	'../../src/wayland-server.c',
36	'../../src/wayland-server.h',
37	'../../src/wayland-server-core.h',
38	'../../src/wayland-shm.c',
39])
40
41cursor_files = files([
42	'../../cursor/wayland-cursor.c',
43	'../../cursor/wayland-cursor.h',
44])
45
46extra_client_files = [
47	'mainpage.dox',
48	wayland_client_protocol_h,
49]
50
51extra_server_files = [
52	'mainpage.dox',
53	wayland_server_protocol_h,
54]
55
56extra_cursor_files = [
57	'mainpage.dox',
58]
59
60gen_doxygen = find_program('gen-doxygen.py')
61
62subdir('xml')
63
64formats = {
65	'html': {
66		'Client': shared_files + client_files + extra_client_files,
67		'Server': shared_files + server_files + extra_server_files,
68		'Cursor': shared_files + cursor_files + extra_cursor_files,
69	},
70}
71
72foreach f_name, sections: formats
73	foreach s_name, s_files: sections
74		t_name = '@0@-@1@-doc'.format(f_name, s_name)
75
76		# We do not really need an output file, but Meson
77		# will complain if one is not set, so we use a
78		# dummy 'stamp' file
79		custom_target(
80			t_name,
81			command: [
82				gen_doxygen,
83				# XXX pass doxygen path as argument
84				'--builddir=@OUTDIR@',
85				'--section=@0@'.format(s_name),
86				'--output-format=@0@'.format(f_name),
87				'--stamp=doc/doxygen/@0@.stamp'.format(t_name),
88				wayland_doxygen,
89				'@INPUT@',
90			],
91			input: s_files,
92			output: '@0@.stamp'.format(t_name),
93			depends: [dot_png, dot_map],
94			build_by_default: true,
95		)
96	endforeach
97endforeach
98
99man_files = shared_files + server_files + client_files + cursor_files
100custom_target(
101	'man-pages-3',
102	command: [
103		gen_doxygen,
104		'--builddir=@OUTDIR@',
105		'--output-format=man3',
106		'--stamp=doc/doxygen/man3.stamp',
107		wayland_doxygen,
108		'@INPUT@',
109	],
110	input: man_files,
111	output: 'man3',
112	build_by_default: true,
113	install: true,
114	install_dir: join_paths(get_option('prefix'), get_option('mandir')),
115)
116