meson.build 26.7 KB
Newer Older
1
project('pulseaudio', 'c', 'cpp',
2
        version : run_command(find_program('git-version-gen'), join_paths(meson.current_source_dir(), '.tarball-version')).stdout().strip(),
3
        meson_version : '>= 0.50.0',
4 5 6
        default_options : [ 'c_std=gnu11', 'cpp_std=c++11' ]
        )

7 8 9 10 11 12
pa_version_str = meson.project_version()
# For tarballs, the first split will do nothing, but for builds in git, we
# split out suffixes when there are commits since the last tag
# (e.g.: v11.99.1-3-gad14bdb24 -> v11.99.1)
version_split = pa_version_str.split('-')[0].split('.')
pa_version_major = version_split[0].split('v')[0]
13
pa_version_minor = version_split[1]
14 15 16 17 18
if version_split.length() > 2
  pa_version_micro = version_split[2]
else
  pa_version_micro = '0'
endif
19 20 21
pa_version_major_minor = pa_version_major + '.' + pa_version_minor

pa_api_version = 12
22
pa_protocol_version = 33
23

24 25
# The stable ABI for client applications, for the version info x:y:z
# always will hold y=z
26
libpulse_version_info = [21, 1, 21]
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

# A simplified, synchronous, ABI-stable interface for client
# applications, for the version info x:y:z always will hold y=z
libpulse_simple_version_info = [1, 1, 1]

# The ABI-stable GLib adapter for client applications, for the version
# info x:y:z always will hold y=z
libpulse_mainloop_glib_version_info = [0, 5, 0]

libpulse_version = '@0@.@1@.@2@'.format(
  libpulse_version_info[0] - libpulse_version_info[2],
  libpulse_version_info[0],
  libpulse_version_info[1],
)

libpulse_simple_version = '@0@.@1@.@2@'.format(
  libpulse_simple_version_info[0] - libpulse_simple_version_info[2],
  libpulse_simple_version_info[0],
  libpulse_simple_version_info[1],
)

libpulse_mainloop_glib_version = '@0@.@1@.@2@'.format(
  libpulse_mainloop_glib_version_info[0] - libpulse_mainloop_glib_version_info[2],
  libpulse_mainloop_glib_version_info[0],
  libpulse_mainloop_glib_version_info[1],
)
53

54 55
# Paths

56
prefix = get_option('prefix')
57
assert(prefix.startswith('/'), 'Prefix is not absolute: "@0@"'.format(prefix))
58

59
bindir = join_paths(prefix, get_option('bindir'))
60
includedir = join_paths(prefix, get_option('includedir'))
61
libdir = join_paths(prefix, get_option('libdir'))
62
libexecdir = join_paths(prefix, get_option('libexecdir'))
Arnaud Rebillout's avatar
Arnaud Rebillout committed
63
mandir = join_paths(prefix, get_option('mandir'))
64
datadir = join_paths(prefix, get_option('datadir'))
65
localedir = join_paths(prefix, get_option('localedir'))
66 67
localstatedir = join_paths(prefix, get_option('localstatedir'))
sysconfdir = join_paths(prefix, get_option('sysconfdir'))
68
privlibdir = join_paths(libdir, 'pulseaudio')
69
alsadatadir = join_paths(datadir, 'pulseaudio', 'alsa-mixer')
70

71
pkgconfigdir = join_paths(libdir, 'pkgconfig')
72
pulselibexecdir = join_paths(libexecdir, 'pulse')
73
pulsesysconfdir = join_paths(sysconfdir, 'pulse')
74

75 76 77 78 79
modlibexecdir = get_option('modlibexecdir')
if modlibexecdir == ''
  modlibexecdir = join_paths(libdir, 'pulse-' + pa_version_major_minor, 'modules')
endif

80 81 82 83 84 85 86 87
padsplibdir = get_option('padsplibdir')
if padsplibdir == ''
  padsplibdir = privlibdir
endif

pulsedsp_location = get_option('pulsedsp-location')
if pulsedsp_location == ''
  pulsedsp_location = join_paths(prefix, padsplibdir)
88 89
endif

90 91 92
systemduserunitdir = get_option('systemduserunitdir')
# the default value is set below

93 94
udevrulesdir = get_option('udevrulesdir')
if udevrulesdir == ''
Arnaud Rebillout's avatar
Arnaud Rebillout committed
95 96
  # absolute path, otherwise meson prepends the prefix
  udevrulesdir = '/lib/udev/rules.d'
97 98
endif

Arnaud Rebillout's avatar
Arnaud Rebillout committed
99 100
vapidir = join_paths(datadir, 'vala', 'vapi')

