• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1wayland_version = meson.project_version().split('.')
2wayland_version_h = configuration_data()
3wayland_version_h.set('WAYLAND_VERSION', meson.project_version())
4wayland_version_h.set('WAYLAND_VERSION_MAJOR', wayland_version[0].to_int())
5wayland_version_h.set('WAYLAND_VERSION_MINOR', wayland_version[1].to_int())
6wayland_version_h.set('WAYLAND_VERSION_MICRO', wayland_version[2].to_int())
7configure_file(
8	input: 'wayland-version.h.in',
9	output: 'wayland-version.h',
10	configuration: wayland_version_h,
11	install: get_option('libraries'),
12	install_dir: join_paths(get_option('prefix'), get_option('includedir'))
13)
14
15
16wayland_util = static_library(
17	'wayland-util',
18	sources: 'wayland-util.c'
19)
20
21wayland_util_dep = declare_dependency(
22	link_with: wayland_util,
23	include_directories: include_directories('.')
24)
25
26if get_option('scanner')
27	# wayland-scanner
28
29	configure_file(
30		input: '../protocol/wayland.dtd',
31		output: 'wayland.dtd.embed',
32		copy: true
33	)
34
35	wayland_scanner_sources = [ 'scanner.c', 'dtddata.S' ]
36	wayland_scanner_includes = [ root_inc, protocol_inc ]
37
38	wayland_scanner = executable(
39		'wayland-scanner',
40		wayland_scanner_sources,
41		c_args: [ '-include', 'config.h' ],
42		include_directories: wayland_scanner_includes,
43		dependencies: [ scanner_deps, wayland_util_dep, ],
44		install: true
45	)
46
47	pkgconfig.generate(
48		name: 'Wayland Scanner',
49		description: 'Wayland scanner',
50		version: meson.project_version(),
51		variables: [
52			'datarootdir=' + join_paths('${prefix}', get_option('datadir')),
53			'pkgdatadir=' + join_paths('${datarootdir}', meson.project_name()),
54			'bindir=' + join_paths('${prefix}', get_option('bindir')),
55			'wayland_scanner=${bindir}/wayland-scanner'
56		],
57		filebase: 'wayland-scanner'
58	)
59endif
60
61if meson.is_cross_build() or not get_option('scanner')
62	scanner_dep = dependency('wayland-scanner', native: true, version: meson.project_version())
63	wayland_scanner_for_build = find_program(scanner_dep.get_pkgconfig_variable('wayland_scanner'))
64else
65	wayland_scanner_for_build = wayland_scanner
66endif
67
68if get_option('libraries')
69	# wayland libraries
70
71	mathlib_dep = cc.find_library('m', required: false)
72	threads_dep = dependency('threads', required: false)
73
74	wayland_private = static_library(
75		'wayland-private',
76		sources: [
77			'connection.c',
78			'wayland-os.c'
79		],
80		dependencies: [ ffi_dep, rt_dep ]
81	)
82
83	wayland_private_dep = declare_dependency(
84		link_with: wayland_private,
85		include_directories: include_directories('.')
86	)
87
88	generated_headers = [
89		{
90			'scanner_args': ['server-header'],
91			'output': 'wayland-server-protocol.h',
92			'install': true,
93		},
94		{
95			'scanner_args': ['server-header', '-c'],
96			'output': 'wayland-server-protocol-core.h',
97			'install': false,
98		},
99		{
100			'scanner_args': ['client-header'],
101			'output': 'wayland-client-protocol.h',
102			'install': true,
103		},
104		{
105			'scanner_args': ['client-header', '-c'],
106			'output': 'wayland-client-protocol-core.h',
107			'install': false,
108		},
109	]
110
111	foreach gen: generated_headers
112		scanner_args = gen['scanner_args']
113		output_file = gen['output']
114		install_file = gen['install']
115		install_dir = join_paths(get_option('prefix'), get_option('includedir'))
116		target_name = output_file.underscorify()
117
118		target = custom_target(
119			target_name,
120			command: [
121				wayland_scanner_for_build, '-s', scanner_args,
122				'@INPUT@', '@OUTPUT@'
123			],
124			input: wayland_protocol_xml,
125			output: output_file,
126			install: install_file,
127			install_dir: install_dir
128		)
129
130		set_variable(target_name, target)
131	endforeach
132
133	wayland_protocol_c = custom_target(
134		'protocol source',
135		command: [
136			wayland_scanner_for_build, '-s', 'public-code', '@INPUT@', '@OUTPUT@'
137		],
138		input: wayland_protocol_xml,
139		output: 'wayland-protocol.c'
140	)
141
142	wayland_server = library(
143		'wayland-server',
144		sources: [
145			wayland_server_protocol_core_h,
146			wayland_server_protocol_h,
147			wayland_protocol_c,
148			'wayland-server.c',
149			'wayland-shm.c',
150			'event-loop.c'
151		],
152		version: '0.1.0',
153		dependencies: [
154			ffi_dep,
155			wayland_private_dep,
156			wayland_util_dep,
157			mathlib_dep,
158			threads_dep,
159			rt_dep
160		],
161		include_directories: root_inc,
162		install: true
163	)
164
165	wayland_server_dep = declare_dependency(
166		link_with: wayland_server,
167		include_directories: [ root_inc, include_directories('.') ],
168		dependencies: [ ffi_dep, mathlib_dep, threads_dep ],
169		sources: [
170			wayland_server_protocol_core_h,
171			wayland_server_protocol_h
172		]
173	)
174
175	pkgconfig.generate(
176		wayland_server,
177		name: 'Wayland Server',
178		description: 'Server side implementation of the Wayland protocol',
179		version: meson.project_version(),
180		filebase: 'wayland-server',
181		variables: [
182			'datarootdir=' + join_paths('${prefix}', get_option('datadir')),
183			'pkgdatadir=' + join_paths('${datarootdir}', meson.project_name())
184		]
185	)
186
187	wayland_client = library(
188		'wayland-client',
189		sources: [
190			wayland_client_protocol_core_h,
191			wayland_client_protocol_h,
192			wayland_protocol_c,
193			'wayland-client.c'
194		],
195		version: '0.3.0',
196		dependencies: [
197			ffi_dep,
198			wayland_private_dep,
199			wayland_util_dep,
200			mathlib_dep,
201			threads_dep
202		],
203		include_directories: root_inc,
204		install: true
205	)
206
207	pkgconfig.generate(
208		wayland_client,
209		name: 'Wayland Client',
210		description: 'Wayland client side library',
211		version: meson.project_version(),
212		filebase: 'wayland-client',
213		variables: [
214			'datarootdir=' + join_paths('${prefix}', get_option('datadir')),
215			'pkgdatadir=' + join_paths('${datarootdir}', meson.project_name())
216		]
217	)
218
219	wayland_client_dep = declare_dependency(
220		link_with: wayland_client,
221		include_directories: [ root_inc, include_directories('.') ],
222		sources: [
223			wayland_client_protocol_core_h,
224			wayland_client_protocol_h
225		]
226	)
227
228	install_headers([
229		'wayland-util.h',
230		'wayland-server.h',
231		'wayland-server-core.h',
232		'wayland-client.h',
233		'wayland-client-core.h',
234	])
235endif
236