source: trunk/third/audiofile/audiofile.m4 @ 17099

Revision 17099, 6.6 KB checked in by ghudson, 23 years ago (diff)
This commit was generated by cvs2svn to compensate for changes in r17098, which included commits to RCS files with non-trunk default branches.
Line 
1# Configure paths for the Audio File Library
2# Bertrand Guiheneuf 98-10-21
3# stolen from esd.m4 in esound :
4# Manish Singh    98-9-30
5# stolen back from Frank Belew
6# stolen from Manish Singh
7# Shamelessly stolen from Owen Taylor
8
9dnl AM_PATH_AUDIOFILE([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]])
10dnl Test for Audio File Library, and define AUDIOFILE_CFLAGS and AUDIOFILE_LIBS.
11dnl
12AC_DEFUN(AM_PATH_AUDIOFILE,
13[dnl
14dnl Get compiler flags and libraries from the audiofile-config script.
15dnl
16AC_ARG_WITH(audiofile-prefix,[  --with-audiofile-prefix=PFX   Prefix where Audio File Library is installed (optional)],
17            audiofile_prefix="$withval", audiofile_prefix="")
18AC_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="")
20AC_ARG_ENABLE(audiofiletest, [  --disable-audiofiletest       Do not try to compile and run a test Audio File Library program], , enable_audiofiletest=yes)
21
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
26     fi
27  fi
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
32     fi
33  fi
34
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)
38  no_audiofile=""
39  if test "$AUDIOFILE_CONFIG" = "no" ; then
40    no_audiofile=yes
41  else
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
51      AC_LANG_SAVE
52      AC_LANG_C
53      ac_save_CFLAGS="$CFLAGS"
54      ac_save_LIBS="$LIBS"
55      CFLAGS="$CFLAGS $AUDIOFILE_CFLAGS"
56      LIBS="$LIBS $AUDIOFILE_LIBS"
57dnl
58dnl Now check if the installed Audio File Library is sufficiently new.
59dnl (Also checks the sanity of the results of audiofile-config to some extent.)
60dnl
61      rm -f conf.audiofiletest
62      AC_TRY_RUN([
63#include <stdio.h>
64#include <stdlib.h>
65#include <string.h>
66#include <audiofile.h>
67
68char*
69my_strdup (char *str)
70{
71  char *new_str;
72 
73  if (str)
74    {
75      new_str = malloc ((strlen (str) + 1) * sizeof(char));
76      strcpy (new_str, str);
77    }
78  else
79    new_str = NULL;
80 
81  return new_str;
82}
83
84int main ()
85{
86  int major, minor, micro;
87  char *tmp_version;
88
89  system ("touch conf.audiofiletest");
90
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, &micro) != 3) {
94     printf("%s, bad version string\n", "$min_audiofile_version");
95     exit(1);
96   }
97
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)))
101    {
102      return 0;
103    }
104  else
105    {
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");
112      return 1;
113    }
114}
115
116],, no_audiofile=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"])
117       CFLAGS="$ac_save_CFLAGS"
118       LIBS="$ac_save_LIBS"
119       AC_LANG_RESTORE
120     fi
121  fi
122  if test "x$no_audiofile" = x ; then
123     AC_MSG_RESULT(yes)
124     ifelse([$2], , :, [$2])     
125  else
126     AC_MSG_RESULT(no)
127     if test "$AUDIOFILE_CONFIG" = "no" ; then
128       cat <<END
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.
133END
134     else
135       if test -f conf.audiofiletest ; then
136        :
137       else
138          echo "*** Could not run Audio File Library test program; checking why..."
139          AC_LANG_SAVE
140          AC_LANG_C
141          CFLAGS="$CFLAGS $AUDIOFILE_CFLAGS"
142          LIBS="$LIBS $AUDIOFILE_LIBS"
143          AC_TRY_LINK([
144#include <stdio.h>
145#include <audiofile.h>
146],      [ return 0; ],
147        [ cat <<END
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.
151***
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.
156***
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
159*** LD_LIBRARY_PATH.
160END
161        ],
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"
168          LIBS="$ac_save_LIBS"
169          AC_LANG_RESTORE
170       fi
171     fi
172     AUDIOFILE_CFLAGS=""
173     AUDIOFILE_LIBS=""
174     ifelse([$3], , :, [$3])
175  fi
176  AC_SUBST(AUDIOFILE_CFLAGS)
177  AC_SUBST(AUDIOFILE_LIBS)
178  rm -f conf.audiofiletest
179])
Note: See TracBrowser for help on using the repository browser.