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