forked from karlstav/cava
-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathmeson.build
More file actions
328 lines (290 loc) · 10.3 KB
/
meson.build
File metadata and controls
328 lines (290 loc) · 10.3 KB
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
project(
'cava',
'c',
version: '0.10.7',
license: 'MIT',
meson_version: '>=0.50.0',
default_options : [
'warning_level=3',
'buildtype=release'
]
)
is_linux = host_machine.system() == 'linux'
is_mac = host_machine.system() == 'darwin'
is_freebsd = host_machine.system() == 'freebsd'
cc = meson.get_compiler('c')
conf = configuration_data()
c_args = ['-Wall',
'-Wextra',
'-Wno-unused-result',
'-Wno-maybe-uninitialized',
'-Wno-vla-parameter'
]
src_files = files('cavacore.c',
'config.c',
'input/common.c',
'input/fifo.c',
'input/shmem.c',
'output/common.c',
'output/terminal_noncurses.c',
'output/raw.c',
'output/noritake.c'
)
h_files = files('include/cava/cavacore.h',
'include/cava/common.h',
'include/cava/config.h')
h_I_files = files('include/cava/input/common.h')
h_O_files = files('include/cava/output/common.h')
deps = []
inc_dirs = ['include']
if is_mac
add_project_arguments('-DNORT', language: 'c')
endif
add_project_arguments('-DPACKAGE="@0@"'.format(meson.project_name()), language: 'c')
add_project_arguments('-DVERSION="@0@"'.format(meson.project_version()), language: 'c')
if not get_option('debug')
add_project_arguments('-DNDEBUG', language: 'c')
endif
### Iniparser
iniparser_dep = cc.find_library('iniparser', has_headers: 'iniparser.h', required: false)
if not iniparser_dep.found()
iniparser_dep = cc.find_library('iniparser', has_headers: 'iniparser/iniparser.h', required: false)
endif
if not iniparser_dep.found()
iniparser_dep = cc.find_library('iniparser4', has_headers: 'iniparser4/iniparser.h', required: false)
endif
if not iniparser_dep.found()
error('iniparser library is required')
else
if not cc.has_function('iniparser_load', dependencies: iniparser_dep)
error('required iniparser_load method in iniparser library is not found')
else
deps += iniparser_dep
endif
endif
### Math
m_dep = cc.find_library('m', required: false)
if not m_dep.found()
error('math library is required')
else
if not cc.has_function('sqrt', dependencies: m_dep)
error('required sqrt method in math library is not found')
else
deps += m_dep
endif
endif
### fftw3
fftw3_dep = dependency('fftw3', required: true, not_found_message: 'fftw3 library is required')
deps += fftw3_dep
### Threads
thread_dep = dependency('threads', required: false, not_found_message: 'building without threads suppport')
if not cc.has_header('pthread.h', dependencies: thread_dep)
warning('pthread.h header not found. building without threads support')
else
if not cc.has_function('pthread_create', dependencies: thread_dep)
warning('pthread_create method not found. build without threads suppport')
else
deps += thread_dep
endif
endif
### alloca
if cc.check_header('alloca.h')
add_project_arguments('-DHAVE_ALLOCA_H', language: 'c')
endif
ncursesw_dep = dependency('ncursesw', required: get_option('output_ncurses'))
if ncursesw_dep.found()
if cc.has_function('initscr', dependencies: ncursesw_dep)
src_files += files('output/terminal_ncurses.c',
'output/terminal_bcircle.c')
deps += ncursesw_dep
add_project_arguments('-DNCURSES', language: 'c')
else
warning('initscr method in ncursesw library is not found. building without ncursesw support')
endif
else
warning('ncursesw library is not found. building without ncursesw support')
endif
### alsa
alsa_dep = cc.find_library('asound', required: get_option('input_alsa'))
if alsa_dep.found()
if cc.has_function('snd_pcm_open', dependencies: alsa_dep)
src_files += 'input/alsa.c'
deps += alsa_dep
add_project_arguments('-DALSA', language: 'c')
else
warning('snd_pcm_open method in alsa library is not found. building without alsa support')
endif
else
warning('alsa library is not found. building without alsa support')
endif
### port
port_dep = cc.find_library('portaudio', required: get_option('input_portaudio'))
if port_dep.found()
if cc.has_function('Pa_Initialize', dependencies: port_dep)
src_files += 'input/portaudio.c'
deps += port_dep
add_project_arguments('-DPORTAUDIO', language: 'c')
else
warning('Pa_Initialize method in portaudio library is not found. building without portaudio')
endif
else
warning('portaudio library is not found. building without portaudio')
endif
### pulse
pulse_dep = dependency('libpulse', required: get_option('input_pulse'), not_found_message: 'libpulse is not found. building without pulse support')
pulse_simple_dep = cc.find_library('pulse-simple', required: get_option('input_pulse'))
if pulse_dep.found() and pulse_simple_dep.found()
if cc.has_function('pa_simple_new', dependencies: [pulse_dep, pulse_simple_dep])
src_files += 'input/pulse.c'
deps += [pulse_dep, pulse_simple_dep]
add_project_arguments('-DPULSE', language: 'c')
else
warning('pa_simple_method in pulse library is not found. building without pulse')
endif
else
warning('pulse library is not found. building without pulse')
endif
### sndio
sndio_dep = cc.find_library('sndio', required: get_option('input_sndio'))
if sndio_dep.found()
if cc.has_function('sio_open', dependencies: sndio_dep)
src_files += 'input/sndio.c'
deps += sndio_dep
add_project_arguments('-DSNDIO', language: 'c')
else
warning('sio_open method in sndio library is not found. building without sndio')
endif
else
warning('sndio library is not found. building without sndio')
endif
### pipewire
pipewire_dep = dependency('libpipewire-0.3', required: get_option('input_pipewire'), not_found_message: 'pipewire is not found. building without pipewire support')
if pipewire_dep.found()
if cc.has_function('pw_stream_connect', dependencies: pipewire_dep)
src_files += 'input/pipewire.c'
deps += pipewire_dep
add_project_arguments('-DPIPEWIRE', language: 'c')
else
warning('pw_stream_connect method in pipewire library is not found. building without pipewire')
endif
endif
### sdl2
sdl2_dep = dependency('sdl2', required: get_option('output_sdl'), not_found_message: 'sdl2 library is not found. building without sdl2')
opengl_dep = dependency('gl', required: get_option('output_sdl_glsl'), not_found_message: 'OpenGL library is not found. building without OpenGL')
if sdl2_dep.found()
if cc.has_function('SDL_Init', dependencies: sdl2_dep)
src_files += 'output/sdl_cava.c'
deps += sdl2_dep
add_project_arguments('-DSDL', language: 'c')
if opengl_dep.found()
src_files += 'output/sdl_glsl.c'
deps += opengl_dep
add_project_arguments('-DSDL_GLSL', language: 'c')
endif
else
warning('SDL_Init method in sdl2 library is not found. building without sdl2')
endif
endif
### OSS
if not get_option('input_oss').disabled()
have_oss = false
if cc.check_header('sys/soundcard.h')
code = '''
#include <sys/soundcard.h>
int main(int argc, char** argv) {
static const int fmts_sle[] = {AFMT_S16_LE, AFMT_S32_LE, AFMT_S24_LE, AFMT_S8};
return 0;
}
'''
if cc.links(code)
have_oss = true
endif
endif
if have_oss
src_files += 'input/oss.c'
add_project_arguments('-DOSS -D__BSD_VISIBLE', language: 'c')
else
warning('No oss dev files found. building without oss')
endif
endif
### JACK
jack_dep = dependency('jack', required: get_option('input_jack'), not_found_message: 'jack library is not found. building without jack')
if jack_dep.found()
src_files += 'input/jack.c'
deps += jack_dep
add_project_arguments('-DJACK', language: 'c')
endif
### Define target
is_exe = false
foreach p : get_option('build_target')
if not is_exe and p != 'lib'
is_exe = true
endif
endforeach
### Cava font
have_font = false
if get_option('cava_font') and is_exe
if is_freebsd
vtfontcvt_prog = find_program('vtfontcvt', native: true)
psf2bdf_prog = find_program('psf2bdf', native: true)
if vtfontcvt_prog.found() and psf2bdf_prog.found()
cava_bdf = configure_file(
command: [
psf2bdf, '--fontname="-gnu-cava-medium-r-normal--16-160-75-75-c-80-iso10646-1"',
'@INPUT@ @OUTPUT@'],
input: 'cava.psf',
output: 'cava.bdf'
)
cava_fnt = configure_file(
command: [
vtfontcvt, '-o', '@OUTPUT@ @INPUT@'],
input: 'cava.bdf',
output: 'cava.fnt'
)
have_font = true
font_dir = join_paths(get_option('prefix'), 'share/cava')
font_file = 'cava.fnt'
else
warning('Font conversion tool missing. Building without cava font supported!')
endif
else
have_font = true
font_dir = join_paths(get_option('prefix'), 'share/consolefonts')
font_file = 'cava.psf'
endif
endif
if have_font
message('Cava font support')
add_project_arguments('-DFONTDIR="@0@"'.format(font_dir), language: 'c')
add_project_arguments('-DFONTFILE="@0@"'.format(font_file), language: 'c')
add_project_arguments('-DCAVAFONT', language: 'c')
install_data(font_file,
install_dir: font_dir)
endif
cava_lib = shared_library('cava',
sources: src_files,
dependencies: deps,
include_directories: inc_dirs,
c_args: c_args,
install: true)
cava_dep = declare_dependency(link_with: cava_lib,
dependencies: deps,
include_directories: inc_dirs)
if is_exe
executable('cava',
[src_files, 'cava.c'],
dependencies: deps,
include_directories: inc_dirs,
c_args: c_args,
install: true)
endif
install_headers(h_files, subdir: 'cava')
install_headers(h_I_files, subdir: 'cava/input')
install_headers(h_O_files, subdir: 'cava/output')
pkg = import('pkgconfig')
pkg.generate(libraries: cava_lib,
subdirs: ['cava', 'cava/input', 'cava/output'],
version: meson.project_version(),
name: 'libcava',
filebase: 'libcava',
description: 'A cava library')