enable deinterlace as part of the fixes for TIVI-513
[profile/ivi/gst-plugins-good.git] / m4 / libfame.m4
1 dnl AM_PATH_LIBFAME([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND [, MODULES]]]])
2 dnl Test for libfame, and define LIBFAME_CFLAGS and LIBFAME_LIBS
3 dnl Vivien Chappelier 12/11/00
4 dnl stolen from ORBit autoconf
5 dnl
6 AC_DEFUN([AM_PATH_LIBFAME],
7 [dnl 
8 dnl Get the cflags and libraries from the libfame-config script
9 dnl
10 AC_ARG_WITH(libfame-prefix,[  --with-libfame-prefix=PFX   Prefix where libfame is installed (optional)],
11             libfame_config_prefix="$withval", libfame_config_prefix="")
12 AC_ARG_WITH(libfame-exec-prefix,[  --with-libfame-exec-prefix=PFX Exec prefix where libfame is installed (optional)],
13             libfame_config_exec_prefix="$withval", libfame_config_exec_prefix="")
14 AC_ARG_ENABLE(libfametest, [  --disable-libfametest       Do not try to compile and run a test libfame program],
15                     , enable_libfametest=yes)
16
17   if test x$libfame_config_exec_prefix != x ; then
18      libfame_config_args="$libfame_config_args --exec-prefix=$libfame_config_exec_prefix"
19      if test x${LIBFAME_CONFIG+set} != xset ; then
20         LIBFAME_CONFIG=$libfame_config_exec_prefix/bin/libfame-config
21      fi
22   fi
23   if test x$libfame_config_prefix != x ; then
24      libfame_config_args="$libfame_config_args --prefix=$libfame_config_prefix"
25      if test x${LIBFAME_CONFIG+set} != xset ; then
26         LIBFAME_CONFIG=$libfame_config_prefix/bin/libfame-config
27      fi
28   fi
29
30   AC_PATH_PROG(LIBFAME_CONFIG, libfame-config, no)
31   min_libfame_version=ifelse([$1], , 0.9.0, $1)
32   AC_MSG_CHECKING(for libfame - version >= $min_libfame_version)
33   no_libfame=""
34   if test "$LIBFAME_CONFIG" = "no" ; then
35     no_libfame=yes
36   else
37     LIBFAME_CFLAGS=`$LIBFAME_CONFIG $libfame_config_args --cflags`
38     LIBFAME_LIBS=`$LIBFAME_CONFIG $libfame_config_args --libs`
39     libfame_config_major_version=`$LIBFAME_CONFIG $libfame_config_args --version | \
40            sed -e 's,[[^0-9.]],,g' -e 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'`
41     libfame_config_minor_version=`$LIBFAME_CONFIG $libfame_config_args --version | \
42            sed -e 's,[[^0-9.]],,g' -e 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'`
43     libfame_config_micro_version=`$LIBFAME_CONFIG $libfame_config_args --version | \
44            sed -e 's,[[^0-9.]],,g' -e 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'`
45     if test "x$enable_libfametest" = "xyes" ; then
46       ac_save_CFLAGS="$CFLAGS"
47       ac_save_LIBS="$LIBS"
48       CFLAGS="$CFLAGS $LIBFAME_CFLAGS"
49       LIBS="$LIBFAME_LIBS $LIBS"
50 dnl
51 dnl Now check if the installed LIBFAME is sufficiently new. (Also sanity
52 dnl checks the results of libfame-config to some extent
53 dnl
54       rm -f conf.libfametest
55       AC_TRY_RUN([
56 #include <fame.h>
57 #include <stdio.h>
58 #include <stdlib.h>
59 #include <string.h>
60
61 int 
62 main ()
63 {
64   int major, minor, micro;
65   char *tmp_version;
66
67   system ("touch conf.libfametest");
68
69   /* HP/UX 9 (%@#!) writes to sscanf strings */
70   tmp_version = strdup("$min_libfame_version");
71   if (sscanf(tmp_version, "%d.%d.%d", &major, &minor, &micro) != 3) {
72      printf("%s, bad version string\n", "$min_libfame_version");
73      exit(1);
74    }
75
76   if ((libfame_major_version != $libfame_config_major_version) ||
77       (libfame_minor_version != $libfame_config_minor_version) ||
78       (libfame_micro_version != $libfame_config_micro_version))
79     {
80       printf("\n*** 'libfame-config --version' returned %d.%d.%d, but Libfame (%d.%d.%d)\n", 
81              $libfame_config_major_version, $libfame_config_minor_version, $libfame_config_micro_version,
82              libfame_major_version, libfame_minor_version, libfame_micro_version);
83       printf ("*** was found! If libfame-config was correct, then it is best\n");
84       printf ("*** to remove the old version of libfame. You may also be able to fix the error\n");
85       printf("*** by modifying your LD_LIBRARY_PATH enviroment variable, or by editing\n");
86       printf("*** /etc/ld.so.conf. Make sure you have run ldconfig if that is\n");
87       printf("*** required on your system.\n");
88       printf("*** If libfame-config was wrong, set the environment variable LIBFAME_CONFIG\n");
89       printf("*** to point to the correct copy of libfame-config, and remove the file config.cache\n");
90       printf("*** before re-running configure\n");
91     } 
92 #if defined (LIBFAME_MAJOR_VERSION) && defined (LIBFAME_MINOR_VERSION) && defined (LIBFAME_MICRO_VERSION)
93   else if ((libfame_major_version != LIBFAME_MAJOR_VERSION) ||
94            (libfame_minor_version != LIBFAME_MINOR_VERSION) ||
95            (libfame_micro_version != LIBFAME_MICRO_VERSION))
96     {
97       printf("*** libfame header files (version %d.%d.%d) do not match\n",
98              LIBFAME_MAJOR_VERSION, LIBFAME_MINOR_VERSION, LIBFAME_MICRO_VERSION);
99       printf("*** library (version %d.%d.%d)\n",
100              libfame_major_version, libfame_minor_version, libfame_micro_version);
101     }
102 #endif /* defined (LIBFAME_MAJOR_VERSION) ... */
103   else
104     {
105       if ((libfame_major_version > major) ||
106         ((libfame_major_version == major) && (libfame_minor_version > minor)) ||
107         ((libfame_major_version == major) && (libfame_minor_version == minor) && (libfame_micro_version >= micro)))
108       {
109         return 0;
110        }
111      else
112       {
113         printf("\n*** An old version of libfame (%d.%d.%d) was found.\n",
114                libfame_major_version, libfame_minor_version, libfame_micro_version);
115         printf("*** You need a version of libfame newer than %d.%d.%d. The latest version of\n",
116                major, minor, micro);
117         printf("*** libfame is always available from http://www-eleves.enst-bretagne.fr/~chappeli/fame\n");
118         printf("***\n");
119         printf("*** If you have already installed a sufficiently new version, this error\n");
120         printf("*** probably means that the wrong copy of the libfame-config shell script is\n");
121         printf("*** being found. The easiest way to fix this is to remove the old version\n");
122         printf("*** of libfame, but you can also set the LIBFAME_CONFIG environment to point to the\n");
123         printf("*** correct copy of libfame-config. (In this case, you will have to\n");
124         printf("*** modify your LD_LIBRARY_PATH enviroment variable, or edit /etc/ld.so.conf\n");
125         printf("*** so that the correct libraries are found at run-time))\n");
126       }
127     }
128   return 1;
129 }
130 ],, no_libfame=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"])
131        CFLAGS="$ac_save_CFLAGS"
132        LIBS="$ac_save_LIBS"
133      fi
134   fi
135   if test "x$no_libfame" = x ; then
136      AC_MSG_RESULT(yes)
137      ifelse([$2], , :, [$2])     
138   else
139      AC_MSG_RESULT(no)
140      if test "$LIBFAME_CONFIG" = "no" ; then
141        echo "*** The libfame-config script installed by libfame could not be found"
142        echo "*** If libfame was installed in PREFIX, make sure PREFIX/bin is in"
143        echo "*** your path, or set the LIBFAME_CONFIG environment variable to the"
144        echo "*** full path to libfame-config."
145      else
146        if test -f conf.libfametest ; then
147         :
148        else
149           echo "*** Could not run libfame test program, checking why..."
150           CFLAGS="$CFLAGS $LIBFAME_CFLAGS"
151           LIBS="$LIBS $LIBFAME_LIBS"
152           AC_TRY_LINK([
153 #include <fame.h>
154 #include <stdio.h>
155 ],      [ return ((libfame_major_version) || (libfame_minor_version) || (libfame_micro_version)); ],
156         [ echo "*** The test program compiled, but did not run. This usually means"
157           echo "*** that the run-time linker is not finding libfame or finding the wrong"
158           echo "*** version of LIBFAME. If it is not finding libfame, you'll need to set your"
159           echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point"
160           echo "*** to the installed location  Also, make sure you have run ldconfig if that"
161           echo "*** is required on your system"
162           echo "***"
163           echo "*** If you have an old version installed, it is best to remove it, although"
164           echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH"
165           echo "***" ],
166         [ echo "*** The test program failed to compile or link. See the file config.log for the"
167           echo "*** exact error that occured. This usually means libfame was incorrectly installed"
168           echo "*** or that you have moved libfame since it was installed. In the latter case, you"
169           echo "*** may want to edit the libfame-config script: $LIBFAME_CONFIG" ])
170           CFLAGS="$ac_save_CFLAGS"
171           LIBS="$ac_save_LIBS"
172        fi
173      fi
174      LIBFAME_CFLAGS=""
175      LIBFAME_LIBS=""
176      ifelse([$3], , :, [$3])
177   fi
178
179   AC_SUBST(LIBFAME_CFLAGS)
180   AC_SUBST(LIBFAME_LIBS)
181   rm -f conf.libfametest
182 ])