forked from drobilla/jalv
-
Notifications
You must be signed in to change notification settings - Fork 4
/
meson.build
416 lines (354 loc) · 10.1 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
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
# Copyright 2020-2022 David Robillard <[email protected]>
# SPDX-License-Identifier: 0BSD OR ISC
project('jalv', ['c', 'cpp'],
version: '1.6.9',
license: 'ISC',
meson_version: '>= 0.56.0',
default_options: [
'b_ndebug=if-release',
'buildtype=release',
'c_std=c99',
'cpp_std=c++14',
])
jalv_src_root = meson.current_source_dir()
major_version = meson.project_version().split('.')[0]
version_suffix = '@0@-@1@'.format(meson.project_name(), major_version)
#######################
# Compilers and Flags #
#######################
# Required tools
cc = meson.get_compiler('c')
# Optional C++ support
if add_languages(['cpp'], native: false, required: get_option('cxx'))
cpp = meson.get_compiler('cpp')
endif
# Set global warning suppressions
subdir('meson/suppressions')
add_project_arguments(c_suppressions, language: ['c'])
if is_variable('cpp')
add_project_arguments(cpp_suppressions, language: ['cpp'])
endif
#######################
# Common Dependencies #
#######################
m_dep = cc.find_library('m', required: false)
thread_dep = dependency('threads')
zix_dep = dependency(
'zix-0',
default_options: [
'benchmarks=disabled',
'docs=disabled',
'tests=disabled',
'tests_cpp=disabled',
],
fallback: ['zix', 'zix_dep'],
version: '>= 0.3.0',
)
serd_dep = dependency(
'serd-0',
default_options: [
'docs=disabled',
'tests=disabled',
'tools=disabled',
],
fallback: ['serd', 'serd_dep'],
version: '>= 0.30.0',
)
sord_dep = dependency(
'sord-0',
default_options: [
'docs=disabled',
'tests=disabled',
'tools=disabled',
],
fallback: ['sord', 'sord_dep'],
version: '>= 0.14.0',
)
lv2_dep = dependency(
'lv2',
default_options: [
'docs=disabled',
'old_headers=false',
'plugins=disabled',
'tests=disabled',
],
fallback: ['lv2', 'lv2_dep'],
version: '>= 1.18.0',
)
sratom_dep = dependency(
'sratom-0',
default_options: [
'docs=disabled',
'tests=disabled',
],
fallback: ['sratom', 'sratom_dep'],
version: '>= 0.6.4',
)
lilv_dep = dependency(
'lilv-0',
default_options: [
'bindings_py=disabled',
'docs=disabled',
'tests=disabled',
'tools=disabled',
],
fallback: ['lilv', 'lilv_dep'],
version: '>= 0.24.0',
)
suil_dep = dependency(
'suil-0',
default_options: [
'docs=disabled',
'tests=disabled',
],
fallback: ['suil', 'suil_dep'],
required: get_option('suil'),
version: '>= 0.10.0',
)
###########
# Drivers #
###########
portaudio_dep = dependency(
'portaudio-2.0',
include_type: 'system',
required: get_option('portaudio'),
version: '>= 2.0.0',
)
jack_dep = dependency(
'jack',
include_type: 'system',
required: get_option('jack'),
version: '>= 0.120.0',
)
backend_sources = files()
if get_option('jack').enabled() and get_option('portaudio').enabled()
error('Only one of jack and portaudio can be enabled')
elif get_option('jack').enabled()
backend_dep = jack_dep
backend_sources += files('src/jack.c')
elif get_option('portaudio').enabled()
backend_dep = portaudio_dep
backend_sources += files('src/portaudio.c')
elif jack_dep.found()
backend_dep = jack_dep
backend_sources += files('src/jack.c')
else
backend_dep = portaudio_dep
backend_sources += files('src/portaudio.c')
endif
if not backend_dep.found()
error('No backend found, either jack or portaudio is required')
endif
##########################
# Platform Configuration #
##########################
platform_defines = [
'-DJALV_VERSION="@0@"'.format(meson.project_version()),
]
suil_defines = ['-DHAVE_SUIL=@0@'.format(suil_dep.found().to_int())]
# Determine whether to use POSIX
no_posix = get_option('posix').disabled() or host_machine.system() == 'windows'
if no_posix
platform_defines += ['-DJALV_NO_POSIX']
elif host_machine.system() == 'darwin'
platform_defines += [
'-D_DARWIN_C_SOURCE',
'-D_POSIX_C_SOURCE=200809L',
'-D_XOPEN_SOURCE=600',
]
else
platform_defines += [
'-D_BSD_SOURCE',
'-D_DEFAULT_SOURCE',
'-D_POSIX_C_SOURCE=200809L',
'-D_XOPEN_SOURCE=600',
]
endif
# Build platform-specific configuration arguments
if get_option('checks').disabled()
# Generic build without platform-specific features
platform_defines += ['-DJALV_NO_DEFAULT_CONFIG']
elif get_option('checks').enabled()
# Only use the features detected by the build system
platform_defines += ['-DJALV_NO_DEFAULT_CONFIG']
if no_posix
platform_defines += ['-DHAVE_FILENO=0']
platform_defines += ['-DHAVE_ISATTY=0']
platform_defines += ['-DHAVE_MLOCK=0']
platform_defines += ['-DHAVE_POSIX_MEMALIGN=0']
platform_defines += ['-DHAVE_SIGACTION=0']
else
fileno_code = '''#include <stdio.h>
int main(void) { return fileno(stdin); }'''
isatty_code = '''#include <unistd.h>
int main(void) { return isatty(0); }'''
mlock_code = '''#include <sys/mman.h>
int main(void) { return mlock(0, 0); }'''
posix_memalign_code = '''#include <stdlib.h>
int main(void) { void* mem; posix_memalign(&mem, 8, 8); }'''
sigaction_code = '''#include <signal.h>
int main(void) { return sigaction(SIGINT, 0, 0); }'''
platform_defines += '-DHAVE_FILENO=@0@'.format(
cc.compiles(fileno_code,
args: platform_defines,
name: 'fileno').to_int())
platform_defines += '-DHAVE_ISATTY=@0@'.format(
cc.compiles(isatty_code,
args: platform_defines,
name: 'isatty').to_int())
platform_defines += '-DHAVE_MLOCK=@0@'.format(
cc.compiles(mlock_code,
args: platform_defines,
name: 'mlock').to_int())
platform_defines += '-DHAVE_POSIX_MEMALIGN=@0@'.format(
cc.compiles(posix_memalign_code,
args: platform_defines,
name: 'posix_memalign').to_int())
platform_defines += '-DHAVE_SIGACTION=@0@'.format(
cc.compiles(sigaction_code,
args: platform_defines,
name: 'sigaction').to_int())
endif
jack_metadata_code = '''#include <jack/metadata.h>
int main(void) { return !!&jack_set_property; }'''
jack_port_type_get_buffer_size_code = '''#include <jack/jack.h>
int main(void) { return !!&jack_port_type_get_buffer_size; }'''
platform_defines += '-DHAVE_JACK_METADATA=@0@'.format(
cc.compiles(jack_metadata_code,
args: platform_defines,
name: 'jack_metadata').to_int())
platform_defines += '-DHAVE_JACK_PORT_TYPE_GET_BUFFER_SIZE=@0@'.format(
cc.compiles(jack_port_type_get_buffer_size_code,
args: platform_defines,
name: 'jack_port_type_get_buffer_size').to_int())
endif
############
# Programs #
############
sources = backend_sources + files(
'src/control.c',
'src/jalv.c',
'src/log.c',
'src/lv2_evbuf.c',
'src/state.c',
'src/symap.c',
'src/worker.c',
)
common_dependencies = [
backend_dep,
lilv_dep,
m_dep,
serd_dep,
sratom_dep,
suil_dep,
thread_dep,
zix_dep,
]
# Internal JACK client library
if jack_dep.found()
shared_library(
'jalv',
sources + files('src/jalv_console.c'),
c_args: c_suppressions + platform_defines + ['-DHAVE_SUIL=0'],
dependencies: common_dependencies,
include_directories: include_directories('src'),
install: true,
install_dir: get_option('prefix') / get_option('libdir') / 'jack',
name_prefix: '',
)
endif
# Console version
executable(
'jalv',
sources + files('src/jalv_console.c'),
c_args: c_suppressions + platform_defines + suil_defines,
dependencies: common_dependencies + [suil_dep],
include_directories: include_directories('src'),
install: true,
)
# Gtk 3.0 GUI version
if not get_option('gtk3').disabled()
gdk3_dep = dependency(
'gdk-3.0',
include_type: 'system',
required: get_option('gtk3'),
version: '>= 3.12.0',
)
gtk3_dep = dependency(
'gtk+-3.0',
include_type: 'system',
required: get_option('gtk3'),
version: '>= 3.12.0',
)
if gdk3_dep.found() and gtk3_dep.found()
config = configuration_data()
config.set('APP_INSTALL_NAME', 'jalv.gtk3')
config.set('APP_HUMAN_NAME', 'Jalv')
config.set('BINDIR', get_option('prefix') / get_option('bindir'))
configure_file(configuration: config,
input: files('jalv.desktop.in'),
output: 'jalv.desktop',
install: true,
install_dir: get_option('datadir') / 'applications')
executable(
'jalv.gtk3',
sources + files('src/jalv_gtk.c'),
c_args: c_suppressions + platform_defines + suil_defines,
dependencies: common_dependencies + [gdk3_dep, gtk3_dep, suil_dep],
include_directories: include_directories('src'),
install: true,
)
endif
endif
# Qt 5 GUI version
if not get_option('qt5').disabled()
qt5_dep = dependency(
'Qt5Widgets',
include_type: 'system',
required: get_option('qt5'),
version: '>= 5.1.0',
)
moc = find_program('moc-qt5', required: false)
if not moc.found()
moc = find_program('moc', required: get_option('qt5'))
endif
if moc.found()
qt_args = []
if cpp.get_id() in ['clang', 'gcc']
qt_args = ['-fPIC']
endif
jalv_qt_hpp = files(jalv_src_root / 'src' / 'jalv_qt.hpp')
jalv_qt5_meta_cpp = custom_target(
'jalv_qt5_meta.cpp',
capture: true,
command: [moc, '@INPUT@'],
input: jalv_qt_hpp,
output: 'jalv_qt5_meta.cpp',
)
executable(
'jalv.qt5',
sources + files('src/jalv_qt.cpp') + [jalv_qt5_meta_cpp],
c_args: c_suppressions + platform_defines + suil_defines,
cpp_args: cpp_suppressions + platform_defines + suil_defines + qt_args,
dependencies: common_dependencies + [qt5_dep, suil_dep],
include_directories: include_directories('src'),
install: true,
)
endif
endif
#################
# Documentation #
#################
subdir('doc')
#########
# Tests #
#########
if not get_option('tests').disabled()
subdir('test')
endif
if not meson.is_subproject()
summary('Install prefix', get_option('prefix'))
summary('Executables', get_option('prefix') / get_option('bindir'))
summary('Man pages', get_option('prefix') / get_option('mandir'))
summary('Backend', backend_dep.name())
endif