1 # CFLAGS and library paths for XMMS
2 # written 15 December 1999 by Ben Gertzfield <che@debian.org>
5 dnl AM_PATH_XMMS([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]])
8 dnl AM_PATH_XMMS(0.9.5.1, , AC_MSG_ERROR([*** XMMS >= 0.9.5.1 not installed - please install first ***]))
10 dnl Defines XMMS_CFLAGS, XMMS_LIBS, XMMS_DATA_DIR, XMMS_PLUGIN_DIR,
11 dnl XMMS_VISUALIZATION_PLUGIN_DIR, XMMS_INPUT_PLUGIN_DIR,
12 dnl XMMS_OUTPUT_PLUGIN_DIR, XMMS_GENERAL_PLUGIN_DIR, XMMS_EFFECT_PLUGIN_DIR,
13 dnl and XMMS_VERSION for your plugin pleasure.
16 dnl XMMS_TEST_VERSION(AVAILABLE-VERSION, NEEDED-VERSION [, ACTION-IF-OKAY [, ACTION-IF-NOT-OKAY]])
17 AC_DEFUN(XMMS_TEST_VERSION, [
19 # Determine which version number is greater. Prints 2 to stdout if
20 # the second number is greater, 1 if the first number is greater,
21 # 0 if the numbers are equal.
23 # Written 15 December 1999 by Ben Gertzfield <che@debian.org>
24 # Revised 15 December 1999 by Jim Monty <monty@primenet.com>
27 xmms_got_version=[` $AWK ' \
29 print vercmp(ARGV[1], ARGV[2]); \
32 function vercmp(ver1, ver2, ver1arr, ver2arr, \
34 ver1int, ver2int, len, i, p) { \
36 ver1len = split(ver1, ver1arr, /\./); \
37 ver2len = split(ver2, ver2arr, /\./); \
39 len = ver1len > ver2len ? ver1len : ver2len; \
41 for (i = 1; i <= len; i++) { \
42 p = 1000 ^ (len - i); \
43 ver1int += ver1arr[i] * p; \
44 ver2int += ver2arr[i] * p; \
47 if (ver1int < ver2int) \
49 else if (ver1int > ver2int) \
55 if test $xmms_got_version -eq 2; then # failure
62 AC_DEFUN(AM_PATH_XMMS,
64 AC_ARG_WITH(xmms-prefix,[ --with-xmms-prefix=PFX Prefix where XMMS is installed (optional)],
65 xmms_config_prefix="$withval", xmms_config_prefix="")
66 AC_ARG_WITH(xmms-exec-prefix,[ --with-xmms-exec-prefix=PFX Exec prefix where XMMS is installed (optional)],
67 xmms_config_exec_prefix="$withval", xmms_config_exec_prefix="")
69 if test x$xmms_config_exec_prefix != x; then
70 xmms_config_args="$xmms_config_args --exec-prefix=$xmms_config_exec_prefix"
71 if test x${XMMS_CONFIG+set} != xset; then
72 XMMS_CONFIG=$xmms_config_exec_prefix/bin/xmms-config
76 if test x$xmms_config_prefix != x; then
77 xmms_config_args="$xmms_config_args --prefix=$xmms_config_prefix"
78 if test x${XMMS_CONFIG+set} != xset; then
79 XMMS_CONFIG=$xmms_config_prefix/bin/xmms-config
83 AC_PATH_PROG(XMMS_CONFIG, xmms-config, no)
84 min_xmms_version=ifelse([$1], ,0.9.5.1, $1)
86 if test "$XMMS_CONFIG" = "no"; then
89 XMMS_CFLAGS=`$XMMS_CONFIG $xmms_config_args --cflags`
90 XMMS_LIBS=`$XMMS_CONFIG $xmms_config_args --libs`
91 XMMS_VERSION=`$XMMS_CONFIG $xmms_config_args --version`
92 XMMS_DATA_DIR=`$XMMS_CONFIG $xmms_config_args --data-dir`
93 XMMS_PLUGIN_DIR=`$XMMS_CONFIG $xmms_config_args --plugin-dir`
94 XMMS_VISUALIZATION_PLUGIN_DIR=`$XMMS_CONFIG $xmms_config_args \
95 --visualization-plugin-dir`
96 XMMS_INPUT_PLUGIN_DIR=`$XMMS_CONFIG $xmms_config_args --input-plugin-dir`
97 XMMS_OUTPUT_PLUGIN_DIR=`$XMMS_CONFIG $xmms_config_args --output-plugin-dir`
98 XMMS_EFFECT_PLUGIN_DIR=`$XMMS_CONFIG $xmms_config_args --effect-plugin-dir`
99 XMMS_GENERAL_PLUGIN_DIR=`$XMMS_CONFIG $xmms_config_args --general-plugin-dir`
101 XMMS_TEST_VERSION($XMMS_VERSION, $min_xmms_version, ,no_xmms=version)
104 AC_MSG_CHECKING(for XMMS - version >= $min_xmms_version)
106 if test "x$no_xmms" = x; then
108 ifelse([$2], , :, [$2])
112 if test "$XMMS_CONFIG" = "no" ; then
113 echo "*** The xmms-config script installed by XMMS could not be found."
114 echo "*** If XMMS was installed in PREFIX, make sure PREFIX/bin is in"
115 echo "*** your path, or set the XMMS_CONFIG environment variable to the"
116 echo "*** full path to xmms-config."
118 if test "$no_xmms" = "version"; then
119 echo "*** An old version of XMMS, $XMMS_VERSION, was found."
120 echo "*** You need a version of XMMS newer than $min_xmms_version."
121 echo "*** The latest version of XMMS is always available from"
122 echo "*** http://www.xmms.org/"
125 echo "*** If you have already installed a sufficiently new version, this error"
126 echo "*** probably means that the wrong copy of the xmms-config shell script is"
127 echo "*** being found. The easiest way to fix this is to remove the old version"
128 echo "*** of XMMS, but you can also set the XMMS_CONFIG environment to point to the"
129 echo "*** correct copy of xmms-config. (In this case, you will have to"
130 echo "*** modify your LD_LIBRARY_PATH enviroment variable, or edit /etc/ld.so.conf"
131 echo "*** so that the correct libraries are found at run-time)"
136 ifelse([$3], , :, [$3])
138 AC_SUBST(XMMS_CFLAGS)
140 AC_SUBST(XMMS_VERSION)
141 AC_SUBST(XMMS_DATA_DIR)
142 AC_SUBST(XMMS_PLUGIN_DIR)
143 AC_SUBST(XMMS_VISUALIZATION_PLUGIN_DIR)
144 AC_SUBST(XMMS_INPUT_PLUGIN_DIR)
145 AC_SUBST(XMMS_OUTPUT_PLUGIN_DIR)
146 AC_SUBST(XMMS_GENERAL_PLUGIN_DIR)
147 AC_SUBST(XMMS_EFFECT_PLUGIN_DIR)
151 dnl Perform a check for a feature for GStreamer
152 dnl Richard Boulton <richard-alsa@tartarus.org>
153 dnl Last modification: 25/06/2001
154 dnl GST_CHECK_FEATURE(FEATURE-NAME, FEATURE-DESCRIPTION,
155 dnl DEPENDENT-PLUGINS, TEST-FOR-FEATURE,
156 dnl DISABLE-BY-DEFAULT, ACTION-IF-USE, ACTION-IF-NOTUSE)
158 dnl This macro adds a command line argument to enable the user to enable
159 dnl or disable a feature, and if the feature is enabled, performs a supplied
160 dnl test to check if the feature is available.
162 dnl The test should define HAVE_<FEATURE-NAME> to "yes" or "no" depending
163 dnl on whether the feature is available.
165 dnl The macro will set USE_<<FEATURE-NAME> to "yes" or "no" depending on
166 dnl whether the feature is to be used.
168 dnl The macro will call AM_CONDITIONAL(USE_<<FEATURE-NAME>, ...) to allow
169 dnl the feature to control what is built in Makefile.ams. If you want
170 dnl additional actions resulting from the test, you can add them with the
171 dnl ACTION-IF-USE and ACTION-IF-NOTUSE parameters.
173 dnl FEATURE-NAME is the name of the feature, and should be in
174 dnl purely upper case characters.
175 dnl FEATURE-DESCRIPTION is used to describe the feature in help text for
176 dnl the command line argument.
177 dnl DEPENDENT-PLUGINS lists any plugins which depend on this feature.
178 dnl TEST-FOR-FEATURE is a test which sets HAVE_<FEATURE-NAME> to "yes"
179 dnl or "no" depending on whether the feature is
181 dnl DISABLE-BY-DEFAULT if "disabled", the feature is disabled by default,
182 dnl if any other value, the feature is enabled by default.
183 dnl ACTION-IF-USE any extra actions to perform if the feature is to be
185 dnl ACTION-IF-NOTUSE any extra actions to perform if the feature is not to
188 AC_DEFUN(GST_CHECK_FEATURE,
190 builtin(define, [gst_endisable], ifelse($5, [disabled], [enable], [disable]))dnl
191 AC_ARG_ENABLE(translit([$1], A-Z, a-z),
192 [ ]builtin(format, --%-26s gst_endisable %s, gst_endisable-translit([$1], A-Z, a-z), [$2]ifelse([$3],,,: [$3])),
193 [ case "${enableval}" in
196 *) AC_MSG_ERROR(bad value ${enableval} for --enable-translit([$1], A-Z, a-z)) ;;
198 [ USE_$1=]ifelse($5, [disabled], [no], [yes])) dnl DEFAULT
200 dnl *** If it's enabled
201 if test x$USE_[$1] = xyes; then
202 gst_check_save_LIBS=$LIBS
203 gst_check_save_LDFLAGS=$LDFLAGS
204 gst_check_save_CFLAGS=$CFLAGS
205 gst_check_save_CPPFLAGS=$CPPFLAGS
206 gst_check_save_CXXFLAGS=$CXXFLAGS
209 LIBS=$gst_check_save_LIBS
210 LDFLAGS=$gst_check_save_LDFLAGS
211 CFLAGS=$gst_check_save_CFLAGS
212 CPPFLAGS=$gst_check_save_CPPFLAGS
213 CXXFLAGS=$gst_check_save_CXXFLAGS
215 dnl If it isn't found, unset USE_[$1]
216 if test x$HAVE_[$1] = xno; then
220 dnl *** Warn if it's disabled or not found
221 if test x$USE_[$1] = xyes; then
222 ifelse([$6], , :, [$6])
224 ifelse([$3], , :, [AC_MSG_WARN(
225 ***** NOTE: These plugins won't be built: [$3]
227 ifelse([$7], , :, [$7])
229 dnl *** Define the conditional as appropriate
230 AM_CONDITIONAL(USE_[$1], test x$USE_[$1] = xyes)
233 dnl Use a -config program which accepts --cflags and --libs parameters
234 dnl to set *_CFLAGS and *_LIBS and check existence of a feature.
235 dnl Richard Boulton <richard-alsa@tartarus.org>
236 dnl Last modification: 26/06/2001
237 dnl GST_CHECK_CONFIGPROG(FEATURE-NAME, CONFIG-PROG-FILENAME, MODULES)
239 dnl This check was written for GStreamer: it should be renamed and checked
240 dnl for portability if you decide to use it elsewhere.
242 AC_DEFUN(GST_CHECK_CONFIGPROG,
244 AC_PATH_PROG([$1]_CONFIG, [$2], no)
245 if test x$[$1]_CONFIG = xno; then
250 [$1]_LIBS=`[$2] --libs [$3]`
251 [$1]_CFLAGS=`[$2] --cflags [$3]`
255 AC_SUBST([$1]_CFLAGS)
259 dnl Perform a check for existence of ARTSC
260 dnl Richard Boulton <richard-alsa@tartarus.org>
261 dnl Last modification: 26/06/2001
262 dnl GST_CHECK_FEATURE(FEATURE-NAME, FEATURE-DESCRIPTION,
263 dnl DEPENDENT-PLUGINS, TEST-FOR-FEATURE)
265 dnl This check was written for GStreamer: it should be renamed and checked
266 dnl for portability if you decide to use it elsewhere.
268 AC_DEFUN(GST_CHECK_ARTSC,
270 AC_PATH_PROG(ARTSC_CONFIG, artsc-config, no)
271 if test x$ARTSC_CONFIG = xno; then
272 AC_MSG_WARN([Couldn't find artsc-config])
277 ARTSC_LIBS=`artsc-config --libs`
278 ARTSC_CFLAGS=`artsc-config --cflags`
279 dnl AC_CHECK_HEADER uses CPPFLAGS, but not CFLAGS.
280 dnl FIXME: Ensure only suitable flags result from artsc-config --cflags
281 CPPFLAGS="$CPPFLAGS $ARTSC_CFLAGS"
282 AC_CHECK_HEADER(artsc.h, HAVE_ARTSC=yes, HAVE_ARTSC=no)
285 AC_SUBST(ARTSC_CFLAGS)
288 dnl sidplay stuff (taken from xmms)
289 AC_DEFUN(AC_FIND_FILE,
294 if test -r "$i/$j"; then
302 AC_DEFUN(AC_PATH_LIBSIDPLAY,
304 AC_MSG_CHECKING([for SIDPLAY includes and library])
306 ac_sidplay_library=NO
310 AC_ARG_WITH(sidplay-includes,
311 [ --with-sidplay-includes=DIR
312 where the sidplay includes are located],
313 [ac_sidplay_cflags="$withval"
316 AC_ARG_WITH(sidplay-library,
317 [ --with-sidplay-library=DIR
318 where the sidplay library is installed],
319 [ac_sidplay_library="$withval"
322 if test "$ac_sidplay_cflags" = NO || test "$ac_sidplay_library" = NO; then
323 #search common locations
325 AC_CACHE_VAL(ac_cv_have_sidplay,
327 sidplay_incdirs="$ac_sidplay_cflags /usr/include /usr/local/include /usr/lib/sidplay/include /usr/local/lib/sidplay/include"
328 AC_FIND_FILE(sidplay/sidtune.h,$sidplay_incdirs,sidplay_foundincdir)
329 ac_sidplay_cflags=$sidplay_foundincdir
331 sidplay_libdirs="$ac_sidplay_library /usr/lib /usr/local/lib /usr/lib/sidplay /usr/local/lib/sidplay"
332 AC_FIND_FILE(libsidplay.so libsidplay.so.1 libsidplay.so.1.36 libsidplay.so.1.37,$sidplay_libdirs,sidplay_foundlibdir)
333 ac_sidplay_library=$sidplay_foundlibdir
335 if test "$ac_sidplay_cflags" = NO || test "$ac_sidplay_library" = NO; then
336 ac_cv_have_sidplay="have_sidplay=no"
337 ac_sidplay_notfound=""
338 if test "$ac_sidplay_cflags" = NO; then
339 if test "$ac_sidplay_library" = NO; then
340 ac_sidplay_notfound="(headers and library)";
342 ac_sidplay_notfound="(headers)";
345 ac_sidplay_notfound="(library)";
347 eval "$ac_cv_have_sidplay"
348 AC_MSG_RESULT([$have_sidplay])
353 ]) dnl AC_CACHE_VAL(ac_cv_have_sidplay,
356 fi dnl if (have_to_search)
358 eval "$ac_cv_have_sidplay"
360 if test "$have_sidplay" != yes; then
361 AC_MSG_RESULT([$have_sidplay]);
363 ac_cv_have_sidplay="have_sidplay=yes \
364 ac_sidplay_cflags=$ac_sidplay_cflags ac_sidplay_library=$ac_sidplay_library"
365 AC_MSG_RESULT([library $ac_sidplay_library, headers $ac_sidplay_cflags])
367 sidplay_library=$ac_sidplay_library
368 sidplay_cflags=$ac_sidplay_cflags
370 SIDPLAY_LIBS="-L$sidplay_library -lsidplay"
371 all_libraries="$SIDPLAY_LIBS $all_libraries"
372 SIDPLAY_CFLAGS="-I$sidplay_cflags"
373 all_includes="$SIDPLAY_CFLAGS $all_includes"
376 dnl Test compilation.
378 AC_MSG_CHECKING([whether -lsidplay works])
379 ac_cxxflags_safe=$CXXFLAGS
380 ac_ldflags_safe=$LDFLAGS
383 CXXFLAGS="$CXXFLAGS -I$sidplay_cflags"
384 LDFLAGS="$LDFLAGS -L$sidplay_library"
387 AC_CACHE_VAL(ac_cv_sidplay_works,
391 #include <sidplay/player.h>
395 sidTune tune = sidTune(0);
398 ac_cv_sidplay_works="yes",
399 ac_cv_sidplay_works="no",
400 ac_cv_sidplay_works="no")
404 CXXFLAGS="$ac_cxxflags_safe"
405 LDFLAGS="$ac_ldflags_safe"
408 AC_MSG_RESULT([$ac_cv_sidplay_works])
409 if test "$ac_cv_sidplay_works" != yes; then
415 AC_SUBST(SIDPLAY_CFLAGS)
416 AC_SUBST(SIDPLAY_LIBS)
418 AC_SUBST(sidplay_library)
419 AC_SUBST(sidplay_cflags)
422 dnl Configure Paths for Alsa
423 dnl Some modifications by Richard Boulton <richard-alsa@tartarus.org>
424 dnl Christopher Lansdown <lansdoct@cs.alfred.edu>
425 dnl Jaroslav Kysela <perex@suse.cz>
426 dnl Last modification: 07/01/2001
427 dnl AM_PATH_ALSA([MINIMUM-VERSION [, ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]])
428 dnl Test for libasound, and define ALSA_CFLAGS and ALSA_LIBS as appropriate.
429 dnl enables arguments --with-alsa-prefix=
430 dnl --with-alsa-enc-prefix=
431 dnl --disable-alsatest (this has no effect, as yet)
433 dnl For backwards compatibility, if ACTION_IF_NOT_FOUND is not specified,
434 dnl and the alsa libraries are not found, a fatal AC_MSG_ERROR() will result.
436 AC_DEFUN(AM_PATH_ALSA,
437 [dnl Save the original CFLAGS, LDFLAGS, and LIBS
438 alsa_save_CFLAGS="$CFLAGS"
439 alsa_save_LDFLAGS="$LDFLAGS"
440 alsa_save_LIBS="$LIBS"
444 dnl Get the cflags and libraries for alsa
446 AC_ARG_WITH(alsa-prefix,
447 [ --with-alsa-prefix=PFX Prefix where Alsa library is installed(optional)],
448 [alsa_prefix="$withval"], [alsa_prefix=""])
450 AC_ARG_WITH(alsa-inc-prefix,
451 [ --with-alsa-inc-prefix=PFX Prefix where include libraries are (optional)],
452 [alsa_inc_prefix="$withval"], [alsa_inc_prefix=""])
454 dnl FIXME: this is not yet implemented
455 AC_ARG_ENABLE(alsatest,
456 [ --disable-alsatest Do not try to compile and run a test Alsa program],
457 [enable_alsatest=no],
458 [enable_alsatest=yes])
460 dnl Add any special include directories
461 AC_MSG_CHECKING(for ALSA CFLAGS)
462 if test "$alsa_inc_prefix" != "" ; then
463 ALSA_CFLAGS="$ALSA_CFLAGS -I$alsa_inc_prefix"
464 CFLAGS="$CFLAGS -I$alsa_inc_prefix"
466 AC_MSG_RESULT($ALSA_CFLAGS)
468 dnl add any special lib dirs
469 AC_MSG_CHECKING(for ALSA LDFLAGS)
470 if test "$alsa_prefix" != "" ; then
471 ALSA_LIBS="$ALSA_LIBS -L$alsa_prefix"
472 LDFLAGS="$LDFLAGS $ALSA_LIBS"
475 dnl add the alsa library
476 ALSA_LIBS="$ALSA_LIBS -lasound -lm -ldl"
477 LIBS=`echo $LIBS | sed 's/-lm//'`
478 LIBS=`echo $LIBS | sed 's/-ldl//'`
479 LIBS=`echo $LIBS | sed 's/ //'`
480 LIBS="$ALSA_LIBS $LIBS"
481 AC_MSG_RESULT($ALSA_LIBS)
483 dnl Check for a working version of libasound that is of the right version.
484 min_alsa_version=ifelse([$1], ,0.1.1,$1)
485 AC_MSG_CHECKING(for libasound headers version >= $min_alsa_version)
487 alsa_min_major_version=`echo $min_alsa_version | \
488 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'`
489 alsa_min_minor_version=`echo $min_alsa_version | \
490 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'`
491 alsa_min_micro_version=`echo $min_alsa_version | \
492 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'`
497 #include <sys/asoundlib.h>
501 /* ensure backward compatibility */
502 #if !defined(SND_LIB_MAJOR) && defined(SOUNDLIB_VERSION_MAJOR)
503 #define SND_LIB_MAJOR SOUNDLIB_VERSION_MAJOR
505 #if !defined(SND_LIB_MINOR) && defined(SOUNDLIB_VERSION_MINOR)
506 #define SND_LIB_MINOR SOUNDLIB_VERSION_MINOR
508 #if !defined(SND_LIB_SUBMINOR) && defined(SOUNDLIB_VERSION_SUBMINOR)
509 #define SND_LIB_SUBMINOR SOUNDLIB_VERSION_SUBMINOR
512 # if(SND_LIB_MAJOR > $alsa_min_major_version)
515 # if(SND_LIB_MAJOR < $alsa_min_major_version)
519 # if(SND_LIB_MINOR > $alsa_min_minor_version)
522 # if(SND_LIB_MINOR < $alsa_min_minor_version)
526 # if(SND_LIB_SUBMINOR < $alsa_min_micro_version)
534 [AC_MSG_RESULT(found.)],
535 [AC_MSG_RESULT(not present.)
536 ifelse([$3], , [AC_MSG_ERROR(Sufficiently new version of libasound not found.)])
541 dnl Now that we know that we have the right version, let's see if we have the library and not just the headers.
542 AC_CHECK_LIB([asound], [snd_seq_create_event],,
543 [ifelse([$3], , [AC_MSG_ERROR(No linkable libasound was found.)])
547 if test "x$alsa_found" = "xyes" ; then
548 ifelse([$2], , :, [$2])
549 LIBS=`echo $LIBS | sed 's/-lasound//g'`
550 LIBS=`echo $LIBS | sed 's/ //'`
551 LIBS="-lasound $LIBS"
553 if test "x$alsa_found" = "xno" ; then
554 ifelse([$3], , :, [$3])
555 CFLAGS="$alsa_save_CFLAGS"
556 LDFLAGS="$alsa_save_LDFLAGS"
557 LIBS="$alsa_save_LIBS"
562 dnl That should be it. Now just export out symbols:
563 AC_SUBST(ALSA_CFLAGS)