Merge branch_beta3 onto the mainline.
[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 != x ; then
16     vorbis_args="$vorbis_args --prefix=$vorbis_prefix"
17     VORBIS_CFLAGS="-I$vorbis_prefix/include"
18     VORBIS_LIBDIR="-L$vorbis_prefix/lib"
19   fi
20
21   VORBIS_LIBS="$VORBIS_LIBDIR -lvorbis -lm"
22   VORBISFILE_LIBS="-lvorbisfile"
23   VORBISENC_LIBS="-lvorbisenc"
24
25   AC_MSG_CHECKING(for Vorbis)
26   no_vorbis=""
27
28
29   if test "x$enable_vorbistest" = "xyes" ; then
30     ac_save_CFLAGS="$CFLAGS"
31     ac_save_LIBS="$LIBS"
32     CFLAGS="$CFLAGS $VORBIS_CFLAGS"
33     LIBS="$LIBS $VORBIS_LIBS $OGG_LIBS"
34 dnl
35 dnl Now check if the installed Vorbis is sufficiently new.
36 dnl
37       rm -f conf.vorbistest
38       AC_TRY_RUN([
39 #include <stdio.h>
40 #include <stdlib.h>
41 #include <string.h>
42 #include <vorbis/codec.h>
43
44 int main ()
45 {
46   system("touch conf.vorbistest");
47   return 0;
48 }
49
50 ],, no_vorbis=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"])
51        CFLAGS="$ac_save_CFLAGS"
52        LIBS="$ac_save_LIBS"
53   fi
54
55   if test "x$no_vorbis" = x ; then
56      AC_MSG_RESULT(yes)
57      ifelse([$1], , :, [$1])     
58   else
59      AC_MSG_RESULT(no)
60      if test -f conf.vorbistest ; then
61        :
62      else
63        echo "*** Could not run Vorbis test program, checking why..."
64        CFLAGS="$CFLAGS $VORBIS_CFLAGS"
65        LIBS="$LIBS $VORBIS_LIBS $OGG_LIBS"
66        AC_TRY_LINK([
67 #include <stdio.h>
68 #include <vorbis/codec.h>
69 ],     [ return 0; ],
70        [ echo "*** The test program compiled, but did not run. This usually means"
71        echo "*** that the run-time linker is not finding Vorbis or finding the wrong"
72        echo "*** version of Vorbis. If it is not finding Vorbis, you'll need to set your"
73        echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point"
74        echo "*** to the installed location  Also, make sure you have run ldconfig if that"
75        echo "*** is required on your system"
76        echo "***"
77        echo "*** If you have an old version installed, it is best to remove it, although"
78        echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH"],
79        [ echo "*** The test program failed to compile or link. See the file config.log for the"
80        echo "*** exact error that occured. This usually means Vorbis was incorrectly installed"
81        echo "*** or that you have moved Vorbis since it was installed." ])
82        CFLAGS="$ac_save_CFLAGS"
83        LIBS="$ac_save_LIBS"
84      fi
85      VORBIS_CFLAGS=""
86      VORBIS_LIBS=""
87      VORBISFILE_LIBS=""
88      VORBISENC_LIBS=""
89      ifelse([$2], , :, [$2])
90   fi
91   AC_SUBST(VORBIS_CFLAGS)
92   AC_SUBST(VORBIS_LIBS)
93   AC_SUBST(VORBISFILE_LIBS)
94   AC_SUBST(VORBISENC_LIBS)
95   rm -f conf.vorbistest
96 ])