101 102 103 104 105 106 107 108 109 110 111 112 113 114 115
bashcompletiondir = get_option('bashcompletiondir')
if bashcompletiondir == ''
  bash_completion_dep = dependency('bash-completion', required : false)
  if bash_completion_dep.found()
    bashcompletiondir = bash_completion_dep.get_pkgconfig_variable('completionsdir')
  else
    bashcompletiondir = join_paths(datadir, 'bash-completion', 'completions')
  endif
endif

zshcompletiondir = get_option('zshcompletiondir')
if zshcompletiondir == ''
  zshcompletiondir = join_paths(datadir, 'zsh', 'site-functions')
endif

116 117
# Configuration data

118 119 120 121 122
cc = meson.get_compiler('c')

cdata = configuration_data()
cdata.set_quoted('PACKAGE', 'pulseaudio')
cdata.set_quoted('PACKAGE_NAME', 'pulseaudio')
123
cdata.set_quoted('PACKAGE_VERSION', pa_version_str)
124
cdata.set_quoted('CANONICAL_HOST', host_machine.cpu())
125 126 127 128
cdata.set('PA_MAJOR', pa_version_major)
cdata.set('PA_MINOR', pa_version_minor)
cdata.set('PA_API_VERSION', pa_api_version)
cdata.set('PA_PROTOCOL_VERSION', pa_protocol_version)
129 130 131 132 133
cdata.set_quoted('PA_MACHINE_ID', join_paths(sysconfdir, 'machine-id'))
cdata.set_quoted('PA_MACHINE_ID_FALLBACK', join_paths(localstatedir, 'lib', 'dbus', 'machine-id'))
cdata.set_quoted('PA_SRCDIR', join_paths(meson.current_source_dir(), 'src'))
cdata.set_quoted('PA_BUILDDIR', meson.current_build_dir())
cdata.set_quoted('PA_SOEXT', '.so')
134
cdata.set_quoted('PA_DEFAULT_CONFIG_DIR', pulsesysconfdir)
135
cdata.set_quoted('PA_BINARY', join_paths(bindir, 'pulseaudio'))
136 137 138
cdata.set_quoted('PA_SYSTEM_RUNTIME_PATH', join_paths(localstatedir, 'run', 'pulse'))
cdata.set_quoted('PA_SYSTEM_CONFIG_PATH', join_paths(localstatedir, 'lib', 'pulse'))
cdata.set_quoted('PA_SYSTEM_STATE_PATH', join_paths(localstatedir, 'lib', 'pulse'))
139
cdata.set_quoted('PA_DLSEARCHPATH', modlibexecdir)
140 141 142 143
cdata.set_quoted('PA_SYSTEM_USER', get_option('system_user'))
cdata.set_quoted('PA_SYSTEM_GROUP', get_option('system_group'))
cdata.set_quoted('PA_ACCESS_GROUP', get_option('access_group'))
cdata.set_quoted('PA_CFLAGS', 'Not yet supported on meson')
144 145
cdata.set_quoted('PA_ALSA_PATHS_DIR', join_paths(alsadatadir, 'paths'))
cdata.set_quoted('PA_ALSA_PROFILE_SETS_DIR', join_paths(alsadatadir, 'profile-sets'))
146
cdata.set_quoted('DESKTOPFILEDIR', join_paths(datadir, 'applications'))
147 148 149
cdata.set_quoted('PULSE_LOCALEDIR', localedir)
cdata.set_quoted('GETTEXT_PACKAGE', 'pulseaudio')
cdata.set('ENABLE_NLS', 1)
150

151
# Platform specifics
152 153 154
# First some defaults to keep config file generation happy
cdata.set('HAVE_COREAUDIO', 0)
cdata.set('HAVE_WAVEOUT', 0)
155 156 157 158 159 160 161 162 163 164 165 166 167 168 169
# FIXME: This was not tested. Maybe some flags should better be CFLAGS,
# rather than ending up in the config.h file?
if host_machine.system() == 'darwin'
  cdata.set('OS_IS_DARWIN', 1)
  cdata.set('_DARWIN_C_SOURCE', '200112L') # Needed to get NSIG on Mac OS
elif host_machine.system() == 'windows'
  cdata.set('OS_IS_WIN32', 1)
  cdata.set('WIN32_LEAN_AND_MEAN', 1) # Needed to avoid including unnecessary headers on Windows
#elif host_machine.system() == 'solaris'
#  # Apparently meson has no solaris support?
#  # Needed to get declarations for msg_control and msg_controllen on Solaris
#  cdata.set('_XOPEN_SOURCE', 600)
#  cdata.set('__EXTENSIONS__', 1)
endif

170 171 172 173
if cc.has_type('_Bool')
  cdata.set('HAVE_STD_BOOL', 1)
endif

174 175 176 177
if host_machine.cpu_family() == 'x86_64' or cc.sizeof('void *') >= 8
  cdata.set('HAVE_FAST_64BIT_OPERATIONS', 1)
endif

178 179 180 181
# Headers

