fixup! Do not install unused script : /usr/sbin/alsa-info
[platform/upstream/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.0.29)
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.15])
12
13 dnl Checks for programs.
14
15 dnl try to gues cross-compiler if not set
16 if test "x$target" != "x$host" -a -z "`echo $CC | grep -e '-gcc'`";
17 then
18   AC_MSG_CHECKING(for cross-compiler)
19
20   which ${program_prefix}gcc >/dev/null 2>&1 && CC=${program_prefix}gcc
21   which ${target_cpu}-${target_os}-gcc >/dev/null 2>&1 \
22   && CC=${target_cpu}-${target-os}-gcc
23   which ${target_cpu}-${target_vendor}-${target_os}-gcc >/dev/null 2>&1 \
24   && CC=${target_cpu}-${target_vendor}-${target_os}-gcc
25
26   AC_MSG_RESULT($CC)
27 fi
28
29 AC_PROG_CC
30 dnl AC_PROG_CXX
31 AC_PROG_INSTALL
32 AC_PROG_MKDIR_P
33 AC_PROG_LN_S
34 AC_PROG_SED
35 PKG_PROG_PKG_CONFIG
36 AM_PATH_ALSA(1.0.27)
37 if test "x$enable_alsatest" = "xyes"; then
38 AC_CHECK_FUNC([snd_ctl_elem_add_enumerated],
39               , [AC_ERROR([No user enum control support in alsa-lib])])
40 fi
41
42 dnl Check components
43 AC_CHECK_HEADERS([alsa/pcm.h], [have_pcm="yes"], [have_pcm="no"],
44   [#include <alsa/asoundlib.h>])
45 AC_CHECK_HEADERS([alsa/mixer.h], [have_mixer="yes"], [have_mixer="no"],
46   [#include <alsa/asoundlib.h>])
47 AC_CHECK_HEADERS([alsa/rawmidi.h], [have_rawmidi="yes"], [have_rawmidi="no"],
48   [#include <alsa/asoundlib.h>])
49 AC_CHECK_HEADERS([alsa/seq.h], [have_seq="yes"], [have_seq="no"],
50   [#include <alsa/asoundlib.h>])
51 AC_CHECK_HEADERS([alsa/use-case.h], [have_ucm="yes"], [have_ucm="no"],
52   [#include <alsa/asoundlib.h>])
53 AC_CHECK_HEADERS([samplerate.h], [have_samplerate="yes"], [have_samplerate="no"],
54   [#include <samplerate.h>])
55
56 AM_CONDITIONAL(HAVE_PCM, test "$have_pcm" = "yes")
57 AM_CONDITIONAL(HAVE_MIXER, test "$have_mixer" = "yes")
58 AM_CONDITIONAL(HAVE_RAWMIDI, test "$have_rawmidi" = "yes")
59 AM_CONDITIONAL(HAVE_SEQ, test "$have_seq" = "yes")
60 AM_CONDITIONAL(HAVE_UCM, test "$have_ucm" = "yes")
61 AM_CONDITIONAL(HAVE_SAMPLERATE, test "$have_samplerate" = "yes")
62
63 dnl Check for librt
64 LIBRT=""
65 AC_MSG_CHECKING(for librt)
66 AC_ARG_WITH(librt,
67   AS_HELP_STRING([--with-librt], [Use librt for monotonic clock (default = yes)]),
68   [ have_librt="$withval" ], [ have_librt="yes" ])
69 if test "$have_librt" = "yes"; then
70   AC_CHECK_LIB([rt], [clock_gettime], [HAVE_LIBRT="yes"])
71   if test "$HAVE_LIBRT" = "yes" ; then
72     LIBRT="-lrt"
73     AC_DEFINE([HAVE_LIBRT], 1, [Have librt])
74     AC_DEFINE([HAVE_CLOCK_GETTIME], 1, [Have clock gettime])
75   fi
76 else
77   AC_MSG_RESULT(no)
78 fi
79
80 dnl Disable alsamixer
81 CURSESINC=""
82 CURSESLIB=""
83 CURSES_CFLAGS=""
84 alsamixer=
85 if test "$have_mixer" = "yes"; then
86 AC_ARG_ENABLE(alsamixer,
87      AS_HELP_STRING([--disable-alsamixer], [Disable alsamixer compilation]),
88      [case "${enableval}" in
89        yes) alsamixer=true ;;
90        no)  alsamixer=false ;;
91        *) AC_MSG_ERROR(bad value ${enableval} for --enable-alsamixer) ;;
92      esac],[alsamixer=true])
93 fi
94 AM_CONDITIONAL(ALSAMIXER, test x$alsamixer = xtrue)
95
96 dnl Disable alsaconf
97 AC_ARG_ENABLE(alsaconf,
98      AS_HELP_STRING([--disable-alsaconf], [Disable alsaconf packaging]),
99      [case "${enableval}" in
100        yes) alsaconf=true ;;
101        no)  alsaconf=false ;;
102        *) AC_MSG_ERROR(bad value ${enableval} for --enable-alsaconf) ;;
103      esac],[alsaconf=true])
104 AM_CONDITIONAL(ALSACONF, test x$alsaconf = xtrue)
105
106 dnl Disable alsaloop
107 AC_ARG_ENABLE(alsaloop,
108      AS_HELP_STRING([--disable-alsaloop], [Disable alsaloop packaging]),
109      [case "${enableval}" in
110        yes) alsaloop=true ;;
111        no)  alsaloop=false ;;
112        *) AC_MSG_ERROR(bad value ${enableval} for --enable-alsaloop) ;;
113      esac],[alsaloop=true])
114 AM_CONDITIONAL(ALSALOOP, test x$alsaloop = xtrue)
115
116 xmlto=""
117 AC_ARG_ENABLE(xmlto,
118  AS_HELP_STRING([--disable-xmlto], [Disable man page creation via xmlto]),
119  xmlto="$enableval", xmlto="yes")
120 if test "$xmlto" = "yes"; then
121   AC_CHECK_PROG([xmlto], [xmlto], [yes])
122 fi
123 AM_CONDITIONAL(USE_XMLTO, test x"$xmlto" = xyes)
124
125 AC_ARG_WITH(
126         [udev-rules-dir],
127         AS_HELP_STRING([--with-udev-rules-dir=DIR],[Directory where to install udev rules to (default=auto)]),
128         [udevrulesdir="$withval"],
129         [udevdir=$($PKG_CONFIG udev --variable=udevdir)
130         if test "x$udevdir" = "x"; then
131             udevrulesdir="/lib/udev/rules.d"
132         else
133             udevrulesdir="$udevdir/rules.d"
134         fi])
135 AC_SUBST(udevrulesdir)
136
137 dnl Checks for header files.
138 AC_HEADER_STDC
139 if test x$alsamixer = xtrue; then
140   AC_ARG_WITH(curses,
141     AS_HELP_STRING([--with-curses=libname], [Specify the curses library to use (default=auto)]),
142     curseslib="$withval",
143     curseslib="auto")
144   CURSESLIBDIR=""
145   NCURSESLIBSUFFIX=""
146   CURSES_NLS="no"
147   if test "$curseslib" = "ncursesw" -o \( "$curseslib" = "auto" -a "$USE_NLS" = "yes" \); then
148     dnl First try out pkg-config, then fall back to old config scripts.
149     PKG_CHECK_MODULES([NCURSESW], [ncursesw], [
150         CURSESINC="<ncurses.h>"
151         CURSESLIB="${NCURSESW_LIBS}"
152         CURSESLIBDIR=
153         CURSES_CFLAGS="${NCURSESW_CFLAGS}"
154         curseslib="ncursesw"
155       ], [
156         AC_CHECK_PROG([ncursesw5_config], [ncursesw5-config], [yes])
157         if test "$ncursesw5_config" = "yes"; then
158           CURSESINC="<ncurses.h>"
159           CURSESLIB=`ncursesw5-config --libs`
160           CURSESLIBDIR=`ncursesw5-config --libdir`
161           CURSES_CFLAGS=`ncursesw5-config --cflags`
162           curseslib="ncursesw"
163         else
164           AC_CHECK_LIB(ncursesw, initscr,
165                      [ CURSESINC='<ncurses.h>'; CURSESLIB='-lncursesw'; curseslib="ncursesw"])
166         fi
167       ])
168     if test -n "$CURSESINC"; then
169       NCURSESLIBSUFFIX="w"
170       CURSES_NLS="yes"
171     fi
172   fi
173   if test "$curseslib" = "ncurses" -o "$curseslib" = "auto"; then
174     dnl First try out pkg-config, then fall back to old config scripts.
175     PKG_CHECK_MODULES([NCURSES], [ncurses], [
176         CURSESINC="<ncurses.h>"
177         CURSESLIB="${NCURSES_LIBS}"
178         CURSESLIBDIR=
179         CURSES_CFLAGS="${NCURSES_CFLAGS}"
180         curseslib="ncurses"
181       ], [
182         AC_CHECK_PROG([ncurses5_config], [ncurses5-config], [yes])
183         if test "$ncurses5_config" = "yes"; then
184           CURSESINC="<ncurses.h>"
185           CURSESLIB=`ncurses5-config --libs`
186           CURSESLIBDIR=`ncurses5-config --libdir`
187           CURSES_CFLAGS=`ncurses5-config --cflags`
188           curseslib="ncurses"
189         else
190           AC_CHECK_LIB(ncurses, initscr,
191                      [ CURSESINC='<ncurses.h>'; CURSESLIB='-lncurses'; curseslib="ncurses"])
192         fi
193       ])
194   fi
195   if test "$curseslib" = "curses" -o "$curseslib" = "auto"; then
196     AC_CHECK_LIB(curses, initscr,
197                  [ CURSESINC='<curses.h>'; CURSESLIB='-lcurses'; curseslib="curses"])
198   fi
199   if test -z "$CURSESINC"; then
200      AC_MSG_ERROR(this packages requires a curses library)
201   fi
202
203   AC_MSG_CHECKING([for curses library])
204   AC_MSG_RESULT([$curseslib])
205   AC_MSG_CHECKING([for curses header name])
206   AC_MSG_RESULT([$CURSESINC])
207   AC_MSG_CHECKING([for curses compiler flags])
208   AC_MSG_RESULT([$CURSES_CFLAGS])
209
210   dnl CURSESLIBS might have the library path at the beginning.  If so, we cut it
211   dnl off so that we can insert the other curses libraries before the ncurses
212   dnl library but after the library path (which is later again prepended below).
213   if test -n "$CURSESLIBDIR"; then
214     if test "-L$CURSESLIBDIR " = "$(echo $CURSESLIB | cut -c-$((${#CURSESLIBDIR}+3)) )"; then
215       CURSESLIB="$(echo $CURSESLIB | cut -c$((${#CURSESLIBDIR}+4))-)"
216     fi
217   fi
218
219   saved_CFLAGS="$CFLAGS"
220   saved_LDFLAGS="$LDFLAGS"
221   saved_LIBS="$LIBS"
222   CFLAGS="$CFLAGS $CURSES_CFLAGS"
223   if test -n "$CURSESLIBDIR"; then
224     LDFLAGS="$LDFLAGS -L$CURSESLIBDIR"
225   fi
226   LIBS="$CURSESLIB $LIBS"
227
228   AC_TRY_LINK([#include <panel.h>], [set_escdelay(100);],[HAVE_CURSES_ESCDELAY="yes"])
229   if test "$HAVE_CURSES_ESCDELAY" = "yes"; then
230     AC_DEFINE([HAVE_CURSES_ESCDELAY], 1, [Have curses set_escdelay])
231   fi
232
233   if test "$USE_NLS" = "yes"; then
234     AC_MSG_CHECKING([for curses NLS support])
235     dnl In theory, a single-byte curses works just fine in ISO 8859-* locales.
236     dnl In practice, however, everybody uses UTF-8 nowadays, so we'd better
237     dnl check for wide-character support.
238     dnl For ncurses/ncursesw, CURSES_NLS was already set above.
239     if test "$curseslib" = "curses"; then
240       AC_TRY_LINK([
241           #define _XOPEN_SOURCE 1
242           #define _XOPEN_SOURCE_EXTENDED 1
243           #include <curses.h>
244         ], [
245           cchar_t wc;
246           setcchar(&wc, L"x", A_NORMAL, 0, 0);
247         ],
248         [CURSES_NLS="yes"])
249     fi
250     AC_MSG_RESULT([$CURSES_NLS])
251     if test "$CURSES_NLS" = "yes"; then
252       AC_DEFINE([ENABLE_NLS_IN_CURSES], [1],
253                 [Define if curses-based programs can show translated messages.])
254     fi
255   fi
256
257   AC_CHECK_HEADERS([panel.h menu.h form.h], [],
258                    [AC_MSG_ERROR([required curses helper header not found])])
259   AC_CHECK_LIB([panel$NCURSESLIBSUFFIX], [new_panel],
260                [CURSESLIB="-lpanel$NCURSESLIBSUFFIX $CURSESLIB"],
261                [AC_MSG_ERROR([panel$NCURSESLIBSUFFIX library not found])])
262   AC_CHECK_LIB([menu$NCURSESLIBSUFFIX], [new_menu],
263                [CURSESLIB="-lmenu$NCURSESLIBSUFFIX $CURSESLIB"],
264                [AC_MSG_ERROR([menu$NCURSESLIBSUFFIX library not found])])
265   AC_CHECK_LIB([form$NCURSESLIBSUFFIX], [new_form],
266                [CURSESLIB="-lform$NCURSESLIBSUFFIX $CURSESLIB"],
267                [AC_MSG_ERROR([form$NCURSESLIBSUFFIX library not found])])
268
269   CFLAGS="$saved_CFLAGS"
270   LDFLAGS="$saved_LDFLAGS"
271   LIBS="$saved_LIBS"
272
273   if test -n "$CURSESLIBDIR"; then
274     CURSESLIB="-L$CURSESLIBDIR $CURSESLIB"
275   fi
276
277   AC_MSG_CHECKING([for curses linker flags])
278   AC_MSG_RESULT([$CURSESLIB])
279 fi
280
281 AC_SUBST(CURSESINC)
282 AC_SUBST(CURSESLIB)
283 AC_SUBST(CURSES_CFLAGS)
284
285 test "x$prefix" = xNONE && prefix=$ac_default_prefix
286
287 eval dir="$datadir"
288 case "$dir" in
289 /*) ;;
290 *) dir="$prefix/share"
291 esac
292
293 soundsdir="$dir/sounds/alsa"
294 AC_DEFINE_UNQUOTED(SOUNDSDIR, "$soundsdir", [directory containing sample data])
295
296 mydatadir="$dir/alsa"
297 AC_DEFINE_UNQUOTED(DATADIR, "$mydatadir", [directory containing alsa configuration])
298 AC_SUBST(mydatadir)
299
300 AC_ARG_WITH(testsound,
301   AS_HELP_STRING([--with-testsound=file], [give the path of test sound file for alsaconf]),
302   TESTSOUND="$withval",
303   TESTSOUND="$dir/test.wav")
304 AC_SUBST(TESTSOUND)
305
306 AC_CONFIG_HEADERS(include/aconfig.h)
307
308 dnl Checks for typedefs, structures, and compiler characteristics.
309 AC_C_CONST
310 AC_C_INLINE
311 AC_HEADER_TIME
312
313 dnl Checks for library functions.
314 AC_PROG_GCC_TRADITIONAL
315
316 dnl Enable largefile support
317 AC_SYS_LARGEFILE
318
319 SAVE_UTIL_VERSION
320
321 AC_SUBST(LIBRT)
322
323 dnl Check for systemd
324 AC_ARG_WITH([systemdsystemunitdir],
325         AS_HELP_STRING([--with-systemdsystemunitdir=DIR], [Directory for systemd service files]),
326         [], [with_systemdsystemunitdir=$($PKG_CONFIG --variable=systemdsystemunitdir systemd)])
327 if test "x$with_systemdsystemunitdir" != xno; then
328         AC_SUBST([systemdsystemunitdir], [$with_systemdsystemunitdir])
329 fi
330 AM_CONDITIONAL(HAVE_SYSTEMD, [test -n "$with_systemdsystemunitdir" -a "x$with_systemdsystemunitdir" != xno ])
331
332 AC_ARG_WITH([asound-state-dir],
333         AS_HELP_STRING([--with-asound-state-dir=DIR], [Directory to place asound.state file in]),
334         [ASOUND_STATE_DIR="$withval"],
335         [ASOUND_STATE_DIR="/var/lib/alsa"])
336 AC_SUBST(ASOUND_STATE_DIR)
337
338 AC_ARG_WITH([alsactl-lock-dir],
339         AS_HELP_STRING([--with-alsactl-lock-dir=DIR], [Directory to place lock files in]),
340         [ASOUND_LOCK_DIR="$withval"],
341         [ASOUND_LOCK_DIR="/var/lock"])
342 AC_SUBST(ASOUND_LOCK_DIR)
343
344 AC_ARG_WITH([alsactl-pidfile-dir],
345         AS_HELP_STRING([--with-alsactl-pidfile-dir=DIR], [Directory to place alsactl.pid file in]),
346         [ALSACTL_PIDFILE_DIR="$withval"],
347         [ALSACTL_PIDFILE_DIR="/var/run"])
348 AC_SUBST(ALSACTL_PIDFILE_DIR)
349
350 AC_ARG_WITH([alsactl-daemonswitch],
351         AS_HELP_STRING([--with-alsactl-daemonswitch=FILE], [File to test for the daemon mode]),
352         [ALSACTL_DAEMONSWITCH="$withval"],
353         [ALSACTL_DAEMONSWITCH="/etc/alsa/state-daemon.conf"])
354 AC_SUBST(ALSACTL_DAEMONSWITCH)
355
356 AC_OUTPUT(Makefile alsactl/Makefile alsactl/init/Makefile \
357           alsamixer/Makefile amidi/Makefile amixer/Makefile \
358           m4/Makefile po/Makefile.in \
359           alsaconf/alsaconf alsaconf/Makefile \
360           alsaconf/po/Makefile \
361           alsaucm/Makefile \
362           aplay/Makefile include/Makefile iecset/Makefile utils/Makefile \
363           utils/alsa-utils.spec seq/Makefile seq/aconnect/Makefile \
364           seq/aplaymidi/Makefile seq/aseqdump/Makefile seq/aseqnet/Makefile \
365           speaker-test/Makefile speaker-test/samples/Makefile \
366           alsaloop/Makefile alsa-info/Makefile)