-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmeson.build
340 lines (292 loc) · 9.65 KB
/
meson.build
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
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
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
# TinyGLUT Small implementation of GLUT (OpenGL Utility Toolkit)
# Copyright (c) 2015-2024, Nicolas Caramelli
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# 1. Redistributions of source code must retain the above copyright notice, this
# list of conditions and the following disclaimer.
#
# 2. Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions and the following disclaimer in the documentation
# and/or other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
project('TinyGLUT', 'c', version: '0.7')
cc = meson.get_compiler('c')
pkgconfig = import('pkgconfig')
#########################
# Configuration options #
#########################
enable_dummy = get_option('dummy')
enable_x11 = get_option('x11')
enable_xcb = get_option('xcb')
enable_directfb = get_option('directfb')
enable_fbdev = get_option('fbdev')
enable_wayland = get_option('wayland')
enable_egl = get_option('egl')
enable_glx = get_option('glx')
enable_dfbgl = get_option('dfbgl')
enable_glfbdev = get_option('glfbdev')
enable_tests = get_option('tests')
#############
# Platforms #
#############
if enable_x11
x11_dep = dependency('x11', required: false)
if not x11_dep.found()
enable_x11 = false
endif
endif
if enable_xcb
xcb_dep = dependency('xcb-keysyms', required: false)
if not xcb_dep.found()
enable_xcb = false
endif
endif
if enable_directfb
directfb_dep = dependency('directfb', required: false)
if not directfb_dep.found()
enable_directfb = false
endif
endif
if enable_fbdev
if not cc.has_header('linux/fb.h') or not cc.has_header('linux/input.h')
enable_fbdev = false
endif
endif
if enable_wayland
wayland_dep = [dependency('wayland-client', required: false), dependency('xkbcommon', required: false)]
foreach dep : wayland_dep
if not dep.found()
enable_wayland = false
endif
endforeach
endif
if not enable_dummy and not enable_x11 and not enable_xcb and not enable_directfb and not enable_fbdev and not enable_wayland
error('No platforms found')
endif
############
# Backends #
############
if enable_egl
egl_dep = dependency('egl', required: false)
if egl_dep.found()
egl_dep = declare_dependency(compile_args: '-DEGL_NO_PLATFORM_SPECIFIC_TYPES', dependencies: egl_dep)
else
enable_egl = false
endif
endif
if enable_dummy
if not enable_egl
enable_dummy = false
endif
endif
if enable_x11
if enable_glx
libdir = run_command('pkg-config', '--variable=libdir', 'gl', check: true).stdout().strip()
if not cc.has_function('glXCreateContext', dependencies: cc.find_library('GL', dirs: libdir))
enable_glx = false
endif
endif
if not enable_glx and not enable_egl
enable_x11 = false
endif
else
enable_glx = false
endif
if enable_xcb
if not enable_egl
enable_xcb = false
endif
endif
if enable_directfb
if enable_dfbgl
message('Checking for DirectFBGL module')
moduledir = run_command('pkg-config', '--variable=moduledir', 'directfb-internal', check: false).stdout().strip()
if import('fs').is_dir(moduledir + '/interfaces/IDirectFBGL')
message('DirectFBGL found')
else
message('DirectFBGL not found')
enable_dfbgl = false
endif
endif
if not enable_dfbgl and not enable_egl
enable_directfb = false
endif
else
enable_dfbgl = false
endif
if enable_fbdev
if enable_glfbdev
libdir = run_command('pkg-config', '--variable=libdir', 'gl', check: true).stdout().strip()
if not cc.has_function('glFBDevCreateContext', dependencies: cc.find_library('GL', dirs: libdir))
enable_glfbdev = false
endif
endif
if not enable_glfbdev and not enable_egl
enable_fbdev = false
endif
else
enable_glfbdev = false
endif
if enable_wayland
if not enable_egl
enable_wayland = false
endif
endif
if enable_glx or enable_glfbdev
gl_dep = dependency('gl', required: false)
if not gl_dep.found()
enable_glx = false
enable_glfbdev = false
endif
endif
if not enable_egl and not enable_glx and not enable_dfbgl and not enable_glfbdev
error('No backends found')
endif
#########
# Tests #
#########
if enable_tests
check_dep = dependency('check', required: false)
libfiu_dep = dependency('libfiu', required: false)
if not check_dep.found() or not libfiu_dep.found()
enable_tests = false
else
add_global_arguments('-DFIU_ENABLE', language: 'c')
endif
endif
#######################
# Build configuration #
#######################
message('')
message('GLUT backends:')
message('')
message(' EGL (Native Platform Graphics Interface) @0@'.format(enable_egl))
if enable_egl
message('')
message(' EGL platforms:')
message(' X11 @0@'.format(enable_x11))
message(' XCB @0@'.format(enable_xcb))
message(' DirectFB @0@'.format(enable_directfb))
message(' FBDev @0@'.format(enable_fbdev))
message(' Wayland @0@'.format(enable_wayland))
message('')
endif
message(' GLX (OpenGL Extension to X11) @0@'.format(enable_glx))
message(' DFBGL (OpenGL Extension to DirectFB) @0@'.format(enable_dfbgl))
message(' GLFBDev (OpenGL Extension to FBDev) @0@'.format(enable_glfbdev))
message('')
message('Tests: @0@'.format(enable_tests))
message('')
###############
# Build rules #
###############
# Platforms plugins
platformsdir = join_paths(get_option('prefix'), get_option('libdir'), 'glut/platforms')
if enable_dummy
library('dummy_plugin', 'dummy.c',
name_prefix: '',
install: true,
install_dir: platformsdir)
endif
if enable_x11
x11_plugin = library('x11_plugin', 'x11.c',
dependencies: x11_dep,
name_prefix: '',
install: true,
install_dir: platformsdir)
endif
if enable_xcb
xcb_plugin = library('xcb_plugin', 'xcb.c',
dependencies: xcb_dep,
name_prefix: '',
install: true,
install_dir: platformsdir)
endif
if enable_directfb
directfb_plugin = library('directfb_plugin', 'directfb.c',
dependencies: directfb_dep,
name_prefix: '',
install: true,
install_dir: platformsdir)
endif
if enable_fbdev
fbdev_plugin = library('fbdev_plugin', 'fbdev.c',
dependencies: dependency('threads'),
name_prefix: '',
install: true,
install_dir: platformsdir)
endif
if enable_wayland
library('wayland_plugin', 'wayland.c',
dependencies: wayland_dep,
name_prefix: '',
install: true,
install_dir: platformsdir)
endif
# Backends plugins
backendsdir = join_paths(get_option('prefix'), get_option('libdir'), 'glut/backends')
if enable_egl
library('egl_plugin', 'egl.c',
c_args: '-DPLATFORMSDIR="' + platformsdir + '"',
dependencies: [egl_dep, libfiu_dep, dependency('dl')],
name_prefix: '',
install: true,
install_dir: backendsdir)
endif
if enable_glx
library('glx_plugin', 'glx.c',
build_rpath: platformsdir,
dependencies: [gl_dep, libfiu_dep],
link_with: x11_plugin,
name_prefix: '',
install: true,
install_dir: backendsdir)
endif
if enable_dfbgl
library('dfbgl_plugin', 'dfbgl.c',
build_rpath: platformsdir,
dependencies: [directfb_dep, libfiu_dep],
link_with: directfb_plugin,
name_prefix: '',
install: true,
install_dir: backendsdir)
endif
if enable_glfbdev
library('glfbdev_plugin', 'glfbdev.c',
build_rpath: platformsdir,
dependencies: [gl_dep, libfiu_dep],
link_with: fbdev_plugin,
name_prefix: '',
install: true,
install_dir: backendsdir)
endif
# GLUT library
libglut = library('glut', 'glut.c',
c_args: '-DBACKENDSDIR="' + backendsdir + '"',
dependencies: [libfiu_dep, dependency('dl')],
version: '3.0.0',
install: true)
install_headers('glut.h', subdir: 'GL')
pkgconfig.generate(filebase: 'glut',
name: 'TinyGLUT',
description: 'Small implementation of GLUT (OpenGL Utility Toolkit)',
libraries: '-L${libdir} -lglut')
if enable_tests
glut_tests = executable('glut-tests', 'glut-tests.c',
build_rpath: join_paths(get_option('prefix'), get_option('libdir')),
link_with: libglut,
dependencies: [check_dep, libfiu_dep])
test('glut-tests', glut_tests)
endif