check_headers = [
  'arpa/inet.h',
182
  'byteswap.h',
183
  'cpuid.h',
184
  'dlfcn.h',
185
  'execinfo.h',
186 187
  'grp.h',
  'langinfo.h',
188
  'linux/sockios.h',
189 190 191 192 193 194 195 196 197 198 199
  'locale.h',
  'netdb.h',
  'netinet/in.h',
  'netinet/in_systm.h',
  'netinet/ip.h',
  'netinet/tcp.h',
  'pcreposix.h',
  'poll.h',
  'pwd.h',
  'regex.h',
  'sched.h',
200
  'stdint.h',
201
  'sys/atomic.h',
202
  'sys/capability.h',
203
  'sys/conf.h',
204
  'sys/dl.h',
205
  'sys/eventfd.h',
206
  'sys/filio.h',
207
  'sys/ioctl.h',
208 209 210 211 212
  'sys/mman.h',
  'sys/prctl.h',
  'sys/resource.h',
  'sys/select.h',
  'sys/socket.h',
213 214
  'sys/syscall.h',
  'sys/uio.h',
215
  'sys/un.h',
216
  'sys/wait.h',
217
  'syslog.h',
218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233
  'valgrind/memcheck.h',
  'xlocale.h',
]

foreach h : check_headers
  if cc.has_header(h)
    define = 'HAVE_' + h.underscorify().to_upper()
    cdata.set(define, 1)
  endif
endforeach

# FIXME: move this to the above set
if cc.has_header('pthread.h')
  cdata.set('HAVE_PTHREAD', 1)
endif

234 235 236 237
if cc.has_header_symbol('pthread.h', 'PTHREAD_PRIO_INHERIT')
  cdata.set('HAVE_PTHREAD_PRIO_INHERIT', 1)
endif

238 239 240 241 242
# Functions

check_functions = [
  'accept4',
  'clock_gettime',
243
  'ctime_r',
244 245 246 247 248
  'fchmod',
  'fchown',
  'fork',
  'fstat',
  'getaddrinfo',
249
  'getgrgid_r',
250
  'getgrnam_r',
251
  'getpwnam_r',
252
  'getpwuid_r',
253 254
  'gettimeofday',
  'getuid',
255
  'lrintf',
256 257
  'lstat',
  'memfd_create',
258
  'mkfifo',
259 260
  'mlock',
  'nanosleep',
261
  'open64',
262 263 264
  'paccept',
  'pipe',
  'pipe2',
265
  'posix_fadvise',
266
  'posix_madvise',
267 268
  'posix_memalign',
  'ppoll',
269 270 271
  'readlink',
  'setegid',
  'seteuid',
272
  'setpgid',
273 274 275
  'setregid',
  'setresgid',
  'setresuid',
276
  'setreuid',
277 278 279
  'setsid',
  'sig2str',
  'sigaction',
280
  'strerror_r',
281
  'strtod_l',
282
  'strtof',
283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298
  'symlink',
  'sysconf',
  'uname',
]

foreach f : check_functions
  if cc.has_function(f)
    define = 'HAVE_' + f.underscorify().to_upper()
    cdata.set(define, 1)
  endif
endforeach

if cc.has_function('SYS_memfd_create', prefix : '#include <sys/syscall.h>')
  cdata.set('HAVE_MEMFD', 1)
endif

299 300 301 302 303 304 305 306 307 308 309 310 311
# Symbols

if cc.has_header_symbol('signal.h', 'SIGXCPU')
  cdata.set('HAVE_SIGXCPU', 1)
endif

if not cc.has_header_symbol('netinet/in.h', 'INADDR_NONE')
  if not cc.has_header_symbol('winsock2.h', 'INADDR_NONE')
    # Define INADDR_NONE if not found (Solaris)
    cdata.set('INADDR_NONE', '0xffffffff')
  endif
endif

312 313 314 315 316 317 318 319 320 321 322 323 324 325
check_decls = [
  [ 'environ', 'unistd.h', '#define _GNU_SOURCE' ],
  [ 'SOUND_PCM_READ_RATE', 'sys/soundcard.h', '' ],
  [ 'SOUND_PCM_READ_CHANNELS', 'sys/soundcard.h', '' ],
  [ 'SOUND_PCM_READ_BITS', 'sys/soundcard.h', '' ],
]

foreach s : check_decls
  if cc.has_header_symbol(s[1], s[0], prefix : s[2])
    define = 'HAVE_DECL_' + s[0].to_upper()
    cdata.set(define, 1)
  endif
endforeach

326 327 328 329 330 331 332 333 334 335
# Types

# FIXME: do we ever care about gid_t not being defined / smaller than an int?
cdata.set('GETGROUPS_T', 'gid_t')

# Include paths

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

336
# CFLAGS/LDFLAGS
337 338 339 340 341

