1 dnl Configure Paths for Alsa
2 dnl Some modifications by Richard Boulton <richard-alsa@tartarus.org>
3 dnl Christopher Lansdown <lansdoct@cs.alfred.edu>
4 dnl Jaroslav Kysela <perex@suse.cz>
5 dnl Last modification: 07/01/2001
6 dnl AM_PATH_ALSA([MINIMUM-VERSION [, ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]])
7 dnl Test for libasound, and define ALSA_CFLAGS and ALSA_LIBS as appropriate.
8 dnl enables arguments --with-alsa-prefix=
9 dnl --with-alsa-enc-prefix=
10 dnl --disable-alsatest (this has no effect, as yet)
12 dnl For backwards compatibility, if ACTION_IF_NOT_FOUND is not specified,
13 dnl and the alsa libraries are not found, a fatal AC_MSG_ERROR() will result.
15 AC_DEFUN(AM_PATH_ALSA,
16 [dnl Save the original CFLAGS, LDFLAGS, and LIBS
17 alsa_save_CFLAGS="$CFLAGS"
18 alsa_save_LDFLAGS="$LDFLAGS"
19 alsa_save_LIBS="$LIBS"
23 dnl Get the cflags and libraries for alsa
25 AC_ARG_WITH(alsa-prefix,
26 [ --with-alsa-prefix=PFX Prefix where Alsa library is installed(optional)],
27 [alsa_prefix="$withval"], [alsa_prefix=""])
29 AC_ARG_WITH(alsa-inc-prefix,
30 [ --with-alsa-inc-prefix=PFX Prefix where include libraries are (optional)],
31 [alsa_inc_prefix="$withval"], [alsa_inc_prefix=""])
33 dnl FIXME: this is not yet implemented
34 AC_ARG_ENABLE(alsatest,
35 [ --disable-alsatest Do not try to compile and run a test Alsa program],
37 [enable_alsatest=yes])
39 dnl Add any special include directories
40 AC_MSG_CHECKING(for ALSA CFLAGS)
41 if test "$alsa_inc_prefix" != "" ; then
42 ALSA_CFLAGS="$ALSA_CFLAGS -I$alsa_inc_prefix"
43 CFLAGS="$CFLAGS -I$alsa_inc_prefix"
45 AC_MSG_RESULT($ALSA_CFLAGS)
47 dnl add any special lib dirs
48 AC_MSG_CHECKING(for ALSA LDFLAGS)
49 if test "$alsa_prefix" != "" ; then
50 ALSA_LIBS="$ALSA_LIBS -L$alsa_prefix"
51 LDFLAGS="$LDFLAGS $ALSA_LIBS"
54 dnl add the alsa library
55 ALSA_LIBS="$ALSA_LIBS -lasound -lm -ldl"
56 LIBS=`echo $LIBS | sed 's/-lm//'`
57 LIBS=`echo $LIBS | sed 's/-ldl//'`
58 LIBS=`echo $LIBS | sed 's/ //'`
59 LIBS="$ALSA_LIBS $LIBS"
60 AC_MSG_RESULT($ALSA_LIBS)
62 dnl Check for a working version of libasound that is of the right version.
63 min_alsa_version=ifelse([$1], ,0.1.1,$1)
64 AC_MSG_CHECKING(for libasound headers version >= $min_alsa_version)
66 alsa_min_major_version=`echo $min_alsa_version | \
67 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'`
68 alsa_min_minor_version=`echo $min_alsa_version | \
69 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'`
70 alsa_min_micro_version=`echo $min_alsa_version | \
71 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'`
76 #include <sys/asoundlib.h>
80 /* ensure backward compatibility */
81 #if !defined(SND_LIB_MAJOR) && defined(SOUNDLIB_VERSION_MAJOR)
82 #define SND_LIB_MAJOR SOUNDLIB_VERSION_MAJOR
84 #if !defined(SND_LIB_MINOR) && defined(SOUNDLIB_VERSION_MINOR)
85 #define SND_LIB_MINOR SOUNDLIB_VERSION_MINOR
87 #if !defined(SND_LIB_SUBMINOR) && defined(SOUNDLIB_VERSION_SUBMINOR)
88 #define SND_LIB_SUBMINOR SOUNDLIB_VERSION_SUBMINOR
91 # if(SND_LIB_MAJOR > $alsa_min_major_version)
94 # if(SND_LIB_MAJOR < $alsa_min_major_version)
98 # if(SND_LIB_MINOR > $alsa_min_minor_version)
101 # if(SND_LIB_MINOR < $alsa_min_minor_version)
105 # if(SND_LIB_SUBMINOR < $alsa_min_micro_version)
113 [AC_MSG_RESULT(found.)],
114 [AC_MSG_RESULT(not present.)
115 ifelse([$3], , [AC_MSG_ERROR(Sufficiently new version of libasound not found.)])
120 dnl Now that we know that we have the right version, let's see if we have the library and not just the headers.
121 AC_CHECK_LIB([asound], [snd_defaults_card],,
122 [ifelse([$3], , [AC_MSG_ERROR(No linkable libasound was found.)])
126 if test "x$alsa_found" = "xyes" ; then
127 ifelse([$2], , :, [$2])
128 LIBS=`echo $LIBS | sed 's/-lasound//g'`
129 LIBS=`echo $LIBS | sed 's/ //'`
130 LIBS="-lasound $LIBS"
132 if test "x$alsa_found" = "xno" ; then
133 ifelse([$3], , :, [$3])
134 CFLAGS="$alsa_save_CFLAGS"
135 LDFLAGS="$alsa_save_LDFLAGS"
136 LIBS="$alsa_save_LIBS"
141 dnl That should be it. Now just export out symbols:
142 AC_SUBST(ALSA_CFLAGS)
146 # CFLAGS and library paths for XMMS
147 # written 15 December 1999 by Ben Gertzfield <che@debian.org>
150 dnl AM_PATH_XMMS([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]])
153 dnl AM_PATH_XMMS(0.9.5.1, , AC_MSG_ERROR([*** XMMS >= 0.9.5.1 not installed - please install first ***]))
155 dnl Defines XMMS_CFLAGS, XMMS_LIBS, XMMS_DATA_DIR, XMMS_PLUGIN_DIR,
156 dnl XMMS_VISUALIZATION_PLUGIN_DIR, XMMS_INPUT_PLUGIN_DIR,
157 dnl XMMS_OUTPUT_PLUGIN_DIR, XMMS_GENERAL_PLUGIN_DIR, XMMS_EFFECT_PLUGIN_DIR,
158 dnl and XMMS_VERSION for your plugin pleasure.
161 dnl XMMS_TEST_VERSION(AVAILABLE-VERSION, NEEDED-VERSION [, ACTION-IF-OKAY [, ACTION-IF-NOT-OKAY]])
162 AC_DEFUN(XMMS_TEST_VERSION, [
164 # Determine which version number is greater. Prints 2 to stdout if
165 # the second number is greater, 1 if the first number is greater,
166 # 0 if the numbers are equal.
168 # Written 15 December 1999 by Ben Gertzfield <che@debian.org>
169 # Revised 15 December 1999 by Jim Monty <monty@primenet.com>
172 xmms_got_version=[` $AWK ' \
174 print vercmp(ARGV[1], ARGV[2]); \
177 function vercmp(ver1, ver2, ver1arr, ver2arr, \
179 ver1int, ver2int, len, i, p) { \
181 ver1len = split(ver1, ver1arr, /\./); \
182 ver2len = split(ver2, ver2arr, /\./); \
184 len = ver1len > ver2len ? ver1len : ver2len; \
186 for (i = 1; i <= len; i++) { \
187 p = 1000 ^ (len - i); \
188 ver1int += ver1arr[i] * p; \
189 ver2int += ver2arr[i] * p; \
192 if (ver1int < ver2int) \
194 else if (ver1int > ver2int) \
200 if test $xmms_got_version -eq 2; then # failure
201 ifelse([$4], , :, $4)
203 ifelse([$3], , :, $3)
207 AC_DEFUN(AM_PATH_XMMS,
209 AC_ARG_WITH(xmms-prefix,[ --with-xmms-prefix=PFX Prefix where XMMS is installed (optional)],
210 xmms_config_prefix="$withval", xmms_config_prefix="")
211 AC_ARG_WITH(xmms-exec-prefix,[ --with-xmms-exec-prefix=PFX Exec prefix where XMMS is installed (optional)],
212 xmms_config_exec_prefix="$withval", xmms_config_exec_prefix="")
214 if test x$xmms_config_exec_prefix != x; then
215 xmms_config_args="$xmms_config_args --exec-prefix=$xmms_config_exec_prefix"
216 if test x${XMMS_CONFIG+set} != xset; then
217 XMMS_CONFIG=$xmms_config_exec_prefix/bin/xmms-config
221 if test x$xmms_config_prefix != x; then
222 xmms_config_args="$xmms_config_args --prefix=$xmms_config_prefix"
223 if test x${XMMS_CONFIG+set} != xset; then
224 XMMS_CONFIG=$xmms_config_prefix/bin/xmms-config
228 AC_PATH_PROG(XMMS_CONFIG, xmms-config, no)
229 min_xmms_version=ifelse([$1], ,0.9.5.1, $1)
231 if test "$XMMS_CONFIG" = "no"; then
234 XMMS_CFLAGS=`$XMMS_CONFIG $xmms_config_args --cflags`
235 XMMS_LIBS=`$XMMS_CONFIG $xmms_config_args --libs`
236 XMMS_VERSION=`$XMMS_CONFIG $xmms_config_args --version`
237 XMMS_DATA_DIR=`$XMMS_CONFIG $xmms_config_args --data-dir`
238 XMMS_PLUGIN_DIR=`$XMMS_CONFIG $xmms_config_args --plugin-dir`
239 XMMS_VISUALIZATION_PLUGIN_DIR=`$XMMS_CONFIG $xmms_config_args \
240 --visualization-plugin-dir`
241 XMMS_INPUT_PLUGIN_DIR=`$XMMS_CONFIG $xmms_config_args --input-plugin-dir`
242 XMMS_OUTPUT_PLUGIN_DIR=`$XMMS_CONFIG $xmms_config_args --output-plugin-dir`
243 XMMS_EFFECT_PLUGIN_DIR=`$XMMS_CONFIG $xmms_config_args --effect-plugin-dir`
244 XMMS_GENERAL_PLUGIN_DIR=`$XMMS_CONFIG $xmms_config_args --general-plugin-dir`
246 XMMS_TEST_VERSION($XMMS_VERSION, $min_xmms_version, ,no_xmms=version)
249 AC_MSG_CHECKING(for XMMS - version >= $min_xmms_version)
251 if test "x$no_xmms" = x; then
253 ifelse([$2], , :, [$2])
257 if test "$XMMS_CONFIG" = "no" ; then
258 echo "*** The xmms-config script installed by XMMS could not be found."
259 echo "*** If XMMS was installed in PREFIX, make sure PREFIX/bin is in"
260 echo "*** your path, or set the XMMS_CONFIG environment variable to the"
261 echo "*** full path to xmms-config."
263 if test "$no_xmms" = "version"; then
264 echo "*** An old version of XMMS, $XMMS_VERSION, was found."
265 echo "*** You need a version of XMMS newer than $min_xmms_version."
266 echo "*** The latest version of XMMS is always available from"
267 echo "*** http://www.xmms.org/"
270 echo "*** If you have already installed a sufficiently new version, this error"
271 echo "*** probably means that the wrong copy of the xmms-config shell script is"
272 echo "*** being found. The easiest way to fix this is to remove the old version"
273 echo "*** of XMMS, but you can also set the XMMS_CONFIG environment to point to the"
274 echo "*** correct copy of xmms-config. (In this case, you will have to"
275 echo "*** modify your LD_LIBRARY_PATH enviroment variable, or edit /etc/ld.so.conf"
276 echo "*** so that the correct libraries are found at run-time)"
281 ifelse([$3], , :, [$3])
283 AC_SUBST(XMMS_CFLAGS)
285 AC_SUBST(XMMS_VERSION)
286 AC_SUBST(XMMS_DATA_DIR)
287 AC_SUBST(XMMS_PLUGIN_DIR)
288 AC_SUBST(XMMS_VISUALIZATION_PLUGIN_DIR)
289 AC_SUBST(XMMS_INPUT_PLUGIN_DIR)
290 AC_SUBST(XMMS_OUTPUT_PLUGIN_DIR)
291 AC_SUBST(XMMS_GENERAL_PLUGIN_DIR)
292 AC_SUBST(XMMS_EFFECT_PLUGIN_DIR)
296 dnl Perform a check for a feature for GStreamer
297 dnl Richard Boulton <richard-alsa@tartarus.org>
298 dnl Last modification: 25/06/2001
299 dnl GST_CHECK_FEATURE(FEATURE-NAME, FEATURE-DESCRIPTION,
300 dnl DEPENDENT-PLUGINS, TEST-FOR-FEATURE,
301 dnl DISABLE-BY-DEFAULT, ACTION-IF-USE, ACTION-IF-NOTUSE)
303 dnl This macro adds a command line argument to enable the user to enable
304 dnl or disable a feature, and if the feature is enabled, performs a supplied
305 dnl test to check if the feature is available.
307 dnl The test should define HAVE_<FEATURE-NAME> to "yes" or "no" depending
308 dnl on whether the feature is available.
310 dnl The macro will set USE_<<FEATURE-NAME> to "yes" or "no" depending on
311 dnl whether the feature is to be used.
313 dnl The macro will call AM_CONDITIONAL(USE_<<FEATURE-NAME>, ...) to allow
314 dnl the feature to control what is built in Makefile.ams. If you want
315 dnl additional actions resulting from the test, you can add them with the
316 dnl ACTION-IF-USE and ACTION-IF-NOTUSE parameters.
318 dnl FEATURE-NAME is the name of the feature, and should be in
319 dnl purely upper case characters.
320 dnl FEATURE-DESCRIPTION is used to describe the feature in help text for
321 dnl the command line argument.
322 dnl DEPENDENT-PLUGINS lists any plugins which depend on this feature.
323 dnl TEST-FOR-FEATURE is a test which sets HAVE_<FEATURE-NAME> to "yes"
324 dnl or "no" depending on whether the feature is
326 dnl DISABLE-BY-DEFAULT if "disabled", the feature is disabled by default,
327 dnl if any other value, the feature is enabled by default.
328 dnl ACTION-IF-USE any extra actions to perform if the feature is to be
330 dnl ACTION-IF-NOTUSE any extra actions to perform if the feature is not to
333 AC_DEFUN(GST_CHECK_FEATURE,
335 builtin(define, [gst_endisable], ifelse($5, [disabled], [enable], [disable]))dnl
336 AC_ARG_ENABLE(translit([$1], A-Z, a-z),
337 [ ]builtin(format, --%-26s gst_endisable %s, gst_endisable-translit([$1], A-Z, a-z), [$2]ifelse([$3],,,: [$3])),
338 [ case "${enableval}" in
341 *) AC_MSG_ERROR(bad value ${enableval} for --enable-translit([$1], A-Z, a-z)) ;;
343 [ USE_$1=]ifelse($5, [disabled], [no], [yes])) dnl DEFAULT
345 dnl *** If it's enabled
346 if test x$USE_[$1] = xyes; then
347 gst_check_save_LIBS=$LIBS
348 gst_check_save_LDFLAGS=$LDFLAGS
349 gst_check_save_CFLAGS=$CFLAGS
350 gst_check_save_CPPFLAGS=$CPPFLAGS
351 gst_check_save_CXXFLAGS=$CXXFLAGS
354 LIBS=$gst_check_save_LIBS
355 LDFLAGS=$gst_check_save_LDFLAGS
356 CFLAGS=$gst_check_save_CFLAGS
357 CPPFLAGS=$gst_check_save_CPPFLAGS
358 CXXFLAGS=$gst_check_save_CXXFLAGS
360 dnl If it isn't found, unset USE_[$1]
361 if test x$HAVE_[$1] = xno; then
365 dnl *** Warn if it's disabled or not found
366 if test x$USE_[$1] = xyes; then
367 ifelse([$6], , :, [$6])
369 ifelse([$3], , :, [AC_MSG_WARN(
370 ***** NOTE: These plugins won't be built: [$3]
372 ifelse([$7], , :, [$7])
374 dnl *** Define the conditional as appropriate
375 AM_CONDITIONAL(USE_[$1], test x$USE_[$1] = xyes)
378 dnl Use a -config program which accepts --cflags and --libs parameters
379 dnl to set *_CFLAGS and *_LIBS and check existence of a feature.
380 dnl Richard Boulton <richard-alsa@tartarus.org>
381 dnl Last modification: 26/06/2001
382 dnl GST_CHECK_CONFIGPROG(FEATURE-NAME, CONFIG-PROG-FILENAME, MODULES)
384 dnl This check was written for GStreamer: it should be renamed and checked
385 dnl for portability if you decide to use it elsewhere.
387 AC_DEFUN(GST_CHECK_CONFIGPROG,
389 AC_PATH_PROG([$1]_CONFIG, [$2], no)
390 if test x$[$1]_CONFIG = xno; then
395 [$1]_LIBS=`[$2] --libs [$3]`
396 [$1]_CFLAGS=`[$2] --cflags [$3]`
400 AC_SUBST([$1]_CFLAGS)
404 dnl Perform a check for existence of ARTSC
405 dnl Richard Boulton <richard-alsa@tartarus.org>
406 dnl Last modification: 26/06/2001
407 dnl GST_CHECK_FEATURE(FEATURE-NAME, FEATURE-DESCRIPTION,
408 dnl DEPENDENT-PLUGINS, TEST-FOR-FEATURE)
410 dnl This check was written for GStreamer: it should be renamed and checked
411 dnl for portability if you decide to use it elsewhere.
413 AC_DEFUN(GST_CHECK_ARTSC,
415 AC_PATH_PROG(ARTSC_CONFIG, artsc-config, no)
416 if test x$ARTSC_CONFIG = xno; then
417 AC_MSG_WARN([Couldn't find artsc-config])
422 ARTSC_LIBS=`artsc-config --libs`
423 ARTSC_CFLAGS=`artsc-config --cflags`
424 dnl AC_CHECK_HEADER uses CPPFLAGS, but not CFLAGS.
425 dnl FIXME: Ensure only suitable flags result from artsc-config --cflags
426 CPPFLAGS="$CPPFLAGS $ARTSC_CFLAGS"
427 AC_CHECK_HEADER(artsc.h, HAVE_ARTSC=yes, HAVE_ARTSC=no)
430 AC_SUBST(ARTSC_CFLAGS)
433 dnl sidplay stuff (taken from xmms)
434 AC_DEFUN(AC_FIND_FILE,
439 if test -r "$i/$j"; then
447 AC_DEFUN(AC_PATH_LIBSIDPLAY,
449 AC_MSG_CHECKING([for SIDPLAY includes and library])
451 ac_sidplay_library=NO
455 AC_ARG_WITH(sidplay-includes,
456 [ --with-sidplay-includes=DIR
457 where the sidplay includes are located],
458 [ac_sidplay_cflags="$withval"
461 AC_ARG_WITH(sidplay-library,
462 [ --with-sidplay-library=DIR
463 where the sidplay library is installed],
464 [ac_sidplay_library="$withval"
467 if test "$ac_sidplay_cflags" = NO || test "$ac_sidplay_library" = NO; then
468 #search common locations
470 AC_CACHE_VAL(ac_cv_have_sidplay,
472 sidplay_incdirs="$ac_sidplay_cflags /usr/include /usr/local/include /usr/lib/sidplay/include /usr/local/lib/sidplay/include"
473 AC_FIND_FILE(sidplay/sidtune.h,$sidplay_incdirs,sidplay_foundincdir)
474 ac_sidplay_cflags=$sidplay_foundincdir
476 sidplay_libdirs="$ac_sidplay_library /usr/lib /usr/local/lib /usr/lib/sidplay /usr/local/lib/sidplay"
477 AC_FIND_FILE(libsidplay.so libsidplay.so.1 libsidplay.so.1.36 libsidplay.so.1.37,$sidplay_libdirs,sidplay_foundlibdir)
478 ac_sidplay_library=$sidplay_foundlibdir
480 if test "$ac_sidplay_cflags" = NO || test "$ac_sidplay_library" = NO; then
481 ac_cv_have_sidplay="have_sidplay=no"
482 ac_sidplay_notfound=""
483 if test "$ac_sidplay_cflags" = NO; then
484 if test "$ac_sidplay_library" = NO; then
485 ac_sidplay_notfound="(headers and library)";
487 ac_sidplay_notfound="(headers)";
490 ac_sidplay_notfound="(library)";
492 eval "$ac_cv_have_sidplay"
493 AC_MSG_RESULT([$have_sidplay])
498 ]) dnl AC_CACHE_VAL(ac_cv_have_sidplay,
501 fi dnl if (have_to_search)
503 eval "$ac_cv_have_sidplay"
505 if test "$have_sidplay" != yes; then
506 AC_MSG_RESULT([$have_sidplay]);
508 ac_cv_have_sidplay="have_sidplay=yes \
509 ac_sidplay_cflags=$ac_sidplay_cflags ac_sidplay_library=$ac_sidplay_library"
510 AC_MSG_RESULT([library $ac_sidplay_library, headers $ac_sidplay_cflags])
512 sidplay_library=$ac_sidplay_library
513 sidplay_cflags=$ac_sidplay_cflags
515 SIDPLAY_LIBS="-L$sidplay_library -lsidplay"
516 all_libraries="$SIDPLAY_LIBS $all_libraries"
517 SIDPLAY_CFLAGS="-I$sidplay_cflags"
518 all_includes="$SIDPLAY_CFLAGS $all_includes"
521 dnl Test compilation.
523 AC_MSG_CHECKING([whether -lsidplay works])
524 ac_cxxflags_safe=$CXXFLAGS
525 ac_ldflags_safe=$LDFLAGS
528 CXXFLAGS="$CXXFLAGS -I$sidplay_cflags"
529 LDFLAGS="$LDFLAGS -L$sidplay_library"
532 AC_CACHE_VAL(ac_cv_sidplay_works,
536 #include <sidplay/player.h>
540 sidTune tune = sidTune(0);
543 ac_cv_sidplay_works="yes",
544 ac_cv_sidplay_works="no",
545 ac_cv_sidplay_works="no")
549 CXXFLAGS="$ac_cxxflags_safe"
550 LDFLAGS="$ac_ldflags_safe"
553 AC_MSG_RESULT([$ac_cv_sidplay_works])
554 if test "$ac_cv_sidplay_works" != yes; then
560 AC_SUBST(SIDPLAY_CFLAGS)
561 AC_SUBST(SIDPLAY_LIBS)
563 AC_SUBST(sidplay_library)
564 AC_SUBST(sidplay_cflags)