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