pa_c_args = ['-DHAVE_CONFIG_H', '-D_GNU_SOURCE']
server_c_args = ['-D__INCLUDED_FROM_PULSE_AUDIO']
cdata.set('MESON_BUILD', 1)

342 343 344 345 346
# On ELF systems we don't want the libraries to be unloaded since we don't clean them up properly,
# so we request the nodelete flag to be enabled.
# On other systems, we don't really know how to do that, but it's welcome if somebody can tell.
nodelete_link_args = ['-Wl,-z,nodelete']

Arnaud Rebillout's avatar
Arnaud Rebillout committed
347 348 349 350 351 352 353
# Code coverage

if get_option('gcov')
  add_project_arguments('--coverage', language: ['c', 'cpp'])
  add_project_link_arguments('--coverage', language: ['c', 'cpp'])
endif

354 355 356
# Core Dependencies

libm_dep = cc.find_library('m', required : true)
357

358
thread_dep = dependency('threads')
359 360 361 362 363 364 365 366 367 368 369
foreach f : [
  'pthread_getname_np',
  'pthread_setaffinity_np',
  'pthread_setname_np',
]
  if cc.has_function(f, dependencies : thread_dep)
    define = 'HAVE_' + f.underscorify().to_upper()
    cdata.set(define, 1)
  endif
endforeach

370 371
cap_dep = cc.find_library('cap', required : false)

372 373 374 375 376
shm_dep = cc.find_library('rt', required : false)
if shm_dep.found()
  cdata.set('HAVE_SHM_OPEN', 1)
endif

377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400
dl_dep = cc.find_library('dl', required : false)
if dl_dep.found()
  cdata.set('HAVE_DLADDR', 1)
endif

have_iconv = false
if cc.has_function('iconv_open')
  iconv_dep = dependency('', required : false)
  have_iconv = true
else
  iconv_dep = cc.find_library('iconv', required : false)
  have_iconv = iconv_dep.found()
endif
if have_iconv
  cdata.set('HAVE_ICONV', 1)
  iconvconsttest = '''#include <iconv.h>
size_t iconv (iconv_t cd, char * *inbuf, size_t *inbytesleft, char * *outbuf, size_t *outbytesleft);
'''
  if cc.compiles(iconvconsttest, dependencies : iconv_dep)
    cdata.set('ICONV_CONST', '')
  else
    cdata.set('ICONV_CONST', 'const')
  endif
endif
401

402 403 404 405 406 407 408 409
# Atomic operations

if get_option('atomic-arm-memory-barrier')
    cdata.set('ATOMIC_ARM_MEMORY_BARRIER_ENABLED', 1)
endif

need_libatomic_ops = false

410 411 412 413 414
atomictest = '''void func() {
  volatile int atomic = 2;
  __sync_bool_compare_and_swap (&atomic, 2, 3);
}
'''
415

416
if cc.compiles(atomictest)
417 418
  cdata.set('HAVE_ATOMIC_BUILTINS', 1)

419 420 421 422 423 424 425
  newatomictest = '''void func() {
    int c = 0;
    __atomic_store_n(&c, 4, __ATOMIC_SEQ_CST);
  }
  '''

  if(cc.compiles(newatomictest))
426
    cdata.set('HAVE_ATOMIC_BUILTINS_MEMORY_MODEL', 1)
427 428
  endif

429 430 431 432
elif host_machine.cpu_family() == 'arm'
  if host_machine.system() == 'linux' and get_option('atomic-arm-linux-helpers')
    cdata.set('ATOMIC_ARM_LINUX_HELPERS', 1)
  else
433
    armatomictest = '''int func() {
434 435
      volatile int a=0;
      int o=0, n=1, r;
436 437 438 439 440 441
      asm volatile (
	      "ldrex    %0, [%1]\n"
	      "subs  %0, %0, %2\n"
	      "strexeq %0, %3, [%1]\n"
	      : "=&r" (r)
	      : "r" (&a), "Ir" (o), "r" (n)
442 443
      : "cc");
      return (a==1 ? 0 : -1);
444
    }
445 446
    '''

447
    if cc.compiles(armatomictest)
448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467
      cdata.set('ATOMIC_ARM_INLINE_ASM', 1)
    else
      need_libatomic_ops = true
    endif
  endif # arm && !linux

elif not ['freebsd', 'netbsd'].contains(host_machine.system())
  need_libatomic_ops = true
endif # !atomic helpers && !arm

if need_libatomic_ops
  assert(cc.has_header('atomic_ops.h'), 'Need libatomic_ops')

  cdata.set('AO_REQUIRE_CAS', 1)

  if host_machine.system() != 'windows'
    libatomic_ops_dep = cc.find_library('atomic_ops', required : true)
  else
    libatomic_ops_dep = dependency('', required: false)
  endif
468
else
469
  libatomic_ops_dep = dependency('', required: false)
470 471
endif

