summaryrefslogtreecommitdiff
path: root/meson.build
blob: 6fabce7ea3ef3a665176846e481a28a96d9d1d10 (plain)
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
project('pipewire', ['c' ],
  version : '0.3.8',
  license : 'MIT',
  meson_version : '>= 0.49.0',
  default_options : [ 'warning_level=3',
                      'c_std=gnu99',
                      'buildtype=debugoptimized' ])


pipewire_version = meson.project_version()
version_arr = pipewire_version.split('.')
pipewire_version_major = version_arr[0]
pipewire_version_minor = version_arr[1]
pipewire_version_micro = version_arr[2]
if version_arr.length() == 4
  pipewire_version_nano = version_arr[3]
else
  pipewire_version_nano = 0
endif

spaversion = '0.2'
apiversion = '0.3'
soversion = 0
libversion = '@0@.@1@.0'.format(soversion, pipewire_version_minor.to_int() * 100 + pipewire_version_micro.to_int())

pipewire_name = 'pipewire-@0@'.format(apiversion)
spa_name = 'spa-@0@'.format(spaversion)

prefix = get_option('prefix')
pipewire_bindir = join_paths(prefix, get_option('bindir'))
pipewire_datadir = join_paths(prefix, get_option('datadir'))
pipewire_libdir = join_paths(prefix, get_option('libdir'))
pipewire_libexecdir = join_paths(prefix, get_option('libexecdir'))
pipewire_localedir = join_paths(prefix, get_option('localedir'))
pipewire_sysconfdir = join_paths(prefix, get_option('sysconfdir'))

pipewire_configdir = join_paths(pipewire_sysconfdir, 'pipewire')
modules_install_dir = join_paths(pipewire_libdir, pipewire_name)

if host_machine.system() == 'linux'
  # glibc ld.so interprets ${LIB} in a library loading path with an
  # appropriate value for the current architecture, typically something
  # like lib, lib64 or lib/x86_64-linux-gnu.
  # This allows the same pw-pulse script to work for both 32- and 64-bit
  # applications on biarch/multiarch distributions, by setting something
  # like LD_LIBRARY_PATH='/usr/${LIB}/pipewire-0.3/pulse'.
  # Note that ${LIB} is a special token expanded by the runtime linker,
  # not an environment variable, and must be passed through literally.
  modules_install_dir_dlopen = join_paths(prefix, '${LIB}', pipewire_name)
else
  modules_install_dir_dlopen = modules_install_dir
endif

spa_plugindir = join_paths(pipewire_libdir, spa_name)

alsadatadir = join_paths(pipewire_datadir, 'alsa-card-profile', 'mixer')

pipewire_headers_dir = join_paths(pipewire_name, 'pipewire')

gnome = import('gnome')
pkgconfig = import('pkgconfig')

have_cpp = add_languages('cpp', required : false)

cc = meson.get_compiler('c')

if cc.get_id() == 'gcc'
  add_global_arguments('-fvisibility=hidden',
			'-Wsign-compare',
			'-Wpointer-arith',
			'-Wformat',
			'-Wformat-security',
			'-Werror=suggest-attribute=format',
			'-Wmissing-braces',
			'-Wtype-limits',
			'-Wold-style-declaration',
			'-Wvariadic-macros',
		        '-Wno-missing-field-initializers',
		        '-Wno-unused-parameter',
			'-Wno-pedantic',
			'-Wunused-result',
			'-DFASTPATH',
#			'-DSPA_DEBUG_MEMCPY',
			language : 'c')
  add_global_arguments('-fvisibility=hidden',
			'-Wsign-compare',
			'-Wpointer-arith',
			'-Wformat',
			'-Wformat-security',
			'-Werror=suggest-attribute=format',
			'-Wmissing-braces',
			'-Wtype-limits',
			'-Wvariadic-macros',
		        '-Wno-missing-field-initializers',
		        '-Wno-unused-parameter',
			'-Wno-pedantic',
			'-Wunused-result',
			language : 'cpp')
  # warn on implicit fall-through if supported by compiler (gcc >= 7.x)
  gcc_major_version = cc.version().split('.')[0]
  if(gcc_major_version.to_int() >= 7)
    add_global_arguments('-Wimplicit-fallthrough', language : 'c')
    add_global_arguments('-Wimplicit-fallthrough', language : 'cpp')
  endif
