device-manager: Add null check in handle_device_connected()
[platform/core/multimedia/pulseaudio-modules-tizen.git] / configure.ac
1 # -*- Autoconf -*-
2 # Process this file with autoconf to produce a configure script.
3
4 # This file is part of PulseAudio.
5 #
6 # Copyright 2004-2008 Lennart Poettering
7 # Copyright 2006-2007 Pierre Ossman <ossman@cendio.se> for Cendio AB
8 #
9 # PulseAudio is free software; you can redistribute it and/or modify it
10 # under the terms of the GNU Lesser General Public License as published by
11 # the Free Software Foundation; either version 2 of the License, or
12 # (at your option) any later version.
13 #
14 # PulseAudio is distributed in the hope that it will be useful, but
15 # WITHOUT ANY WARRANTY; without even the implied warranty of
16 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 # General Public License for more details.
18 #
19 # You should have received a copy of the GNU Lesser General Public License
20 # along with PulseAudio; if not, write to the Free Software Foundation,
21 # Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
22
23 AC_PREREQ(2.63)
24
25 AC_INIT([pulseaudio-module-tizen],[0.1])
26 AC_CONFIG_SRCDIR([src/module-tizenaudio-policy.c])
27 AC_CONFIG_MACRO_DIR([m4])
28 AC_CONFIG_HEADERS([config.h])
29 AM_INIT_AUTOMAKE([foreign 1.11 -Wall -Wno-portability subdir-objects silent-rules color-tests dist-xz tar-ustar])
30
31 #### Checks for programs. ####
32
33 # mkdir -p
34
35 AC_PROG_MKDIR_P
36
37 # CC
38
39 AC_PROG_CC
40 AC_PROG_CC_C99
41 AM_PROG_CC_C_O
42 # Only required if you want the WebRTC canceller -- no runtime dep on
43 # libstdc++ otherwise
44 AC_PROG_CXX
45 AC_PROG_GCC_TRADITIONAL
46 AC_USE_SYSTEM_EXTENSIONS
47
48 # M4
49
50 AC_CHECK_PROGS([M4], gm4 m4, no)
51 AS_IF([test "x$M4" = "xno"], AC_MSG_ERROR([m4 missing]))
52
53 # pkg-config
54
55 PKG_PROG_PKG_CONFIG
56
57 #### Compiler flags ####
58
59 AX_APPEND_COMPILE_FLAGS(
60     [-Wall -W -Wextra -pipe -Wno-long-long -Wno-overlength-strings -Wunsafe-loop-optimizations -Wundef -Wformat=2 -Wlogical-op -Wsign-compare -Wformat-security -Wmissing-include-dirs -Wformat-nonliteral -Wold-style-definition -Wpointer-arith -Winit-self -Wdeclaration-after-statement -Wfloat-equal -Wmissing-prototypes -Wstrict-prototypes -Wredundant-decls -Wmissing-declarations -Wmissing-noreturn -Wshadow -Wendif-labels -Wcast-align -Wstrict-aliasing -Wwrite-strings -Wno-unused-parameter -ffast-math -fno-common -fdiagnostics-show-option],
61     [], [-pedantic -Werror])
62
63 # Only enable fastpath asserts when doing a debug build, e.g. from bootstrap.sh.
64 AS_CASE([" $CFLAGS "], [*" -O0 "*], [], [AX_APPEND_FLAG(["-DFASTPATH"], [CPPFLAGS])])
65
66 # Only set _FORTIFY_SOURCE when optimizations are enabled. If optimizations
67 # are disabled, _FORTIFY_SOURCE doesn't do anything, and causes tons of
68 # warnings during compiling on some distributions (at least Fedora).
69 AS_CASE([" $CFLAGS "], [*" -O0 "*], [], [AX_APPEND_FLAG(["-D_FORTIFY_SOURCE=2"], [CPPFLAGS])])
70
71
72 #### Linker flags ####
73
74 # Use immediate (now) bindings; avoids the funky re-call in itself.
75 # The -z now syntax is lifted from Sun's linker and works with GNU's too, other linkers might be added later.
76 AX_APPEND_LINK_FLAGS([-Wl,-z,now], [IMMEDIATE_LDFLAGS])
77 AC_SUBST([IMMEDIATE_LDFLAGS])
78
79 # On ELF systems we don't want the libraries to be unloaded since we don't clean them up properly,
80 # so we request the nodelete flag to be enabled.
81 # On other systems, we don't really know how to do that, but it's welcome if somebody can tell.
82 AX_APPEND_LINK_FLAGS([-Wl,-z,nodelete], [NODELETE_LDFLAGS])
83 AC_SUBST([NODELETE_LDFLAGS])
84
85 # Check for the proper way to build libraries that have no undefined symbols
86 case $host in
87     # FreeBSD (et al.) does not complete linking for shared objects when pthreads
88     # are requested, as different implementations are present.
89     *-freebsd* | *-openbsd*) ;;
90     *)
91         for possible_flag in "-Wl,--no-undefined" "-Wl,-z,defs"; do
92             AX_CHECK_LINK_FLAG([$possible_flag], [NOUNDEFINED_LDFLAGS="$possible_flag"; break])
93         done
94     ;;
95 esac
96 AC_SUBST([NOUNDEFINED_LDFLAGS])
97
98
99 #### Atomic operations ####
100
101 # Native atomic operation support
102 AC_ARG_ENABLE([atomic-arm-linux-helpers],
103     AS_HELP_STRING([--disable-atomic-arm-linux-helpers],[use inline asm or libatomic_ops instead]))
104
105 AC_ARG_ENABLE([atomic-arm-memory-barrier],
106     AS_HELP_STRING([--enable-atomic-arm-memory-barrier],[only really needed in SMP arm systems]))
107
108 if test "x$enable_atomic_arm_memory_barrier" = "xyes"; then
109     AC_DEFINE_UNQUOTED(ATOMIC_ARM_MEMORY_BARRIER_ENABLED, 1, [Enable memory barriers])
110 fi
111
112 # If everything else fails use libatomic_ops
113 need_libatomic_ops=yes
114
115 AC_CACHE_CHECK([whether $CC knows __sync_bool_compare_and_swap()],
116     pulseaudio_cv_sync_bool_compare_and_swap, [
117     AC_LINK_IFELSE(
118         [AC_LANG_PROGRAM([], [[int a = 4; __sync_bool_compare_and_swap(&a, 4, 5);]])],
119         [pulseaudio_cv_sync_bool_compare_and_swap=yes],
120         [pulseaudio_cv_sync_bool_compare_and_swap=no])
121     ])
122
123 if test "$pulseaudio_cv_sync_bool_compare_and_swap" = "yes" ; then
124     AC_DEFINE([HAVE_ATOMIC_BUILTINS], 1, [Have __sync_bool_compare_and_swap() and friends.])
125     need_libatomic_ops=no
126 else
127     # HW specific atomic ops stuff
128     AC_MSG_CHECKING([architecture for native atomic operations])
129     case $host in
130         arm*)
131             AC_MSG_RESULT([arm])
132             AC_MSG_CHECKING([whether we can use Linux kernel helpers])
133             # The Linux kernel helper functions have been there since 2.6.16. However
134             # compile time checking for kernel version in cross compile environment
135             # (which is usually the case for arm cpu) is tricky (or impossible).
136             if test "x$os_is_linux" = "x1" && test "x$enable_atomic_arm_linux_helpers" != "xno"; then
137                 AC_MSG_RESULT([yes])
138                 AC_DEFINE_UNQUOTED(ATOMIC_ARM_LINUX_HELPERS, 1, [special arm linux implementation])
139                 need_libatomic_ops=no
140             else
141                 AC_MSG_RESULT([no])
142                 AC_CACHE_CHECK([compiler support for arm inline asm atomic operations],
143                     pulseaudio_cv_support_arm_atomic_ops, [
144                     AC_COMPILE_IFELSE(
145                         [AC_LANG_PROGRAM([], [[
146                             volatile int a=0;
147                             int o=0, n=1, r;
148                             asm volatile ("ldrex    %0, [%1]\n"
149                                           "subs  %0, %0, %2\n"
150                                           "strexeq %0, %3, [%1]\n"
151                                           : "=&r" (r)
152                                           : "r" (&a), "Ir" (o), "r" (n)
153                                           : "cc");
154                             return (a==1 ? 0 : -1);
155                         ]])],
156                         [pulseaudio_cv_support_arm_atomic_ops=yes],
157                         [pulseaudio_cv_support_arm_atomic_ops=no])
158                 ])
159                 AS_IF([test "$pulseaudio_cv_support_arm_atomic_ops" = "yes"], [
160                     AC_DEFINE([ATOMIC_ARM_INLINE_ASM], 1, [Have ARM atomic instructions.])
161                     need_libatomic_ops=no
162                 ])
163             fi
164         ;;
165         *-netbsdelf5*)
166             AC_MSG_RESULT([yes])
167             need_libatomic_ops=no
168         ;;
169         *-freebsd*)
170             AC_MSG_RESULT([yes])
171             need_libatomic_ops=no
172         ;;
173         *)
174             AC_MSG_RESULT([unknown])
175         ;;
176     esac
177 fi
178
179 # If we're on ARM, check for the ARMV6 instructions we need */
180 case $host in
181   arm*)
182     AC_CACHE_CHECK([support for required armv6 instructions],
183       pulseaudio_cv_support_armv6,
184       [AC_COMPILE_IFELSE(
185          [AC_LANG_PROGRAM([],
186            [[volatile int a = -60000, b = 0xaaaabbbb, c = 0xccccdddd;
187              asm volatile ("ldr r0, %2 \n"
188                            "ldr r2, %3 \n"
189                            "ldr r3, %4 \n"
190                            "ssat r1, #8, r0 \n"
191                            "str r1, %0 \n"
192                            "pkhbt r1, r3, r2, LSL #8 \n"
193                            "str r1, %1 \n"
194                            : "=m" (a), "=m" (b)
195                            : "m" (a), "m" (b), "m" (c)
196                            : "r0", "r1", "r2", "r3", "cc");
197              return (a == -128 && b == 0xaabbdddd) ? 0 : -1;
198            ]])],
199          [pulseaudio_cv_support_armv6=yes],
200          [pulseaudio_cv_support_armv6=no])
201       ])
202     AS_IF([test "$pulseaudio_cv_support_armv6" = "yes"], [
203         AC_DEFINE([HAVE_ARMV6], 1, [Have ARMv6 instructions.])
204       ])
205   ;;
206   *)
207   ;;
208 esac
209
210 #### libtool stuff ####
211
212 LT_PREREQ(2.4)
213 LT_INIT([dlopen win32-dll disable-static])
214
215 dnl As an extra safety device, check for lt_dladvise_init() which is
216 dnl only implemented in libtool 2.x, and refine as we go if we have
217 dnl refined requirements.
218 dnl
219 dnl Check the header files first since the system may have a
220 dnl libltdl.so for runtime, but no headers, and we want to bail out as
221 dnl soon as possible.
222 dnl
223 dnl We don't need any special variable for this though, since the user
224 dnl can give the proper place to find libltdl through the standard
225 dnl variables like LDFLAGS and CPPFLAGS.
226
227 AC_CHECK_HEADER([ltdl.h],
228     [AC_CHECK_LIB([ltdl], [lt_dladvise_init], [LIBLTDL=-lltdl], [LIBLTDL=])],
229     [LIBLTDL=])
230
231 AS_IF([test "x$LIBLTDL" = "x"],
232     [AC_MSG_ERROR([Unable to find libltdl version 2. Makes sure you have libtool 2.4 or later installed.])])
233 AC_SUBST([LIBLTDL])
234
235
236 ###################################
237 #   Basic environment checks      #
238 ###################################
239
240 #### Checks for header files. ####
241
242 # ISO
243 AC_HEADER_STDC
244
245 # POSIX
246 AC_CHECK_HEADERS_ONCE([arpa/inet.h glob.h grp.h netdb.h netinet/in.h \
247     netinet/in_systm.h netinet/tcp.h poll.h pwd.h sched.h \
248     sys/mman.h sys/select.h sys/socket.h sys/wait.h \
249     sys/uio.h syslog.h sys/dl.h dlfcn.h linux/sockios.h])
250 AC_CHECK_HEADERS([netinet/ip.h], [], [],
251                  [#include <sys/types.h>
252                   #if HAVE_NETINET_IN_H
253                   # include <netinet/in.h>
254                   #endif
255                   #if HAVE_NETINET_IN_SYSTM_H
256                   # include <netinet/in_systm.h>
257                   #endif
258                  ])
259 AC_CHECK_HEADERS([sys/resource.h], [HAVE_SYS_RESOURCE_H=1], [HAVE_SYS_RESOURCE_H=0])
260 AC_SUBST(HAVE_SYS_RESOURCE_H)
261 AC_CHECK_HEADERS([sys/un.h], [HAVE_AF_UNIX=1], [HAVE_AF_UNIX=0])
262 AM_CONDITIONAL(HAVE_AF_UNIX, test "x$HAVE_AF_UNIX" = "x1")
263 AC_SUBST(HAVE_AF_UNIX)
264
265 # Linux
266 AC_CHECK_HEADERS([linux/input.h], [HAVE_EVDEV=1], [HAVE_EVDEV=0])
267 AM_CONDITIONAL([HAVE_EVDEV], [test "x$HAVE_EVDEV" = "x1"])
268
269 AC_CHECK_HEADERS_ONCE([sys/prctl.h])
270
271 #### Check for libs ####
272
273 # ISO
274 AC_SEARCH_LIBS([pow], [m])
275
276 # POSIX
277 AC_SEARCH_LIBS([sched_setscheduler], [rt])
278 AC_SEARCH_LIBS([dlopen], [dl])
279 AC_SEARCH_LIBS([shm_open], [rt])
280 AC_SEARCH_LIBS([inet_ntop], [nsl])
281 AC_SEARCH_LIBS([timer_create], [rt])
282 AC_SEARCH_LIBS([pthread_setaffinity_np], [pthread])
283 AC_SEARCH_LIBS([pthread_getname_np], [pthread])
284 AC_SEARCH_LIBS([pthread_setname_np], [pthread])
285
286 # BSD
287 AC_SEARCH_LIBS([connect], [socket])
288 AC_SEARCH_LIBS([backtrace], [execinfo ubacktrace])
289
290
291 #### Check for functions ####
292
293 # ISO
294 AC_CHECK_FUNCS_ONCE([lrintf strtof])
295
296 # POSIX
297 AC_FUNC_FORK
298 AC_FUNC_GETGROUPS
299 AC_CHECK_FUNCS_ONCE([chmod chown fstat fchown fchmod clock_gettime getaddrinfo getgrgid_r getgrnam_r \
300     getpwnam_r getpwuid_r gettimeofday getuid mlock nanosleep \
301     pipe posix_fadvise posix_madvise posix_memalign setpgid setsid shm_open \
302     sigaction sleep symlink sysconf uname pthread_setaffinity_np pthread_getname_np pthread_setname_np])
303 AC_CHECK_FUNCS([mkfifo], [HAVE_MKFIFO=1], [HAVE_MKFIFO=0])
304 AC_SUBST(HAVE_MKFIFO)
305 AM_CONDITIONAL(HAVE_MKFIFO, test "x$HAVE_MKFIFO" = "x1")
306
307 # X/OPEN
308 AC_CHECK_FUNCS_ONCE([readlink])
309
310 # SUSv2
311 AC_CHECK_FUNCS_ONCE([ctime_r usleep])
312
313 # SUSv3
314 AC_CHECK_FUNCS_ONCE([strerror_r])
315
316 # BSD
317 AC_CHECK_FUNCS_ONCE([lstat])
318
319 # Non-standard
320 AC_CHECK_FUNCS_ONCE([setresuid setresgid setreuid setregid seteuid setegid ppoll strsignal sig2str strtof_l pipe2 accept4])
321
322 AC_FUNC_ALLOCA
323
324 AC_CHECK_FUNCS([regexec], [HAVE_REGEX=1], [HAVE_REGEX=0])
325 AM_CONDITIONAL(HAVE_REGEX, [test "x$HAVE_REGEX" = "x1"])
326
327 # Large File-Support (LFS)
328 AC_SYS_LARGEFILE
329 # Check for open64 to know if the current system does have open64() and similar functions
330 AC_CHECK_FUNCS_ONCE([open64])
331
332
333 ###################################
334 #      External libraries         #
335 ###################################
336
337 PKG_CHECK_MODULES(PA, libpulse)
338 AC_SUBST(PA_CFLAGS)
339 AC_SUBST(PA_LIBS)
340 AC_SUBST(PA_LDFLAGS)
341
342 PKG_CHECK_MODULES(PACORE, pulsecore)
343 AC_SUBST(PACORE_CFLAGS)
344 AC_SUBST(PACORE_LIBS)
345 AC_SUBST(PACORE_LDFLAGS)
346
347 #### [lib]iconv ####
348
349 AM_ICONV
350
351 #### json parsing ####
352
353 PKG_CHECK_MODULES(LIBJSON, [ json-c >= 0.11 ])
354
355 #### Sound file ####
356 PKG_CHECK_MODULES(INIPARSER, iniparser)
357 AC_SUBST(INIPARSER_CFLAGS)
358 AC_SUBST(INIPARSER_LIBS)
359
360 PKG_CHECK_MODULES(VCONF, vconf)
361 AC_SUBST(VCONF_CFLAGS)
362 AC_SUBST(VCONF_LIBS)
363
364 PKG_CHECK_MODULES(DNSSD, dns_sd)
365 AC_SUBST(DNSSD_CFLAGS)
366 AC_SUBST(DNSSD_LIBS)
367
368 PKG_CHECK_MODULES(HALAPIAUDIO, hal-api-audio)
369 AC_SUBST(HALAPIAUDIO_CFLAGS)
370 AC_SUBST(HALAPIAUDIO_LIBS)
371
372 dnl use hal tc ------------------------------------------------------------
373 AC_ARG_ENABLE(haltc, AC_HELP_STRING([--enable-haltc], [using haltc]),
374 [
375  case "${enableval}" in
376          yes) ENABLE_HALTC=yes ;;
377          no)  ENABLE_HALTC=no ;;
378          *)   AC_MSG_ERROR(bad value ${enableval} for --enable-haltc) ;;
379  esac
380  ],[USE_HALTC=no])
381 AM_CONDITIONAL(ENABLE_HALTC, test "x$ENABLE_HALTC" = "xyes")
382 dnl end --------------------------------------------------------------------
383
384 dnl use acm ----------------------------------------------------------------
385 AC_ARG_ENABLE(acm, AC_HELP_STRING([--enable-acm], [using acm]),
386 [
387  case "${enableval}" in
388          yes) ENABLE_ACM=yes ;;
389          no)  ENABLE_ACM=no ;;
390          *)   AC_MSG_ERROR(bad value ${enableval} for --enable-acm) ;;
391  esac
392  ],[USE_ACM=no])
393 AM_CONDITIONAL(ENABLE_ACM, test "x$ENABLE_ACM" = "xyes")
394 dnl end --------------------------------------------------------------------
395
396 dnl use aec ----------------------------------------------------------------
397 AC_ARG_ENABLE(aec, AC_HELP_STRING([--enable-aec], [using aec]),
398 [
399  case "${enableval}" in
400          yes) ENABLE_AEC=yes ;;
401          no)  ENABLE_AEC=no ;;
402          *)   AC_MSG_ERROR(bad value ${enableval} for --enable-aec) ;;
403  esac
404  ],[USE_AEC=no])
405 AM_CONDITIONAL(ENABLE_AEC, test "x$ENABLE_AEC" = "xyes")
406 dnl end --------------------------------------------------------------------
407
408 #### D-Bus support (optional) ####
409
410 AC_ARG_ENABLE([dbus],
411     AS_HELP_STRING([--disable-dbus],[Disable optional D-Bus support]))
412
413 AS_IF([test "x$enable_dbus" != "xno"],
414     [PKG_CHECK_MODULES(DBUS, [ dbus-1 >= 1.4.12 ], HAVE_DBUS=1, HAVE_DBUS=0)],
415     HAVE_DBUS=0)
416
417 AS_IF([test "x$enable_dbus" = "xyes" && test "x$HAVE_DBUS" = "x0"],
418     [AC_MSG_ERROR([*** D-Bus not available or too old version])])
419
420 AS_IF([test "x$HAVE_DBUS" = "x1"],
421     [
422         save_CFLAGS="$CFLAGS"; CFLAGS="$CFLAGS $DBUS_CFLAGS"
423         save_LIBS="$LIBS"; LIBS="$LIBS $DBUS_LIBS"
424         AC_CHECK_FUNCS(dbus_watch_get_unix_fd)
425         CFLAGS="$save_CFLAGS"
426         LIBS="$save_LIBS"
427     ])
428
429 AC_SUBST(HAVE_DBUS)
430 AM_CONDITIONAL([HAVE_DBUS], [test "x$HAVE_DBUS" = x1])
431 AS_IF([test "x$HAVE_DBUS" = "x1"], AC_DEFINE([HAVE_DBUS], 1, [Have D-Bus.]))
432
433 PA_MACHINE_ID="${sysconfdir}/machine-id"
434 AX_DEFINE_DIR(PA_MACHINE_ID, PA_MACHINE_ID, [D-Bus machine-id file])
435 PA_MACHINE_ID_FALLBACK="${localstatedir}/lib/dbus/machine-id"
436 AX_DEFINE_DIR(PA_MACHINE_ID_FALLBACK, PA_MACHINE_ID_FALLBACK,
437               [Fallback machine-id file])
438
439 #### vconf helper support (optional) ####
440 PKG_CHECK_MODULES(GLIB2, glib-2.0)
441 AC_SUBST(GLIB2_CFLAGS)
442 AC_SUBST(GLIB2_LIBS)
443
444 AC_ARG_ENABLE(vconf-helper, AC_HELP_STRING([--enable-vconf-helper], [using vconf-helper]),
445 [
446  case "${enableval}" in
447          yes) ENABLE_VCONF_HELPER=yes ;;
448          no)  ENABLE_VCONF_HELPER=no ;;
449          *)   AC_MSG_ERROR(bad value ${enableval} for --enable-vconf-helper) ;;
450  esac
451  ],[ENABLE_VCONF_HELPER=no])
452 AM_CONDITIONAL(ENABLE_VCONF_HELPER, test "x$ENABLE_VCONF_HELPER" = "xyes")
453
454 ###################################
455 #            Output               #
456 ###################################
457
458 AC_DEFINE_UNQUOTED(PA_CFLAGS, "$CFLAGS", [The CFLAGS used during compilation])
459
460 AC_CONFIG_FILES([
461 Makefile
462 ])
463 AC_OUTPUT