• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1project('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        default_options : [ 'c_std=gnu11', 'cpp_std=c++11' ]
5        )
6
7meson.add_dist_script('scripts/save-tarball-version.sh', meson.project_version())
8
9pa_version_str = meson.project_version()
10# For tarballs, the first split will do nothing, but for builds in git, we
11# split out suffixes when there are commits since the last tag
12# (e.g.: v11.99.1-3-gad14bdb24 -> v11.99.1)
13version_split = pa_version_str.split('-')[0].split('.')
14pa_version_major = version_split[0].split('v')[0]
15pa_version_minor = version_split[1]
16if version_split.length() > 2
17  pa_version_micro = version_split[2]
18else
19  pa_version_micro = '0'
20endif
21pa_version_major_minor = pa_version_major + '.' + pa_version_minor
22
23pa_api_version = 12
24pa_protocol_version = 35
25
26# The stable ABI for client applications, for the version info x:y:z
27# always will hold x=z
28libpulse_version_info = [24, 2, 24]
29
30# A simplified, synchronous, ABI-stable interface for client
31# applications, for the version info x:y:z always will hold x=z
32libpulse_simple_version_info = [1, 1, 1]
33
34# The ABI-stable GLib adapter for client applications, for the version
35# info x:y:z always will hold x=z
36libpulse_mainloop_glib_version_info = [0, 6, 0]
37
38libpulse_version = '@0@.@1@.@2@'.format(
39  libpulse_version_info[0] - libpulse_version_info[2],
40  libpulse_version_info[0],
41  libpulse_version_info[1],
42)
43
44libpulse_simple_version = '@0@.@1@.@2@'.format(
45  libpulse_simple_version_info[0] - libpulse_simple_version_info[2],
46  libpulse_simple_version_info[0],
47  libpulse_simple_version_info[1],
48)
49
50libpulse_mainloop_glib_version = '@0@.@1@.@2@'.format(
51  libpulse_mainloop_glib_version_info[0] - libpulse_mainloop_glib_version_info[2],
52  libpulse_mainloop_glib_version_info[0],
53  libpulse_mainloop_glib_version_info[1],
54)
55
56i18n = import('i18n')
57
58# Paths
59
60prefix = get_option('prefix')
61assert(prefix.startswith('/'), 'Prefix is not absolute: "@0@"'.format(prefix))
62
63bindir = join_paths(prefix, get_option('bindir'))
64includedir = join_paths(prefix, get_option('includedir'))
65libdir = join_paths(prefix, get_option('libdir'))
66libexecdir = join_paths(prefix, get_option('libexecdir'))
67mandir = join_paths(prefix, get_option('mandir'))
68datadir = join_paths(prefix, get_option('datadir'))
69localedir = join_paths(prefix, get_option('localedir'))
70localstatedir = join_paths(prefix, get_option('localstatedir'))
71sysconfdir = join_paths(prefix, get_option('sysconfdir'))
72privlibdir = join_paths(libdir, 'pulseaudio')
73po_dir = join_paths(meson.current_source_dir(), 'po')
74
75if host_machine.system() == 'windows'
76  # Windows only supports loading libraries from the same dir as the executable
77  privlibdir = bindir
78endif
79
80alsadatadir = get_option('alsadatadir')
81if alsadatadir == ''
82  alsadatadir = join_paths(datadir, 'pulseaudio', 'alsa-mixer')
83endif
84
85pkgconfigdir = join_paths(libdir, 'pkgconfig')
86pulselibexecdir = join_paths(libexecdir, 'pulse')
87pulsesysconfdir = join_paths(sysconfdir, 'pulse')
88
89modlibexecdir = get_option('modlibexecdir')
90if modlibexecdir == ''
91  modlibexecdir = join_paths(libdir, 'pulseaudio', 'modules')
92endif
93
94if host_machine.system() == 'windows'
95  # Windows only supports loading libraries from the same dir as the executable
96  modlibexecdir = bindir
97endif
98
99padsplibdir = get_option('padsplibdir')
100if padsplibdir == ''
101  padsplibdir = privlibdir
102endif
103
104pulsedsp_location = get_option('pulsedsp-location')
105if pulsedsp_location == ''
106  pulsedsp_location = join_paths(prefix, padsplibdir)
107endif
108
109systemduserunitdir = get_option('systemduserunitdir')
110# the default value is set below
111
112udevrulesdir = get_option('udevrulesdir')
113if udevrulesdir == ''
114  # absolute path, otherwise meson prepends the prefix
115  udevrulesdir = '/lib/udev/rules.d'
116endif
117
118vapidir = join_paths(datadir, 'vala', 'vapi')
119
120bashcompletiondir = get_option('bashcompletiondir')
121if bashcompletiondir == ''
122  bash_completion_dep = dependency('bash-completion', required : false)
123  if bash_completion_dep.found()
124    bashcompletiondir = bash_completion_dep.get_pkgconfig_variable('completionsdir')
125  else
126    bashcompletiondir = join_paths(datadir, 'bash-completion', 'completions')
127  endif
128endif
129
130zshcompletiondir = get_option('zshcompletiondir')
131if zshcompletiondir == ''
132  zshcompletiondir = join_paths(datadir, 'zsh', 'site-functions')
133endif
134
135# Configuration data
136
137cc = meson.get_compiler('c')
138
139cdata = configuration_data()
140cdata.set_quoted('PACKAGE', 'pulseaudio')
141cdata.set_quoted('PACKAGE_NAME', 'pulseaudio')
142cdata.set_quoted('PACKAGE_VERSION', pa_version_str)
143cdata.set('PA_MAJOR', pa_version_major)
144cdata.set('PA_MINOR', pa_version_minor)
145cdata.set('PA_API_VERSION', pa_api_version)
146cdata.set('PA_PROTOCOL_VERSION', pa_protocol_version)
147cdata.set_quoted('PA_MACHINE_ID', join_paths(sysconfdir, 'machine-id'))
148cdata.set_quoted('PA_MACHINE_ID_FALLBACK', join_paths(localstatedir, 'lib', 'dbus', 'machine-id'))
149cdata.set_quoted('PA_SRCDIR', join_paths(meson.current_source_dir(), 'src'))
150cdata.set_quoted('PA_BUILDDIR', meson.current_build_dir())
151cdata.set_quoted('PA_SOEXT', '.so')
152cdata.set_quoted('PA_DEFAULT_CONFIG_DIR', pulsesysconfdir)
153cdata.set('PA_DEFAULT_CONFIG_DIR_UNQUOTED', pulsesysconfdir)
154cdata.set_quoted('PA_BINARY', join_paths(bindir, 'pulseaudio'))
155cdata.set_quoted('PA_SYSTEM_RUNTIME_PATH', join_paths(localstatedir, 'run', 'pulse'))
156cdata.set_quoted('PA_SYSTEM_CONFIG_PATH', join_paths(localstatedir, 'lib', 'pulse'))
157cdata.set_quoted('PA_SYSTEM_STATE_PATH', join_paths(localstatedir, 'lib', 'pulse'))
158cdata.set_quoted('PA_DLSEARCHPATH', modlibexecdir)
159cdata.set_quoted('PA_SYSTEM_USER', get_option('system_user'))
160cdata.set_quoted('PA_SYSTEM_GROUP', get_option('system_group'))
161cdata.set_quoted('PA_ACCESS_GROUP', get_option('access_group'))
162cdata.set_quoted('PA_CFLAGS', 'Not yet supported on meson')
163cdata.set_quoted('PA_ALSA_PATHS_DIR', join_paths(alsadatadir, 'paths'))
164cdata.set_quoted('PA_ALSA_PROFILE_SETS_DIR', join_paths(alsadatadir, 'profile-sets'))
165cdata.set_quoted('DESKTOPFILEDIR', join_paths(datadir, 'applications'))
166cdata.set_quoted('PULSE_LOCALEDIR', localedir)
167cdata.set_quoted('GETTEXT_PACKAGE', 'pulseaudio')
168cdata.set('ENABLE_NLS', 1)
169cdata.set('top_srcdir', meson.source_root())
170
171# Platform specifics
172# First some defaults to keep config file generation happy
173cdata.set('HAVE_COREAUDIO', 0)
174cdata.set('HAVE_WAVEOUT', 0)
175cdata.set('OS_IS_FREEBSD', 0)
176
177platform_socket_dep = []
178platform_dep = []
179
180if host_machine.endian() == 'big'
181  cdata.set('WORDS_BIGENDIAN', 1)
182endif
183
184# FIXME: This was not tested. Maybe some flags should better be CFLAGS,
185# rather than ending up in the config.h file?
186if host_machine.system() == 'darwin'
187  cdata.set('OS_IS_DARWIN', 1)
188  cdata.set('_DARWIN_C_SOURCE', '200112L') # Needed to get NSIG on Mac OS
189elif host_machine.system() == 'windows'
190  cdata.set('OS_IS_WIN32', 1)
191  cdata.set('HAVE_WINDOWS_H', 1)
192  cdata.set('HAVE_WAVEOUT', 1)
193  cdata.set('HAVE_WINSOCK2_H', 1)
194  cdata.set('HAVE_WS2TCPIP_H', 1)
195  cdata.set('WIN32_LEAN_AND_MEAN', 1) # Needed to avoid including unnecessary headers on Windows
196  cdata.set('gid_t', 'int')
197  cdata.set('uid_t', 'int')
198  ws2_32_dep = meson.get_compiler('c').find_library('ws2_32')
199  winsock_dep = meson.get_compiler('c').find_library('wsock32')
200  ole32_dep = meson.get_compiler('c').find_library('ole32')
201  ssp_dep = meson.get_compiler('c').find_library('ssp')
202  pcreposix_dep = meson.get_compiler('c').find_library('pcreposix')
203  platform_socket_dep = [ws2_32_dep, winsock_dep]
204  platform_dep = [ole32_dep, ssp_dep, pcreposix_dep]
205elif host_machine.system() == 'freebsd'
206  cdata.set('OS_IS_FREEBSD', 1)
207#elif host_machine.system() == 'solaris'
208#  # Apparently meson has no solaris support?
209#  # Needed to get declarations for msg_control and msg_controllen on Solaris
210#  cdata.set('_XOPEN_SOURCE', 600)
211#  cdata.set('__EXTENSIONS__', 1)
212endif
213
214if cc.has_type('_Bool')
215  cdata.set('HAVE_STD_BOOL', 1)
216endif
217
218if host_machine.cpu_family() == 'x86_64' or cc.sizeof('void *') >= 8
219  cdata.set('HAVE_FAST_64BIT_OPERATIONS', 1)
220endif
221
222# Headers
223
224check_headers = [
225  'arpa/inet.h',
226  'byteswap.h',
227  'dlfcn.h',
228  'execinfo.h',
229  'grp.h',
230  'langinfo.h',
231  'linux/sockios.h',
232  'locale.h',
233  'netdb.h',
234  'netinet/in.h',
235  'netinet/in_systm.h',
236  'netinet/ip.h',
237  'netinet/tcp.h',
238  'pcreposix.h',
239  'poll.h',
240  'pwd.h',
241  'regex.h',
242  'sched.h',
243  'stdint.h',
244  'sys/atomic.h',
245  'sys/capability.h',
246  'sys/conf.h',
247  'sys/dl.h',
248  'sys/eventfd.h',
249  'sys/filio.h',
250  'sys/ioctl.h',
251  'sys/mman.h',
252  'sys/prctl.h',
253  'sys/resource.h',
254  'sys/select.h',
255  'sys/socket.h',
256  'sys/syscall.h',
257  'sys/uio.h',
258  'sys/un.h',
259  'sys/wait.h',
260  'syslog.h',
261  'xlocale.h',
262]
263
264foreach h : check_headers
265  if cc.has_header(h)
266    define = 'HAVE_' + h.underscorify().to_upper()
267    cdata.set(define, 1)
268  endif
269endforeach
270
271if cc.has_header('valgrind/memcheck.h', required: get_option('valgrind'))
272  cdata.set('HAVE_VALGRIND_MEMCHECK_H', 1)
273endif
274
275# FIXME: move this to the above set
276if host_machine.system() != 'windows'
277  if cc.has_header('pthread.h')
278    cdata.set('HAVE_PTHREAD', 1)
279  endif
280endif
281
282if cc.has_header_symbol('pthread.h', 'PTHREAD_PRIO_INHERIT')
283  cdata.set('HAVE_PTHREAD_PRIO_INHERIT', 1)
284endif
285
286# Headers which are usable
287
288check_usable_headers = [
289  'cpuid.h',
290]
291
292foreach h : check_usable_headers
293  if cc.check_header(h)
294    define = 'HAVE_' + h.underscorify().to_upper()
295    cdata.set(define, 1)
296  endif
297endforeach
298
299# Functions
300
301check_functions = [
302  'accept4',
303  'clock_gettime',
304  'ctime_r',
305  'fchmod',
306  'fchown',
307  'fork',
308  'fstat',
309  'getaddrinfo',
310  'getgrgid_r',
311  'getgrnam_r',
312  'getpwnam_r',
313  'getpwuid_r',
314  'gettimeofday',
315  'getuid',
316  'lrintf',
317  'lstat',
318  'memfd_create',
319  'mkfifo',
320  'mlock',
321  'nanosleep',
322  'open64',
323  'paccept',
324  'pipe',
325  'pipe2',
326  'posix_fadvise',
327  'posix_madvise',
328  'posix_memalign',
329  'ppoll',
330  'readlink',
331  'setegid',
332  'seteuid',
333  'setpgid',
334  'setregid',
335  'setresgid',
336  'setresuid',
337  'setreuid',
338  'setsid',
339  'sig2str',
340  'sigaction',
341  'strerror_r',
342  'strtod_l',
343  'strtof',
344  'symlink',
345  'sysconf',
346  'uname',
347]
348
349foreach f : check_functions
350  if cc.has_function(f)
351    define = 'HAVE_' + f.underscorify().to_upper()
352
353    if f == 'posix_memalign' and host_machine.system() == 'windows'
354      message('Win32/mingw32 does not properly define posix_memalign.')
355    elif f == 'fork' and host_machine.system() == 'windows'
356      # __builtin_fork is defined and compiles properly, but calling __builtin_fork() does not.
357      # This causes Meson to think that Windows has a fork() which causes a link error...
358      message('Win32/mingw32 does not properly define fork.')
359    else
360      cdata.set(define, 1)
361    endif
362  endif
363endforeach
364
365if cc.has_header_symbol('sys/syscall.h', 'SYS_memfd_create') \
366  or cc.has_function('memfd_create')
367  cdata.set('HAVE_MEMFD', 1)
368endif
369
370if cc.has_function('dgettext')
371  if host_machine.system() != 'windows'
372    libintl_dep = []
373  else
374    libintl_dep = cc.find_library('intl')
375  endif
376else
377  libintl_dep = cc.find_library('intl')
378endif
379
380# Symbols
381
382if cc.has_header_symbol('signal.h', 'SIGXCPU')
383  cdata.set('HAVE_SIGXCPU', 1)
384endif
385
386if not cc.has_header_symbol('netinet/in.h', 'INADDR_NONE')
387  if not cc.has_header_symbol('winsock2.h', 'INADDR_NONE')
388    # Define INADDR_NONE if not found (Solaris)
389    cdata.set('INADDR_NONE', '0xffffffff')
390  endif
391endif
392
393check_decls = [
394  [ 'environ', 'unistd.h', '#define _GNU_SOURCE' ],
395  [ 'SOUND_PCM_READ_RATE', 'sys/soundcard.h', '' ],
396  [ 'SOUND_PCM_READ_CHANNELS', 'sys/soundcard.h', '' ],
397  [ 'SOUND_PCM_READ_BITS', 'sys/soundcard.h', '' ],
398]
399
400foreach s : check_decls
401  if cc.has_header_symbol(s[1], s[0], prefix : s[2])
402    define = 'HAVE_DECL_' + s[0].to_upper()
403    cdata.set(define, 1)
404  endif
405endforeach
406
407# Types
408
409# FIXME: do we ever care about gid_t not being defined / smaller than an int?
410cdata.set('GETGROUPS_T', 'gid_t')
411
412# Include paths
413
414configinc = include_directories('.')
415topinc = include_directories('src')
416
417# CFLAGS/LDFLAGS
418
419pa_c_args = ['-DHAVE_CONFIG_H', '-D_GNU_SOURCE']
420server_c_args = ['-D__INCLUDED_FROM_PULSE_AUDIO']
421cdata.set('MESON_BUILD', 1)
422
423# On ELF systems we don't want the libraries to be unloaded since we don't clean them up properly,
424# so we request the nodelete flag to be enabled.
425# On other systems, we don't really know how to do that, but it's welcome if somebody can tell.
426# Windows doesn't support this flag.
427if host_machine.system() != 'windows'
428  nodelete_link_args = ['-Wl,-z,nodelete']
429else
430  nodelete_link_args = []
431endif
432
433# Code coverage
434
435if get_option('gcov')
436  add_project_arguments('--coverage', language: ['c', 'cpp'])
437  add_project_link_arguments('--coverage', language: ['c', 'cpp'])
438endif
439
440# Core Dependencies
441
442libm_dep = cc.find_library('m', required : true)
443
444thread_dep = dependency('threads')
445foreach f : [
446  'pthread_getname_np',
447  'pthread_setaffinity_np',
448  'pthread_setname_np',
449]
450  if cc.has_function(f, dependencies : thread_dep)
451    define = 'HAVE_' + f.underscorify().to_upper()
452    cdata.set(define, 1)
453  endif
454endforeach
455
456cap_dep = cc.find_library('cap', required : false)
457
458shm_dep = cc.find_library('rt', required : false)
459if cc.has_function('shm_open', dependencies : shm_dep)
460  cdata.set('HAVE_SHM_OPEN', 1)
461endif
462
463dl_dep = cc.find_library('dl', required : false)
464if cc.has_function('dladdr', dependencies : dl_dep)
465  cdata.set('HAVE_DLADDR', 1)
466endif
467
468have_iconv = false
469if cc.has_function('iconv_open')
470  iconv_dep = dependency('', required : false)
471  have_iconv = true
472  # tell the libiconv header to pretend to be libc iconv
473  cdata.set('LIBICONV_PLUG', 1)
474else
475  iconv_dep = cc.find_library('iconv', required : false)
476  have_iconv = iconv_dep.found()
477endif
478if have_iconv
479  cdata.set('HAVE_ICONV', 1)
480  iconvconsttest = '''#include <iconv.h>
481size_t iconv (iconv_t cd, char * *inbuf, size_t *inbytesleft, char * *outbuf, size_t *outbytesleft);
482'''
483  if cc.compiles(iconvconsttest, dependencies : iconv_dep)
484    cdata.set('ICONV_CONST', '')
485  else
486    cdata.set('ICONV_CONST', 'const')
487  endif
488endif
489
490# Used for backtraces on BSD
491execinfo_dep = cc.find_library('execinfo', required : false)
492
493# Atomic operations
494
495if get_option('atomic-arm-memory-barrier')
496    cdata.set('ATOMIC_ARM_MEMORY_BARRIER_ENABLED', 1)
497endif
498
499need_libatomic_ops = false
500
501atomictest = '''void func() {
502  volatile int atomic = 2;
503  __sync_bool_compare_and_swap (&atomic, 2, 3);
504}
505'''
506
507if cc.compiles(atomictest)
508  cdata.set('HAVE_ATOMIC_BUILTINS', 1)
509
510  newatomictest = '''void func() {
511    int c = 0;
512    __atomic_store_n(&c, 4, __ATOMIC_SEQ_CST);
513  }
514  '''
515
516  if(cc.compiles(newatomictest))
517    cdata.set('HAVE_ATOMIC_BUILTINS_MEMORY_MODEL', 1)
518  endif
519
520elif host_machine.cpu_family() == 'arm'
521  if host_machine.system() == 'linux' and get_option('atomic-arm-linux-helpers')
522    cdata.set('ATOMIC_ARM_LINUX_HELPERS', 1)
523  else
524    armatomictest = '''int func() {
525      volatile int a=0;
526      int o=0, n=1, r;
527      asm volatile (
528	      "ldrex    %0, [%1]\n"
529	      "subs  %0, %0, %2\n"
530	      "strexeq %0, %3, [%1]\n"
531	      : "=&r" (r)
532	      : "r" (&a), "Ir" (o), "r" (n)
533      : "cc");
534      return (a==1 ? 0 : -1);
535    }
536    '''
537
538    if cc.compiles(armatomictest)
539      cdata.set('ATOMIC_ARM_INLINE_ASM', 1)
540    else
541      need_libatomic_ops = true
542    endif
543  endif # arm && !linux
544
545elif not ['freebsd', 'netbsd'].contains(host_machine.system())
546  need_libatomic_ops = true
547endif # !atomic helpers && !arm
548
549if need_libatomic_ops
550  assert(cc.has_header('atomic_ops.h'), 'Need libatomic_ops')
551
552  cdata.set('AO_REQUIRE_CAS', 1)
553
554  if host_machine.system() != 'windows'
555    libatomic_ops_dep = cc.find_library('atomic_ops', required : true)
556  else
557    libatomic_ops_dep = dependency('', required: false)
558  endif
559else
560  libatomic_ops_dep = dependency('', required: false)
561endif
562
563# ARM checks
564# ARMV6 instructions we need
565if host_machine.cpu_family() == 'arm'
566  armv6test = '''int func() {
567    volatile int a = -60000, b = 0xaaaabbbb, c = 0xccccdddd;
568    asm volatile ("ldr r0, %2 \n"
569                  "ldr r2, %3 \n"
570                  "ldr r3, %4 \n"
571                  "ssat r1, #8, r0 \n"
572                  "str r1, %0 \n"
573                  "pkhbt r1, r3, r2, LSL #8 \n"
574                  "str r1, %1 \n"
575                  : "=m" (a), "=m" (b)
576                  : "m" (a), "m" (b), "m" (c)
577                  : "r0", "r1", "r2", "r3", "cc");
578    return (a == -128 && b == 0xaabbdddd) ? 0 : -1;
579  }
580  '''
581
582  if cc.compiles(armv6test)
583    cdata.set('HAVE_ARMV6', 1)
584  endif
585endif
586# NEON checks are automatically done by the unstable-simd module
587
588# Dependencies common to client, daemon and modules
589
590if get_option('ipv6')
591  cdata.set('HAVE_IPV6', 1)
592endif
593
594dbus_dep = dependency('dbus-1', version : '>= 1.4.12', required : get_option('dbus'))
595if dbus_dep.found()
596  cdata.set('HAVE_DBUS', 1)
597endif
598
599glib_dep = dependency('glib-2.0', version : '>= 2.28.0', required: get_option('glib'))
600if glib_dep.found()
601  cdata.set('HAVE_GLIB', 1)
602  cdata.set('HAVE_GLIB20', 1) # to match the AM_CONDITIONAL for CMake file generation
603endif
604
605sndfile_dep = dependency('sndfile', version : '>= 1.0.20')
606
607libsystemd_dep = dependency('libsystemd', required : get_option('systemd'))
608if libsystemd_dep.found()
609  cdata.set('HAVE_SYSTEMD_DAEMON', 1)
610  cdata.set('HAVE_SYSTEMD_LOGIN', 1)
611  cdata.set('HAVE_SYSTEMD_JOURNAL', 1)
612endif
613
614x11_dep = dependency('x11-xcb', required : get_option('x11'))
615
616# OSS support
617if cc.has_header('sys/soundcard.h', required: get_option('oss-output'))
618  # OSS output via daemon module-detect
619  cdata.set('HAVE_OSS_OUTPUT', 1)
620  # OSS wrapper
621  cdata.set('HAVE_OSS_WRAPPER', 1)
622  cdata.set('PULSEDSP_LOCATION', pulsedsp_location)
623endif
624
625fftw_dep = dependency('fftw3f', required : get_option('fftw'))
626if fftw_dep.found()
627  cdata.set('HAVE_FFTW', 1)
628endif
629
630# Client library dependencies
631
632if get_option('client')
633  asyncns_dep = dependency('libasyncns', version : '>= 0.1', required : get_option('asyncns'))
634  if asyncns_dep.found()
635    cdata.set('HAVE_LIBASYNCNS', 1)
636  endif
637
638  gtk_dep = dependency('gtk+-3.0', required : get_option('gtk'))
639  if gtk_dep.found()
640    cdata.set('HAVE_GTK', 1)
641  endif
642endif
643
644# Daemon and module dependencies
645
646if get_option('daemon')
647  # FIXME: make sure it's >= 2.2
648  ltdl_dep = cc.find_library('ltdl', required : true)
649
650  # FIXME: can meson support libtool -dlopen/-dlpreopen things?
651  #        and do we still want to support this at all?
652  cdata.set('DISABLE_LIBTOOL_PRELOAD', 1)
653
654  if get_option('database') == 'tdb'
655    database_dep = dependency('tdb')
656  elif get_option('database') == 'gdbm'
657    database_dep = cc.find_library('gdbm', required : true)
658  else
659    database_dep = dependency('', required: false)
660  endif
661
662  if get_option('legacy-database-entry-format')
663    cdata.set('ENABLE_LEGACY_DATABASE_ENTRY_FORMAT', 1)
664  endif
665
666  if get_option('stream-restore-clear-old-devices')
667    cdata.set('STREAM_RESTORE_CLEAR_OLD_DEVICES', 1)
668  endif
669
670  if get_option('running-from-build-tree')
671    cdata.set('HAVE_RUNNING_FROM_BUILD_TREE', 1)
672  endif
673
674  if get_option('enable-smoother-2')
675    cdata.set('USE_SMOOTHER_2', 1)
676  endif
677
678  alsa_dep = dependency('alsa', version : '>= 1.0.24', required : get_option('alsa'))
679  if alsa_dep.found()
680    cdata.set('HAVE_ALSA', 1)
681    cdata.set('HAVE_ALSA_UCM', 1)
682  endif
683
684  gio_dep = dependency('gio-2.0', version : '>= 2.26.0')
685  if get_option('gsettings').enabled()
686    assert(gio_dep.found(), 'GSettings support needs glib I/O library (GIO)')
687    cdata.set('HAVE_GSETTINGS', 1)
688  else
689    cdata.set('HAVE_GSETTINGS', 0)
690  endif
691
692  have_orcc = false
693  orcc_args = []
694  orc_dep = dependency('orc-0.4', version : '>= 0.4.11', required : get_option('orc'))
695  orcc = find_program('orcc', required : get_option('orc'))
696  if orc_dep.found() and orcc.found()
697    have_orcc = true
698    orcc_args = [orcc]
699    #orcc_args = [orcc, '--include', 'glib.h']
700    cdata.set('HAVE_ORC', 1)
701  else
702    cdata.set('DISABLE_ORC', 1)
703  endif
704
705  samplerate_dep = dependency('samplerate', version : '>= 0.1.0', required : get_option('samplerate'))
706  if samplerate_dep.found()
707    cdata.set('HAVE_LIBSAMPLERATE', 1)
708  endif
709
710  speex_dep = dependency('speexdsp', version : '>= 1.2', required : get_option('speex'))
711  if speex_dep.found()
712    cdata.set('HAVE_SPEEX', 1)
713  endif
714
715  soxr_dep = dependency('soxr', version : '>= 0.1.1', required : get_option('soxr'))
716  if soxr_dep.found()
717    cdata.set('HAVE_SOXR', 1)
718  endif
719
720  webrtc_dep = dependency('webrtc-audio-processing', version : '>= 0.2', required : get_option('webrtc-aec'))
721  if webrtc_dep.found()
722    cdata.set('HAVE_WEBRTC', 1)
723  endif
724
725  systemd_dep = dependency('systemd', required : get_option('systemd'))
726  if systemd_dep.found() and systemduserunitdir == ''
727    systemduserunitdir = systemd_dep.get_pkgconfig_variable('systemduserunitdir')
728  endif
729
730  libelogind_dep = dependency('libelogind', required : get_option('elogind'))
731  if libelogind_dep.found()
732    cdata.set('HAVE_SYSTEMD_LOGIN', 1)
733  endif
734
735  tcpwrap_dep = cc.find_library('wrap', required: get_option('tcpwrap'))
736  if cc.has_header('tcpd.h') and cc.has_function('hosts_access', dependencies : tcpwrap_dep)
737    cdata.set('HAVE_LIBWRAP', 1)
738  endif
739
740  if x11_dep.found()
741    xcb_dep  = dependency('xcb',  required : true, version : '>= 1.6')
742    ice_dep  = dependency('ice',  required : true)
743    sm_dep   = dependency('sm',   required : true)
744    xtst_dep = dependency('xtst', required : true)
745    cdata.set('HAVE_X11', 1)
746    if cc.has_function('XSetIOErrorExitHandler', dependencies: x11_dep)
747      cdata.set('HAVE_XSETIOERROREXITHANDLER', 1)
748    endif
749  endif
750
751  avahi_dep = dependency('avahi-client', version : '>= 0.6.0', required : get_option('avahi'), disabler : true)
752  if avahi_dep.found()
753    cdata.set('HAVE_AVAHI', 1)
754  else
755    cdata.set('HAVE_AVAHI', 0)
756  endif
757
758  sbc_dep = dependency('sbc', version : '>= 1.0', required : false)
759
760  bluez_dep = dependency('bluez', required : get_option('bluez5'))
761
762  if bluez_dep.found()
763    assert(dbus_dep.found(), 'BlueZ requires D-Bus support')
764    assert(sbc_dep.found(), 'BlueZ requires SBC support')
765    cdata.set('HAVE_SBC', 1)
766    cdata.set('HAVE_BLUEZ', 1)
767    cdata.set('HAVE_BLUEZ_5', 1)
768    if get_option('bluez5-native-headset')
769      cdata.set('HAVE_BLUEZ_5_NATIVE_HEADSET', 1)
770    endif
771    if get_option('bluez5-ofono-headset')
772      cdata.set('HAVE_BLUEZ_5_OFONO_HEADSET', 1)
773    endif
774  endif
775
776  jack_dep = dependency('jack', version : '>= 0.117.0', required : get_option('jack'))
777  if jack_dep.found()
778    cdata.set('HAVE_JACK', 1)
779  endif
780
781  lirc_dep = dependency('lirc', required : get_option('lirc'))
782  if lirc_dep.found()
783    cdata.set('HAVE_LIRC', 1)
784  endif
785
786  openssl_dep = dependency('openssl', version : '>= 0.9', required : get_option('openssl'))
787  if openssl_dep.found()
788    cdata.set('HAVE_OPENSSL', 1)
789  endif
790
791  udev_dep = dependency('libudev', version : '>= 143', required : get_option('udev'))
792  if udev_dep.found()
793    cdata.set('HAVE_UDEV', 1)
794  endif
795
796  if get_option('hal-compat')
797    cdata.set('HAVE_HAL_COMPAT', 1)
798  endif
799
800  gst_dep = dependency('gstreamer-1.0', version : '>= 1.14', required : get_option('gstreamer'))
801  gstapp_dep = dependency('gstreamer-app-1.0', required : get_option('gstreamer'))
802  gstrtp_dep = dependency('gstreamer-rtp-1.0', required : get_option('gstreamer'))
803
804  have_gstreamer = false
805  if gst_dep.found() and gstapp_dep.found() and gstrtp_dep.found()
806    assert(gio_dep.found(), 'GStreamer-based RTP needs glib I/O library (GIO)')
807    have_gstreamer = true
808  endif
809
810  bluez5_gst_dep = dependency('gstreamer-1.0', version : '>= 1.14', required : get_option('bluez5-gstreamer'))
811  bluez5_gstapp_dep = dependency('gstreamer-app-1.0', required : get_option('bluez5-gstreamer'))
812  have_bluez5_gstreamer = false
813  if bluez5_gst_dep.found() and bluez5_gstapp_dep.found()
814    have_bluez5_gstreamer = true
815    cdata.set('HAVE_GSTLDAC', 1)
816    cdata.set('HAVE_GSTAPTX', 1)
817  endif
818endif
819
820# These are required for the CMake file generation
821cdata.set('PA_LIBDIR', libdir)
822cdata.set('PA_INCDIR', includedir)
823
824# Test dependencies
825
826check_dep = dependency('check', version : '>= 0.9.10', required : get_option('tests'))
827
828# Subdirs
829
830if get_option('doxygen')
831  subdir('doxygen')
832endif
833if get_option('client')
834  subdir('po')
835endif
836if get_option('man')
837  subdir('man')
838endif
839subdir('shell-completion/bash')
840subdir('shell-completion/zsh')
841subdir('src')
842if get_option('client')
843 subdir('vala')
844endif
845
846# Now generate config.h from everything above
847configure_file(output : 'config.h', configuration : cdata)
848
849if get_option('client')
850
851  # pkg-config files
852
853  pc_cdata = configuration_data()
854
855  pc_cdata.set('prefix', prefix)
856  pc_cdata.set('exec_prefix', prefix)
857  pc_cdata.set('libdir', libdir)
858  pc_cdata.set('includedir', includedir)
859  pc_cdata.set('modlibexecdir', modlibexecdir)
860  pc_cdata.set('PACKAGE_VERSION', pa_version_str)
861  pc_cdata.set('PA_MAJORMINOR', pa_version_major_minor)
862  # FIXME: the line below is wrong. Currently the meson thread dep lacks documentation,
863  # and doesn't allow introspection, ie. none of get_pkgconfig_variable() or
864  # get_configtool_variable() work with it, so we have no way to get this flag right,
865  # unless we do all the work ourselves. See current work in glib, also meson #553.
866  pc_cdata.set('PTHREAD_LIBS', '-pthread')
867
868  pc_files = [
869    'libpulse.pc',
870    'libpulse-simple.pc',
871  ]
872
873  if glib_dep.found()
874    pc_files += 'libpulse-mainloop-glib.pc'
875  endif
876
877  foreach file : pc_files
878    configure_file(
879      input : file + '.in',
880      output : file,
881      configuration : pc_cdata,
882      install_dir : pkgconfigdir)
883  endforeach
884
885  # CMake files
886
887  m4 = find_program('m4', required: true)
888
889  cmakedir = join_paths(libdir, 'cmake', 'PulseAudio')
890
891  cmake_template_file = configure_file(
892    input : 'PulseAudioConfig.cmake.in',
893    output : 'PulseAudioConfig.cmake.tmp',
894    configuration: cdata,
895  )
896
897  custom_target('PulseAudioConfig.cmake',
898    input : cmake_template_file,
899    output : 'PulseAudioConfig.cmake',
900    capture : true,
901    command : [m4, '@INPUT@'],
902    build_by_default : true,
903    install : true,
904    install_dir : cmakedir,
905  )
906
907  configure_file(
908    input : 'PulseAudioConfigVersion.cmake.in',
909    output : 'PulseAudioConfigVersion.cmake',
910    configuration: cdata,
911    install : true,
912    install_dir : cmakedir,
913  )
914
915endif # client
916
917############################################################
918
919# Final summary
920
921summary = [
922  '',
923  '---{ @0@ @1@ }---'.format(meson.project_name(), meson.project_version()),
924  '',
925  'prefix:                        @0@'.format(prefix),
926  'bindir:                        @0@'.format(bindir),
927  'libdir:                        @0@'.format(libdir),
928  'libexecdir:                    @0@'.format(libexecdir),
929  'mandir:                        @0@'.format(mandir),
930  'datadir:                       @0@'.format(datadir),
931  'sysconfdir:                    @0@'.format(sysconfdir),
932  'localstatedir:                 @0@'.format(localstatedir),
933  'modlibexecdir:                 @0@'.format(modlibexecdir),
934  'alsadatadir:                   @0@'.format(alsadatadir),
935  'System Runtime Path:           @0@'.format(cdata.get_unquoted('PA_SYSTEM_RUNTIME_PATH')),
936  'System State Path:             @0@'.format(cdata.get_unquoted('PA_SYSTEM_STATE_PATH')),
937  'System Config Path:            @0@'.format(cdata.get_unquoted('PA_SYSTEM_CONFIG_PATH')),
938  'Bash completions directory:    @0@'.format(bashcompletiondir),
939  'Zsh completions directory:     @0@'.format(zshcompletiondir),
940  'Compiler:                      @0@ @1@'.format(cc.get_id(), cc.version()),
941#  'CFLAGS:                        @0@'.format(${CFLAGS}),
942#  'CPPFLAGS:                      @0@'.format(${CPPFLAGS}),
943#  'LIBS:                          @0@'.format(${LIBS}),
944  '',
945  'Enable pulseaudio daemon:      @0@'.format(get_option('daemon')),
946  'Enable pulseaudio client:      @0@'.format(get_option('client')),
947  '',
948  'Enable memfd shared memory:    @0@'.format(cdata.has('HAVE_MEMFD')),
949  'Enable X11:                    @0@'.format(x11_dep.found()),
950  'Enable D-Bus:                  @0@'.format(dbus_dep.found()),
951  'Enable GLib 2:                 @0@'.format(glib_dep.found()),
952  'Enable systemd integration:    @0@'.format(libsystemd_dep.found()),
953  'Enable FFTW:                   @0@'.format(fftw_dep.found()),
954  'Enable IPv6:                   @0@'.format(get_option('ipv6')),
955  'Enable Gcov coverage:          @0@'.format(get_option('gcov')),
956  'Enable Valgrind:               @0@'.format(cdata.has('HAVE_VALGRIND_MEMCHECK_H')),
957  'Enable man pages:              @0@'.format(get_option('man')),
958  'Enable unit tests:             @0@'.format(get_option('tests')),
959]
960
961if get_option('client')
962summary += [
963  '',
964  '--- Pulseaudio client features ---',
965  '',
966  'Enable Gtk+ 3:                 @0@'.format(gtk_dep.found()),
967  'Enable Async DNS:              @0@'.format(asyncns_dep.found()),
968  'Enable OSS Wrapper:            @0@'.format(cdata.has('HAVE_OSS_WRAPPER')),
969]
970endif
971
972if get_option('daemon')
973summary += [
974  '',
975  '--- Pulseaudio daemon features ---',
976  '',
977  'Safe X11 I/O errors:           @0@'.format(cdata.has('HAVE_XSETIOERROREXITHANDLER')),
978  'Enable Avahi:                  @0@'.format(avahi_dep.found()),
979  'Enable OSS Output:             @0@'.format(cdata.has('HAVE_OSS_OUTPUT')),
980#  'Enable EsounD:                 @0@'.format(${ENABLE_ESOUND}),
981  'Enable Alsa:                   @0@'.format(alsa_dep.found()),
982  'Enable Jack:                   @0@'.format(jack_dep.found()),
983  'Enable LIRC:                   @0@'.format(lirc_dep.found()),
984#  'Enable CoreAudio:              @0@'.format(${ENABLE_COREAUDIO}),
985#  'Enable Solaris:                @0@'.format(${ENABLE_SOLARIS}),
986#  'Enable WaveOut:                @0@'.format(${ENABLE_WAVEOUT}),
987  'Enable GSettings:              @0@'.format(gio_dep.found()),
988  'Enable BlueZ 5:              @0@'.format(cdata.has('HAVE_BLUEZ_5')),
989  '  Enable native headsets:    @0@'.format(cdata.has('HAVE_BLUEZ_5_NATIVE_HEADSET')),
990  '  Enable  ofono headsets:    @0@'.format(cdata.has('HAVE_BLUEZ_5_OFONO_HEADSET')),
991  '  Enable GStreamer based codecs: @0@'.format(have_bluez5_gstreamer),
992  'Enable GStreamer:              @0@'.format(have_gstreamer),
993  'Enable libsamplerate:          @0@'.format(samplerate_dep.found()),
994  'Enable ORC:                    @0@'.format(have_orcc),
995  'Enable Adrian echo canceller:  @0@'.format(get_option('adrian-aec')),
996  'Enable Speex (resampler, AEC): @0@'.format(speex_dep.found()),
997  'Enable SoXR (resampler):       @0@'.format(soxr_dep.found()),
998  'Enable WebRTC echo canceller:  @0@'.format(webrtc_dep.found()),
999  '',
1000  'Enable udev:                   @0@'.format(udev_dep.found()),
1001  '  Enable HAL->udev compat:     @0@'.format(get_option('hal-compat')),
1002  'Enable systemd units:          @0@'.format(systemd_dep.found()),
1003  'Enable elogind:                @0@'.format(libelogind_dep.found()),
1004  'Enable TCP Wrappers:           @0@'.format(tcpwrap_dep.found()),
1005  'Enable OpenSSL (for Airtunes): @0@'.format(openssl_dep.found()),
1006  'Database:                      @0@'.format(get_option('database')),
1007  'Legacy Database Entry Support: @0@'.format(get_option('legacy-database-entry-format')),
1008  'module-stream-restore:',
1009  '  Clear old devices:           @0@'.format(get_option('stream-restore-clear-old-devices')),
1010  'Running from build tree:       @0@'.format(get_option('running-from-build-tree')),
1011  'System User:                   @0@'.format(cdata.get_unquoted('PA_SYSTEM_USER')),
1012  'System Group:                  @0@'.format(cdata.get_unquoted('PA_SYSTEM_GROUP')),
1013  'Access Group:                  @0@'.format(cdata.get_unquoted('PA_ACCESS_GROUP')),
1014#  'Enable per-user EsounD socket: @0@'.format(${ENABLE_PER_USER_ESOUND_SOCKET}),
1015#  'Force preopen:                 @0@'.format(${FORCE_PREOPEN}),
1016#  'Preopened modules:             @0@'.format(${PREOPEN_MODS}),
1017]
1018endif
1019
1020message('\n    '.join(summary))
1021
1022# Sanity checks
1023
1024if get_option('daemon') and not speex_dep.found() and not webrtc_dep.found() and not get_option('adrian-aec')
1025  error('At least one echo canceller implementation must be available!')
1026endif
1027
1028if get_option('daemon') and samplerate_dep.found()
1029  warning('Support for libsamplerate is DEPRECATED')
1030endif
1031
1032if host_machine.system() != 'windows' and not dbus_dep.found()
1033  message = [
1034    'You do not have D-Bus support enabled. It is strongly recommended',
1035    'that you enable D-Bus support if your platform supports it.',
1036    'Many parts of PulseAudio use D-Bus, from ConsoleKit interaction',
1037    'to the Device Reservation Protocol to speak to JACK, Bluetooth',
1038    'support and even a native control protocol for communicating and',
1039    'controlling the PulseAudio daemon itself.',
1040  ]
1041  warning('\n' + '\n'.join(message))
1042endif
1043
1044if get_option('daemon') and host_machine.system() == 'linux' and not udev_dep.found()
1045  message = [
1046    'You do not have udev support enabled. It is strongly recommended',
1047    'that you enable udev support if your platform supports it as it is',
1048    'the primary method used to detect hardware audio devices (on Linux)',
1049    'and is thus a critical part of PulseAudio on that platform.',
1050  ]
1051  warning('\n' + '\n'.join(message))
1052endif
1053
1054if get_option('daemon') and host_machine.system() != 'windows' and not speex_dep.found()
1055  message = [
1056    'You do not have speex support enabled. It is strongly recommended',
1057    'that you enable speex support if your platform supports it as it is',
1058    'the primary method used for audio resampling and is thus a critical',
1059    'part of PulseAudio on that platform.',
1060  ]
1061  warning('\n' + '\n'.join(message))
1062endif
1063