1project('pipewire', ['c' ], 2 version : '0.3.43', 3 license : [ 'MIT', 'LGPL-2.1-or-later', 'GPL-2.0-only' ], 4 meson_version : '>= 0.56.0', 5 default_options : [ 'warning_level=3', 6 'c_std=gnu99', 7 'cpp_std=c++17', 8 'b_pie=true', 9 #'b_sanitize=address,undefined', 10 'buildtype=debugoptimized' ]) 11 12pipewire_version = meson.project_version() 13version_arr = pipewire_version.split('.') 14pipewire_version_major = version_arr[0] 15pipewire_version_minor = version_arr[1] 16pipewire_version_micro = version_arr[2] 17if version_arr.length() == 4 18 pipewire_version_nano = version_arr[3] 19else 20 pipewire_version_nano = 0 21endif 22 23spaversion = '0.2' 24apiversion = '0.3' 25soversion = 0 26libversion = '@0@.@1@.0'.format(soversion, pipewire_version_minor.to_int() * 100 + pipewire_version_micro.to_int()) 27 28pipewire_name = 'pipewire-@0@'.format(apiversion) 29spa_name = 'spa-@0@'.format(spaversion) 30 31prefix = get_option('prefix') 32pipewire_bindir = prefix / get_option('bindir') 33pipewire_datadir = prefix / get_option('datadir') 34pipewire_libdir = prefix / get_option('libdir') 35pipewire_libexecdir = prefix / get_option('libexecdir') 36pipewire_localedir = prefix / get_option('localedir') 37pipewire_sysconfdir = prefix / get_option('sysconfdir') 38 39pipewire_configdir = pipewire_sysconfdir / 'pipewire' 40pipewire_confdatadir = pipewire_datadir / 'pipewire' 41modules_install_dir = pipewire_libdir / pipewire_name 42 43if host_machine.system() == 'linux' 44 # glibc ld.so interprets ${LIB} in a library loading path with an 45 # appropriate value for the current architecture, typically something 46 # like lib, lib64 or lib/x86_64-linux-gnu. 47 # This allows the same pw-jack script to work for both 32- and 64-bit 48 # applications on biarch/multiarch distributions, by setting something 49 # like LD_LIBRARY_PATH='/usr/${LIB}/pipewire-0.3/jack'. 50 # Note that ${LIB} is a special token expanded by the runtime linker, 51 # not an environment variable, and must be passed through literally. 52 modules_install_dir_dlopen = prefix / '${LIB}' / pipewire_name 53else 54 modules_install_dir_dlopen = modules_install_dir 55endif 56 57spa_plugindir = pipewire_libdir / spa_name 58spa_datadir = pipewire_datadir / spa_name 59 60alsadatadir = pipewire_datadir / 'alsa-card-profile' / 'mixer' 61 62pipewire_headers_dir = pipewire_name / 'pipewire' 63 64pkgconfig = import('pkgconfig') 65 66cc = meson.get_compiler('c') 67 68common_flags = [ 69 '-fvisibility=hidden', 70 '-Werror=suggest-attribute=format', 71 '-Wsign-compare', 72 '-Wpointer-arith', 73 '-Wpointer-sign', 74 '-Wformat', 75 '-Wformat-security', 76 '-Wimplicit-fallthrough', 77 '-Wmissing-braces', 78 '-Wtype-limits', 79 '-Wvariadic-macros', 80 '-Wno-missing-field-initializers', 81 '-Wno-unused-parameter', 82 '-Wno-pedantic', 83 '-Wold-style-declaration', 84 '-Wunused-result', 85] 86 87cc_flags = common_flags + [ 88 '-D_GNU_SOURCE', 89 '-DFASTPATH', 90# '-DSPA_DEBUG_MEMCPY', 91] 92add_project_arguments(cc.get_supported_arguments(cc_flags), language: 'c') 93 94have_cpp = add_languages('cpp', native: false, required : false) 95 96if have_cpp 97 cxx = meson.get_compiler('cpp') 98 cxx_flags = common_flags 99 add_project_arguments(cxx.get_supported_arguments(cxx_flags), language: 'cpp') 100endif 101 102sse_args = '-msse' 103sse2_args = '-msse2' 104ssse3_args = '-mssse3' 105sse41_args = '-msse4.1' 106fma_args = '-mfma' 107avx_args = '-mavx' 108avx2_args = '-mavx2' 109 110have_sse = cc.has_argument(sse_args) 111have_sse2 = cc.has_argument(sse2_args) 112have_ssse3 = cc.has_argument(ssse3_args) 113have_sse41 = cc.has_argument(sse41_args) 114have_fma = cc.has_argument(fma_args) 115have_avx = cc.has_argument(avx_args) 116have_avx2 = cc.has_argument(avx2_args) 117 118have_neon = false 119if host_machine.cpu_family() == 'aarch64' 120 if cc.compiles(''' 121 #include <arm_neon.h> 122 int main () { 123 float *s; 124 asm volatile( 125 " ld1 { v0.4s }, [%[s]], #16\n" 126 " fcvtzs v0.4s, v0.4s, #31\n" 127 : [s] "+r" (s) : :); 128 } 129 ''', 130 name : 'aarch64 Neon Support') 131 neon_args = [] 132 have_neon = true 133 134 endif 135elif cc.has_argument('-mfpu=neon') 136 if cc.compiles(''' 137 #include <arm_neon.h> 138 int main () { 139 float *s; 140 asm volatile( 141 " vld1.32 { q0 }, [%[s]]!\n" 142 " vcvt.s32.f32 q0, q0, #31\n" 143 : [s] "+r" (s) : :); 144 } 145 ''', 146 args: '-mfpu=neon', 147 name : 'arm Neon Support') 148 neon_args = ['-mfpu=neon'] 149 have_neon = true 150 endif 151endif 152 153libatomic = cc.find_library('atomic', required : false) 154 155test_8_byte_atomic = ''' 156#include <stdint.h> 157 158int main(void) 159{ 160 int64_t eight; 161 __atomic_fetch_add(&eight, 123, __ATOMIC_SEQ_CST); 162 return 0; 163} 164''' 165 166# We currently assume that libatomic is unnecessary for 4-byte atomic 167# operations on any reasonable architecture. 168if cc.links( 169 test_8_byte_atomic, 170 name : '8-byte __atomic_fetch_add without libatomic') 171 atomic_dep = dependency('', required: false) 172elif cc.links( 173 test_8_byte_atomic, 174 dependencies : libatomic, 175 name : '8-byte __atomic_fetch_add with libatomic') 176 atomic_dep = libatomic 177else 178 error('8-byte atomic operations are required') 179endif 180 181versiondata = configuration_data() 182versiondata.set('PIPEWIRE_VERSION_MAJOR', pipewire_version_major) 183versiondata.set('PIPEWIRE_VERSION_MINOR', pipewire_version_minor) 184versiondata.set('PIPEWIRE_VERSION_MICRO', pipewire_version_micro) 185versiondata.set('PIPEWIRE_VERSION_NANO', pipewire_version_nano) 186versiondata.set_quoted('PIPEWIRE_API_VERSION', apiversion) 187 188cdata = configuration_data() 189cdata.set_quoted('PIPEWIRE_CONFDATADIR', pipewire_confdatadir) 190cdata.set_quoted('LOCALEDIR', pipewire_localedir) 191cdata.set_quoted('LIBDIR', pipewire_libdir) 192cdata.set_quoted('GETTEXT_PACKAGE', meson.project_name()) 193cdata.set_quoted('PACKAGE', 'pipewire') 194cdata.set_quoted('PACKAGE_NAME', 'PipeWire') 195cdata.set_quoted('PACKAGE_STRING', 'PipeWire @0@'.format(pipewire_version)) 196cdata.set_quoted('PACKAGE_TARNAME', 'pipewire') 197cdata.set_quoted('PACKAGE_URL', 'https://pipewire.org') 198cdata.set_quoted('PACKAGE_VERSION', pipewire_version) 199cdata.set_quoted('MODULEDIR', modules_install_dir) 200cdata.set_quoted('PIPEWIRE_CONFIG_DIR', pipewire_configdir) 201cdata.set_quoted('PLUGINDIR', spa_plugindir) 202cdata.set_quoted('SPADATADIR', spa_datadir) 203# FIXME: --with-memory-alignment],[8,N,malloc,pagesize (default is 32)]) option 204cdata.set('MEMORY_ALIGNMENT_MALLOC', 1) 205cdata.set_quoted('PA_ALSA_PATHS_DIR', alsadatadir / 'paths') 206cdata.set_quoted('PA_ALSA_PROFILE_SETS_DIR', alsadatadir / 'profile-sets') 207 208if host_machine.endian() == 'big' 209 cdata.set('WORDS_BIGENDIAN', 1) 210endif 211 212check_headers = [['dlfcn.h','HAVE_DLFCN_H'], 213 ['inttypes.h', 'HAVE_INTTYPES_H'], 214 ['memory.h', 'HAVE_MEMORY_H'], 215 ['poll.h', 'HAVE_POLL_H'], 216 ['stddef.h', 'HAVE_STDDEF_H'], 217 ['stdint.h', 'HAVE_STDINT_H'], 218 ['stdio_ext.h', 'HAVE_STDIO_EXT_H'], 219 ['strings.h', 'HAVE_STRINGS_H'], 220 ['string.h', 'HAVE_STRING_H'], 221 ['sys/mount.h', 'HAVE_SYS_MOUNT_H'], 222 ['sys/param.h', 'HAVE_SYS_PARAM_H'], 223 ['sys/poll.h', 'HAVE_SYS_POLL_H'], 224 ['sys/prctl.h', 'HAVE_SYS_PRCTL_H'], 225 ['sys/random.h', 'HAVE_SYS_RANDOM_H'], 226 ['sys/socket.h', 'HAVE_SYS_SOCKET_H'], 227 ['sys/stat.h', 'HAVE_SYS_STAT_H'], 228 ['sys/times.h', 'HAVE_SYS_TIMES_H'], 229 ['sys/time.h', 'HAVE_SYS_TIME_H'], 230 ['sys/types.h', 'HAVE_SYS_TYPES_H'], 231 ['sys/utsname.h', 'HAVE_SYS_UTSNAME_H'], 232 ['sys/vfs.h', 'HAVE_SYS_VFS_H'], 233 ['sys/wait.h', 'HAVE_SYS_WAIT_H'], 234 ['pwd.h', 'HAVE_PWD_H'], 235 ['ucontext.h', 'HAVE_UCONTEXT_H'], 236 ['unistd.h', 'HAVE_UNISTD_H'], 237] 238 239foreach h : check_headers 240 if cc.has_header(h.get(0)) 241 cdata.set(h.get(1), 1) 242 endif 243endforeach 244 245if cc.has_function('poll', prefix : '#include<poll.h>') 246 cdata.set('HAVE_POLL', 1) 247endif 248if cc.has_function('pselect', prefix : '#include<sys/select.h>') 249 cdata.set('HAVE_PSELECT', 1) 250endif 251cdata.set('HAVE_MMAP', 1) 252 253if cc.has_function('posix_memalign', prefix : '#include<stdlib.h>') 254 cdata.set('HAVE_POSIX_MEMALIGN', 1) 255endif 256if cc.has_function('getpagesize', prefix : '#include<unistd.h>') 257 cdata.set('HAVE_GETPAGESIZE', 1) 258endif 259if cc.has_function('gettid', prefix : '#include<unistd.h>', args: [ '-D_GNU_SOURCE' ]) 260 cdata.set('HAVE_GETTID', 1) 261endif 262if cc.has_function('clock_gettime', prefix : '#include <time.h>') 263 cdata.set('HAVE_CLOCK_GETTIME', 1) 264endif 265 266if cc.has_type('ptrdiff_t', prefix : '#include <stddef.h>') 267 cdata.set('HAVE_PTRDIFF_T', 1) 268endif 269 270if cc.has_header_symbol('string.h', 'strndupa', args : [ '-D_GNU_SOURCE' ]) 271 cdata.set('HAVE_STRNDUPA', 1) 272endif 273 274if cc.has_function('mkstemp', prefix : '#include <stdlib.h>') 275 cdata.set('HAVE_MKSTEMP', 1) 276endif 277 278if cc.has_function('memfd_create', prefix : '#include <sys/mman.h>', args : [ '-D_GNU_SOURCE' ]) 279 cdata.set('HAVE_MEMFD_CREATE', 1) 280endif 281 282if cc.has_function('getrandom', prefix : '#include <stddef.h>\n#include <sys/random.h>', args : [ '-D_GNU_SOURCE' ]) 283 cdata.set('HAVE_GETRANDOM', 1) 284endif 285 286if cc.has_function('sigabbrev_np', prefix : '#include <string.h>', args : [ '-D_GNU_SOURCE' ]) 287 cdata.set('HAVE_SIGABBREV_NP', 1) 288endif 289 290if cc.get_define('SYS_pidfd_open', prefix : '#include <sys/syscall.h>') != '' 291 cdata.set('HAVE_PIDFD_OPEN', 1) 292endif 293 294systemd = dependency('systemd', required: get_option('systemd')) 295systemd_dep = dependency('libsystemd',required: get_option('systemd')) 296summary({'systemd conf data': systemd.found()}, bool_yn: true) 297summary({'libsystemd': systemd_dep.found()}, bool_yn: true) 298if systemd.found() and systemd_dep.found() 299 cdata.set('HAVE_SYSTEMD', 1) 300endif 301 302configinc = include_directories('.') 303includes_inc = include_directories('include') 304pipewire_inc = include_directories('src') 305 306makedata = configuration_data() 307makedata.set('BUILD_ROOT', meson.project_build_root()) 308makedata.set('SOURCE_ROOT', meson.project_source_root()) 309makedata.set('VERSION', pipewire_version) 310if version_arr.length() == 4 311 makedata.set('TAG', 'HEAD') 312else 313 makedata.set('TAG', pipewire_version) 314endif 315 316configure_file(input : 'Makefile.in', 317 output : 'Makefile', 318 configuration : makedata) 319 320# Find dependencies 321mathlib = cc.find_library('m', required : false) 322rt_lib = cc.find_library('rt', required : false) # clock_gettime 323dl_lib = cc.find_library('dl', required : false) 324pthread_lib = dependency('threads') 325dbus_dep = dependency('dbus-1', required : get_option('dbus')) 326summary({'dbus (Bluetooth, rtkit, portal, pw-reserve)': dbus_dep.found()}, bool_yn: true, section: 'Misc dependencies') 327if dbus_dep.found() 328 cdata.set('HAVE_DBUS', 1) 329endif 330sdl_dep = dependency('sdl2', required : get_option('sdl2')) 331summary({'SDL 2': sdl_dep.found()}, bool_yn: true, section: 'Misc dependencies') 332drm_dep = dependency('libdrm', required : false) 333readline_dep = dependency('readline', required : false) 334 335if not readline_dep.found() 336 readline_dep = cc.find_library('readline', required: false) 337endif 338 339summary({'readline (for pw-cli)': readline_dep.found()}, bool_yn: true, section: 'Misc dependencies') 340ncurses_dep = dependency('ncursesw', required : false) 341sndfile_dep = dependency('sndfile', version : '>= 1.0.20', required : get_option('sndfile')) 342summary({'sndfile': sndfile_dep.found()}, bool_yn: true, section: 'pw-cat/pw-play/pw-dump/filter-chain') 343if sndfile_dep.found() 344 cdata.set('HAVE_SNDFILE', 1) 345endif 346pulseaudio_dep = dependency('libpulse', required : get_option('libpulse')) 347summary({'libpulse': pulseaudio_dep.found()}, bool_yn: true, section: 'Streaming between daemons') 348avahi_dep = dependency('avahi-client', required : get_option('avahi')) 349summary({'Avahi DNS-SD (Zeroconf)': avahi_dep.found()}, bool_yn: true, 350 section: 'Streaming between daemons') 351 352libusb_dep = dependency('libusb-1.0', required : get_option('libusb')) 353summary({'libusb (Bluetooth quirks)': libusb_dep.found()}, bool_yn: true, section: 'Backend') 354if libusb_dep.found() 355 cdata.set('HAVE_LIBUSB', 1) 356endif 357 358cap_lib = dependency('libcap', required : false) 359if cap_lib.found() 360 cdata.set('HAVE_LIBCAP', 1) 361endif 362 363gst_option = get_option('gstreamer') 364gst_deps_def = { 365 'glib-2.0': {'version': '>=2.32.0'}, 366 'gobject-2.0': {}, 367 'gmodule-2.0': {}, 368 'gio-2.0': {}, 369 'gio-unix-2.0': {}, 370 'gstreamer-1.0': {'version': '>= 1.10.0'}, 371 'gstreamer-plugins-base-1.0': {}, 372 'gstreamer-video-1.0': {}, 373 'gstreamer-audio-1.0': {}, 374 'gstreamer-allocators-1.0': {}, 375} 376 377gst_dep = [] 378foreach depname, kwargs: gst_deps_def 379 dep = dependency(depname, required: gst_option, kwargs: kwargs) 380 summary({depname: dep.found()}, bool_yn: true, section: 'GStreamer modules') 381 if not dep.found() 382 # Beware, there's logic below depending on the array clear here! 383 gst_dep = [] 384 if get_option('gstreamer-device-provider').enabled() 385 error('`gstreamer-device-provider` is enabled but `@0@` was not found.'.format(depname)) 386 endif 387 break 388 endif 389 gst_dep += [dep] 390endforeach 391 392# This code relies on the array being empty if any dependency was not found 393gst_dp_found = gst_dep.length() > 0 394summary({'gstreamer-device-provider': gst_dp_found}, bool_yn: true, section: 'Backend') 395 396if not get_option('gstreamer-device-provider').disabled() 397 cdata.set('HAVE_GSTREAMER_DEVICE_PROVIDER', 1) 398endif 399 400webrtc_dep = dependency('webrtc-audio-processing', 401 version : ['>= 0.2', '< 1.0'], 402 required : get_option('echo-cancel-webrtc')) 403summary({'WebRTC Echo Canceling': webrtc_dep.found()}, bool_yn: true, section: 'Misc dependencies') 404 405if webrtc_dep.found() 406 cdata.set('HAVE_WEBRTC', 1) 407endif 408 409# On FreeBSD, epoll-shim library is required for eventfd() and timerfd() 410epoll_shim_dep = (build_machine.system() == 'dragonfly' 411 ? dependency('epoll-shim', required: true) 412 : dependency('', required: false)) 413 414libinotify_dep = (build_machine.system() == 'dragonfly' 415 ? dependency('libinotify', required: true) 416 : dependency('', required: false)) 417 418# On FreeBSD, libintl library is required for gettext 419libintl_dep = dependency('intl', required: false) 420 421if not libintl_dep.found() 422 libintl_dep = cc.find_library('intl', required: false) 423endif 424summary({'intl support': libintl_dep.found()}, bool_yn: true) 425 426need_alsa = get_option('pipewire-alsa').enabled() or 'media-session' in get_option('session-managers') 427alsa_dep = dependency('alsa', version : '>=1.1.7', required: need_alsa) 428summary({'pipewire-alsa': alsa_dep.found()}, bool_yn: true) 429 430if build_machine.system() == 'dragonfly' 431# On FreeBSD the OpenSSL library may come from base or a package. 432# Check for a package first and fallback to the base library if we can't find it via pkgconfig 433 openssl_lib = dependency('openssl', required: false) 434 if not openssl_lib.found() 435 openssl_lib = declare_dependency(link_args : [ '-lssl', '-lcrypto']) 436 endif 437else 438 openssl_lib = dependency('openssl', required: get_option('raop')) 439endif 440summary({'OpenSSL (for raop-sink)': openssl_lib.found()}, bool_yn: true) 441 442lilv_lib = dependency('lilv-0', required: get_option('lv2')) 443summary({'lilv (for lv2 plugins)': lilv_lib.found()}, bool_yn: true) 444if lilv_lib.found() 445 cdata.set('HAVE_LILV', 1) 446endif 447 448installed_tests_metadir = pipewire_datadir / 'installed-tests' / pipewire_name 449installed_tests_execdir = pipewire_libexecdir / 'installed-tests' / pipewire_name 450installed_tests_enabled = not get_option('installed_tests').disabled() 451installed_tests_template = files('template.test.in') 452 453if not get_option('tests').disabled() 454 gstack = find_program('gstack', required : false) 455 cdata.set10('HAVE_GSTACK', gstack.found()) 456endif 457 458subdir('po') 459subdir('spa') 460subdir('src') 461 462if not get_option('tests').disabled() 463 subdir('test') 464endif 465 466configure_file(output : 'config.h', 467 configuration : cdata) 468 469if not get_option('pipewire-jack').disabled() 470 subdir('pipewire-jack') 471endif 472if not get_option('pipewire-v4l2').disabled() 473 subdir('pipewire-v4l2') 474endif 475 476if alsa_dep.found() 477 subdir('pipewire-alsa/alsa-plugins') 478 subdir('pipewire-alsa/conf') 479 subdir('pipewire-alsa/tests') 480endif 481 482doxygen = find_program('doxygen', required : get_option('docs')) 483if doxygen.found() 484 subdir('doc') 485endif 486 487if not get_option('man').disabled() 488 rst2man = find_program('rst2man', required: false) 489 if not rst2man.found() 490 rst2man = find_program('rst2man.py', required: get_option('man')) 491 endif 492 summary({'Manpage generation': rst2man.found()}, bool_yn: true) 493 if rst2man.found() 494 subdir('man') 495 endif 496endif 497 498setenv = find_program('pw-uninstalled.sh') 499run_target('pw-uninstalled', 500 command : [setenv, 501 '-b@0@'.format(meson.project_build_root()), 502 '-v@0@'.format(pipewire_version)] 503) 504 505if meson.version().version_compare('>=0.58.0') 506 devenv = environment() 507 508 builddir = meson.project_build_root() 509 srcdir = meson.project_source_root() 510 511 devenv.set('PIPEWIRE_CONFIG_DIR', pipewire_dep.get_variable(internal: 'confdatadir')) 512 devenv.set('PIPEWIRE_MODULE_DIR', pipewire_dep.get_variable(internal: 'moduledir')) 513 514 devenv.set('SPA_PLUGIN_DIR', spa_dep.get_variable(internal: 'plugindir')) 515 devenv.set('SPA_DATA_DIR', spa_dep.get_variable(internal: 'datadir')) 516 517 devenv.set('GST_PLUGIN_PATH', builddir / 'src'/ 'gst') 518 519 devenv.set('ALSA_PLUGIN_DIR', builddir / 'pipewire-alsa' / 'alsa-plugins') 520 devenv.set('ACP_PATHS_DIR', srcdir / 'spa' / 'plugins' / 'alsa' / 'mixer' / 'paths') 521 devenv.set('ACP_PROFILES_DIR', srcdir / 'spa' / 'plugins' / 'alsa' / 'mixer' / 'profile-sets') 522 523 devenv.set('LD_LIBRARY_PATH', builddir / 'pipewire-jack' / 'src') 524 525 devenv.set('PW_UNINSTALLED', '1') 526 527 meson.add_devenv(devenv) 528endif 529