1 # Configure paths for the Audio File Library
2 # Bertrand Guiheneuf 98-10-21
3 # stolen from esd.m4 in esound :
5 # stolen back from Frank Belew
6 # stolen from Manish Singh
7 # Shamelessly stolen from Owen Taylor
9 dnl AM_PATH_AUDIOFILE([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]])
10 dnl Test for Audio File Library, and define AUDIOFILE_CFLAGS and AUDIOFILE_LIBS.
12 AC_DEFUN([AM_PATH_AUDIOFILE],
14 dnl Get compiler flags and libraries from the audiofile-config script.
16 AC_ARG_WITH(audiofile-prefix,[ --with-audiofile-prefix=PFX Prefix where Audio File Library is installed (optional)],
17 audiofile_prefix="$withval", audiofile_prefix="")
18 AC_ARG_WITH(audiofile-exec-prefix,[ --with-audiofile-exec-prefix=PFX Exec prefix where Audio File Library is installed (optional)],
19 audiofile_exec_prefix="$withval", audiofile_exec_prefix="")
20 AC_ARG_ENABLE(audiofiletest, [ --disable-audiofiletest Do not try to compile and run a test Audio File Library program], , enable_audiofiletest=yes)
22 if test x$audiofile_exec_prefix != x ; then
23 audiofile_args="$audiofile_args --exec-prefix=$audiofile_exec_prefix"
24 if test x${AUDIOFILE_CONFIG+set} != xset ; then
25 AUDIOFILE_CONFIG=$audiofile_exec_prefix/bin/audiofile-config
28 if test x$audiofile_prefix != x ; then
29 audiofile_args="$audiofile_args --prefix=$audiofile_prefix"
30 if test x${AUDIOFILE_CONFIG+set} != xset ; then
31 AUDIOFILE_CONFIG=$audiofile_prefix/bin/audiofile-config
35 AC_PATH_PROG(AUDIOFILE_CONFIG, audiofile-config, no)
36 min_audiofile_version=ifelse([$1], ,0.2.5,$1)
37 AC_MSG_CHECKING(for Audio File Library - version >= $min_audiofile_version)
39 if test "$AUDIOFILE_CONFIG" = "no" ; then
42 AUDIOFILE_LIBS=`$AUDIOFILE_CONFIG $audiofileconf_args --libs`
43 AUDIOFILE_CFLAGS=`$AUDIOFILE_CONFIG $audiofileconf_args --cflags`
44 audiofile_major_version=`$AUDIOFILE_CONFIG $audiofile_args --version | \
45 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'`
46 audiofile_minor_version=`$AUDIOFILE_CONFIG $audiofile_args --version | \
47 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'`
48 audiofile_micro_version=`$AUDIOFILE_CONFIG $audiofile_config_args --version | \
49 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'`
50 if test "x$enable_audiofiletest" = "xyes" ; then
53 ac_save_CFLAGS="$CFLAGS"
55 CFLAGS="$CFLAGS $AUDIOFILE_CFLAGS"
56 LIBS="$LIBS $AUDIOFILE_LIBS"
58 dnl Now check if the installed Audio File Library is sufficiently new.
59 dnl (Also checks the sanity of the results of audiofile-config to some extent.)
61 rm -f conf.audiofiletest
66 #include <audiofile.h>
75 new_str = malloc ((strlen (str) + 1) * sizeof(char));
76 strcpy (new_str, str);
86 int major, minor, micro;
89 system ("touch conf.audiofiletest");
91 /* HP/UX 9 (%@#!) writes to sscanf strings */
92 tmp_version = my_strdup("$min_audiofile_version");
93 if (sscanf(tmp_version, "%d.%d.%d", &major, &minor, µ) != 3) {
94 printf("%s, bad version string\n", "$min_audiofile_version");
98 if (($audiofile_major_version > major) ||
99 (($audiofile_major_version == major) && ($audiofile_minor_version > minor)) ||
100 (($audiofile_major_version == major) && ($audiofile_minor_version == minor) && ($audiofile_micro_version >= micro)))
106 printf("\n*** 'audiofile-config --version' returned %d.%d.%d, but the minimum version\n", $audiofile_major_version, $audiofile_minor_version, $audiofile_micro_version);
107 printf("*** of the Audio File Library required is %d.%d.%d. If audiofile-config is correct, then it is\n", major, minor, micro);
108 printf("*** best to upgrade to the required version.\n");
109 printf("*** If audiofile-config was wrong, set the environment variable AUDIOFILE_CONFIG\n");
110 printf("*** to point to the correct copy of audiofile-config, and remove the file\n");
111 printf("*** config.cache before re-running configure\n");
116 ],, no_audiofile=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"])
117 CFLAGS="$ac_save_CFLAGS"
122 if test "x$no_audiofile" = x ; then
124 ifelse([$2], , :, [$2])
127 if test "$AUDIOFILE_CONFIG" = "no" ; then
129 *** The audiofile-config script installed by the Audio File Library could
130 *** not be found. If the Audio File Library was installed in PREFIX, make
131 *** sure PREFIX/bin is in your path, or set the AUDIOFILE_CONFIG
132 *** environment variable to the full path to audiofile-config.
135 if test -f conf.audiofiletest ; then
138 echo "*** Could not run Audio File Library test program; checking why..."
141 CFLAGS="$CFLAGS $AUDIOFILE_CFLAGS"
142 LIBS="$LIBS $AUDIOFILE_LIBS"
145 #include <audiofile.h>
148 *** The test program compiled, but did not run. This usually means that
149 *** the run-time linker is not finding Audio File Library or finding the
150 *** wrong version of Audio File Library.
152 *** If it is not finding Audio File Library, you'll need to set your
153 *** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point
154 *** to the installed location. Also, make sure you have run ldconfig if
155 *** that is required on your system.
157 *** If you have an old version installed, it is best to remove it, although
158 *** you may also be able to get things to work by modifying
162 [ echo "*** The test program failed to compile or link. See the file config.log"
163 echo "*** for the exact error that occured. This usually means the Audio File"
164 echo "*** Library was incorrectly installed or that you have moved the Audio"
165 echo "*** File Library since it was installed. In the latter case, you may want"
166 echo "*** to edit the audiofile-config script: $AUDIOFILE_CONFIG" ])
167 CFLAGS="$ac_save_CFLAGS"
174 ifelse([$3], , :, [$3])
176 AC_SUBST(AUDIOFILE_CFLAGS)
177 AC_SUBST(AUDIOFILE_LIBS)
178 rm -f conf.audiofiletest