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