fixed minor errors in Jeff's patches.
[platform/upstream/libvorbis.git] / vorbis.m4
1 # Configure paths for libvorbis
2 # Jack Moffitt <jack@icecast.org> 10-21-2000
3 # Shamelessly stolen from Owen Taylor and Manish Singh
4
5 dnl AM_PATH_VORBIS([ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]])
6 dnl Test for libvorbis, and define VORBIS_CFLAGS and VORBIS_LIBS
7 dnl
8 AC_DEFUN(AM_PATH_VORBIS,
9 [dnl 
10 dnl Get the cflags and libraries
11 dnl
12 AC_ARG_WITH(vorbis-prefix,[  --with-vorbis-prefix=PFX   Prefix where libvorbis is installed (optional)], vorbis_prefix="$withval", vorbis_prefix="")
13 AC_ARG_ENABLE(vorbistest, [  --disable-vorbistest       Do not try to compile and run a test Vorbis program],, enable_vorbistest=yes)
14
15   if test "x$vorbis_prefix" != "xNONE" ; then
16     vorbis_args="$vorbis_args --prefix=$vorbis_prefix"
17     VORBIS_CFLAGS="-I$vorbis_prefix/include"
18     VORBIS_LIBDIR="-L$vorbis_prefix/lib"
19   elif test "$prefix" != ""; then
20     vorbis_args="$vorbis_args --prefix=$prefix"
21     VORBIS_CFLAGS="-I$prefix/include"
22     VORBIS_LIBDIR="-L$prefix/lib"
23   fi
24
25   VORBIS_LIBS="$VORBIS_LIBDIR -lvorbis -lm"
26   VORBISFILE_LIBS="-lvorbisfile"
27   VORBISENC_LIBS="-lvorbisenc"
28
29   AC_MSG_CHECKING(for Vorbis)
30   no_vorbis=""
31
32
33   if test "x$enable_vorbistest" = "xyes" ; then
34     ac_save_CFLAGS="$CFLAGS"
35     ac_save_LIBS="$LIBS"
36     CFLAGS="$CFLAGS $VORBIS_CFLAGS"
37     LIBS="$LIBS $VORBIS_LIBS $OGG_LIBS"
38 dnl
39 dnl Now check if the installed Vorbis is sufficiently new.
40 dnl
41       rm -f conf.vorbistest
42       AC_TRY_RUN([
43 #include <stdio.h>
44 #include <stdlib.h>
45 #include <string.h>
46 #include <vorbis/codec.h>
47
48 int main ()
49 {
50   system("touch conf.vorbistest");
51   return 0;
52 }
53
54 ],, no_vorbis=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"])
55        CFLAGS="$ac_save_CFLAGS"
56        LIBS="$ac_save_LIBS"
57   fi
58
59   if test "x$no_vorbis" = "x" ; then
60      AC_MSG_RESULT(yes)
61      ifelse([$1], , :, [$1])     
62   else
63      AC_MSG_RESULT(no)
64      if test -f conf.vorbistest ; then
65        :
66      else
67        echo "*** Could not run Vorbis test program, checking why..."
68        CFLAGS="$CFLAGS $VORBIS_CFLAGS"
69        LIBS="$LIBS $VORBIS_LIBS $OGG_LIBS"
70        AC_TRY_LINK([
71 #include <stdio.h>
72 #include <vorbis/codec.h>
73 ],     [ return 0; ],
74        [ echo "*** The test program compiled, but did not run. This usually means"
75        echo "*** that the run-time linker is not finding Vorbis or finding the wrong"
76        echo "*** version of Vorbis. If it is not finding Vorbis, you'll need to set your"
77        echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point"
78        echo "*** to the installed location  Also, make sure you have run ldconfig if that"
79        echo "*** is required on your system"
80        echo "***"
81        echo "*** If you have an old version installed, it is best to remove it, although"
82        echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH"],
83        [ echo "*** The test program failed to compile or link. See the file config.log for the"
84        echo "*** exact error that occured. This usually means Vorbis was incorrectly installed"
85        echo "*** or that you have moved Vorbis since it was installed." ])
86        CFLAGS="$ac_save_CFLAGS"
87        LIBS="$ac_save_LIBS"
88      fi
89      VORBIS_CFLAGS=""
90      VORBIS_LIBS=""
91      VORBISFILE_LIBS=""
92      VORBISENC_LIBS=""
93      ifelse([$2], , :, [$2])
94   fi
95   AC_SUBST(VORBIS_CFLAGS)
96   AC_SUBST(VORBIS_LIBS)
97   AC_SUBST(VORBISFILE_LIBS)
98   AC_SUBST(VORBISENC_LIBS)
99   rm -f conf.vorbistest
100 ])