Add automated test on delayed return value handling in ExternalInterface.call().
[gnash.git] / macros / ffmpeg.m4
blobd1d8426643a7248485a2937a70cbea24279359c7
1 dnl  
2 dnl  Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010,
3 dnl  2011 Free Software Foundation, Inc.
4 dnl  
5 dnl  This program is free software; you can redistribute it and/or modify
6 dnl  it under the terms of the GNU General Public License as published by
7 dnl  the Free Software Foundation; either version 3 of the License, or
8 dnl  (at your option) any later version.
9 dnl  
10 dnl  This program is distributed in the hope that it will be useful,
11 dnl  but WITHOUT ANY WARRANTY; without even the implied warranty of
12 dnl  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 dnl  GNU General Public License for more details.
14 dnl  You should have received a copy of the GNU General Public License
15 dnl  along with this program; if not, write to the Free Software
16 dnl  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
18 AC_DEFUN([GNASH_PATH_FFMPEG],
21   dnl Backup LIBS and CFLAGS vars, we'll add user-specified dirs there
22   backupLIBS="$LIBS"
23   backupCFLAGS="$CFLAGS"
24   avcodec_h=""
25   avcodec_version_h=""
26   ffmpeg_top_incl=""
28   dnl If the user specify an path to include headers from, we assume it's the full
29   dnl path to the header file, and not the top level path without the 'ffmpeg' node
30   dnl of the path. This is made more fun my the way ffmpeg changes directory layout
31   dnl reasonably often.
32   dnl
33   dnl ffmpeg_top_level - the top level directory without the ffmpeg specific part.
34   dnl           ie... /usr/local/include/ffmpeg becomes /usr/local/include, and
35   dnl           /usr/local/include/ffmpeg/libavcodec becomes /usr/local/include/ffmpeg.
36   dnl avcode_h - stores the path and file name for avcodec.h, which is used later on
37   dnl           in this macro to extract the version number of ffmpeg we're using.
38   AC_ARG_WITH(ffmpeg_incl, AC_HELP_STRING([--with-ffmpeg-incl], [directory where avcodec.h is]), with_ffmpeg_incl=${withval})
39   AC_CACHE_VAL(ac_cv_path_ffmpeg_incl,[
40     if test x"${with_ffmpeg_incl}" != x ; then
41       dnl top level path for include files minus the last directory from the user
42       dnl specified path.
43       ffmpeg_top_incl=`dirname ${with_ffmpeg_incl}`
44       if test -f ${with_ffmpeg_incl}/avcodec.h; then
45         ac_cv_path_ffmpeg_incl="-I`(cd ${ffmpeg_top_incl}; pwd)`"
46         if test -f ${with_ffmpeg_incl}/version.h && $EGREP LIBAVCODEC_VERSION ${with_ffmpeg_incl}/version.h 2>&1 >/dev/null; then
47           avcodec_h=${with_ffmpeg_incl}/version.h
48         else
49           avcodec_h=${with_ffmpeg_incl}/avcodec.h
50         fi
51       else
52         AC_MSG_ERROR([${with_ffmpeg_incl} directory does not contain the avcodec.h header])
53       fi
54       if test -f ${with_ffmpeg_incl}/version.h; then
55         avcodec_version_h=${with_ffmpeg_incl}/version.h
56       fi
57     fi
58   ])
60   dnl Try to find avcodec.h ourselves
61   if test x${ffmpeg_top_incl} = x; then
62     AC_MSG_CHECKING([location of avcodec.h])
63     dnl Try PKG_CONFIG if available
64     if test x"$PKG_CONFIG" != x; then dnl {
65       if $PKG_CONFIG --exists libavcodec; then dnl {
66         dnl Some systems return /usr/include/ffmpeg, others /usr/include.
67         dnl We use #include <ffmpeg/avcodec.h> everywhere so weed out funny
68         dnl values into the short form.
69         ffmpeg_pkg=`$PKG_CONFIG --cflags-only-I libavcodec`
70         ffmpeg_top_incl=`echo ${ffmpeg_pkg} | sed  -e 's:-I::'`
71         dnl Make sure a header file really exists in the given path.
72         dnl Ubuntu like the headers here in the top level ffmpeg directory.
73         for i in "" ffmpeg libavcodec ffmpeg/libavcodec; do
74           if test -f ${ffmpeg_top_incl}/${i}/avcodec.h; then
75             ac_cv_path_ffmpeg_incl="-I`(cd ${ffmpeg_top_incl}; pwd)`"
76             if test -f ${ffmpeg_top_incl}/${i}/version.h && $EGREP LIBAVCODEC_VERSION ${ffmpeg_top_incl}/${i}/version.h  2>&1 >/dev/null; then
77               avcodec_h="${ffmpeg_top_incl}/${i}/version.h"
78             else
79               avcodec_h="${ffmpeg_top_incl}/${i}/avcodec.h"
80             fi
81             if test -f ${ffmpeg_top_incl}/${i}/version.h; then
82               avcodec_version_h=${ffmpeg_top_incl}/${i}/version.h
83             fi
84             break
85           fi
86         done
87       fi
88     fi
89   fi
91   dnl if pkg-config doesn't have the values we want, or they're plain wrong, look
92   dnl in several common places ourselves. Note that the variable ffmpeg_top_incl
93   dnl contains the value of the top level path that has been found.
94   if test x"${ac_cv_path_ffmpeg_incl}" = x ; then
95     newlist="/usr/include/ffmpeg $incllist"
96     for ffmpeg_top_incl in $newlist; do
97       for i in ffmpeg libavcodec ffmpeg/libavcodec; do
98         if test -f ${ffmpeg_top_incl}/${i}/avcodec.h; then
99           ac_cv_path_ffmpeg_incl="-I`(cd ${ffmpeg_top_incl}/${i}; pwd)`"
100           if test -f ${ffmpeg_top_incl}/${i}/version.h && $EGREP LIBAVCODEC_VERSION ${ffmpeg_top_incl}/${i}/version.h  2>&1 >/dev/null; then
101             avcodec_h=${ffmpeg_top_incl}/${i}/version.h
102           else
103             avcodec_h=${ffmpeg_top_incl}/${i}/avcodec.h
104           fi
105           if test -f ${ffmpeg_top_incl}/${i}/version.h; then
106             avcodec_version_h=${ffmpeg_top_incl}/${i}/version.h
107           fi
108           break
109         fi
110       done
111       if test x"${ac_cv_path_ffmpeg_incl}" != x ; then
112         break
113       fi
114     done
115   fi
117   dnl Because the avcodec.h header file might be found by any one of
118   dnl the above ways, we set the version macros after all those tests
119   dnl are done so we only have to do it once.
120   newer_ffmpeg=`echo ${avcodec_h} | grep -c libavcodec`
121   if test ${newer_ffmpeg} -eq 0; then
122     AC_DEFINE(HAVE_FFMPEG_AVCODEC_H, 1, [Define if you have avcodec.h installed.])
123   else
124     AC_DEFINE(HAVE_LIBAVCODEC_AVCODEC_H, 1, [Define if you have avcodec.h installed.])
125   fi
127   if test x"${ac_cv_path_ffmpeg_incl}" = x ; then
128     have_ffmpeg=no
129     AC_MSG_RESULT(none found)
130   else
131     have_ffmpeg=yes
132     AC_MSG_RESULT(${ac_cv_path_ffmpeg_incl})
133   fi
135   dnl Find and check libavcodec version number to make sure we have a usable
136   dnl version and to enable/disable features according to version.
137   dnl We need LIBAVCODEC VERSION of at least 51.29.0 to get avcodec_decode_audio2
138   dnl
139   dnl We try to get the avcodec version as a decimal number
140   dnl so that we can compare it numerically against what we require.
141   dnl
142   dnl This previous version makes ffmpeg fail and then grubs the version string
143   dnl out of the resulting usage message e.g. "  libavcodec version: 51.40.2"
144   dnl Early versions of ffmpeg do not output this string at all.
145   dnl
146   dnl   AC_PATH_PROG(FFMPEG, ffmpeg, ,[${pathlist}])
147   dnl   if test "x$FFMPEG" = "x" ; then
148   dnl     ffmpeg_version=`$FFMPEG uglyhack 2>&1 | grep "libavcodec version" | cut -d ' ' -f 5 | tr -d '.'`
149   dnl     if test "$ffmpeg_version" -lt 51290; then
150   dnl       AC_MSG_ERROR([])
151   dnl     fi
152   dnl   fi
153   dnl
154   dnl These days we check avcodec.h and pick the version out of the constants,
155   dnl simply throwing away all non-digits.
156   dnl
157   dnl In earlier versions we have:
158   dnl #define FFMPEG_VERSION_INT     0x000409
159   dnl #define FFMPEG_VERSION         "0.4.9-pre1"
160   dnl #define LIBAVCODEC_BUILD       4731
161   dnl #define LIBAVCODEC_VERSION_INT FFMPEG_VERSION_INT
162   dnl #define LIBAVCODEC_VERSION     FFMPEG_VERSION
163   dnl
164   dnl elsewhere, FFMPEG_VERSION may also be the quoted string "CVS"
165   dnl
166   dnl This changed from the above to
167   dnl #define LIBAVCODEC_VERSION_INT ((49<<16)+(0<<8)+0)
168   dnl #define LIBAVCODEC_VERSION     49.0.0
169   dnl #define LIBAVCODEC_BUILD       LIBAVCODEC_VERSION_INT
170   dnl (note, LIBAVCODEC_VERSION also changes from a quoted string to unquoted)
171   dnl see http://lists.mplayerhq.hu/pipermail/ffmpeg-cvslog/2005-July/000570.html
172   dnl
173   dnl
174   dnl This changed from the above to
175   dnl #define LIBAVCODEC_VERSION_MAJOR 51
176   dnl #define LIBAVCODEC_VERSION_MINOR 54
177   dnl #define LIBAVCODEC_VERSION_MICRO  0
178   dnl 
179   dnl #define LIBAVCODEC_VERSION_INT  AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
180   dnl                                                LIBAVCODEC_VERSION_MINOR, \
181   dnl                                                LIBAVCODEC_VERSION_MICRO)
182   dnl #define LIBAVCODEC_VERSION      AV_VERSION(LIBAVCODEC_VERSION_MAJOR,    \
183   dnl                                            LIBAVCODEC_VERSION_MINOR,    \
184   dnl                                            LIBAVCODEC_VERSION_MICRO)
185   
186   dnl Those deb-heads at Debian redefine LIBAVCODEC_VERSION in their versions to
187   dnl (e.g.) 1d.51.38.0 or dnl 0d.51.11.0 - we need to discard the prefixed
188   dnl rubbish.
189   dnl
190   dnl Other values or LIBAVCODEC_VERSION spotted in the wild:
191   dnl 50.0.0  50.5.0  51.7.0  51.8.0  0d.51.8.0  51.40.4
192   dnl presumably this will change to 52.0.0 at some point...
193   dnl
194   dnl We can ignore the very early versions because 51.10.0 is necessary to decode
195   dnl Flash video at all. However the current solution will incorrectly succeed
196   dnl on early debian/ubuntu 1d.* version numbers and incorrectly fail
197   dnl when 52.0.0 happens.
198   dnl
199   dnl The most reliable way is to compile a test program to print the value of
200   dnl LIBAVCODEC_BUILD, which got up to dnl 4718 at version 0.4.9-pre1,
201   dnl then changed to (major<<16 + minor<<8 + micro) from then on.
202   dnl There is code to do this in transcode's configure.in, but when
203   dnl cross-compiling we cannot run a test program, which suggests that
204   dnl a modified form of grepping may be better, making sure all old kinds of
205   dnl version numbering fail gracefully.
207   versionfile=""
209   dnl Check avcodec version number, if it was found
210   if test x"${avcodec_version_h}" != x; then
211     versionfile=${avcodec_version_h}
212   else
213     if test x"${avcodec_h}" != x; then
214       versionfile=${avcodec_h}
215     fi
216   fi
218   if test x"${versionfile}" != x; then
220     AC_MSG_CHECKING([ffmpeg version])
222     ffmpeg_major_version=`$EGREP "define LIBAVCODEC_VERSION_MAJOR " ${versionfile} 2>&1 | sed -e "s%[[^0-9]]%%g"`
223     ffmpeg_minor_version=`$EGREP "define LIBAVCODEC_VERSION_MINOR " ${versionfile} 2>&1 | sed -e "s%[[^0-9]]%%g"`
224     ffmpeg_micro_version=`$EGREP "define LIBAVCODEC_VERSION_MICRO " ${versionfile} 2>&1 | sed -e "s%[[^0-9]]%%g"`
226     if test x"${ffmpeg_major_version}" != x ; then
228       ffmpeg_version="${ffmpeg_major_version}.${ffmpeg_minor_version}.${ffmpeg_micro_version}"
230     else
232       dnl #define LIBAVCODEC_VERSION_TRIPLET 51,50,1
233       ffmpeg_version=`$EGREP "define LIBAVCODEC_VERSION_TRIPLET " ${versionfile}  2>&1 | awk '{print $'3'}' | sed -e "s%,%.%g"`
235       if test x"${ffmpeg_version}" = x ; then
237         dnl NOTE: the [0-9]*d. pattern discards deb-heads rubbish prefix
238         ffmpeg_version=`$EGREP "define LIBAVCODEC_VERSION " ${versionfile} | awk '{print $'3'}' 2>&1 | sed -e "s%^[[0-9]]d\.%%"` 
240         if test x"${ffmpeg_version}" = x ; then
241           ffmpeg_version=`$EGREP "define LIBAVCODEC_BUILD " ${versionfile} 2>&1  | awk '{print $'3'}'`
242         fi
243       fi
245       if test x"${ffmpeg_version}" != x ; then
246         ffmpeg_major_version=`echo ${ffmpeg_version} | cut -d. -f1`
247         ffmpeg_minor_version=`echo ${ffmpeg_version} | cut -d. -f2`
248         ffmpeg_micro_version=`echo ${ffmpeg_version} | cut -d. -f3`
249       fi
251     fi
253     ffmpeg_num_version=`printf %02d%02d%02d $ffmpeg_major_version $ffmpeg_minor_version $ffmpeg_micro_version`
255     AC_MSG_RESULT($ffmpeg_version ($ffmpeg_num_version))
258 dnl  minimum supported libavcodec version = Debian stable one = currently Wheezy 7.0 53.35.00
260     if test -z "$ffmpeg_num_version" -o "$ffmpeg_num_version" -lt 533500; then
261       AC_MSG_WARN([Wrong ffmpeg/libavcodec version! 53.35.0 or greater required, $ffmpeg_version detected.])
262     else
263       ffmpeg_version_check=ok
264     fi
266   else
267     AC_MSG_WARN([Could not check ffmpeg version (can't find avcodec.h file)])
268     # ffmpeg_version_check=ok # this is NOT ok, why would it be ?! 
269   fi
271 dnl Check if installed ffmpeg/libav already switched aac decoding from S16 to
272 dnl float planar format (FLTP). If recent enough, we'll recommend to install
273 dnl a dedicate resampling library to get aac properly decoded.
274 dnl Commit in question (3d3cf6745e2a5dc9c377244454c3186d75b177fa) corresponds
275 dnl to libavcodec ffmpeg version 54.77.100 / libav version 54.33.0.
276 dnl | ffmpeg | 1.0 (54.59.100) S16 | 1.1 (54.86.100) FLTP |
277 dnl | libav  | 0.8 (53.35.0)   S16 | 9   (54.35.0)   FLTP |
279   if test ${ffmpeg_major_version} -ge 55 -o \
280     \( ${ffmpeg_major_version} -eq 54 -a ${ffmpeg_micro_version} -eq 0 \) -o \
281     \( ${ffmpeg_major_version} -eq 54 -a ${ffmpeg_minor_version} -ge 77 -a \
282     ${ffmpeg_micro_version} -ge 100 \); then
283       ffmpeg_aac_float_planar=yes
284   fi
286   LIBAVCODEC_IDENT=${ffmpeg_version}
287   FFMPEG_CFLAGS="-D__STDC_CONSTANT_MACROS ${ac_cv_path_ffmpeg_incl}"
289   AC_MSG_CHECKING([for avformat.h])
290   if test -f "${ffmpeg_top_incl}/avformat.h"; then
291     AC_DEFINE(HAVE_FFMPEG_AVFORMAT_H, 1, [Define if avformat.h is found])
292     avformat_h="${ffmpeg_top_incl}/avformat.h"
293   else
294     if test -f "${ffmpeg_top_incl}/libavformat/avformat.h"; then
295       AC_DEFINE(HAVE_LIBAVFORMAT_AVFORMAT_H, 1, [Define if avformat.h is found])
296       avformat_h="${ffmpeg_top_incl}/libavformat/avformat.h"
297     else
298       avformat_h=""
299     fi
300   fi
301   AC_MSG_RESULT($avformat_h)
303   AC_MSG_CHECKING([for swscale.h])
304   have_ffmpeg_swscale=no
305   if test -f "${ffmpeg_top_incl}/ffmpeg/swscale.h"; then
306     have_ffmpeg_swscale=yes
307     AC_DEFINE(HAVE_FFMPEG_SWSCALE_H, 1, [Define if swscale.h is found])
308   fi
309   if test -f "${ffmpeg_top_incl}/libswscale/swscale.h"; then
310     have_ffmpeg_swscale=yes
311     AC_DEFINE(HAVE_LIBSWSCALE_SWSCALE_H, 1, [Define if swscale.h is found])
312   fi
313   if test -f "${ffmpeg_top_incl}/swscale.h"; then
314     have_ffmpeg_swscale=yes
315     AC_DEFINE(HAVE_SWSCALE_H, 1, [Define if swscale.h is found])
316   fi
317   AC_MSG_RESULT($have_ffmpeg_swscale)
319   if test x"$have_ffmpeg_swscale" = "xno" -a 1$ffmpeg_num_version -ge 1"520000"; then
320      AC_MSG_WARN([Cannot find swscale.h, required for ffmpeg versions >= 52.0.0 (detected version: $ffmpeg_version)])
321      ffmpeg_version_check=
322   fi
324   AC_MSG_CHECKING([for libavutil/opt.h])
325   have_ffmpeg_libavutil=no
326   if test -f "${ffmpeg_top_incl}/libavutil/opt.h"; then
327     have_ffmpeg_libavutil=yes
328     AC_DEFINE(HAVE_LIBAVUTIL_OPT_H, 1, [Define if libavutil/opt.h is found])
329   fi
330   AC_MSG_RESULT($have_ffmpeg_libavutil)
332   AC_MSG_CHECKING([for swresample.h])
333   have_ffmpeg_swresample=no
334   if test -f "${ffmpeg_top_incl}/ffmpeg/swresample.h"; then
335     have_ffmpeg_swresample=yes
336     AC_DEFINE(HAVE_FFMPEG_SWRESAMPLE_H, 1, [Define if swresample.h is found])
337   fi
338   if test -f "${ffmpeg_top_incl}/libswresample/swresample.h"; then
339     have_ffmpeg_swresample=yes
340     AC_DEFINE(HAVE_LIBSWRESAMPLE_SWRESAMPLE_H, 1, [Define if swresample.h is found])
341   fi
342   if test -f "${ffmpeg_top_incl}/swresample.h"; then
343     have_ffmpeg_swresample=yes
344     AC_DEFINE(HAVE_SWRESAMPLE_H, 1, [Define if swresample.h is found])
345   fi
346   AC_MSG_RESULT($have_ffmpeg_swresample)
348   AC_MSG_CHECKING([for avresample.h])
349   have_libav_avresample=no
350   if test -f "${ffmpeg_top_incl}/libav/avresample.h"; then
351     have_libav_avresample=yes
352     AC_DEFINE(HAVE_LIBAV_AVRESAMPLE_H, 1, [Define if avresample.h is found])
353   fi
354   if test -f "${ffmpeg_top_incl}/libavresample/avresample.h"; then
355     have_libav_avresample=yes
356     AC_DEFINE(HAVE_LIBAVRESAMPLE_AVRESAMPLE_H, 1, [Define if avresample.h is found])
357   fi
358   if test -f "${ffmpeg_top_incl}/avresample.h"; then
359     have_libav_avresample=yes
360     AC_DEFINE(HAVE_AVRESAMPLE_H, 1, [Define if avresample.h is found])
361   fi
362   AC_MSG_RESULT($have_libav_avresample)
364   AC_MSG_CHECKING([for libavcodec/vaapi.h])
365   have_ffmpeg_vaapi="no"
366   if test -f "${ffmpeg_top_incl}/ffmpeg/vaapi.h"; then
367     have_ffmpeg_vaapi="yes"
368     AC_DEFINE(HAVE_FFMPEG_VAAPI_H, 1, [Defined if ffmpeg/vaapi.h is found])
369   fi
370   if test -f "${ffmpeg_top_incl}/libavcodec/vaapi.h"; then
371     have_ffmpeg_vaapi="yes"
372     AC_DEFINE(HAVE_LIBAVCODEC_VAAPI_H, 1, [Defined if libavcodec/vaapi.h is found])
373   fi
374   AC_MSG_RESULT($have_ffmpeg_vaapi)
376   dnl ---------------------------------
377   dnl
378   dnl FFMPEG libs checking
379   dnl
380   dnl ---------------------------------
382   top_lib_dir=""
384   dnl Did they tell us where the libs are ?
385   AC_ARG_WITH(ffmpeg_lib, AC_HELP_STRING([--with-ffmpeg-lib], [directory where ffmpeg libraries are]), with_ffmpeg_lib=${withval})
386   AC_CACHE_VAL(ac_cv_path_ffmpeg_lib, [
387     if test x"${with_ffmpeg_lib}" != x ; then
388       if test -f ${with_ffmpeg_lib}/libavcodec.a -o -f ${with_ffmpeg_lib}/libavcodec.${shlibext}; then
389               ac_cv_path_ffmpeg_lib="-L`(cd ${with_ffmpeg_lib}; pwd)`"
390           libavcodec="-lavcodec"
391           LIBS="${ac_cv_path_ffmpeg_lib} $LIBS" dnl <-- What is this needed for ?
392           top_lib_dir=${with_ffmpeg_lib}
393       else
394               AC_MSG_ERROR([${with_ffmpeg_lib} directory doesn't contain libavcodec libraries.])
395       fi
396       if test -f ${with_ffmpeg_lib}/libavformat.a -o -f ${with_ffmpeg_lib}/libavformat.${shlibext}; then
397               ac_cv_path_ffmpeg_lib="-L`(cd ${with_ffmpeg_lib}; pwd)`"
398           libavformat="-lavformat"
399           top_lib_dir=${with_ffmpeg_lib}
400       else
401               AC_MSG_ERROR([${with_ffmpeg_lib} directory doesn't contain libavformat libraries.])
402       fi
403     fi
404   ])
406   dnl Look for the AVCODEC library
408   dnl Try with pkg-config (if not cross-compiling)
409   if test x"${cross_compiling}" = xno; then
410     if test x"$PKG_CONFIG" != x -a x"${libavcodec}" = x; then
411       $PKG_CONFIG --exists libavcodec && libavcodec=`$PKG_CONFIG --libs libavcodec`
412       dnl
413       dnl WARNING: we won't be able to set top_lib_dir here, as pkg-config doesn't
414       dnl          return any -L when not neeed.
415       dnl          We won't need top_lib_dir either, as the only use for it
416       dnl          is to look for other required libraries, while pkg-config 
417       dnl          probably include them all, so not a big deal.
418       dnl
419     fi
420   fi
422   if test x"${libavcodec}" != x; then
423     ac_cv_path_ffmpeg_lib="${ac_cv_path_ffmpeg_lib} ${libavcodec}"
424   else
425     AC_MSG_CHECKING([for libavcodec library])
426     for i in $libslist; do
427       if test -f $i/libavcodec.a -o -f $i/libavcodec.${shlibext}; then
428         if test x${top_lib_dir} = x; then top_lib_dir=$i; fi
429         AC_MSG_RESULT(${top_lib_dir}/libavcodec)
430             if test ! x"$i" = x"/usr/lib" -a ! x"$i" = x"/usr/lib64"; then
431           ac_cv_path_ffmpeg_lib="-L$i -lavcodec"
432           break
433         else
434           ac_cv_path_ffmpeg_lib="-lavcodec"
435               break
436         fi
437       fi
438     done
440     if test x"${libavcodec}" = x; then
441       AC_MSG_RESULT(no)
442       if test x${cross_compiling} = xno; then
443         dnl avcodec_decode_audio2 starts 51.29.0
444         AC_CHECK_LIB(avcodec, ff_eval, [ac_cv_path_ffmpeg_lib="${ac_cv_path_ffmpeg_lib} -lavcodec"])
445       fi
446     fi
447   fi
449   if test x$top_lib_dir != x; then
450     AC_MSG_NOTICE([ffmpeg top lib dir is $top_lib_dir])
451   fi
453   dnl Start of all optional library tests {
454   dnl
455   dnl TODO: skip these tests if we got ac_cv_path_ffmpeg_lib
456   dnl       from pkg-config, as it would likely bring all
457   dnl       required libs in. 
458   dnl
459   if test x"${ac_cv_path_ffmpeg_lib}" != x; then
461     dnl Look for the DTS library, which is required on some systems. {
462     dnl
463     dnl TODO: skip this if -ldts is already in due to pkg-config 
464     dnl
465     AC_MSG_CHECKING([for libdts library])
466     if test x"$PKG_CONFIG" != x -a x${cross_compiling} = xno; then
467       $PKG_CONFIG --exists libdts && libdts=`$PKG_CONFIG --libs-only-l libdts`
468     else
469       libdts=""
470     fi
471     if test x"${libdts}" = x; then
472       if test -f ${top_lib_dir}/libdts.a -o -f ${top_lib_dir}/libdts.${shlibext}; then
473         ac_cv_path_ffmpeg_lib="${ac_cv_path_ffmpeg_lib} -ldts"
474         AC_MSG_RESULT(${top_lib_dir}/libdts)
475       else
476         AC_MSG_RESULT(no)
477         if test x${cross_compiling} = xno; then
478           AC_CHECK_LIB(dts, dts_init, [ac_cv_path_ffmpeg_lib="${ac_cv_path_ffmpeg_lib} -ldts"])
479         fi
480       fi
481     else
482       AC_MSG_RESULT(${libdts})
483       ac_cv_path_ffmpeg_lib="${ac_cv_path_ffmpeg_lib} ${libdts}"      
484     fi
485     dnl End of DTS library looking }
486         
487     dnl Look for the VORBISENC library, which is required on some systems. {
488     AC_MSG_CHECKING([for libvorbisenc library])
489     if test x"$PKG_CONFIG" != x -a x${cross_compiling} = xno; then
490       $PKG_CONFIG --exists vorbisenc && libvorbisenc=`$PKG_CONFIG --libs-only-l vorbisenc`
491     else
492       libvorbisenc=""
493     fi
494     if test x"${libvorbisenc}" = x; then
495       if test -f ${top_lib_dir}/libvorbisenc.a -o -f ${top_lib_dir}/libvorbisenc.${shlibext}; then
496         ac_cv_path_ffmpeg_lib="${ac_cv_path_ffmpeg_lib} -lvorbisenc"
497         AC_MSG_RESULT(${top_lib_dir}/libvorbisenc)
498       else
499         AC_MSG_RESULT(no)
500         if test x${cross_compiling} = xno; then
501           AC_CHECK_LIB(vorbisenc, vorbis_encode_init, [ac_cv_path_ffmpeg_lib="${ac_cv_path_ffmpeg_lib} -lvorbisenc"])
502         fi
503       fi
504     else
505       AC_MSG_RESULT(${libvorbisenc})
506       ac_cv_path_ffmpeg_lib="${ac_cv_path_ffmpeg_lib} ${libvorbisenc}"
507     fi
508     dnl End of VORBINSEC library looking }
509         
511     dnl Look for the AVFORMAT library {
512     dnl
513     dnl TODO: libavformat be mandatory, thus linked in already ?
514     dnl
516     AC_MSG_CHECKING([for libavformat library])
518     dnl Try with pkg-config (if not cross-compiling)
519     if test x"${cross_compiling}" = xno; then
520       if test x"$PKG_CONFIG" != x -a x${libavformat} = x; then
521         $PKG_CONFIG --exists libavformat && libavformat=`$PKG_CONFIG --libs-only-l libavformat`
522       fi
523     fi
525     if test x"${libavformat}" = x; then
526       if test -f ${top_lib_dir}/libavformat.a -o -f ${top_lib_dir}/libavformat.${shlibext}; then
527         ac_cv_path_ffmpeg_lib="-lavformat ${ac_cv_path_ffmpeg_lib}" 
528         AC_MSG_RESULT(${top_lib_dir}/libavformat)
529       else
530         AC_MSG_RESULT(no)
531         if test x${cross_compiling} = xno; then
532           AC_CHECK_LIB(libavformat, av_open_input_file, [ac_cv_path_ffmpeg_lib="${ac_cv_path_ffmpeg_lib} -lavformat"])
533         fi
534       fi
535     else
536       AC_MSG_RESULT(${libavformat})
537       ac_cv_path_ffmpeg_lib="${ac_cv_path_ffmpeg_lib} ${libavformat}"      
538     fi
540     dnl End of AVFORMAT library looking }
542     dnl Look for the AVUTIL library, which is required on some systems. {
543     dnl
544     dnl TODO: skip this if -lavutil is already in due to pkg-config 
545     dnl
546     AC_MSG_CHECKING([for libavutil library])
547     if test x"$PKG_CONFIG" != x -a x${cross_compiling} = xno; then
548       $PKG_CONFIG --exists libavutil && libavutil=`$PKG_CONFIG --libs-only-l libavutil`
549     else
550       libavutil=""
551     fi
552     if test x"${libavutil}" = x; then
553       if test -f ${top_lib_dir}/libavutil.a -o -f ${top_lib_dir}/libavutil.${shlibext}; then
554         ac_cv_path_ffmpeg_lib="${ac_cv_path_ffmpeg_lib} -lavutil"
555         AC_MSG_RESULT(${top_lib_dir}/libavutil)
556       else
557         AC_MSG_RESULT(no)
558         if test x${cross_compiling} = xno; then
559            AC_CHECK_LIB(avutil, av_log, [ac_cv_path_ffmpeg_lib="${ac_cv_path_ffmpeg_lib} -lavutil"])
560         fi
561       fi
562     else
563       AC_MSG_RESULT(${libavutil})
564       ac_cv_path_ffmpeg_lib="${ac_cv_path_ffmpeg_lib} ${libavutil}"
565     fi
566     dnl End of AVUTIL library looking }
567         
568     dnl Look for the THEORA library, which is required on some systems. {
569     dnl
570     dnl TODO: skip this if -ltheora is already in due to pkg-config 
571     dnl
572     AC_MSG_CHECKING([for libtheora library])
573     if test x"$PKG_CONFIG" != x -a x${cross_compiling} = xno; then
574       $PKG_CONFIG --exists theora && libtheora=`$PKG_CONFIG --libs-only-l theora`
575     else
576       libtheora=""
577     fi
578     if test x"${libtheora}" = x; then
579       if test -f ${top_lib_dir}/libtheora.a -o -f ${top_lib_dir}/libtheora.${shlibext}; then
580         ac_cv_path_ffmpeg_lib="${ac_cv_path_ffmpeg_lib} -ltheora"
581         AC_MSG_RESULT(${top_lib_dir}/libtheora)
582       else
583         AC_MSG_RESULT(no)
584         if test x${cross_compiling} = xno; then
585           AC_CHECK_LIB(theora, theora_encode_init, [ac_cv_path_ffmpeg_lib="${ac_cv_path_ffmpeg_lib} -ltheora"])
586         fi
587       fi
588     else
589       AC_MSG_RESULT(${libtheora})
590       ac_cv_path_ffmpeg_lib="${ac_cv_path_ffmpeg_lib} ${libtheora}"      
591     fi
592     dnl End of THEORA library looking }
594     dnl Look for the GSM library, which is required on some systems. {
595     AC_MSG_CHECKING([for libgsm library])
596     if test x"$PKG_CONFIG" != x -a x${cross_compiling} = xno; then
597       $PKG_CONFIG --exists gsm && libgsm=`$PKG_CONFIG --libs-only-l gsm`
598     else
599       libgsm=""
600     fi
602     if test x"${libgsm}" = x; then
603       if test -f ${top_lib_dir}/libgsm.a -o -f ${top_lib_dir}/libgsm.${shlibext}; then
604         ac_cv_path_ffmpeg_lib="${ac_cv_path_ffmpeg_lib} -lgsm"
605         AC_MSG_RESULT(${top_lib_dir}/libgsm)
606       else
607         AC_MSG_RESULT(no)
608         if test x${cross_compiling} = xno; then
609           AC_CHECK_LIB(gsm, gsm_destroy, [ac_cv_path_ffmpeg_lib="${ac_cv_path_ffmpeg_lib} -lgsm"])
610         fi
611       fi
612     else
613       AC_MSG_RESULT(${libgsm})
614     fi
616     ac_cv_path_ffmpeg_lib="${ac_cv_path_ffmpeg_lib} ${libgsm}"
617     dnl End of GSM library looking }
618     
619     dnl Look for the DC1394 library, which is required on some systems. {
620     dnl
621     dnl TODO: skip this if -ldc1394 is already in due to pkg-config 
622     dnl
623     AC_MSG_CHECKING([for libdc1394 library])
624     if test x"$PKG_CONFIG" != x -a x${cross_compiling} = xno; then
625       $PKG_CONFIG --exists libdc  && libdc=`$PKG_CONFIG --libs-only-l libdc1394`
626     else
627       libtdc=""
628     fi
629     if test x"${libdc}" = x; then
630       if test -f ${top_lib_dir}/libdc1394.a -o -f ${top_lib_dir}/libdc1394.${shlibext}; then
631         ac_cv_path_ffmpeg_lib="${ac_cv_path_ffmpeg_lib} -ldc1394"
632         AC_MSG_RESULT(${top_lib_dir}/libdc1394)
633       else
634         AC_MSG_RESULT(no)
635         if test x${cross_compiling} = xno; then
636           AC_CHECK_LIB(dc1394_control, dc1394_is_camera, [ac_cv_path_ffmpeg_lib="${ac_cv_path_ffmpeg_lib} -ldc1394_control"])
637         fi
638       fi
639     else
640       AC_MSG_RESULT(${libdc})
641       ac_cv_path_ffmpeg_lib="${ac_cv_path_ffmpeg_lib} ${libdc}"
642     fi
643     dnl End of DC1394 library looking }
645     dnl Look for the SWSCALE library {
646     dnl
647     dnl This is required on some system if ffmpeg is
648     dnl configured with --enable-gpl --enable-swscale.
649     AC_MSG_CHECKING([for libswscale library])
650     if test x"$PKG_CONFIG" != x -a x${cross_compiling} = xno; then
651       $PKG_CONFIG --exists libswscale  && libsws=`$PKG_CONFIG --libs-only-l libswscale`
652     else
653       libsws=""
654     fi
655     if test x"${libsws}" = x; then
656       if test -f ${top_lib_dir}/libswscale.a -o -f ${top_lib_dir}/libswscale.${shlibext}; then
657         ac_cv_path_ffmpeg_lib="${ac_cv_path_ffmpeg_lib} -lswscale"
658         AC_MSG_RESULT(yes)
659       else
660         AC_MSG_RESULT(no)
661         if test x${cross_compiling} = xno; then
662           AC_CHECK_LIB(swscale, sws_scale, [ac_cv_path_ffmpeg_lib="${ac_cv_path_ffmpeg_lib} -lswscale"])
663         fi
664       fi
665     else
666       AC_MSG_RESULT(${libsws})
667       ac_cv_path_ffmpeg_lib="${ac_cv_path_ffmpeg_lib} ${libsws}"
668     fi
669     dnl End of SWSCALE library looking }
671     dnl Look for the {SW,AV}RESAMPLE libraries {
672     dnl
673     AC_MSG_CHECKING([for libswresample library])
674     if test x"$PKG_CONFIG" != x -a x${cross_compiling} = xno; then
675       $PKG_CONFIG --exists libswresample  && libswresample=`$PKG_CONFIG --libs-only-l libswresample`
676     else
677       libswresample=""
678     fi
679     if test x"${libswresample}" = x; then
680       if test -f ${top_lib_dir}/libswresample.a -o -f ${top_lib_dir}/libswresample.${shlibext}; then
681         ac_cv_path_ffmpeg_lib="${ac_cv_path_ffmpeg_lib} -lswresample"
682         AC_MSG_RESULT(yes)
683       else
684         AC_MSG_RESULT(no)
685         if test x${cross_compiling} = xno; then
686           AC_CHECK_LIB(swresample, swresample, [ac_cv_path_ffmpeg_lib="${ac_cv_path_ffmpeg_lib} -lswresample"])
687         fi
688       fi
689     else
690       AC_MSG_RESULT(${libswresample})
691       ac_cv_path_ffmpeg_lib="${ac_cv_path_ffmpeg_lib} ${libswresample}"
692     fi
694     AC_MSG_CHECKING([for libavresample library])
695     if test x"$PKG_CONFIG" != x -a x${cross_compiling} = xno; then
696       $PKG_CONFIG --exists libavresample  && libavresample=`$PKG_CONFIG --libs-only-l libavresample`
697     else
698       libavresample=""
699     fi
700     if test x"${libavresample}" = x; then
701       if test -f ${top_lib_dir}/libavresample.a -o -f ${top_lib_dir}/libavresample.${shlibext}; then
702         ac_cv_path_ffmpeg_lib="${ac_cv_path_ffmpeg_lib} -lavresample"
703         AC_MSG_RESULT(yes)
704       else
705         AC_MSG_RESULT(no)
706         if test x${cross_compiling} = xno; then
707           AC_CHECK_LIB(avresample, avresample, [ac_cv_path_ffmpeg_lib="${ac_cv_path_ffmpeg_lib} -lavresample"])
708         fi
709       fi
710     else
711       AC_MSG_RESULT(${libavresample})
712       ac_cv_path_ffmpeg_lib="${ac_cv_path_ffmpeg_lib} ${libavresample}"
713     fi
714     dnl End of {SW,AV}RESAMPLE libraries looking }
716   fi
717   dnl End of all optional library tests }
719   # Set final compilation flags, eliminating the pointless "-I/usr/include"
720   if test x"${ac_cv_path_ffmpeg_lib}" != x ; then
721     FFMPEG_LIBS="${ac_cv_path_ffmpeg_lib}"
722   else
723     FFMPEG_LIBS=""
724   fi
726   AC_SUBST(LIBAVCODEC_IDENT)
727   AC_SUBST(FFMPEG_CFLAGS)  
728   AC_SUBST(FFMPEG_LIBS)
730   LIBS="$backupLIBS"
731   CFLAGS="$backupCFLAGS"
734 # Local Variables:
735 # c-basic-offset: 2
736 # tab-width: 2
737 # indent-tabs-mode: nil
738 # End: