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