OSDN Git Service

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