1dnl Process this file with autoconf to produce a configure script.
2AC_PREREQ(2.59)
3AC_INIT(alsa-utils, 1.2.2)
4AC_CONFIG_SRCDIR([aplay/aplay.c])
5AC_PREFIX_DEFAULT(/usr)
6AM_INIT_AUTOMAKE
7
8AM_MAINTAINER_MODE([enable])
9
10AM_GNU_GETTEXT([external])
11AM_GNU_GETTEXT_VERSION([0.19.8])
12
13dnl Checks for programs.
14
15AC_PROG_CC
16dnl AC_PROG_CXX
17AC_PROG_INSTALL
18AC_PROG_MKDIR_P
19AC_PROG_LN_S
20AC_PROG_SED
21PKG_PROG_PKG_CONFIG
22AM_PATH_ALSA(1.0.27)
23if test "x$enable_alsatest" = "xyes"; then
24AC_CHECK_FUNC([snd_ctl_elem_add_enumerated],
25	      , [AC_ERROR([No user enum control support in alsa-lib])])
26fi
27
28dnl Check components
29AC_CHECK_HEADERS([alsa/pcm.h], [have_pcm="yes"], [have_pcm="no"],
30  [#include <alsa/asoundlib.h>])
31AC_CHECK_HEADERS([alsa/mixer.h], [have_mixer="yes"], [have_mixer="no"],
32  [#include <alsa/asoundlib.h>])
33AC_CHECK_HEADERS([alsa/rawmidi.h], [have_rawmidi="yes"], [have_rawmidi="no"],
34  [#include <alsa/asoundlib.h>])
35AC_CHECK_HEADERS([alsa/seq.h], [have_seq="yes"], [have_seq="no"],
36  [#include <alsa/asoundlib.h>])
37AC_CHECK_HEADERS([alsa/use-case.h], [have_ucm="yes"], [have_ucm="no"],
38  [#include <alsa/asoundlib.h>])
39AC_CHECK_HEADERS([alsa/topology.h], [have_topology="yes"], [have_topology="no"],
40  [#include <alsa/asoundlib.h>])
41AC_CHECK_HEADERS([samplerate.h], [have_samplerate="yes"], [have_samplerate="no"],
42  [#include <samplerate.h>])
43
44AC_CHECK_LIB([asound], [snd_seq_client_info_get_card], [HAVE_SEQ_CLIENT_INFO_GET_CARD="yes"])
45if test "$HAVE_SEQ_CLIENT_INFO_GET_CARD" = "yes" ; then
46    AC_DEFINE([HAVE_SEQ_CLIENT_INFO_GET_CARD], 1, [alsa-lib supports snd_seq_client_info_get_card])
47fi
48AC_CHECK_LIB([asound], [snd_seq_client_info_get_pid], [HAVE_SEQ_CLIENT_INFO_GET_PID="yes"])
49if test "$HAVE_SEQ_CLIENT_INFO_GET_PID" = "yes" ; then
50    AC_DEFINE([HAVE_SEQ_CLIENT_INFO_GET_PID], 1, [alsa-lib supports snd_seq_client_info_get_pid])
51fi
52AC_CHECK_LIB([atopology], [snd_tplg_save], [have_topology="yes"], [have_topology="no"])
53
54#
55# NOTE: The library 'libffado' (at least v2.4.1) executes ctor/dtor of instances
56# for some objects in startup/finish routines of C runtime. As a result, it
57# outputs some superfluos messages. Furthermore, it brings much memory leak
58# internally. Totally, libffado support is not recommended at all in usual
59# purposes except for technical preview.
60#
61AC_CHECK_LIB([ffado], [ffado_streaming_init], [have_ffado="yes"], [have_ffado="no"])
62AS_IF([test x"$have_ffado" = xyes],
63      [AC_DEFINE([WITH_FFADO], [1], [Define if FFADO library is available])])
64
65AM_CONDITIONAL(HAVE_PCM, test "$have_pcm" = "yes")
66AM_CONDITIONAL(HAVE_MIXER, test "$have_mixer" = "yes")
67AM_CONDITIONAL(HAVE_RAWMIDI, test "$have_rawmidi" = "yes")
68AM_CONDITIONAL(HAVE_SEQ, test "$have_seq" = "yes")
69AM_CONDITIONAL(HAVE_UCM, test "$have_ucm" = "yes")
70AM_CONDITIONAL(HAVE_TOPOLOGY, test "$have_topology" = "yes")
71AM_CONDITIONAL(HAVE_SAMPLERATE, test "$have_samplerate" = "yes")
72AM_CONDITIONAL(HAVE_FFADO, test "$have_ffado" = "yes")
73
74dnl Use tinyalsa
75alsabat_backend_tiny=
76AC_ARG_ENABLE(alsabat_backend_tiny,
77    AS_HELP_STRING([--enable-alsabat-backend-tiny], [Use tinyalsa for alsabat backend]),
78    [case "${enableval}" in
79      yes) alsabat_backend_tiny=true ;;
80      no) alsabat_backend_tiny=false ;;
81      *) AC_MSG_ERROR(bad value ${enableval} for --enable-alsabat-backend-tiny) ;;
82    esac],[alsabat_backend_tiny=false])
83
84dnl Disable bat
85bat=
86if test "$have_pcm" = "yes"; then
87AC_ARG_ENABLE(bat,
88     AS_HELP_STRING([--disable-bat], [Disable bat compilation]),
89     [case "${enableval}" in
90       yes) bat=true ;;
91       no)  bat=false ;;
92       *) AC_MSG_ERROR(bad value ${enableval} for --enable-bat) ;;
93     esac],[bat=true])
94fi
95AM_CONDITIONAL(BAT, test x$bat = xtrue)
96
97if test x$bat = xtrue; then
98
99  saved_CFLAGS="$CFLAGS"
100  saved_LDFLAGS="$LDFLAGS"
101  saved_LIBS="$LIBS"
102  FFTW_INC=""
103  FFTW_LIB=""
104  FFTW_CFLAGS=""
105  dnl Check for libfftw3
106  have_libfftw3="yes"
107  AC_CHECK_LIB([fftw3f], [fftwf_malloc], , [have_libfftw3="no"])
108  dnl Check for libtinyalsa
109  have_libtinyalsa=
110  if test x$alsabat_backend_tiny = xtrue; then
111    have_libtinyalsa="yes"
112    AC_CHECK_LIB([tinyalsa], [pcm_open], , [have_libtinyalsa="no"])
113  fi
114  AC_CHECK_LIB([m], [sqrtf], , [AC_MSG_ERROR([Error: Need sqrtf])])
115  AC_CHECK_LIB([pthread], [pthread_create], , [AC_MSG_ERROR([Error: need PTHREAD library])])
116  FFTW_CFLAGS="$CFLAGS"
117  FFTW_LIB="$LIBS"
118  CFLAGS="$saved_CFLAGS"
119  LDFLAGS="$saved_LDFLAGS"
120  LIBS="$saved_LIBS"
121  AC_SUBST(FFTW_INC)
122  AC_SUBST(FFTW_LIB)
123  AC_SUBST(FFTW_CFLAGS)
124
125fi
126AM_CONDITIONAL(HAVE_LIBFFTW3, test "$have_libfftw3" = "yes")
127AM_CONDITIONAL(HAVE_LIBTINYALSA, test "$have_libtinyalsa" = "yes")
128
129dnl Check for librt
130LIBRT=""
131AC_MSG_CHECKING(for librt)
132AC_ARG_WITH(librt,
133  AS_HELP_STRING([--with-librt], [Use librt for monotonic clock (default = yes)]),
134  [ have_librt="$withval" ], [ have_librt="yes" ])
135if test "$have_librt" = "yes"; then
136  AC_CHECK_LIB([rt], [clock_gettime], [HAVE_LIBRT="yes"])
137  if test "$HAVE_LIBRT" = "yes" ; then
138    LIBRT="-lrt"
139    AC_DEFINE([HAVE_LIBRT], 1, [Have librt])
140    AC_DEFINE([HAVE_CLOCK_GETTIME], 1, [Have clock gettime])
141  fi
142else
143  AC_MSG_RESULT(no)
144fi
145
146dnl Disable alsamixer
147CURSESINC=""
148CURSESLIB=""
149CURSES_CFLAGS=""
150alsamixer=
151if test "$have_mixer" = "yes"; then
152AC_ARG_ENABLE(alsamixer,
153     AS_HELP_STRING([--disable-alsamixer], [Disable alsamixer compilation]),
154     [case "${enableval}" in
155       yes) alsamixer=true ;;
156       no)  alsamixer=false ;;
157       *) AC_MSG_ERROR(bad value ${enableval} for --enable-alsamixer) ;;
158     esac],[alsamixer=true])
159fi
160AM_CONDITIONAL(ALSAMIXER, test x$alsamixer = xtrue)
161
162dnl Disable alsaconf
163AC_ARG_ENABLE(alsaconf,
164     AS_HELP_STRING([--disable-alsaconf], [Disable alsaconf packaging]),
165     [case "${enableval}" in
166       yes) alsaconf=true ;;
167       no)  alsaconf=false ;;
168       *) AC_MSG_ERROR(bad value ${enableval} for --enable-alsaconf) ;;
169     esac],[alsaconf=true])
170AM_CONDITIONAL(ALSACONF, test x$alsaconf = xtrue)
171
172dnl Disable alsaloop
173AC_ARG_ENABLE(alsaloop,
174     AS_HELP_STRING([--disable-alsaloop], [Disable alsaloop packaging]),
175     [case "${enableval}" in
176       yes) alsaloop=true ;;
177       no)  alsaloop=false ;;
178       *) AC_MSG_ERROR(bad value ${enableval} for --enable-alsaloop) ;;
179     esac],[alsaloop=true])
180AM_CONDITIONAL(ALSALOOP, test x$alsaloop = xtrue)
181
182xmlto_available=""
183AC_ARG_ENABLE(xmlto,
184 AS_HELP_STRING([--disable-xmlto], [Disable man page creation via xmlto]),
185 xmlto="$enableval", xmlto="yes")
186if test "$xmlto" = "yes"; then
187  AC_CHECK_PROG([xmlto_available], [xmlto], [yes])
188fi
189AM_CONDITIONAL(USE_XMLTO, test x"$xmlto_available" = xyes)
190
191rst2man_available=""
192AC_ARG_ENABLE(rst2man,
193 AS_HELP_STRING([--disable-rst2man], [Disable man page creation via rst2man]),
194 rst2man="$enableval", rst2man="yes")
195if test "$rst2man" = "yes"; then
196  AC_CHECK_PROG([rst2man_available], [rst2man], [yes])
197fi
198AM_CONDITIONAL(USE_RST2MAN, test x"$rst2man_available" = xyes)
199
200AC_ARG_WITH(
201        [udev-rules-dir],
202        AS_HELP_STRING([--with-udev-rules-dir=DIR],[Directory where to install udev rules to (default=auto)]),
203        [udevrulesdir="$withval"],
204        [udevdir=$($PKG_CONFIG udev --variable=udevdir)
205        if test "x$udevdir" = "x"; then
206            udevrulesdir="/lib/udev/rules.d"
207        else
208            udevrulesdir="$udevdir/rules.d"
209        fi])
210AC_SUBST(udevrulesdir)
211
212dnl Checks for header files.
213AC_HEADER_STDC
214if test x$alsamixer = xtrue; then
215  AC_ARG_WITH(curses,
216    AS_HELP_STRING([--with-curses=libname], [Specify the curses library to use (default=auto)]),
217    curseslib="$withval",
218    curseslib="auto")
219  CURSESLIBDIR=""
220  NCURSESLIBSUFFIX=""
221  CURSES_NLS="no"
222  if test "$curseslib" = "ncursesw" -o \( "$curseslib" = "auto" -a "$USE_NLS" = "yes" \); then
223    dnl First try out pkg-config, then fall back to old config scripts.
224    PKG_CHECK_MODULES([NCURSESW], [ncursesw], [
225        CURSESINC="<ncurses.h>"
226        CURSESLIB="${NCURSESW_LIBS}"
227        CURSESLIBDIR=
228        CURSES_CFLAGS="${NCURSESW_CFLAGS}"
229        curseslib="ncursesw"
230      ], [
231        AC_CHECK_PROG([ncursesw5_config], [ncursesw5-config], [yes])
232        if test "$ncursesw5_config" = "yes"; then
233          CURSESINC="<ncurses.h>"
234          CURSESLIB=`ncursesw5-config --libs`
235          CURSESLIBDIR=`ncursesw5-config --libdir`
236          CURSES_CFLAGS=`ncursesw5-config --cflags`
237          curseslib="ncursesw"
238        else
239          AC_CHECK_LIB(ncursesw, initscr,
240                     [ CURSESINC='<ncurses.h>'; CURSESLIB='-lncursesw'; curseslib="ncursesw"])
241        fi
242      ])
243    if test -n "$CURSESINC"; then
244      NCURSESLIBSUFFIX=""
245      CURSES_NLS="yes"
246    fi
247  fi
248  if test "$curseslib" = "ncurses" -o "$curseslib" = "auto"; then
249    dnl First try out pkg-config, then fall back to old config scripts.
250    PKG_CHECK_MODULES([NCURSES], [ncurses], [
251        CURSESINC="<ncurses.h>"
252        CURSESLIB="${NCURSES_LIBS}"
253        CURSESLIBDIR=
254        CURSES_CFLAGS="${NCURSES_CFLAGS}"
255        curseslib="ncurses"
256      ], [
257        AC_CHECK_PROG([ncurses5_config], [ncurses5-config], [yes])
258        if test "$ncurses5_config" = "yes"; then
259          CURSESINC="<ncurses.h>"
260          CURSESLIB=`ncurses5-config --libs`
261          CURSESLIBDIR=`ncurses5-config --libdir`
262          CURSES_CFLAGS=`ncurses5-config --cflags`
263          curseslib="ncurses"
264        else
265          AC_CHECK_LIB(ncurses, initscr,
266                     [ CURSESINC='<ncurses.h>'; CURSESLIB='-lncurses'; curseslib="ncurses"])
267        fi
268      ])
269  fi
270  if test "$curseslib" = "curses" -o "$curseslib" = "auto"; then
271    AC_CHECK_LIB(curses, initscr,
272                 [ CURSESINC='<curses.h>'; CURSESLIB='-lcurses'; curseslib="curses"])
273  fi
274  if test -z "$CURSESINC"; then
275     AC_MSG_ERROR(this packages requires a curses library)
276  fi
277
278  AC_MSG_CHECKING([for curses library])
279  AC_MSG_RESULT([$curseslib])
280  AC_MSG_CHECKING([for curses header name])
281  AC_MSG_RESULT([$CURSESINC])
282  AC_MSG_CHECKING([for curses compiler flags])
283  AC_MSG_RESULT([$CURSES_CFLAGS])
284
285  dnl CURSESLIBS might have the library path at the beginning.  If so, we cut it
286  dnl off so that we can insert the other curses libraries before the ncurses
287  dnl library but after the library path (which is later again prepended below).
288  if test -n "$CURSESLIBDIR"; then
289    if test "-L$CURSESLIBDIR " = "$(echo $CURSESLIB | cut -c-$((${#CURSESLIBDIR}+3)) )"; then
290      CURSESLIB="$(echo $CURSESLIB | cut -c$((${#CURSESLIBDIR}+4))-)"
291    fi
292  fi
293
294  saved_CFLAGS="$CFLAGS"
295  saved_LDFLAGS="$LDFLAGS"
296  saved_LIBS="$LIBS"
297  CFLAGS="$CFLAGS $CURSES_CFLAGS"
298  if test -n "$CURSESLIBDIR"; then
299    LDFLAGS="$LDFLAGS -L$CURSESLIBDIR"
300  fi
301  LIBS="$CURSESLIB $LIBS"
302
303  AC_TRY_LINK([#include <panel.h>], [set_escdelay(100);],[HAVE_CURSES_ESCDELAY="yes"])
304  if test "$HAVE_CURSES_ESCDELAY" = "yes"; then
305    AC_DEFINE([HAVE_CURSES_ESCDELAY], 1, [Have curses set_escdelay])
306  fi
307
308  if test "$USE_NLS" = "yes"; then
309    AC_MSG_CHECKING([for curses NLS support])
310    dnl In theory, a single-byte curses works just fine in ISO 8859-* locales.
311    dnl In practice, however, everybody uses UTF-8 nowadays, so we'd better
312    dnl check for wide-character support.
313    dnl For ncurses/ncursesw, CURSES_NLS was already set above.
314    if test "$curseslib" = "curses"; then
315      AC_TRY_LINK([
316          #define _XOPEN_SOURCE 1
317          #define _XOPEN_SOURCE_EXTENDED 1
318          #include <curses.h>
319        ], [
320          cchar_t wc;
321          setcchar(&wc, L"x", A_NORMAL, 0, 0);
322        ],
323        [CURSES_NLS="yes"])
324    fi
325    AC_MSG_RESULT([$CURSES_NLS])
326    if test "$CURSES_NLS" = "yes"; then
327      AC_DEFINE([ENABLE_NLS_IN_CURSES], [1],
328                [Define if curses-based programs can show translated messages.])
329    fi
330  fi
331
332  AC_CHECK_HEADERS([panel.h menu.h form.h], [],
333                   [AC_MSG_ERROR([required curses helper header not found])])
334  AC_CHECK_LIB([panel$NCURSESLIBSUFFIX], [new_panel],
335               [CURSESLIB="-lpanel$NCURSESLIBSUFFIX $CURSESLIB"],
336               [AC_MSG_ERROR([panel$NCURSESLIBSUFFIX library not found])])
337  AC_CHECK_LIB([menu$NCURSESLIBSUFFIX], [new_menu],
338               [CURSESLIB="-lmenu$NCURSESLIBSUFFIX $CURSESLIB"],
339               [AC_MSG_ERROR([menu$NCURSESLIBSUFFIX library not found])])
340  AC_CHECK_LIB([form$NCURSESLIBSUFFIX], [new_form],
341               [CURSESLIB="-lform$NCURSESLIBSUFFIX $CURSESLIB"],
342               [AC_MSG_ERROR([form$NCURSESLIBSUFFIX library not found])])
343
344  CFLAGS="$saved_CFLAGS"
345  LDFLAGS="$saved_LDFLAGS"
346  LIBS="$saved_LIBS"
347
348  if test -n "$CURSESLIBDIR"; then
349    CURSESLIB="-L$CURSESLIBDIR $CURSESLIB"
350  fi
351
352  AC_MSG_CHECKING([for curses linker flags])
353  AC_MSG_RESULT([$CURSESLIB])
354fi
355
356AC_SUBST(CURSESINC)
357AC_SUBST(CURSESLIB)
358AC_SUBST(CURSES_CFLAGS)
359
360test "x$prefix" = xNONE && prefix=$ac_default_prefix
361
362eval dir="$datadir"
363case "$dir" in
364/*) ;;
365*) dir="$prefix/share"
366esac
367
368soundsdir="$dir/sounds/alsa"
369AC_DEFINE_UNQUOTED(SOUNDSDIR, "$soundsdir", [directory containing sample data])
370
371mydatadir="$dir/alsa"
372AC_DEFINE_UNQUOTED(DATADIR, "$mydatadir", [directory containing alsa configuration])
373AC_SUBST(mydatadir)
374
375AC_ARG_WITH(testsound,
376  AS_HELP_STRING([--with-testsound=file], [give the path of test sound file for alsaconf]),
377  TESTSOUND="$withval",
378  TESTSOUND="$dir/test.wav")
379AC_SUBST(TESTSOUND)
380
381AC_CONFIG_HEADERS(include/aconfig.h)
382
383dnl Checks for typedefs, structures, and compiler characteristics.
384AC_C_CONST
385AC_C_INLINE
386AC_HEADER_TIME
387
388dnl Checks for library functions.
389AC_PROG_GCC_TRADITIONAL
390
391dnl Enable largefile support
392AC_SYS_LARGEFILE
393
394SAVE_UTIL_VERSION
395
396AC_SUBST(LIBRT)
397
398dnl Check for systemd
399PKG_CHECK_MODULES(SYSTEMD, [systemd >= 18],
400        [have_min_systemd="yes"],
401        [have_min_systemd="no"])
402AC_ARG_WITH([systemdsystemunitdir],
403        AS_HELP_STRING([--with-systemdsystemunitdir=DIR], [Directory for systemd service files]),
404        [], [with_systemdsystemunitdir=$($PKG_CONFIG --variable=systemdsystemunitdir systemd)])
405if test "x$with_systemdsystemunitdir" != xno; then
406        AC_SUBST([systemdsystemunitdir], [$with_systemdsystemunitdir])
407fi
408AM_CONDITIONAL(HAVE_SYSTEMD, [test "$have_min_systemd" = "yes" \
409        -a -n "$with_systemdsystemunitdir" -a "x$with_systemdsystemunitdir" != xno ])
410
411AC_ARG_WITH([asound-state-dir],
412        AS_HELP_STRING([--with-asound-state-dir=DIR], [Directory to place asound.state file in]),
413        [ASOUND_STATE_DIR="$withval"],
414        [ASOUND_STATE_DIR="/var/lib/alsa"])
415AC_SUBST(ASOUND_STATE_DIR)
416
417AC_ARG_WITH([alsactl-lock-dir],
418        AS_HELP_STRING([--with-alsactl-lock-dir=DIR], [Directory to place lock files in]),
419        [ASOUND_LOCK_DIR="$withval"],
420        [ASOUND_LOCK_DIR="/var/lock"])
421AC_SUBST(ASOUND_LOCK_DIR)
422
423AC_ARG_WITH([alsactl-pidfile-dir],
424        AS_HELP_STRING([--with-alsactl-pidfile-dir=DIR], [Directory to place alsactl.pid file in]),
425        [ALSACTL_PIDFILE_DIR="$withval"],
426        [ALSACTL_PIDFILE_DIR="/var/run"])
427AC_SUBST(ALSACTL_PIDFILE_DIR)
428
429AC_ARG_WITH([alsactl-daemonswitch],
430        AS_HELP_STRING([--with-alsactl-daemonswitch=FILE], [File to test for the daemon mode]),
431        [ALSACTL_DAEMONSWITCH="$withval"],
432        [ALSACTL_DAEMONSWITCH="/etc/alsa/state-daemon.conf"])
433AC_SUBST(ALSACTL_DAEMONSWITCH)
434
435AC_OUTPUT(Makefile alsactl/Makefile alsactl/init/Makefile \
436	  alsamixer/Makefile amidi/Makefile amixer/Makefile \
437	  m4/Makefile po/Makefile.in \
438	  alsaconf/alsaconf alsaconf/Makefile \
439	  alsaconf/po/Makefile \
440	  alsaucm/Makefile topology/Makefile \
441	  bat/Makefile bat/tests/Makefile bat/tests/asound_state/Makefile \
442	  aplay/Makefile include/Makefile iecset/Makefile utils/Makefile \
443	  utils/alsa-utils.spec seq/Makefile seq/aconnect/Makefile \
444	  seq/aplaymidi/Makefile seq/aseqdump/Makefile seq/aseqnet/Makefile \
445	  speaker-test/Makefile speaker-test/samples/Makefile \
446	  alsaloop/Makefile alsa-info/Makefile \
447	  axfer/Makefile axfer/test/Makefile)
448