meson: Fix bluez5 version requirement
[platform/upstream/pulseaudio.git] / meson.build
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.47.0',
4         default_options : [ 'c_std=gnu11', 'cpp_std=c++11' ]
5         )
6
7 pa_version_str = meson.project_version()
8 # For tarballs, the first split will do nothing, but for builds in git, we
9 # split out suffixes when there are commits since the last tag
10 # (e.g.: v11.99.1-3-gad14bdb24 -> v11.99.1)
11 version_split = pa_version_str.split('-')[0].split('.')
12 pa_version_major = version_split[0].split('v')[0]
13 pa_version_minor = version_split[1]
14 if version_split.length() > 2
15   pa_version_micro = version_split[2]
16 else
17   pa_version_micro = '0'
18 endif
19 pa_version_major_minor = pa_version_major + '.' + pa_version_minor
20
21 pa_api_version = 12
22 pa_protocol_version = 33
23
24 apiversion = '1.0'
25 soversion = 0
26 # FIXME: this doesn't actually do what we want it to
27 # maintaining compatibility with the previous libtool versioning
28 # current = minor * 100 + micro
29 libversion = '@0@.@1@.0'.format(soversion, pa_version_minor.to_int() * 100 + pa_version_micro.to_int())
30
31 # Paths
32
33 prefix = get_option('prefix')
34 if not prefix.startswith('/')
35   error('Prefix is not absolute: "@0@"'.format(prefix))
36 endif
37
38 bindir = join_paths(prefix, get_option('bindir'))
39 libdir = join_paths(prefix, get_option('libdir'))
40 datadir = join_paths(prefix, get_option('datadir'))
41 localstatedir = join_paths(prefix, get_option('localstatedir'))
42 sysconfdir = join_paths(prefix, get_option('sysconfdir'))
43
44 pulsedspdir = get_option('pulsedspdir')
45 if pulsedspdir == ''
46   join_paths(libdir, 'pulseaudio')
47 endif
48
49 # Configuration data
50
51 cc = meson.get_compiler('c')
52
53 cdata = configuration_data()
54 cdata.set_quoted('PACKAGE', 'pulseaudio')
55 cdata.set_quoted('PACKAGE_NAME', 'pulseaudio')
56 cdata.set_quoted('PACKAGE_VERSION', pa_version_str)
57 cdata.set_quoted('CANONICAL_HOST', host_machine.cpu())
58 cdata.set('PA_MAJOR', pa_version_major)
59 cdata.set('PA_MINOR', pa_version_minor)
60 cdata.set('PA_API_VERSION', pa_api_version)
61 cdata.set('PA_PROTOCOL_VERSION', pa_protocol_version)
62 cdata.set_quoted('PA_MACHINE_ID', join_paths(sysconfdir, 'machine-id'))
63 cdata.set_quoted('PA_MACHINE_ID_FALLBACK', join_paths(localstatedir, 'lib', 'dbus', 'machine-id'))
64 cdata.set_quoted('PA_SRCDIR', join_paths(meson.current_source_dir(), 'src'))
65 cdata.set_quoted('PA_BUILDDIR', meson.current_build_dir())
66 cdata.set_quoted('PA_SOEXT', '.so')
67 cdata.set_quoted('PA_DEFAULT_CONFIG_DIR', join_paths(sysconfdir, 'pulse'))
68 cdata.set_quoted('PA_BINARY', join_paths(bindir, 'pulseaudio'))
69 cdata.set_quoted('PA_SYSTEM_RUNTIME_PATH', join_paths(localstatedir, 'run', 'pulse'))
70 cdata.set_quoted('PA_SYSTEM_CONFIG_PATH', join_paths(localstatedir, 'lib', 'pulse'))
71 cdata.set_quoted('PA_SYSTEM_STATE_PATH', join_paths(localstatedir, 'lib', 'pulse'))
72 cdata.set_quoted('PA_DLSEARCHPATH', join_paths(libdir, 'pulse-' + pa_version_major_minor, 'modules'))
73 cdata.set_quoted('PA_SYSTEM_USER', get_option('system_user'))
74 cdata.set_quoted('PA_SYSTEM_GROUP', get_option('system_group'))
75 cdata.set_quoted('PA_ACCESS_GROUP', get_option('access_group'))
76 cdata.set_quoted('PA_CFLAGS', 'Not yet supported on meson')
77 cdata.set_quoted('PA_ALSA_PATHS_DIR', join_paths(datadir, 'pulseaudio', 'alsa-mixer', 'paths'))
78 cdata.set_quoted('PA_ALSA_PROFILE_SETS_DIR', join_paths(datadir, 'pulseaudio', 'alsa-mixer', 'profile-sets'))
79 cdata.set_quoted('DESKTOPFILEDIR', join_paths(datadir, 'applications'))
80
81 # Headers
82
83 check_headers = [
84   'arpa/inet.h',
85   'cpuid.h',
86   'execinfo.h',
87   'grp.h',
88   'langinfo.h',
89   'locale.h',
90   'netdb.h',
91   'netinet/in.h',
92   'netinet/in_systm.h',
93   'netinet/ip.h',
94   'netinet/tcp.h',
95   'pcreposix.h',
96   'poll.h',
97   'pwd.h',
98   'regex.h',
99   'sched.h',
100   'sys/capability.h',
101   'sys/ioctl.h',
102   'sys/mman.h',
103   'sys/prctl.h',
104   'sys/resource.h',
105   'sys/select.h',
106   'sys/socket.h',
107   'sys/un.h',
108   'sys/wait.h',
109   'valgrind/memcheck.h',
110   'xlocale.h',
111 ]
112
113 foreach h : check_headers
114   if cc.has_header(h)
115     define = 'HAVE_' + h.underscorify().to_upper()
116     cdata.set(define, 1)
117   endif
118 endforeach
119
120 # FIXME: move this to the above set
121 if cc.has_header('pthread.h')
122   cdata.set('HAVE_PTHREAD', 1)
123 endif
124
125 # Functions
126
127 check_functions = [
128   'accept4',
129   'clock_gettime',
130   'fchmod',
131   'fchown',
132   'fork',
133   'fstat',
134   'getaddrinfo',
135   'getgrgid_r',
136   'getpwnam_r',
137   'gettimeofday',
138   'getuid',
139   'lstat',
140   'memfd_create',
141   'mlock',
142   'nanosleep',
143   'paccept',
144   'pipe',
145   'pipe2',
146   'posix_madvise',
147   'readlink',
148   'setegid',
149   'seteuid',
150   'setregid',
151   'setreuid',
152   'setresgid',
153   'setresuid',
154   'setsid',
155   'sig2str',
156   'sigaction',
157   'strtod_l',
158   'symlink',
159   'sysconf',
160   'uname',
161 ]
162
163 foreach f : check_functions
164   if cc.has_function(f)
165     define = 'HAVE_' + f.underscorify().to_upper()
166     cdata.set(define, 1)
167   endif
168 endforeach
169
170 shm_dep = cc.find_library('rt', required : false)
171 if shm_dep.found()
172   cdata.set('HAVE_SHM_OPEN', 1)
173 endif
174
175 if cc.has_function('SYS_memfd_create', prefix : '#include <sys/syscall.h>')
176   cdata.set('HAVE_MEMFD', 1)
177 endif
178
179 # Types
180
181 # FIXME: do we ever care about gid_t not being defined / smaller than an int?
182 cdata.set('GETGROUPS_T', 'gid_t')
183
184 # Include paths
185
186 configinc = include_directories('.')
187 topinc = include_directories('src')
188
189 # CFLAGS
190
191 pa_c_args = ['-DHAVE_CONFIG_H', '-D_GNU_SOURCE']
192 server_c_args = ['-D__INCLUDED_FROM_PULSE_AUDIO']
193 cdata.set('MESON_BUILD', 1)
194
195 # Core Dependencies
196
197 libm_dep = cc.find_library('m', required : true)
198 thread_dep = dependency('threads')
199 cap_dep = cc.find_library('cap', required : false)
200
201 if get_option('database') == 'tdb'
202   database_dep = dependency('tdb')
203 elif get_option('database') == 'gdbm'
204   database_dep = cc.find_library('gdbm', required : true)
205 endif
206
207 atomictest = '''void func() {
208   volatile int atomic = 2;
209   __sync_bool_compare_and_swap (&atomic, 2, 3);
210 }
211 '''
212 if cc.compiles(atomictest)
213   cdata.set('HAVE_ATOMIC_BUILTINS', true)
214 else
215   # FIXME: check if we need libatomic_ops
216 endif
217
218 # FIXME: make sure it's >= 2.2
219 ltdl_dep = cc.find_library('ltdl', required : true)
220 # FIXME: can meson support libtool -dlopen/-dlpreopen things?
221 #        and do we still want to support this at all?
222 cdata.set('DISABLE_LIBTOOL_PRELOAD', 1)
223
224 sndfile_dep = dependency('sndfile', version : '>= 1.0.20')
225
226 dbus_dep = dependency('dbus-1', version : '>= 1.4.12', required : get_option('dbus'))
227 if dbus_dep.found()
228   cdata.set('HAVE_DBUS', 1)
229 endif
230
231 x11_dep = dependency('x11-xcb', required : get_option('x11'))
232 if x11_dep.found()
233   xcb_dep  = dependency('xcb',  required : true, version : '>= 1.6')
234   ice_dep  = dependency('ice',  required : true)
235   sm_dep   = dependency('sm',   required : true)
236   xtst_dep = dependency('xtst', required : true)
237   cdata.set('HAVE_X11', 1)
238 endif
239
240 alsa_dep = dependency('alsa', version : '>= 1.0.24', required : get_option('alsa'))
241 if alsa_dep.found()
242   cdata.set('HAVE_ALSA', 1)
243   cdata.set('HAVE_ALSA_UCM', 1)
244 endif
245
246 systemd_dep = dependency('libsystemd', required : get_option('systemd'))
247 if systemd_dep.found()
248   cdata.set('HAVE_SYSTEMD_DAEMON', 1)
249   cdata.set('HAVE_SYSTEMD_LOGIN', 1)
250   cdata.set('HAVE_SYSTEMD_JOURNAL', 1)
251 endif
252
253 # FIXME: support ORC
254 cdata.set('DISABLE_ORC', 1)
255
256 # Module dependencies
257
258 if cc.has_header('sys/soundcard.h')
259   cdata.set('HAVE_OSS_OUTPUT', 1)
260   cdata.set('HAVE_OSS_WRAPPER', 1)
261   cdata.set_quoted('PULSEDSP_LOCATION', pulsedspdir)
262 endif
263
264 avahi_dep = dependency('avahi-client', version : '>= 0.6.0', required : get_option('avahi'))
265 if avahi_dep.found()
266   cdata.set('HAVE_AVAHI', 1)
267 endif
268
269 bluez_dep = dependency('bluez', version : '>= 5.0', required : get_option('bluez5'))
270 sbc_dep = dependency('sbc', version : '>= 1.0', required : false)
271 if bluez_dep.found()
272   assert(dbus_dep.found(), 'BlueZ requires D-Bus support')
273   assert(sbc_dep.found(), 'BlueZ requires SBC support')
274   cdata.set('HAVE_SBC', 1)
275   cdata.set('HAVE_BLUEZ', 1)
276   cdata.set('HAVE_BLUEZ_5', 1)
277   if get_option('bluez5-native-headset')
278     cdata.set('HAVE_BLUEZ_5_NATIVE_HEADSET', 1)
279   endif
280   if get_option('bluez5-ofono-headset')
281     cdata.set('HAVE_BLUEZ_5_OFONO_HEADSET', 1)
282   endif
283 endif
284
285 jack_dep = dependency('jack', version : '>= 0.117.0', required : false)
286 if jack_dep.found()
287   cdata.set('HAVE_JACK', 1)
288 endif
289
290 fftw_dep = dependency('fftw3f', required : false)
291 if fftw_dep.found()
292   cdata.set('HAVE_FFTW', 1)
293 endif
294
295 lirc_dep = dependency('lirc', required : false)
296 if lirc_dep.found()
297   cdata.set('HAVE_LIRC', 1)
298 endif
299
300 openssl_dep = dependency('openssl', version : '>= 0.9', required : false)
301 if openssl_dep.found()
302   cdata.set('HAVE_OPENSSL', 1)
303 endif
304
305 speex_dep = dependency('speexdsp', version : '>= 1.2', required : false)
306 if speex_dep.found()
307   cdata.set('HAVE_SPEEX', 1)
308 endif
309
310 udev_dep = dependency('libudev', version : '>= 143', required : false)
311 if udev_dep.found()
312   cdata.set('HAVE_UDEV', 1)
313 endif
314
315 webrtc_dep = dependency('webrtc-audio-processing', version : '>= 0.2', required : false)
316 if webrtc_dep.found()
317   cdata.set('HAVE_WEBRTC', 1)
318 endif
319
320 # Now generate config.h from everything above
321 configure_file(output : 'config.h', configuration : cdata)
322
323 subdir('man')
324 subdir('src')