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
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
|
project(
'mpd',
['c', 'cpp'],
version: '0.21.9',
meson_version: '>= 0.49.0',
default_options: [
'c_std=c99',
'cpp_std=c++14'
],
license: 'GPLv2+',
)
version_cxx = vcs_tag(input: 'src/GitVersion.cxx', output: 'GitVersion.cxx')
compiler = meson.get_compiler('cpp')
c_compiler = meson.get_compiler('c')
conf = configuration_data()
conf.set_quoted('PACKAGE', meson.project_name())
conf.set_quoted('PACKAGE_NAME', meson.project_name())
conf.set_quoted('PACKAGE_VERSION', meson.project_version())
conf.set_quoted('VERSION', meson.project_version())
conf.set_quoted('PROTOCOL_VERSION', '0.21.6')
conf.set_quoted('SYSTEM_CONFIG_FILE_LOCATION', join_paths(get_option('prefix'), get_option('sysconfdir'), 'mpd.conf'))
common_cppflags = [
'-D_GNU_SOURCE',
]
common_cflags = [
]
common_cxxflags = [
]
test_common_flags = [
'-Wall',
'-Wextra',
'-fvisibility=hidden',
'-ffast-math',
'-ftree-vectorize',
]
test_cxxflags = test_common_flags + [
'-fno-threadsafe-statics',
'-fmerge-all-constants',
'-Wmissing-declarations',
'-Wshadow',
'-Wpointer-arith',
'-Wcast-qual',
'-Wwrite-strings',
'-Wsign-compare',
'-Wno-non-virtual-dtor',
# work around bogus GCC7 warning "mangled name for ... will change
# in C++17 because the exception specification is part of a function
# type"
'-Wno-noexcept-type',
]
if compiler.get_id() == 'clang'
# Workaround for clang bug
# https://bugs.llvm.org/show_bug.cgi?id=32611
test_cxxflags += '-funwind-tables'
endif
test_cflags = test_common_flags + [
'-Wmissing-prototypes',
'-Wshadow',
'-Wpointer-arith',
'-Wstrict-prototypes',
'-Wcast-qual',
'-Wwrite-strings',
'-pedantic',
]
test_ldflags = [
]
if get_option('buildtype') != 'debug'
test_cflags += [
'-ffunction-sections',
'-fdata-sections',
]
test_ldflags += [
'-Wl,--gc-sections',
]
endif
add_global_arguments(common_cxxflags + compiler.get_supported_arguments(test_cxxflags), language: 'cpp')
add_global_arguments(common_cflags + c_compiler.get_supported_arguments(test_cflags), language: 'c')
add_global_link_arguments(compiler.get_supported_link_arguments(test_ldflags), language: 'cpp')
is_linux = host_machine.system() == 'linux'
is_android = get_option('android_ndk') != ''
is_darwin = host_machine.system() == 'darwin'
is_windows = host_machine.system() == 'windows'
is_haiku = host_machine.system() == 'haiku'
if is_android
common_cppflags += '-DANDROID'
endif
if is_windows
common_cppflags += [
'-DWIN32_LEAN_AND_MEAN',
'-DWINVER=0x0600', '-D_WIN32_WINNT=0x0600',
'-DSTRICT',
'-DUNICODE', '-D_UNICODE',
]
subdir('win32')
endif
if is_android
subdir('android')
endif
add_global_arguments(common_cppflags, language: 'c')
add_global_arguments(common_cppflags, language: 'cpp')
enable_daemon = not is_windows and not is_android and get_option('daemon')
conf.set('ENABLE_DAEMON', enable_daemon)
conf.set('HAVE_LOCALE_H', compiler.has_header('locale.h'))
conf.set('HAVE_GETPWNAM_R', compiler.has_function('getpwnam_r'))
conf.set('HAVE_GETPWUID_R', compiler.has_function('getpwuid_r'))
conf.set('HAVE_INITGROUPS', compiler.has_function('initgroups'))
conf.set('HAVE_FNMATCH', compiler.has_function('fnmatch'))
conf.set('HAVE_STRNDUP', compiler.has_function('strndup', prefix: '#define _GNU_SOURCE\n#include <string.h>'))
conf.set('HAVE_STRCASESTR', compiler.has_function('strcasestr'))
conf.set('HAVE_PRCTL', is_linux)
conf.set('USE_EVENTFD', is_linux and get_option('eventfd'))
conf.set('USE_SIGNALFD', is_linux and get_option('signalfd'))
if is_windows
conf.set('USE_WINSELECT', true)
elif is_linux and get_option('epoll')
conf.set('USE_EPOLL', true)
else
conf.set('USE_POLL', true)
endif
if not get_option('syslog').disabled()
if compiler.has_function('syslog')
conf.set('HAVE_SYSLOG', true)
elif get_option('syslog').enabled()
error('syslog() not found')
endif
endif
enable_database = get_option('database')
conf.set('ENABLE_DATABASE', enable_database)
enable_inotify = get_option('inotify') and is_linux and enable_database
conf.set('ENABLE_INOTIFY', enable_inotify)
conf.set('ENABLE_DSD', get_option('dsd'))
inc = include_directories(
'src',
# for the generated config.h
'.',
)
boost_dep = dependency('boost', version: '>= 1.58')
if boost_dep.version() == '1.67'
# https://github.com/MusicPlayerDaemon/MPD/pull/384
# https://github.com/boostorg/lockfree/commit/12726cda009a855073b9bedbdce57b6ce7763da2
warning('Your Boost version 1.67 is known to be buggy, and the MPD build will fail. Please upgrade to Boost 1.68 or later.')
endif
sources = [
version_cxx,
'src/Main.cxx',
'src/protocol/Ack.cxx',
'src/protocol/ArgParser.cxx',
'src/protocol/Result.cxx',
'src/command/CommandError.cxx',
'src/command/AllCommands.cxx',
'src/command/QueueCommands.cxx',
'src/command/TagCommands.cxx',
'src/command/PlayerCommands.cxx',
'src/command/PlaylistCommands.cxx',
'src/command/FileCommands.cxx',
'src/command/OutputCommands.cxx',
'src/command/MessageCommands.cxx',
'src/command/ClientCommands.cxx',
'src/command/PartitionCommands.cxx',
'src/command/OtherCommands.cxx',
'src/command/CommandListBuilder.cxx',
'src/Idle.cxx',
'src/IdleFlags.cxx',
'src/decoder/Domain.cxx',
'src/decoder/Thread.cxx',
'src/decoder/Control.cxx',
'src/decoder/Bridge.cxx',
'src/decoder/DecoderPrint.cxx',
'src/client/Listener.cxx',
'src/client/Client.cxx',
'src/client/ClientEvent.cxx',
'src/client/ClientExpire.cxx',
'src/client/ClientGlobal.cxx',
'src/client/ClientIdle.cxx',
'src/client/ClientList.cxx',
'src/client/ClientNew.cxx',
'src/client/ClientProcess.cxx',
'src/client/ClientRead.cxx',
'src/client/ClientWrite.cxx',
'src/client/ClientMessage.cxx',
'src/client/ClientSubscribe.cxx',
'src/client/ClientFile.cxx',
'src/client/Response.cxx',
'src/Listen.cxx',
'src/LogInit.cxx',
'src/LogBackend.cxx',
'src/Log.cxx',
'src/ls.cxx',
'src/Instance.cxx',
'src/win32/Win32Main.cxx',
'src/MusicBuffer.cxx',
'src/MusicPipe.cxx',
'src/MusicChunk.cxx',
'src/MusicChunkPtr.cxx',
'src/Mapper.cxx',
'src/Partition.cxx',
'src/Permission.cxx',
'src/player/CrossFade.cxx',
'src/player/Thread.cxx',
'src/player/Control.cxx',
'src/PlaylistError.cxx',
'src/PlaylistPrint.cxx',
'src/PlaylistSave.cxx',
'src/playlist/PlaylistStream.cxx',
'src/playlist/PlaylistMapper.cxx',
'src/playlist/PlaylistAny.cxx',
'src/playlist/PlaylistSong.cxx',
'src/playlist/PlaylistQueue.cxx',
'src/playlist/Print.cxx',
'src/db/PlaylistVector.cxx',
'src/queue/Queue.cxx',
'src/queue/QueuePrint.cxx',
'src/queue/QueueSave.cxx',
'src/queue/Playlist.cxx',
'src/queue/PlaylistControl.cxx',
'src/queue/PlaylistEdit.cxx',
'src/queue/PlaylistTag.cxx',
'src/queue/PlaylistState.cxx',
'src/ReplayGainGlobal.cxx',
'src/LocateUri.cxx',
'src/SongUpdate.cxx',
'src/SongLoader.cxx',
'src/SongPrint.cxx',
'src/SongSave.cxx',
'src/StateFile.cxx',
'src/StateFileConfig.cxx',
'src/Stats.cxx',
'src/TagPrint.cxx',
'src/TagSave.cxx',
'src/TagFile.cxx',
'src/TagStream.cxx',
'src/TimePrint.cxx',
'src/mixer/Volume.cxx',
'src/PlaylistFile.cxx',
]
if not is_android
sources += [
'src/CommandLine.cxx',
'src/unix/SignalHandlers.cxx',
]
else
sources += [
'src/android/Context.cxx',
'src/android/Environment.cxx',
'src/android/LogListener.cxx',
]
endif
if enable_daemon
sources += 'src/unix/Daemon.cxx'
endif
if enable_database
sources += [
'src/queue/PlaylistUpdate.cxx',
'src/command/StorageCommands.cxx',
'src/command/DatabaseCommands.cxx',
]
endif
subdir('src/util')
subdir('src/system')
subdir('src/thread')
subdir('src/event')
subdir('src/lib/dbus')
subdir('src/lib/icu')
subdir('src/lib/smbclient')
subdir('src/lib/zlib')
subdir('src/lib/alsa')
subdir('src/lib/curl')
subdir('src/lib/expat')
subdir('src/lib/ffmpeg')
subdir('src/lib/gcrypt')
subdir('src/lib/nfs')
subdir('src/lib/oss')
subdir('src/lib/pcre')
subdir('src/lib/pulse')
subdir('src/lib/sndio')
subdir('src/lib/sqlite')
subdir('src/lib/systemd')
subdir('src/lib/upnp')
subdir('src/lib/yajl')
subdir('src/fs')
subdir('src/config')
subdir('src/net')
subdir('src/tag')
subdir('src/pcm')
subdir('src/neighbor')
subdir('src/input')
subdir('src/archive')
subdir('src/filter')
subdir('src/mixer')
subdir('src/output')
subdir('src/lib/xiph')
subdir('src/decoder')
subdir('src/encoder')
subdir('src/song')
subdir('src/playlist')
subdir('src/zeroconf')
if curl_dep.found()
sources += 'src/RemoteTagCache.cxx'
endif
if sqlite_dep.found()
sources += [
'src/command/StickerCommands.cxx',
'src/sticker/StickerDatabase.cxx',
'src/sticker/StickerPrint.cxx',
'src/sticker/SongSticker.cxx',
]
endif
basic = static_library(
'basic',
'src/ReplayGainInfo.cxx',
'src/ReplayGainMode.cxx',
'src/SingleMode.cxx',
include_directories: inc,
)
basic_dep = declare_dependency(
link_with: basic,
)
if enable_database
subdir('src/storage')
else
storage_glue_dep = dependency('', required: false)
endif
subdir('src/db')
if neighbor_glue_dep.found()
sources += 'src/command/NeighborCommands.cxx'
endif
if archive_glue_dep.found()
sources += [
'src/TagArchive.cxx',
'src/db/update/Archive.cxx',
]
endif
if is_windows
sources += windows_resources
endif
link_args = []
more_deps = []
if is_android
subdir('src/java')
target_type = 'shared_library'
target_name = 'mpd'
link_args += [
'-Wl,--no-undefined,-shared,-Bsymbolic',
'-llog',
'-lz',
]
more_deps += [
declare_dependency(sources: [classes_jar]),
java_dep,
]
elif is_haiku
target_type = 'executable'
target_name = 'mpd.nores'
link_args += [
'-lnetwork',
'-lbe',
]
else
target_type = 'executable'
target_name = 'mpd'
endif
mpd = build_target(
target_name,
sources,
target_type: target_type,
include_directories: inc,
dependencies: [
basic_dep,
config_dep,
dbus_dep,
fs_dep,
net_dep,
util_dep,
event_dep,
thread_dep,
neighbor_glue_dep,
input_glue_dep,
archive_glue_dep,
output_glue_dep,
mixer_glue_dep,
decoder_glue_dep,
encoder_glue_dep,
playlist_glue_dep,
db_glue_dep,
storage_glue_dep,
song_dep,
systemd_dep,
sqlite_dep,
zeroconf_dep,
more_deps,
],
link_args: link_args,
install: not is_android and not is_haiku,
)
if is_android
subdir('android/apk')
endif
if is_haiku
subdir('src/haiku')
custom_target(
'mpd',
output: 'mpd',
input: [mpd, rsrc],
command: [addres, '@OUTPUT@', '@INPUT0@', '@INPUT1@'],
install: true,
install_dir: get_option('bindir'),
)
endif
configure_file(output: 'config.h', configuration: conf)
if systemd_dep.found()
subdir('systemd')
endif
install_data(
'mpd.svg',
install_dir: join_paths(get_option('datadir'), 'icons', 'hicolor', 'scalable', 'apps'),
)
install_data(
'AUTHORS', 'COPYING', 'NEWS', 'README.md',
install_dir: join_paths(get_option('datadir'), 'doc', meson.project_name()),
)
if get_option('documentation')
subdir('doc')
endif
if get_option('test')
subdir('test')
endif
|