1dnl Process this file with autoconf to produce a configure script.
2AC_PREREQ(2.59)
3AC_INIT(alsa-lib, 1.2.2)
4
5AC_CONFIG_SRCDIR([src/control/control.c])
6AC_CONFIG_MACRO_DIR([m4])
7
8dnl *************************************************
9dnl current:revision:age
10dnl change (without API) = c:r+1:a
11dnl change API = c+1:0:a
12dnl add API = c+1:0:a+1
13dnl remove API = c+1:0:0
14dnl *************************************************
15AC_CANONICAL_HOST
16AM_INIT_AUTOMAKE
17eval LIBTOOL_VERSION_INFO="2:0:0"
18dnl *************************************************
19AM_CONDITIONAL([INSTALL_M4], [test -n "${ACLOCAL}"])
20
21AM_MAINTAINER_MODE([enable])
22
23# Test for new silent rules and enable only if they are available
24m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
25
26AC_PREFIX_DEFAULT(/usr)
27
28dnl Checks for programs.
29
30AC_PROG_CC
31AC_PROG_CPP
32AC_USE_SYSTEM_EXTENSIONS
33AC_PROG_INSTALL
34AC_PROG_LN_S
35AC_DISABLE_STATIC
36AC_LIBTOOL_DLOPEN
37AM_PROG_LIBTOOL
38
39CC_NOUNDEFINED
40
41dnl Checks for header files.
42AC_HEADER_STDC
43AC_CONFIG_HEADERS(include/config.h)
44
45dnl Checks for typedefs, structures, and compiler characteristics.
46AC_C_CONST
47AC_C_INLINE
48AC_HEADER_TIME
49
50dnl Checks for library functions.
51AC_PROG_GCC_TRADITIONAL
52AC_CHECK_FUNCS([uselocale])
53
54SAVE_LIBRARY_VERSION
55AC_SUBST(LIBTOOL_VERSION_INFO)
56
57test "x$prefix" = xNONE && prefix=$ac_default_prefix
58
59dnl Do not build static and shared libraries together
60if test "$enable_static" = "$enable_shared" -a "$enable_static" = "yes"; then
61cat <<EOF
62  Please, do not try to compile static and shared libraries together.
63  See INSTALL file for more details (do not use --enable-shared=yes with
64  --enable-static=yes).
65EOF
66  exit 1
67fi
68
69dnl ALSA configuration directory
70AC_ARG_WITH(configdir,
71    AS_HELP_STRING([--with-configdir=dir],
72	[path where ALSA config files are stored]),
73    confdir="$withval", confdir="")
74if test -z "$confdir"; then
75    eval dir="$datadir"
76    case "$dir" in
77    /*) ;;
78    *) dir="$prefix/share"
79    esac
80    confdir="$dir/alsa"
81fi
82ALSA_CONFIG_DIR="$confdir"
83AC_DEFINE_UNQUOTED(ALSA_CONFIG_DIR, "$confdir", [directory containing ALSA configuration database])
84AC_SUBST(ALSA_CONFIG_DIR)
85
86dnl ALSA plugin directory
87test "x$exec_prefix" = xNONE && exec_prefix=$prefix
88
89AC_ARG_WITH(plugindir,
90    AS_HELP_STRING([--with-plugindir=dir],
91	[path where ALSA plugin files are stored]),
92    plugindir="$withval", plugindir="")
93if test -z "$plugindir"; then
94    eval dir="$libdir"
95    case "$dir" in
96    /*) ;;
97    *) dir="$dir"
98    esac
99    plugindir="$dir/$PACKAGE"
100fi
101AC_DEFINE_UNQUOTED(ALSA_PLUGIN_DIR, "$plugindir", [directory containing ALSA add-on modules])
102ALSA_PLUGIN_DIR="$plugindir"
103AC_SUBST(ALSA_PLUGIN_DIR)
104
105AC_ARG_WITH(pkgconfdir,
106    AS_HELP_STRING([--with-pkgconfdir=dir],
107	[path where pkgconfig files are stored]),
108    pkgconfdir="$withval", pkgconfdir="")
109if test -z "$pkgconfdir"; then
110    eval dir="$libdir"
111    case "$dir" in
112    /*) ;;
113    *) dir="$dir"
114    esac
115    pkgconfdir="$dir/pkgconfig"
116fi
117AC_DEFINE_UNQUOTED(ALSA_PKGCONF_DIR, "$pkgconfdir", [directory containing pkgconfig files])
118ALSA_PKGCONF_DIR="$pkgconfdir"
119AC_SUBST(ALSA_PKGCONF_DIR)
120
121dnl Check for versioned symbols
122AC_MSG_CHECKING(for versioned symbols)
123AC_ARG_WITH(versioned,
124  AS_HELP_STRING([--with-versioned],
125    [shared library will be compiled with versioned symbols (default = yes)]),
126  versioned="$withval", versioned="yes")
127if test "$versioned" = "yes"; then
128  # it seems that GNU ld versions since 2.10 are not broken
129  xres=`grep '^VERSION=' ${srcdir}/ltmain.sh | cut -d = -f 2 | cut -d \" -f 2`
130  major=`echo $xres | cut -d . -f 1`
131  minor=`echo $xres | cut -d . -f 2`
132  pass=0
133  if test $major -eq 1 && test $minor -gt 3; then
134    pass=1
135  else
136    if test $major -gt 1; then
137      pass=1
138    fi
139  fi
140  if test $pass -eq 1; then
141    AC_DEFINE(VERSIONED_SYMBOLS,,[compiled with versioned symbols])
142    AC_MSG_RESULT(yes)
143  else
144    AC_MSG_RESULT(broken libtool - use libtool v1.4+; no versions)
145  fi
146else
147  AC_MSG_RESULT(no)
148fi
149AM_CONDITIONAL([VERSIONED_SYMBOLS], [test x$versioned = xyes])
150
151dnl Check for symbolic-functions
152AC_MSG_CHECKING(for symbolic-functions)
153AC_ARG_ENABLE(symbolic-functions,
154  AS_HELP_STRING([--enable-symbolic-functions],
155    [use -Bsymbolic-functions option if available (optmization for size and speed)]),
156  symfuncs="$enableval", symfuncs="no")
157if test "$symfuncs" = "yes"; then
158  if ld --help | grep -q -- '-Bsymbolic-functions'; then
159    AC_MSG_RESULT(yes)
160  else
161    AC_MSG_RESULT(not supported by ld)
162    symfuncs="no"
163  fi
164else
165  AC_MSG_RESULT(no)
166fi
167AM_CONDITIONAL([SYMBOLIC_FUNCTIONS], [test x"$symfuncs" = xyes])
168
169dnl See if toolchain has a custom prefix for symbols ...
170AC_MSG_CHECKING(for custom symbol prefixes)
171SYMBOL_PREFIX=` \
172	echo "PREFIX=__USER_LABEL_PREFIX__" \
173		| ${CPP-${CC-gcc} -E} - 2>&1 \
174		| ${EGREP-grep} "^PREFIX=" \
175		| ${SED-sed} "s:^PREFIX=::"`
176AC_DEFINE_UNQUOTED([__SYMBOL_PREFIX], "$SYMBOL_PREFIX", [Toolchain Symbol Prefix])
177AC_SUBST(SYMBOL_PREFIX)
178AC_MSG_RESULT($SYMBOL_PREFIX)
179
180dnl Check for debug...
181AC_MSG_CHECKING(for debug)
182AC_ARG_WITH(debug,
183  AS_HELP_STRING([--with-debug],
184    [library will be compiled with asserts (default = yes)]),
185  debug="$withval", debug="yes")
186if test "$debug" = "yes"; then
187  AC_MSG_RESULT(yes)
188else
189  AC_DEFINE(NDEBUG,,[No assert debug])
190  AC_MSG_RESULT(no)
191fi
192
193if test "$debug" = "yes"; then
194  AC_MSG_CHECKING(for debug assert)
195  AC_ARG_ENABLE(debug-assert,
196    AS_HELP_STRING([--enable-debug],
197      [enable assert call at the default error message handler]),
198    debug_assert="$enableval", debug_assert="no")
199  if test "$debug_assert" = "yes"; then
200    AC_MSG_RESULT(yes)
201    AC_DEFINE(ALSA_DEBUG_ASSERT,,[Enable assert at error message handler])
202  else
203    AC_MSG_RESULT(no)
204  fi
205fi
206
207dnl Temporary directory
208AC_MSG_CHECKING(for tmpdir)
209AC_ARG_WITH(tmpdir,
210  AS_HELP_STRING([--with-tmpdir=directory],
211    [directory to put tmp socket files (/tmp)]),
212  tmpdir="$withval", tmpdir="/tmp")
213AC_MSG_RESULT($tmpdir)
214AC_DEFINE_UNQUOTED(TMPDIR, "$tmpdir", [directory to put tmp socket files])
215
216dnl Check for softfloat...
217AC_MSG_CHECKING(for softfloat)
218AC_ARG_WITH(softfloat,
219  AS_HELP_STRING([--with-softfloat],
220    [do you have floating point unit on this machine? (optional)]),
221  [case "$withval" in
222	y|yes) softfloat=yes ;;
223	*) softfloat=no ;;
224   esac],)
225if test "$softfloat" = "yes" ; then
226  AC_DEFINE(HAVE_SOFT_FLOAT, "1", [Avoid calculation in float])
227  AC_MSG_RESULT(yes)
228else
229  AC_MSG_RESULT(no)
230fi
231
232ALSA_DEPLIBS=""
233if test "$softfloat" != "yes"; then
234  ALSA_DEPLIBS="-lm"
235fi
236
237dnl Check for libdl
238AC_MSG_CHECKING(for libdl)
239AC_ARG_WITH(libdl,
240  AS_HELP_STRING([--with-libdl], [Use libdl for plugins (default = yes)]),
241  [ have_libdl="$withval" ], [ have_libdl="yes" ])
242HAVE_LIBDL=
243if test "$have_libdl" = "yes"; then
244  AC_CHECK_LIB([dl], [dlsym], [HAVE_LIBDL="yes"])
245  if test "$HAVE_LIBDL" = "yes" ; then
246    ALSA_DEPLIBS="$ALSA_DEPLIBS -ldl"
247    AC_DEFINE([HAVE_LIBDL], 1, [Have libdl])
248  fi
249else
250  AC_MSG_RESULT(no)
251fi
252AM_CONDITIONAL([BUILD_MODULES], [test "$HAVE_LIBDL" = "yes"])
253
254dnl Check for pthread
255AC_MSG_CHECKING(for pthread)
256AC_ARG_WITH(pthread,
257  AS_HELP_STRING([--with-pthread], [Use pthread (default = yes)]),
258  [ have_pthread="$withval" ], [ have_pthread="yes" ])
259if test "$have_pthread" = "yes"; then
260  AC_CHECK_LIB([pthread], [pthread_join], [HAVE_LIBPTHREAD="yes"])
261  if test "$HAVE_LIBPTHREAD" = "yes"; then
262    ALSA_DEPLIBS="$ALSA_DEPLIBS -lpthread"
263    AC_DEFINE([HAVE_LIBPTHREAD], 1, [Have libpthread])
264  fi
265else
266  AC_MSG_RESULT(no)
267fi
268
269dnl Check for pthread
270if test "$HAVE_LIBPTHREAD" = "yes"; then
271  AC_CHECK_DECL(PTHREAD_MUTEX_RECURSIVE,
272    AC_DEFINE(HAVE_PTHREAD_MUTEX_RECURSIVE, [],
273      [Define if your pthreads implementation have PTHREAD_MUTEX_RECURSIVE]),
274    ,
275    [#include <pthread.h>])
276fi
277
278dnl Check for __thread
279AC_MSG_CHECKING([for __thread])
280AC_LINK_IFELSE([AC_LANG_PROGRAM([#if defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__)) && ((__GNUC__ < 4) || (__GNUC__ == 4 && __GNUC_MINOR__ < 1) || (__GNUC__ == 4 && __GNUC_MINOR__ == 1 && __GNUC_PATCHLEVEL__ < 2))
281#error gcc has this bug: http://gcc.gnu.org/ml/gcc-bugs/2006-09/msg02275.html
282#endif], [static __thread int p = 0])],
283[AC_DEFINE(HAVE___THREAD, 1,
284Define to 1 if compiler supports __thread)
285AC_MSG_RESULT([yes])],
286[AC_MSG_RESULT([no])])
287
288dnl Check for librt
289AC_MSG_CHECKING(for librt)
290AC_ARG_WITH(librt,
291  AS_HELP_STRING([--with-librt], [Use librt for monotonic clock (default = yes)]),
292  [ have_librt="$withval" ], [ have_librt="yes" ])
293if test "$have_librt" = "yes"; then
294  AC_CHECK_LIB([rt], [clock_gettime], [HAVE_LIBRT="yes"])
295  if test "$HAVE_LIBRT" = "yes" ; then
296    ALSA_DEPLIBS="$ALSA_DEPLIBS -lrt"
297    AC_DEFINE([HAVE_LIBRT], 1, [Have librt])
298    AC_DEFINE([HAVE_CLOCK_GETTIME], 1, [Have clock gettime])
299  fi
300else
301  AC_MSG_RESULT(no)
302fi
303
304AC_SUBST(ALSA_DEPLIBS)
305
306dnl Check for use of wordexp...
307AC_MSG_CHECKING(for use of wordexp)
308AC_ARG_WITH(wordexp,
309  AS_HELP_STRING([--with-wordexp],
310    [Use wordexp when expanding configs (default = no)]),
311  [case "$withval" in
312	y|yes) wordexp=yes ;;
313	*) wordexp=no ;;
314   esac],)
315if test "$wordexp" = "yes" ; then
316  AC_DEFINE(HAVE_WORDEXP, "1", [Enable use of wordexp])
317  AC_MSG_RESULT(yes)
318  AC_CHECK_HEADER([wordexp.h],[], [AC_MSG_ERROR([Couldn't find wordexp.h])])
319else
320  AC_MSG_RESULT(no)
321fi
322
323dnl Check for headers
324AC_CHECK_HEADERS([endian.h sys/endian.h sys/shm.h])
325
326dnl Check for resmgr support...
327AC_MSG_CHECKING(for resmgr support)
328AC_ARG_ENABLE(resmgr,
329  AS_HELP_STRING([--enable-resmgr], [support resmgr (optional)]),
330  resmgr="$enableval", resmgr="no")
331AC_MSG_RESULT($resmgr)
332if test "$resmgr" = "yes"; then
333  AC_CHECK_LIB(resmgr, rsm_open_device,,
334    AC_ERROR([Cannot find libresmgr]))
335  AC_DEFINE(SUPPORT_RESMGR, "1", [Support resmgr with alsa-lib])
336fi
337
338dnl Check for aload* support...
339AC_MSG_CHECKING(for aload* support)
340AC_ARG_ENABLE(aload,
341  AS_HELP_STRING([--disable-aload], [disable reading /dev/aload*]),
342  aload="$enableval", aload="yes")
343AC_MSG_RESULT($aload)
344if test "$aload" = "yes"; then
345  AC_DEFINE(SUPPORT_ALOAD, "1", [Support /dev/aload* access for auto-loading])
346fi
347
348dnl Check for non-standard /dev directory
349AC_MSG_CHECKING([for ALSA device file directory])
350AC_ARG_WITH(alsa-devdir,
351  AS_HELP_STRING([--with-alsa-devdir=dir],
352    [directory with ALSA device files (default /dev/snd)]),
353  [alsa_dev_dir="$withval"],
354  [alsa_dev_dir="/dev/snd"])
355dnl make sure it has a trailing slash
356if echo "$alsa_dev_dir" | grep -v '/$' > /dev/null; then
357  alsa_dev_dir="$alsa_dev_dir/"
358fi
359AC_DEFINE_UNQUOTED(ALSA_DEVICE_DIRECTORY, "$alsa_dev_dir", [Directory with ALSA device files])
360AC_MSG_RESULT([$alsa_dev_dir])
361
362AC_MSG_CHECKING([for aload* device file directory])
363AC_ARG_WITH(aload-devdir,
364  AS_HELP_STRING([--with-aload-devdir=dir],
365    [directory with aload* device files (default /dev)]),
366  [aload_dev_dir="$withval"],
367  [aload_dev_dir="/dev"])
368if echo "$aload_dev_dir" | grep -v '/$' > /dev/null; then
369  aload_dev_dir="$aload_dev_dir/"
370fi
371AC_DEFINE_UNQUOTED(ALOAD_DEVICE_DIRECTORY, "$aload_dev_dir", [Directory with aload* device files])
372AC_MSG_RESULT([$aload_dev_dir])
373
374dnl Build conditions
375AC_ARG_ENABLE(mixer,
376  AS_HELP_STRING([--disable-mixer], [disable the mixer component]),
377  [build_mixer="$enableval"], [build_mixer="yes"])
378AC_ARG_ENABLE(pcm,
379  AS_HELP_STRING([--disable-pcm], [disable the PCM component]),
380  [build_pcm="$enableval"], [build_pcm="yes"])
381AC_ARG_ENABLE(rawmidi,
382  AS_HELP_STRING([--disable-rawmidi], [disable the raw MIDI component]),
383  [build_rawmidi="$enableval"], [build_rawmidi="yes"])
384AC_ARG_ENABLE(hwdep,
385  AS_HELP_STRING([--disable-hwdep], [disable the hwdep component]),
386  [build_hwdep="$enableval"], [build_hwdep="yes"])
387AC_ARG_ENABLE(seq,
388  AS_HELP_STRING([--disable-seq], [disable the sequencer component]),
389  [build_seq="$enableval"], [build_seq="yes"])
390AC_ARG_ENABLE(ucm,
391  AS_HELP_STRING([--disable-ucm], [disable the use-case-manager component]),
392  [build_ucm="$enableval"], [build_ucm="yes"])
393AC_ARG_ENABLE(topology,
394  AS_HELP_STRING([--disable-topology], [disable the DSP topology component]),
395  [build_topology="$enableval"], [build_topology="yes"])
396AC_ARG_ENABLE(alisp,
397  AS_HELP_STRING([--enable-alisp], [enable the alisp component]),
398  [build_alisp="$enableval"], [build_alisp="no"])
399test "$softfloat" = "yes" && build_alisp="no"
400AC_ARG_ENABLE(old-symbols,
401  AS_HELP_STRING([--disable-old-symbols], [disable old obsoleted symbols]),
402  [keep_old_symbols="$enableval"], [keep_old_symbols="yes"])
403AM_CONDITIONAL([KEEP_OLD_SYMBOLS], [test x$keep_old_symbols = xyes])
404
405AC_ARG_ENABLE(mixer-modules,
406  AS_HELP_STRING([--enable-mixer-modules], [enable the additional mixer modules (experimental)]),
407  [build_mixer_modules="$enableval"], [build_mixer_modules="no"])
408
409AC_ARG_ENABLE(mixer-pymods,
410  AS_HELP_STRING([--enable-mixer-pymods], [enable the mixer python modules (experimental)]),
411  [build_mixer_pymodules="$enableval"], [build_mixer_pymodules="no"])
412
413AC_ARG_ENABLE(python,
414  AS_HELP_STRING([--disable-python], [disable the python components]),
415  [build_python="$enableval"], [build_python="yes"])
416
417AC_ARG_ENABLE(python2,
418  AS_HELP_STRING([--enable-python2], [prefer python2]),
419  [build_python2="$enableval"], [build_python2="no"])
420PYTHON_LIBS=""
421PYTHON_INCLUDES=""
422if test "$build_python" = "yes" -a "$build_mixer_pymodules" = "yes"; then
423  pythonlibs0=
424  pythoninc0=
425  if test "$build_python2" != "yes"; then
426    pythonlibs0=$(python3-config --libs)
427    pythoninc0=$(python3-config --includes)
428  fi
429  if test -z "$pythonlibs0"; then
430    pythonlibs0=$(python-config --libs)
431    pythoninc0=$(python-config --includes)
432  fi
433  AC_ARG_WITH(pythonlibs,
434    AS_HELP_STRING([--with-pythonlibs=ldflags],
435      [specify python libraries (-lpthread -lm -ldl -lpython2.4)]),
436    pythonlibs="$withval", pythonlibs=$pythonlibs0)
437  AC_ARG_WITH(pythonincludes,
438    AS_HELP_STRING([--with-pythonincludes=Cflags],
439      [specify python C header files (-I/usr/include/python)]),
440    pythonincludes="$withval", pythonincludes=$pythoninc0)
441  if test -z "$pythonlibs"; then
442    echo "Unable to determine python libraries! Probably python-config is not"
443    echo "available on this system. Please, use --with-pythonlibs and"
444    echo "--with-pythonincludes options. Python components are disabled in this build."
445    build_python="no"
446  else
447    PYTHON_LIBS="$pythonlibs"
448    PYTHON_INCLUDES="$pythonincludes"
449  fi
450fi
451if test "$build_python" != "yes"; then
452  build_mixer_pymodules=
453fi
454AC_SUBST(PYTHON_LIBS)
455AC_SUBST(PYTHON_INCLUDES)
456
457AM_CONDITIONAL([BUILD_MIXER], [test x$build_mixer = xyes])
458AM_CONDITIONAL([BUILD_PCM], [test x$build_pcm = xyes])
459AM_CONDITIONAL([BUILD_RAWMIDI], [test x$build_rawmidi = xyes])
460AM_CONDITIONAL([BUILD_HWDEP], [test x$build_hwdep = xyes])
461AM_CONDITIONAL([BUILD_SEQ], [test x$build_seq = xyes])
462AM_CONDITIONAL([BUILD_UCM], [test x$build_ucm = xyes])
463AM_CONDITIONAL([BUILD_TOPOLOGY], [test x$build_topology = xyes])
464AM_CONDITIONAL([BUILD_ALISP], [test x$build_alisp = xyes])
465AM_CONDITIONAL([BUILD_MIXER_MODULES], [test x$build_mixer_modules = xyes])
466AM_CONDITIONAL([BUILD_MIXER_PYMODULES], [test x$build_mixer_pymodules = xyes])
467
468if test "$build_mixer" = "yes"; then
469  AC_DEFINE([BUILD_MIXER], "1", [Build mixer component])
470fi
471if test "$build_pcm" = "yes"; then
472  AC_DEFINE([BUILD_PCM], "1", [Build PCM component])
473fi
474if test "$build_rawmidi" = "yes"; then
475  AC_DEFINE([BUILD_RAWMIDI], "1", [Build raw MIDI component])
476fi
477if test "$build_hwdep" = "yes"; then
478  AC_DEFINE([BUILD_HWDEP], "1", [Build hwdep component])
479fi
480if test "$build_seq" = "yes"; then
481  AC_DEFINE([BUILD_SEQ], "1", [Build sequencer component])
482fi
483if test "$build_ucm" = "yes"; then
484  AC_DEFINE([BUILD_UCM], "1", [Build UCM component])
485fi
486if test "$build_topology" = "yes"; then
487  AC_DEFINE([BUILD_TOPOLOGY], "1", [Build DSP Topology component])
488fi
489
490dnl PCM Plugins
491
492if test "$build_pcm" = "yes"; then
493AC_ARG_WITH(pcm-plugins,
494  AS_HELP_STRING([--with-pcm-plugins=<list>],
495    [build PCM plugins (default = all)]),
496  [pcm_plugins="$withval"], [pcm_plugins="all"])
497else
498pcm_plugins=""
499fi
500
501dnl check atomics for pcm_meter
502
503AC_MSG_CHECKING([whether GCC supports builtin atomic intrinsics])
504if test -z "$gcc_have_atomics"; then
505  gcc_have_atomics=no
506  AC_TRY_LINK([],
507    [int i;
508     __atomic_load_n(&i, __ATOMIC_SEQ_CST);
509     __atomic_add_fetch(&i, 0, __ATOMIC_SEQ_CST);
510    ],
511    [gcc_have_atomics=yes],
512    [gcc_have_atomics=no])
513fi
514AC_MSG_RESULT($gcc_have_atomics)
515
516PCM_PLUGIN_LIST="copy linear route mulaw alaw adpcm rate plug multi shm file null empty share meter hooks lfloat ladspa dmix dshare dsnoop asym iec958 softvol extplug ioplug mmap_emul"
517
518build_pcm_plugin="no"
519for t in $PCM_PLUGIN_LIST; do
520  eval build_pcm_$t="no"
521done
522
523pcm_plugins=`echo $pcm_plugins | sed 's/,/ /g'`
524for p in $pcm_plugins; do
525  for t in $PCM_PLUGIN_LIST; do
526    if test "$p" = "$t" -o "$p" = "all"; then
527      eval build_pcm_$t="yes"
528      build_pcm_plugin="yes"
529    fi
530  done
531done
532
533dnl special dependencies
534if test "$build_pcm_plug" = "yes"; then
535  build_pcm_linear="yes"
536  build_pcm_copy="yes"
537fi
538
539if test "$build_pcm_ioplug" = "yes"; then
540  build_pcm_extplug="yes"
541fi
542
543if test "$HAVE_LIBDL" != "yes"; then
544  build_pcm_meter="no"
545  build_pcm_ladspa="no"
546  build_pcm_pcm_ioplug="no"
547  build_pcm_pcm_extplug="no"
548fi
549
550if test "$HAVE_LIBPTHREAD" != "yes"; then
551  build_pcm_share="no"
552fi
553
554if test "$softfloat" = "yes"; then
555  build_pcm_lfloat="no"
556  build_pcm_ladspa="no"
557fi
558
559if test "$gcc_have_atomics" != "yes"; then
560  build_pcm_meter="no"
561fi
562
563if test "$ac_cv_header_sys_shm_h" != "yes"; then
564  build_pcm_dmix="no"
565  build_pcm_dshare="no"
566  build_pcm_dsnoop="no"
567  build_pcm_shm="no"
568fi
569
570AM_CONDITIONAL([BUILD_PCM_PLUGIN], [test x$build_pcm_plugin = xyes])
571AM_CONDITIONAL([BUILD_PCM_PLUGIN_COPY], [test x$build_pcm_copy = xyes])
572AM_CONDITIONAL([BUILD_PCM_PLUGIN_LINEAR], [test x$build_pcm_linear = xyes])
573AM_CONDITIONAL([BUILD_PCM_PLUGIN_ROUTE], [test x$build_pcm_route = xyes])
574AM_CONDITIONAL([BUILD_PCM_PLUGIN_MULAW], [test x$build_pcm_mulaw = xyes])
575AM_CONDITIONAL([BUILD_PCM_PLUGIN_ALAW], [test x$build_pcm_alaw = xyes])
576AM_CONDITIONAL([BUILD_PCM_PLUGIN_ADPCM], [test x$build_pcm_adpcm = xyes])
577AM_CONDITIONAL([BUILD_PCM_PLUGIN_RATE], [test x$build_pcm_rate = xyes])
578AM_CONDITIONAL([BUILD_PCM_PLUGIN_PLUG], [test x$build_pcm_plug = xyes])
579AM_CONDITIONAL([BUILD_PCM_PLUGIN_MULTI], [test x$build_pcm_multi = xyes])
580AM_CONDITIONAL([BUILD_PCM_PLUGIN_SHM], [test x$build_pcm_shm = xyes])
581AM_CONDITIONAL([BUILD_PCM_PLUGIN_FILE], [test x$build_pcm_file = xyes])
582AM_CONDITIONAL([BUILD_PCM_PLUGIN_NULL], [test x$build_pcm_null = xyes])
583AM_CONDITIONAL([BUILD_PCM_PLUGIN_EMPTY], [test x$build_pcm_empty = xyes])
584AM_CONDITIONAL([BUILD_PCM_PLUGIN_SHARE], [test x$build_pcm_share = xyes])
585AM_CONDITIONAL([BUILD_PCM_PLUGIN_METER], [test x$build_pcm_meter = xyes])
586AM_CONDITIONAL([BUILD_PCM_PLUGIN_HOOKS], [test x$build_pcm_hooks = xyes])
587AM_CONDITIONAL([BUILD_PCM_PLUGIN_LFLOAT], [test x$build_pcm_lfloat = xyes])
588AM_CONDITIONAL([BUILD_PCM_PLUGIN_LADSPA], [test x$build_pcm_ladspa = xyes])
589AM_CONDITIONAL([BUILD_PCM_PLUGIN_DMIX], [test x$build_pcm_dmix = xyes])
590AM_CONDITIONAL([BUILD_PCM_PLUGIN_DSHARE], [test x$build_pcm_dshare = xyes])
591AM_CONDITIONAL([BUILD_PCM_PLUGIN_DSNOOP], [test x$build_pcm_dsnoop = xyes])
592AM_CONDITIONAL([BUILD_PCM_PLUGIN_ASYM], [test x$build_pcm_asym = xyes])
593AM_CONDITIONAL([BUILD_PCM_PLUGIN_IEC958], [test x$build_pcm_iec958 = xyes])
594AM_CONDITIONAL([BUILD_PCM_PLUGIN_SOFTVOL], [test x$build_pcm_softvol = xyes])
595AM_CONDITIONAL([BUILD_PCM_PLUGIN_EXTPLUG], [test x$build_pcm_extplug = xyes])
596AM_CONDITIONAL([BUILD_PCM_PLUGIN_IOPLUG], [test x$build_pcm_ioplug = xyes])
597AM_CONDITIONAL([BUILD_PCM_PLUGIN_MMAP_EMUL], [test x$build_pcm_mmap_emul = xyes])
598
599dnl Defines for plug plugin
600if test "$build_pcm_rate" = "yes"; then
601  AC_DEFINE([BUILD_PCM_PLUGIN_RATE], "1", [Build PCM rate plugin])
602fi
603if test "$build_pcm_route" = "yes"; then
604  AC_DEFINE([BUILD_PCM_PLUGIN_ROUTE], "1", [Build PCM route plugin])
605fi
606if test "$build_pcm_lfloat" = "yes"; then
607  AC_DEFINE([BUILD_PCM_PLUGIN_LFLOAT], "1", [Build PCM lfloat plugin])
608fi
609if test "$build_pcm_adpcm" = "yes"; then
610  AC_DEFINE([BUILD_PCM_PLUGIN_ADPCM], "1", [Build PCM adpcm plugin])
611fi
612if test "$build_pcm_mulaw" = "yes"; then
613  AC_DEFINE([BUILD_PCM_PLUGIN_MULAW], "1", [Build PCM mulaw plugin])
614fi
615if test "$build_pcm_alaw" = "yes"; then
616  AC_DEFINE([BUILD_PCM_PLUGIN_ALAW], "1", [Build PCM alaw plugin])
617fi
618if test "$build_pcm_mmap_emul" = "yes"; then
619  AC_DEFINE([BUILD_PCM_PLUGIN_MMAP_EMUL], "1", [Build PCM mmap-emul plugin])
620fi
621
622
623dnl Create PCM plugin symbol list for static library
624rm -f "$srcdir"/src/pcm/pcm_symbols_list.c
625touch "$srcdir"/src/pcm/pcm_symbols_list.c
626for t in $PCM_PLUGIN_LIST; do
627  if eval test \$build_pcm_$t = yes; then
628    echo \&_snd_module_pcm_$t, >> "$srcdir"/src/pcm/pcm_symbols_list.c
629  fi
630done
631
632dnl Control Plugins
633
634AC_ARG_WITH(ctl-plugins,
635  AS_HELP_STRING([--with-ctl-plugins=<list>],
636    [build control plugins (default = all)]),
637  [ctl_plugins="$withval"], [ctl_plugins="all"])
638
639CTL_PLUGIN_LIST="shm ext"
640
641build_ctl_plugin="no"
642for t in $CTL_PLUGIN_LIST; do
643  eval build_ctl_$t="no"
644done
645
646ctl_plugins=`echo $ctl_plugins | sed 's/,/ /g'`
647for p in $ctl_plugins; do
648  for t in $CTL_PLUGIN_LIST; do
649    if test "$p" = "$t" -o "$p" = "all"; then
650      eval build_ctl_$t="yes"
651      build_ctl_plugin="yes"
652    fi
653  done
654done
655
656if test "$ac_cv_header_sys_shm_h" != "yes"; then
657  build_ctl_shm="no"
658fi
659
660AM_CONDITIONAL([BUILD_CTL_PLUGIN], [test x$build_ctl_plugin = xyes])
661AM_CONDITIONAL([BUILD_CTL_PLUGIN_SHM], [test x$build_ctl_shm = xyes])
662AM_CONDITIONAL([BUILD_CTL_PLUGIN_EXT], [test x$build_ctl_ext = xyes])
663
664dnl Create ctl plugin symbol list for static library
665rm -f "$srcdir"/src/control/ctl_symbols_list.c
666touch "$srcdir"/src/control/ctl_symbols_list.c
667for t in $CTL_PLUGIN_LIST; do
668  if eval test \$build_ctl_$t = yes; then
669    echo \&_snd_module_control_$t, >> "$srcdir"/src/control/ctl_symbols_list.c
670  fi
671done
672
673dnl Max number of cards
674AC_MSG_CHECKING(for max number of cards)
675AC_ARG_WITH(max-cards,
676  AS_HELP_STRING([--with-max-cards], [Specify the max number of cards (default = 32)]),
677  [ max_cards="$withval" ], [ max_cards="32" ])
678AC_MSG_RESULT([$max_cards])
679
680if test "$max_cards" -lt 1; then
681   AC_ERROR([Invalid max cards $max_cards])
682elif test "$max_cards" -gt 256; then
683   AC_ERROR([Invalid max cards $max_cards])
684fi
685AC_DEFINE_UNQUOTED(SND_MAX_CARDS, $max_cards, [Max number of cards])
686
687dnl Check for thread-safe API functions
688if test "$HAVE_LIBPTHREAD" = "yes"; then
689AC_MSG_CHECKING(for thread-safe API functions)
690AC_ARG_ENABLE(thread-safety,
691  AS_HELP_STRING([--disable-thread-safety],
692    [disable thread-safe API functions]),
693  threadsafe="$enableval", threadsafe="yes")
694if test "$threadsafe" = "yes"; then
695  AC_MSG_RESULT(yes)
696  AC_DEFINE([THREAD_SAFE_API], "1", [Disable thread-safe API functions])
697else
698  AC_MSG_RESULT(no)
699fi
700fi
701
702dnl Make a symlink for inclusion of alsa/xxx.h
703if test ! -L "$srcdir"/include/alsa ; then
704  echo "Making a symlink include/alsa"
705  rm -f "$srcdir"/include/alsa
706  ln -sf . "$srcdir"/include/alsa
707fi
708
709AC_OUTPUT(Makefile doc/Makefile doc/pictures/Makefile doc/doxygen.cfg \
710	  include/Makefile include/sound/Makefile include/sound/uapi/Makefile \
711	  src/Versions src/Makefile \
712          src/control/Makefile src/mixer/Makefile \
713	  src/pcm/Makefile src/pcm/scopes/Makefile \
714	  src/rawmidi/Makefile src/timer/Makefile \
715          src/hwdep/Makefile src/seq/Makefile src/ucm/Makefile \
716          src/alisp/Makefile src/topology/Makefile \
717	  src/conf/Makefile \
718	  src/conf/cards/Makefile \
719	  src/conf/pcm/Makefile \
720	  modules/Makefile modules/mixer/Makefile modules/mixer/simple/Makefile \
721	  alsalisp/Makefile aserver/Makefile \
722	  test/Makefile test/lsb/Makefile \
723	  utils/Makefile utils/alsa-lib.spec utils/alsa.pc utils/alsa-topology.pc)
724
725dnl Create asoundlib.h dynamically according to configure options
726echo "Creating asoundlib.h..."
727cp "$srcdir"/include/asoundlib-head.h include/asoundlib.h
728test "$ac_cv_header_endian_h" = "yes" && echo "#include <endian.h>" >> include/asoundlib.h
729if test "$ac_cv_header_sys_endian_h" = "yes"; then
730cat >> include/asoundlib.h <<EOF
731#include <sys/endian.h>
732#ifndef __BYTE_ORDER
733#define __BYTE_ORDER BYTE_ORDER
734#endif
735#ifndef __LITTLE_ENDIAN
736#define __LITTLE_ENDIAN LITTLE_ENDIAN
737#endif
738#ifndef __BIG_ENDIAN
739#define __BIG_ENDIAN BIG_ENDIAN
740#endif
741EOF
742fi
743cat >> include/asoundlib.h <<EOF
744
745#ifndef __GNUC__
746#define __inline__ inline
747#endif
748
749#include <alsa/asoundef.h>
750#include <alsa/version.h>
751#include <alsa/global.h>
752#include <alsa/input.h>
753#include <alsa/output.h>
754#include <alsa/error.h>
755#include <alsa/conf.h>
756EOF
757test "$build_pcm" = "yes" && echo "#include <alsa/pcm.h>" >> include/asoundlib.h
758test "$build_rawmidi" = "yes" && echo "#include <alsa/rawmidi.h>" >> include/asoundlib.h
759test "$build_pcm" = "yes" && echo "#include <alsa/timer.h>" >> include/asoundlib.h
760test "$build_hwdep" = "yes" && echo "#include <alsa/hwdep.h>" >> include/asoundlib.h
761echo "#include <alsa/control.h>" >> include/asoundlib.h
762test "$build_mixer" = "yes" && echo "#include <alsa/mixer.h>" >> include/asoundlib.h
763test "$build_seq" = "yes" && echo "#include <alsa/seq_event.h>" >> include/asoundlib.h
764test "$build_seq" = "yes" && echo "#include <alsa/seq.h>" >> include/asoundlib.h
765test "$build_seq" = "yes" && echo "#include <alsa/seqmid.h>" >> include/asoundlib.h
766test "$build_seq" = "yes" && echo "#include <alsa/seq_midi_event.h>" >> include/asoundlib.h
767cat "$srcdir"/include/asoundlib-tail.h >> include/asoundlib.h
768