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