endif

sse_args = '-msse'
sse2_args = '-msse2'
ssse3_args = '-mssse3'
sse41_args = '-msse4.1'
fma_args = '-mfma'
avx_args = '-mavx'
avx2_args = '-mavx2'

have_sse = cc.has_argument(sse_args)
have_sse2 = cc.has_argument(sse2_args)
have_ssse3 = cc.has_argument(ssse3_args)
have_sse41 = cc.has_argument(sse41_args)
have_fma = cc.has_argument(fma_args)
have_avx = cc.has_argument(avx_args)
have_avx2 = cc.has_argument(avx2_args)

have_neon = false
if host_machine.cpu_family() == 'aarch64'
  if cc.compiles('''
    #include <arm_neon.h>
    int main () {
      float *s;
      asm volatile(
	"      ld1 { v0.4s }, [%[s]], #16\n"
        "      fcvtzs v0.4s, v0.4s, #31\n"
	: [s] "+r" (s) : :);
    }
    ''',
    name : 'aarch64 Neon Support')
      neon_args = []
      have_neon = true

  endif
elif cc.has_argument('-mfpu=neon')
  if cc.compiles('''
    #include <arm_neon.h>
    int main () {
      float *s;
      asm volatile(
        "      vld1.32 { q0 }, [%[s]]!\n"
        "      vcvt.s32.f32 q0, q0, #31\n"
	: [s] "+r" (s) : :);
    }
    ''',
    args: '-mfpu=neon',
    name : 'arm Neon Support')
      neon_args = ['-mfpu=neon']
      have_neon = true
  endif
endif


cdata = configuration_data()
cdata.set('PIPEWIRE_VERSION_MAJOR', pipewire_version_major)
cdata.set('PIPEWIRE_VERSION_MINOR', pipewire_version_minor)
cdata.set('PIPEWIRE_VERSION_MICRO', pipewire_version_micro)
cdata.set('PIPEWIRE_VERSION_NANO', pipewire_version_nano)
cdata.set('PIPEWIRE_API_VERSION', '"@0@"'.format(apiversion))
cdata.set('PIPEWIRE_DATADIR', '"@0@"'.format(pipewire_datadir))
cdata.set('LOCALEDIR', '"@0@"'.format(pipewire_localedir))
cdata.set('LIBDIR', '"@0@"'.format(pipewire_libdir))
cdata.set('GETTEXT_PACKAGE', '"pipewire"')
cdata.set('PIPEWIRE_LICENSE', '"MIT"')
cdata.set('PIPEWIRE_PACKAGE_ORIGIN', '"Unknown package origin"')
cdata.set('PIPEWIRE_PACKAGE_NAME', '"PipeWire source release"')
cdata.set('PACKAGE', '"pipewire"')
cdata.set('PACKAGE_NAME', '"PipeWire"')
cdata.set('PACKAGE_STRING', '"PipeWire @0@"'.format(pipewire_version))
cdata.set('PACKAGE_TARNAME', '"pipewire"')
cdata.set('PACKAGE_URL', '"http://pipewire.org"')
cdata.set('PACKAGE_VERSION', '"@0@"'.format(pipewire_version))
cdata.set('MODULEDIR', '"@0@"'.format(modules_install_dir))
cdata.set('PIPEWIRE_CONFIG_DIR', '"@0@"'.format(pipewire_configdir))
cdata.set('VERSION', '"@0@"'.format(pipewire_version))
cdata.set('PLUGINDIR', '"@0@"'.format(spa_plugindir))
# FIXME: --with-memory-alignment],[8,N,malloc,pagesize (default is 32)]) option
cdata.set('MEMORY_ALIGNMENT_MALLOC', 1)
cdata.set_quoted('PA_ALSA_PATHS_DIR', join_paths(alsadatadir, 'paths'))
cdata.set_quoted('PA_ALSA_PROFILE_SETS_DIR', join_paths(alsadatadir, 'profile-sets'))