472 473 474
# ARM checks
# ARMV6 instructions we need
if host_machine.cpu_family() == 'arm'
475
  armv6test = '''int func() {
476 477 478 479 480 481 482 483 484 485 486 487
    volatile int a = -60000, b = 0xaaaabbbb, c = 0xccccdddd;
    asm volatile ("ldr r0, %2 \n"
                  "ldr r2, %3 \n"
                  "ldr r3, %4 \n"
                  "ssat r1, #8, r0 \n"
                  "str r1, %0 \n"
                  "pkhbt r1, r3, r2, LSL #8 \n"
                  "str r1, %1 \n"
                  : "=m" (a), "=m" (b)
                  : "m" (a), "m" (b), "m" (c)
                  : "r0", "r1", "r2", "r3", "cc");
    return (a == -128 && b == 0xaabbdddd) ? 0 : -1;
488
  }
489 490 491 492 493 494 495 496
  '''

  if cc.compiles(armv6test)
    cdata.set('HAVE_ARMV6', 1)
  endif
endif
# NEON checks are automatically done by the unstable-simd module

497 498 499 500 501 502
# FIXME: make sure it's >= 2.2
ltdl_dep = cc.find_library('ltdl', required : true)
# FIXME: can meson support libtool -dlopen/-dlpreopen things?
#        and do we still want to support this at all?
cdata.set('DISABLE_LIBTOOL_PRELOAD', 1)

503 504 505 506
if get_option('database') == 'tdb'
  database_dep = dependency('tdb')
elif get_option('database') == 'gdbm'
  database_dep = cc.find_library('gdbm', required : true)
507
else
508
  database_dep = dependency('', required: false)
509 510 511 512 513 514 515 516 517 518
endif

if get_option('ipv6')
  cdata.set('HAVE_IPV6', 1)
endif

if get_option('legacy-database-entry-format')
  cdata.set('ENABLE_LEGACY_DATABASE_ENTRY_FORMAT', 1)
endif

519 520 521 522
if get_option('running-from-build-tree')
  cdata.set('HAVE_RUNNING_FROM_BUILD_TREE', 1)
endif

523 524 525 526 527 528 529 530 531 532
alsa_dep = dependency('alsa', version : '>= 1.0.24', required : get_option('alsa'))
if alsa_dep.found()
  cdata.set('HAVE_ALSA', 1)
  cdata.set('HAVE_ALSA_UCM', 1)
endif

asyncns_dep = dependency('libasyncns', version : '>= 0.1', required : get_option('asyncns'))
if asyncns_dep.found()
  cdata.set('HAVE_LIBASYNCNS', 1)
endif
533

534
dbus_dep = dependency('dbus-1', version : '>= 1.4.12', required : get_option('dbus'))
535 536 537 538
if dbus_dep.found()
  cdata.set('HAVE_DBUS', 1)
endif

539 540 541 542 543
gio_dep = dependency('gio-2.0', version : '>= 2.26.0', required : get_option('gsettings'))
if gio_dep.found()
  cdata.set('HAVE_GSETTINGS', 1)
endif

544 545 546 547 548
glib_dep = dependency('glib-2.0', version : '>= 2.4.0', required: get_option('glib'))
if glib_dep.found()
  cdata.set('HAVE_GLIB', 1)
endif

549 550 551 552 553
gtk_dep = dependency('gtk+-3.0', required : get_option('gtk'))
if gtk_dep.found()
  cdata.set('HAVE_GTK', 1)
endif

Arnaud Rebillout's avatar
Arnaud Rebillout committed
554 555 556 557 558 559 560 561 562 563 564 565 566
have_orcc = false
orcc_args = []
orc_dep = dependency('orc-0.4', version : '>= 0.4.11', required : get_option('orc'))
orcc = find_program('orcc', required : get_option('orc'))
if orc_dep.found() and orcc.found()
  have_orcc = true
  orcc_args = [orcc]
  #orcc_args = [orcc, '--include', 'glib.h']
  cdata.set('HAVE_ORC', 1)
else
  cdata.set('DISABLE_ORC', 1)
endif

567 568 569 570 571
samplerate_dep = dependency('samplerate', version : '>= 0.1.0', required : get_option('samplerate'))
if samplerate_dep.found()
  cdata.set('HAVE_LIBSAMPLERATE', 1)
endif

572 573
sndfile_dep = dependency('sndfile', version : '>= 1.0.20')

574 575 576 577 578
soxr_dep = dependency('soxr', version : '>= 0.1.1', required : get_option('soxr'))
if soxr_dep.found()
  cdata.set('HAVE_SOXR', 1)
endif

579 580
libsystemd_dep = dependency('libsystemd', required : get_option('systemd'))
if libsystemd_dep.found()
581 582 583
  cdata.set('HAVE_SYSTEMD_DAEMON', 1)
  cdata.set('HAVE_SYSTEMD_LOGIN', 1)
  cdata.set('HAVE_SYSTEMD_JOURNAL', 1)
