9acbe29135d497905aa752b09f5730f11d8d650b
[platform/upstream/gstreamer.git] / m4 / gst-ivorbis.m4
1 # Configure paths for Tremor
2
3 dnl XIPH_PATH_IVORBIS([ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]])
4 dnl Test for libivorbis, and define IVORBIS_CFLAGS and IVORBIS_LIBS
5 dnl
6 AC_DEFUN(XIPH_PATH_IVORBIS,
7 [dnl 
8 dnl Get the cflags and libraries
9 dnl
10 AC_ARG_WITH(ivorbis,[  --with-ivorbis=PFX   Prefix where libivorbis is installed (optional)], ivorbis_prefix="$withval", ivorbis_prefix="")
11 AC_ARG_WITH(ivorbis-libraries,[  --with-ivorbis-libraries=DIR   Directory where libivorbis library is installed (optional)], ivorbis_libraries="$withval", ivorbis_libraries="")
12 AC_ARG_WITH(ivorbis-includes,[  --with-ivorbis-includes=DIR   Directory where libivorbis header files are installed (optional)], ivorbis_includes="$withval", ivorbis_includes="")
13 AC_ARG_ENABLE(ivorbistest, [  --disable-ivorbistest       Do not try to compile and run a test Ivorbis program],, enable_ivorbistest=yes)
14
15   if test "x$ivorbis_libraries" != "x" ; then
16     IVORBIS_LIBS="-L$ivorbis_libraries"
17   elif test "x$ivorbis_prefix" != "x" ; then
18     IVORBIS_LIBS="-L$ivorbis_prefix/lib"
19   elif test "x$prefix" != "xNONE"; then
20     IVORBIS_LIBS="-L$prefix/lib"
21   fi
22
23   IVORBIS_LIBS="$IVORBIS_LIBS -lvorbisidec -lm"
24
25   if test "x$ivorbis_includes" != "x" ; then
26     IVORBIS_CFLAGS="-I$ivorbis_includes"
27   elif test "x$ivorbis_prefix" != "x" ; then
28     IVORBIS_CFLAGS="-I$ivorbis_prefix/include"
29   elif test "x$prefix" != "xNONE"; then
30     IVORBIS_CFLAGS="-I$prefix/include"
31   fi
32
33   AC_MSG_CHECKING(for Tremor)
34   no_ivorbis=""
35
36   if test "x$enable_ivorbistest" = "xyes" ; then
37     ac_save_CFLAGS="$CFLAGS"
38     ac_save_LIBS="$LIBS"
39     CFLAGS="$CFLAGS $IVORBIS_CFLAGS $OGG_CFLAGS"
40     LIBS="$LIBS $IVORBIS_LIBS $OGG_LIBS"
41 dnl
42 dnl Now check if the installed Tremor is sufficiently new.
43 dnl
44       rm -f conf.ivorbistest
45       AC_TRY_COMPILE([
46 #include <stdio.h>
47 #include <stdlib.h>
48 #include <string.h>
49 #include <tremor/codec.h>
50
51 int main ()
52 {
53 }
54
55 ],, no_ivorbis=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_ivorbis" = "x" ; then
61      AC_MSG_RESULT(yes)
62      ifelse([$1], , :, [$1])     
63   else
64      AC_MSG_RESULT(no)
65      IVORBIS_CFLAGS=""
66      IVORBIS_LIBS=""
67      IVORBISFILE_LIBS=""
68      ifelse([$2], , :, [$2])
69   fi
70   AC_SUBST(IVORBIS_CFLAGS)
71   AC_SUBST(IVORBIS_LIBS)
72   AC_SUBST(IVORBISFILE_LIBS)
73 ])