check_headers = [['dlfcn.h','HAVE_DLFCN_H'],
  ['inttypes.h', 'HAVE_INTTYPES_H'],
  ['memory.h', 'HAVE_MEMORY_H'],
  ['poll.h', 'HAVE_POLL_H'],
  ['stddef.h', 'HAVE_STDDEF_H'],
  ['stdint.h', 'HAVE_STDINT_H'],
  ['stdio_ext.h', 'HAVE_STDIO_EXT_H'],
  ['strings.h', 'HAVE_STRINGS_H'],
  ['string.h', 'HAVE_STRING_H'],
  ['sys/param.h', 'HAVE_SYS_PARAM_H'],
  ['sys/poll.h', 'HAVE_SYS_POLL_H'],
  ['sys/prctl.h', 'HAVE_SYS_PRCTL_H'],
  ['sys/socket.h', 'HAVE_SYS_SOCKET_H'],
  ['sys/stat.h', 'HAVE_SYS_STAT_H'],
  ['sys/times.h', 'HAVE_SYS_TIMES_H'],
  ['sys/time.h', 'HAVE_SYS_TIME_H'],
  ['sys/types.h', 'HAVE_SYS_TYPES_H'],
  ['sys/utsname.h', 'HAVE_SYS_UTSNAME_H'],
  ['sys/wait.h', 'HAVE_SYS_WAIT_H'],
  ['pwd.h', 'HAVE_PWD_H'],
  ['ucontext.h', 'HAVE_UCONTEXT_H'],
  ['unistd.h', 'HAVE_UNISTD_H'],
  ['valgrind/valgrind.h', 'HAVE_VALGRIND_VALGRIND_H'],
]

foreach h : check_headers
  if cc.has_header(h.get(0))
    cdata.set(h.get(1), 1)
  endif
endforeach

if cc.has_function('poll', prefix : '#include<poll.h>')
  cdata.set('HAVE_POLL', 1)
endif
if cc.has_function('pselect', prefix : '#include<sys/select.h>')
  cdata.set('HAVE_PSELECT', 1)
endif
cdata.set('HAVE_MMAP', 1)

if cc.has_function('posix_memalign', prefix : '#include<stdlib.h>')
  cdata.set('HAVE_POSIX_MEMALIGN', 1)
endif
if cc.has_function('getpagesize', prefix : '#include<unistd.h>')
  cdata.set('HAVE_GETPAGESIZE', 1)
endif
if cc.has_function('clock_gettime', prefix : '#include <time.h>')
  cdata.set('HAVE_CLOCK_GETTIME', 1)
endif

if cc.has_type('ptrdiff_t', prefix : '#include <stddef.h>')
  cdata.set('HAVE_PTRDIFF_T', 1)
endif

if cc.has_function('mkstemp', prefix : '#include <stdlib.h>')
  cdata.set('HAVE_MKSTEMP', 1)
endif

if cc.has_function('memfd_create', prefix : '#include <sys/mman.h>', args : [ '-D_GNU_SOURCE' ])
  cdata.set('HAVE_MEMFD_CREATE', 1)
endif

if get_option('systemd')
  systemd = dependency('systemd', required: false)
  systemd_dep = dependency('libsystemd', required: false)
  if systemd.found() and systemd_dep.found()
    cdata.set('HAVE_SYSTEMD_DAEMON', 1)
  else
    warning('Systemd integration was enabled, but systemd is not available')
  endif