584 585 586 587
endif
systemd_dep = dependency('systemd', required : get_option('systemd'))
if systemd_dep.found() and systemduserunitdir == ''
  systemduserunitdir = systemd_dep.get_pkgconfig_variable('systemduserunitdir')
588 589
endif

590
x11_dep = dependency('x11-xcb', required : get_option('x11'))
591
if x11_dep.found()
592 593 594 595
  xcb_dep  = dependency('xcb',  required : true, version : '>= 1.6')
  ice_dep  = dependency('ice',  required : true)
  sm_dep   = dependency('sm',   required : true)
  xtst_dep = dependency('xtst', required : true)
596 597 598 599
  cdata.set('HAVE_X11', 1)
endif

# Module dependencies
600

601 602 603
if cc.has_header('sys/soundcard.h')
  cdata.set('HAVE_OSS_OUTPUT', 1)
  cdata.set('HAVE_OSS_WRAPPER', 1)
604
  cdata.set('PULSEDSP_LOCATION', pulsedsp_location)
605 606
endif

607 608 609 610
if get_option('hal-compat')
  cdata.set('HAVE_HAL_COMPAT', 1)
endif

611
avahi_dep = dependency('avahi-client', version : '>= 0.6.0', required : get_option('avahi'), disabler : true)
612 613 614 615
if avahi_dep.found()
  cdata.set('HAVE_AVAHI', 1)
endif

Arnaud Rebillout's avatar
Arnaud Rebillout committed
616
sbc_dep = dependency('sbc', version : '>= 1.0', required : false)
617
if get_option('bluez5')
Arnaud Rebillout's avatar
Arnaud Rebillout committed
618 619 620 621 622 623 624 625 626 627 628
  assert(dbus_dep.found(), 'BlueZ requires D-Bus support')
  assert(sbc_dep.found(), 'BlueZ requires SBC support')
  cdata.set('HAVE_SBC', 1)
  cdata.set('HAVE_BLUEZ', 1)
  cdata.set('HAVE_BLUEZ_5', 1)
  if get_option('bluez5-native-headset')
    cdata.set('HAVE_BLUEZ_5_NATIVE_HEADSET', 1)
  endif
  if get_option('bluez5-ofono-headset')
    cdata.set('HAVE_BLUEZ_5_OFONO_HEADSET', 1)
  endif
629 630
endif

Arnaud Rebillout's avatar
Arnaud Rebillout committed
631 632 633 634 635
fftw_dep = dependency('fftw3f', required : get_option('fftw'))
if fftw_dep.found()
  cdata.set('HAVE_FFTW', 1)
endif

Arnaud Rebillout's avatar
Arnaud Rebillout committed
636
jack_dep = dependency('jack', version : '>= 0.117.0', required : get_option('jack'))
637 638 639 640
if jack_dep.found()
  cdata.set('HAVE_JACK', 1)
endif

Arnaud Rebillout's avatar
Arnaud Rebillout committed
641
lirc_dep = dependency('lirc', required : get_option('lirc'))
642 643 644 645
if lirc_dep.found()
  cdata.set('HAVE_LIRC', 1)
endif

646
openssl_dep = dependency('openssl', version : '>= 0.9', required : get_option('openssl'))
647 648 649 650
if openssl_dep.found()
  cdata.set('HAVE_OPENSSL', 1)
endif

Arnaud Rebillout's avatar
Arnaud Rebillout committed
651
speex_dep = dependency('speexdsp', version : '>= 1.2', required : get_option('speex'))
652 653 654 655
if speex_dep.found()
  cdata.set('HAVE_SPEEX', 1)
endif

Arnaud Rebillout's avatar
Arnaud Rebillout committed
656
udev_dep = dependency('libudev', version : '>= 143', required : get_option('udev'))
657 658 659
if udev_dep.found()
  cdata.set('HAVE_UDEV', 1)
endif
660

Arnaud Rebillout's avatar
Arnaud Rebillout committed
661
webrtc_dep = dependency('webrtc-audio-processing', version : '>= 0.2', required : get_option('webrtc-aec'))
662 663 664 665
if webrtc_dep.found()
  cdata.set('HAVE_WEBRTC', 1)
endif

Arnaud Rebillout's avatar
Arnaud Rebillout committed
666 667 668 669 670 671 672
# These are required for the CMake file generation
cdata.set('PA_LIBDIR', libdir)
cdata.set('PA_INCDIR', includedir)
if glib_dep.found()
  cdata.set('HAVE_GLIB20', 1) # to match the AM_CONDITIONAL for CMake file generation
endif

673 674 675 676
# Test dependencies

check_dep = dependency('check', version : '>= 0.9.10', required : get_option('tests'))

677 678 679 680 681 682 683 684 685 686 687
# Subdirs

subdir('po')
if get_option('man')
  subdir('man')
