attempt to fix my sucky dv and festival breakage.
[platform/upstream/gstreamer.git] / m4 / libdv.m4
1 # Configure paths for libdv
2 # copied from vorbis.m4 by Thomas
3 # checks for libdv 0.9.5 since that added an extra argument to _init
4 # Shamelessly stolen from Owen Taylor and Manish Singh
5
6 dnl AM_PATH_LIBDV([ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]])
7 dnl Test for liblibdv, and define LIBDV_CFLAGS and LIBDV_LIBS
8 dnl
9 AC_DEFUN(AM_PATH_LIBDV,
10 [dnl 
11 dnl Get the cflags and libraries
12
13 AC_ARG_WITH(libdv,[  --with-libdv=PFX   Prefix where libdv is installed (optional)], libdv_prefix="$withval", libdv_prefix="")
14 AC_ARG_WITH(libdv-libraries,[  --with-libdv-libraries=DIR   Directory where libdv library is installed (optional)], libdv_libraries="$withval", libdv_libraries="")
15 AC_ARG_WITH(libdv-includes,[  --with-libdv-includes=DIR   Directory where libdv header files are installed (optional)], libdv_includes="$withval", libdv_includes="")
16 AC_ARG_ENABLE(libdvtest, [  --disable-libdvtest       Do not try to compile and run a test libdv program],, enable_libdvtest=yes)
17
18   if test "x$libdv_libraries" != "x" ; then
19     LIBDV_LIBS="-L$libdv_libraries"
20   elif test "x$libdv_prefix" != "x" ; then
21     LIBDV_LIBS="-L$libdv_prefix/lib"
22   elif test "x$prefix" != "xNONE"; then
23     LIBDV_LIBS="-L$prefix/lib"
24   fi
25
26   LIBDV_LIBS="$LIBDV_LIBS -ldv -lm"
27
28   if test "x$libdv_includes" != "x" ; then
29     LIBDV_CFLAGS="-I$libdv_includes"
30   elif test "x$libdv_prefix" != "x" ; then
31     LIBDV_CFLAGS="-I$libdv_prefix/include"
32   elif test "x$prefix" != "xNONE"; then
33     LIBDV_CFLAGS="-I$prefix/include"
34   fi
35
36
37   AC_MSG_CHECKING(for libdv)
38   no_libdv=""
39
40
41   if test "x$enable_libdvtest" = "xyes" ; then
42     ac_save_CFLAGS="$CFLAGS"
43     ac_save_LIBS="$LIBS"
44     CFLAGS="$CFLAGS $LIBDV_CFLAGS"
45     LIBS="$LIBS $LIBDV_LIBS"
46 dnl
47 dnl Now check if the installed libdv is sufficiently new.
48 dnl
49       dnl rm -f conf.libdvtest
50       AC_TRY_RUN([
51 #include <stdio.h>
52 #include <stdlib.h>
53 #include <string.h>
54 #include <libdv/dv.h>
55
56 int main ()
57 {
58   dv_decoder_new (0, 0, 0);
59   return 0;
60 }
61
62 ],, no_libdv=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_libdv" = "x" ; then
68      AC_MSG_RESULT(yes)
69      ifelse([$1], , :, [$1])     
70   else
71      AC_MSG_RESULT(no)
72      if test -f conf.libdvtest ; then
73        :
74      else
75        echo "*** Could not run libdv test program, checking why..."
76        CFLAGS="$CFLAGS $LIBDV_CFLAGS"
77        LIBS="$LIBS $LIBDV_LIBS"
78        AC_TRY_LINK([
79 #include <stdio.h>
80 #include <libdv/dv.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 libdv or finding the wrong"
84        echo "*** version of libdv. If it is not finding libdv, 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 libdv was incorrectly installed"
93        echo "*** or that you have moved libdv since it was installed." ])
94        CFLAGS="$ac_save_CFLAGS"
95        LIBS="$ac_save_LIBS"
96      fi
97      LIBDV_CFLAGS=""
98      LIBDV_LIBS=""
99      LIBDVFILE_LIBS=""
100      LIBDVENC_LIBS=""
101      ifelse([$2], , :, [$2])
102   fi
103   AC_SUBST(LIBDV_CFLAGS)
104   AC_SUBST(LIBDV_LIBS)
105   AC_SUBST(LIBDVFILE_LIBS)
106   AC_SUBST(LIBDVENC_LIBS)
107   dnl rm -f conf.libdvtest
108 ])