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