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