endif
subdir('shell-completion/bash')
subdir('shell-completion/zsh')
subdir('src')
subdir('vala')

688 689 690
# Now generate config.h from everything above
configure_file(output : 'config.h', configuration : cdata)

691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724
# pkg-config files

pc_cdata = configuration_data()

pc_cdata.set('prefix', prefix)
pc_cdata.set('exec_prefix', prefix)
pc_cdata.set('libdir', libdir)
pc_cdata.set('includedir', includedir)
pc_cdata.set('modlibexecdir', modlibexecdir)
pc_cdata.set('PACKAGE_VERSION', pa_version_str)
pc_cdata.set('PA_MAJORMINOR', pa_version_major_minor)
# FIXME: the line below is wrong. Currently the meson thread dep lacks documentation,
# and doesn't allow introspection, ie. none of get_pkgconfig_variable() or
# get_configtool_variable() work with it, so we have no way to get this flag right,
# unless we do all the work ourselves. See current work in glib, also meson #553.
pc_cdata.set('PTHREAD_LIBS', '-pthread')

pc_files = [
  'libpulse.pc',
  'libpulse-simple.pc',
]

if glib_dep.found()
  pc_files += 'libpulse-mainloop-glib.pc'
endif

foreach file : pc_files
  configure_file(
    input : file + '.in',
    output : file,
    configuration : pc_cdata,
    install_dir : pkgconfigdir)
endforeach

Arnaud Rebillout's avatar
Arnaud Rebillout committed
725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754
# CMake files

m4 = find_program('m4', required: true)

cmakedir = join_paths(libdir, 'cmake', 'PulseAudio')

cmake_template_file = configure_file(
  input : 'PulseAudioConfig.cmake.in',
  output : 'PulseAudioConfig.cmake.tmp',
  configuration: cdata,
)

custom_target('PulseAudioConfig.cmake',
  input : cmake_template_file,
  output : 'PulseAudioConfig.cmake',
  capture : true,
  command : [m4, '@INPUT@'],
  build_by_default : true,
  install : true,
  install_dir : cmakedir,
)

configure_file(
  input : 'PulseAudioConfigVersion.cmake.in',
  output : 'PulseAudioConfigVersion.cmake',
  configuration: cdata,
  install : true,
  install_dir : cmakedir,
)

755 756 757 758 759 760 761 762 763 764 765 766
############################################################

# Final summary