endif

if get_option('bluez5')
  if get_option('bluez5-backend-native')
    cdata.set('HAVE_BLUEZ_5_BACKEND_NATIVE', 1)
  endif
  if get_option('bluez5-backend-ofono')
    cdata.set('HAVE_BLUEZ_5_BACKEND_OFONO', 1)
  endif
endif

configure_file(input : 'config.h.meson',
  output : 'config.h',
  configuration : cdata)

configinc = include_directories('.')
pipewire_inc = include_directories('src')

makedata = configuration_data()
  makedata.set('BUILD_ROOT', meson.build_root())
  makedata.set('VERSION', pipewire_version)
if version_arr.length() == 4
  makedata.set('TAG', 'HEAD')
else
  makedata.set('TAG', pipewire_version)
endif

configure_file(input : 'Makefile.in',
  output : 'Makefile',
  configuration : makedata)

# Find dependencies
mathlib = cc.find_library('m', required : false)
rt_lib = cc.find_library('rt', required : false) # clock_gettime
dl_lib = cc.find_library('dl', required : false)
pthread_lib = dependency('threads')
dbus_dep = dependency('dbus-1')
sdl_dep = dependency('sdl2', required : false)
sndfile_dep = dependency('sndfile', version : '>= 1.0.20', required : false)

if get_option('gstreamer') or get_option('pipewire-pulseaudio')
  glib_dep = dependency('glib-2.0', version : '>=2.32.0')
endif

if get_option('gstreamer')
  gobject_dep = dependency('gobject-2.0')
  gmodule_dep = dependency('gmodule-2.0')
  gio_dep = [dependency('gio-2.0'), dependency('gio-unix-2.0')]
  gst_dep = [dependency('gstreamer-1.0', version : '>= 1.10.0'),
             dependency('gstreamer-plugins-base-1.0'),
             dependency('gstreamer-video-1.0'),
             dependency('gstreamer-audio-1.0'),
             dependency('gstreamer-allocators-1.0'),]
endif

# On FreeBSD, epoll-shim library is required for eventfd() and timerfd()
epoll_shim_dep = (build_machine.system() == 'freebsd'
    ? dependency('epoll-shim', required: true)
    : dependency('', required: false))

alsa_dep = (get_option('pipewire-alsa')
    ? dependency('alsa', version : '>=1.1.7')
    : dependency('', required: false))

installed_tests_metadir = join_paths(pipewire_datadir, 'installed-tests', pipewire_name)
installed_tests_execdir = join_paths(pipewire_libexecdir, 'installed-tests', pipewire_name)
installed_tests_enabled = get_option('installed_tests')
installed_tests_template = files('template.test.in')

subdir('spa')
subdir('src')

if get_option('pipewire-jack')
  jack_dep = dependency('jack', version : '>= 1.9.10')
  subdir('pipewire-jack/src')
endif

if get_option('pipewire-pulseaudio')
  pulseaudio_dep = dependency('libpulse', version : '>= 11.1')
  subdir('pipewire-pulseaudio/src')
endif

if get_option('pipewire-alsa')
  subdir('pipewire-alsa/alsa-plugins')
  subdir('pipewire-alsa/conf')
endif

if get_option('docs')
  doxygen = find_program('doxygen', required : false)
  if doxygen.found()
    subdir('doc')
  else
    warning('Documentation was enabled, but doxygen is not available')
  endif
endif

if get_option('man')
  xmltoman = find_program('xmltoman', required : false)
  if xmltoman.found()
    subdir('man')
  else
    warning('Man page generation was enabled, but xmltoman is not available')
  endif
endif

setenv = find_program('pw-uninstalled.sh')
run_target('uninstalled', command : [setenv,
    '-b@0@'.format(meson.build_root()), '-v@0@'.format(pipewire_version)])