summary = [
  '',
  '---{ @0@ @1@ }---'.format(meson.project_name(), meson.project_version()),
  '',
  'prefix:                        @0@'.format(prefix),
  'bindir:                        @0@'.format(bindir),
  'libdir:                        @0@'.format(libdir),
  'libexecdir:                    @0@'.format(libexecdir),
Arnaud Rebillout's avatar
Arnaud Rebillout committed
767
  'mandir:                        @0@'.format(mandir),
768 769 770
  'datadir:                       @0@'.format(datadir),
  'sysconfdir:                    @0@'.format(sysconfdir),
  'localstatedir:                 @0@'.format(localstatedir),
771
  'modlibexecdir:                 @0@'.format(modlibexecdir),
772 773 774
  'System Runtime Path:           @0@'.format(cdata.get_unquoted('PA_SYSTEM_RUNTIME_PATH')),
  'System State Path:             @0@'.format(cdata.get_unquoted('PA_SYSTEM_STATE_PATH')),
  'System Config Path:            @0@'.format(cdata.get_unquoted('PA_SYSTEM_CONFIG_PATH')),
775 776
  'Bash completions directory:    @0@'.format(bashcompletiondir),
  'Zsh completions directory:     @0@'.format(zshcompletiondir),
777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799
  'Compiler:                      @0@ @1@'.format(cc.get_id(), cc.version()),
#  'CFLAGS:                        @0@'.format(${CFLAGS}),
#  'CPPFLAGS:                      @0@'.format(${CPPFLAGS}),
#  'LIBS:                          @0@'.format(${LIBS}),
  '',
  'Enable memfd shared memory:    @0@'.format(cdata.has('HAVE_MEMFD')),
  'Enable X11:                    @0@'.format(x11_dep.found()),
#  'Enable OSS Output:             @0@'.format(${ENABLE_OSS_OUTPUT}),
#  'Enable OSS Wrapper:            @0@'.format(${ENABLE_OSS_WRAPPER}),
#  'Enable EsounD:                 @0@'.format(${ENABLE_ESOUND}),
  'Enable Alsa:                   @0@'.format(alsa_dep.found()),
#  'Enable CoreAudio:              @0@'.format(${ENABLE_COREAUDIO}),
#  'Enable Solaris:                @0@'.format(${ENABLE_SOLARIS}),
#  'Enable WaveOut:                @0@'.format(${ENABLE_WAVEOUT}),
  'Enable GLib 2:                 @0@'.format(glib_dep.found()),
#  'Enable GConf:                  @0@'.format(${ENABLE_GCONF}),
  'Enable GSettings:              @0@'.format(gio_dep.found()),
  'Enable Gtk+ 3:                 @0@'.format(gtk_dep.found()),
  'Enable Avahi:                  @0@'.format(avahi_dep.found()),
  'Enable Jack:                   @0@'.format(jack_dep.found()),
  'Enable Async DNS:              @0@'.format(asyncns_dep.found()),
  'Enable LIRC:                   @0@'.format(lirc_dep.found()),
  'Enable D-Bus:                  @0@'.format(dbus_dep.found()),
800
  '  Enable BlueZ 5:              @0@'.format(get_option('bluez5')),
801 802 803 804
  '    Enable native headsets:    @0@'.format(get_option('bluez5-native-headset')),
  '    Enable  ofono headsets:    @0@'.format(get_option('bluez5-ofono-headset')),
  'Enable udev:                   @0@'.format(udev_dep.found()),
  '  Enable HAL->udev compat:     @0@'.format(get_option('hal-compat')),
805
  'Enable systemd:                @0@'.format(libsystemd_dep.found()),
806 807 808 809 810
#  'Enable TCP Wrappers:           @0@'.format(${ENABLE_TCPWRAP}),
  'Enable libsamplerate:          @0@'.format(samplerate_dep.found()),
  'Enable IPv6:                   @0@'.format(get_option('ipv6')),
  'Enable OpenSSL (for Airtunes): @0@'.format(openssl_dep.found()),
  'Enable FFTW:                   @0@'.format(fftw_dep.found()),
Arnaud Rebillout's avatar
Arnaud Rebillout committed
811
  'Enable ORC:                    @0@'.format(have_orcc),
812 813 814 815
  'Enable Adrian echo canceller:  @0@'.format(get_option('adrian-aec')),
  'Enable Speex (resampler, AEC): @0@'.format(speex_dep.found()),
  'Enable SoXR (resampler):       @0@'.format(soxr_dep.found()),
  'Enable WebRTC echo canceller:  @0@'.format(webrtc_dep.found()),
Arnaud Rebillout's avatar
Arnaud Rebillout committed
816
  'Enable Gcov coverage:          @0@'.format(get_option('gcov')),
817
  'Enable man pages:              @0@'.format(get_option('man')),
818
  'Enable unit tests:             @0@'.format(get_option('tests')),
819 820 821
  '',
  'Database:                      @0@'.format(get_option('database')),
  'Legacy Database Entry Support: @0@'.format(get_option('legacy-database-entry-format')),
822
  'Running from build tree:       @0@'.format(get_option('running-from-build-tree')),
823 824 825 826 827 828 829 830 831 832 833
  'System User:                   @0@'.format(cdata.get_unquoted('PA_SYSTEM_USER')),
  'System Group:                  @0@'.format(cdata.get_unquoted('PA_SYSTEM_GROUP')),
  'Access Group:                  @0@'.format(cdata.get_unquoted('PA_ACCESS_GROUP')),
#  'Enable per-user EsounD socket: @0@'.format(${ENABLE_PER_USER_ESOUND_SOCKET}),
#  'Force preopen:                 @0@'.format(${FORCE_PREOPEN}),
#  'Preopened modules:             @0@'.format(${PREOPEN_MODS}),
]

message('\n    '.join(summary))

# Sanity checks
834 835 836 837 838

if not speex_dep.found() and not webrtc_dep.found() and not get_option('adrian-aec')
  error('At least one echo canceller implementation must be available!')
endif

839 840 841
if samplerate_dep.found()
  warning('Support for libsamplerate is DEPRECATED')
endif
842

843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873
if host_machine.system() != 'windows'
  if not dbus_dep.found()
    message = [
      'You do not have D-Bus support enabled. It is strongly recommended',
      'that you enable D-Bus support if your platform supports it.',
      'Many parts of PulseAudio use D-Bus, from ConsoleKit interaction',
      'to the Device Reservation Protocol to speak to JACK, Bluetooth',
      'support and even a native control protocol for communicating and',
      'controlling the PulseAudio daemon itself.',
    ]
    warning('\n' + '\n'.join(message))
  endif
  if not udev_dep.found()
    message = [
      'You do not have udev support enabled. It is strongly recommended',
      'that you enable udev support if your platform supports it as it is',
      'the primary method used to detect hardware audio devices (on Linux)',
      'and is thus a critical part of PulseAudio on that platform.',
    ]
    warning('\n' + '\n'.join(message))
  endif
  if not speex_dep.found()
    message = [
      'You do not have speex support enabled. It is strongly recommended',
      'that you enable speex support if your platform supports it as it is',
      'the primary method used for audio resampling and is thus a critical',
      'part of PulseAudio on that platform.',
    ]
    warning('\n' + '\n'.join(message))
  endif
endif