reduce verbosity
[gnash.git] / macros / ffmpeg.m4
blob917307c233ea440a19ce4b6fa758b3045d9047fc
1 dnl  
2 dnl    Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
3 dnl  
4 dnl  This program is free software; you can redistribute it and/or modify
5 dnl  it under the terms of the GNU General Public License as published by
6 dnl  the Free Software Foundation; either version 3 of the License, or
7 dnl  (at your option) any later version.
8 dnl  
9 dnl  This program is distributed in the hope that it will be useful,
10 dnl  but WITHOUT ANY WARRANTY; without even the implied warranty of
11 dnl  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 dnl  GNU General Public License for more details.
13 dnl  You should have received a copy of the GNU General Public License
14 dnl  along with this program; if not, write to the Free Software
15 dnl  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
17 AC_DEFUN([GNASH_PATH_FFMPEG],
20   dnl Backup LIBS and CFLAGS vars, we'll add user-specified dirs there
21   backupLIBS="$LIBS"
22   backupCFLAGS="$CFLAGS"
23   avcodec_h=""
24   ffmpeg_top_incl=""
26   dnl If the user specify an path to include headers from, we assume it's the full
27   dnl path to the header file, and not the top level path without the 'ffmpeg' node
28   dnl of the path. This is made more fun my the way ffmpeg changes directory layout
29   dnl reasonably often.
30   dnl
31   dnl ffmpeg_top_level - the top level directory without the ffmpeg specific part.
32   dnl           ie... /usr/local/include/ffmpeg becomes /usr/local/include, and
33   dnl           /usr/local/include/ffmpeg/libavcodec becomes /usr/local/include/ffmpeg.
34   dnl avcode_h - stores the path and file name for avcodec.h, which is used later on
35   dnl           in this macro to extract the version number of ffmpeg we're using.
36   AC_ARG_WITH(ffmpeg_incl, AC_HELP_STRING([--with-ffmpeg-incl], [directory where avcodec.h is]), with_ffmpeg_incl=${withval})
37   AC_CACHE_VAL(ac_cv_path_ffmpeg_incl,[
38     if test x"${with_ffmpeg_incl}" != x ; then
39       dnl top level path for include files minus the last directory from the user
40       dnl specified path.
41       ffmpeg_top_incl=`dirname ${with_ffmpeg_incl}`
42       if test -f ${with_ffmpeg_incl}/avcodec.h; then
43         ac_cv_path_ffmpeg_incl="-I`(cd ${ffmpeg_top_incl}; pwd)`"
44         avcodec_h=${with_ffmpeg_incl}/avcodec.h
45       else
46         AC_MSG_ERROR([${with_ffmpeg_incl} directory does not contain the avcodec.h header])
47       fi
48     fi
49   ])
51   dnl Try to find avcodec.h ourselves
52   if test x${ffmpeg_top_incl} = x; then
53     AC_MSG_CHECKING([location of avcodec.h])
54     dnl Try PKG_CONFIG if available
55     if test x"$PKG_CONFIG" != x; then dnl {
56       if $PKG_CONFIG --exists libavcodec; then dnl {
57         dnl Some systems return /usr/include/ffmpeg, others /usr/include.
58         dnl We use #include <ffmpeg/avcodec.h> everywhere so weed out funny
59         dnl values into the short form.
60         ffmpeg_pkg=`$PKG_CONFIG --cflags-only-I libavcodec`
61         ffmpeg_top_incl=`echo ${ffmpeg_pkg} | sed  -e 's:-I::'`
62         dnl Make sure a header file really exists in the given path.
63         dnl Ubuntu like the headers here in the top level ffmpeg directory.
64         for i in "" ffmpeg libavcodec ffmpeg/libavcodec; do
65           if test -f ${ffmpeg_top_incl}/${i}/avcodec.h; then
66             ac_cv_path_ffmpeg_incl="-I`(cd ${ffmpeg_top_incl}; pwd)`"
67             avcodec_h="${ffmpeg_top_incl}/${i}/avcodec.h"
68             break
69           fi
70         done
71       fi
72     fi
73   fi
75   dnl if pkg-config doesn't have the values we want, or they're plain wrong, look
76   dnl in several common places ourselves. Note that the variable ffmpeg_top_incl
77   dnl contains the value of the top level path that has been found.
78   if test x"${ac_cv_path_ffmpeg_incl}" = x ; then
79     newlist="/usr/include/ffmpeg $incllist"
80     for ffmpeg_top_incl in $newlist; do
81       for i in ffmpeg libavcodec ffmpeg/libavcodec; do
82         if test -f ${ffmpeg_top_incl}/${i}/avcodec.h; then
83           ac_cv_path_ffmpeg_incl="-I`(cd ${ffmpeg_top_incl}/${i}; pwd)`"
84           avcodec_h=${ffmpeg_top_incl}/${i}/avcodec.h
85           break
86         fi
87       done
88       if test x"${ac_cv_path_ffmpeg_incl}" != x ; then
89         break
90       fi
91     done
92   fi
94   dnl Because the avcodec.h header file might be found by any one of
95   dnl the above ways, we set the version macros after all those tests
96   dnl are done so we only have to do it once.
97   newer_ffmpeg=`echo ${avcodec_h} | grep -c libavcodec`
98   if test ${newer_ffmpeg} -eq 0; then
99     AC_DEFINE(HAVE_FFMPEG_AVCODEC_H, 1, [Define if you have avcodec.h installed.])
100   else
101     AC_DEFINE(HAVE_LIBAVCODEC_AVCODEC_H, 1, [Define if you have avcodec.h installed.])
102   fi
104   if test x"${ac_cv_path_ffmpeg_incl}" = x ; then
105     have_ffmpeg=no
106     AC_MSG_RESULT(none found)
107   else
108     have_ffmpeg=yes
109     AC_MSG_RESULT(${ac_cv_path_ffmpeg_incl})
110   fi
112   dnl Find and check libavcodec version number to make sure we have a usable
113   dnl version and to enable/disable features according to version.
114   dnl We need LIBAVCODEC VERSION of at least 51.29.0 to get avcodec_decode_audio2
115   dnl
116   dnl We try to get the avcodec version as a decimal number
117   dnl so that we can compare it numerically against what we require.
118   dnl
119   dnl This previous version makes ffmpeg fail and then grubs the version string
120   dnl out of the resulting usage message e.g. "  libavcodec version: 51.40.2"
121   dnl Early versions of ffmpeg do not output this string at all.
122   dnl
123   dnl   AC_PATH_PROG(FFMPEG, ffmpeg, ,[${pathlist}])
124   dnl   if test "x$FFMPEG" = "x" ; then
125   dnl     ffmpeg_version=`$FFMPEG uglyhack 2>&1 | grep "libavcodec version" | cut -d ' ' -f 5 | tr -d '.'`
126   dnl     if test "$ffmpeg_version" -lt 51290; then
127   dnl       AC_MSG_ERROR([])
128   dnl     fi
129   dnl   fi
130   dnl
131   dnl These days we check avcodec.h and pick the version out of the constants,
132   dnl simply throwing away all non-digits.
133   dnl
134   dnl In earlier versions we have:
135   dnl #define FFMPEG_VERSION_INT     0x000409
136   dnl #define FFMPEG_VERSION         "0.4.9-pre1"
137   dnl #define LIBAVCODEC_BUILD       4731
138   dnl #define LIBAVCODEC_VERSION_INT FFMPEG_VERSION_INT
139   dnl #define LIBAVCODEC_VERSION     FFMPEG_VERSION
140   dnl
141   dnl elsewhere, FFMPEG_VERSION may also be the quoted string "CVS"
142   dnl
143   dnl This changed from the above to
144   dnl #define LIBAVCODEC_VERSION_INT ((49<<16)+(0<<8)+0)
145   dnl #define LIBAVCODEC_VERSION     49.0.0
146   dnl #define LIBAVCODEC_BUILD       LIBAVCODEC_VERSION_INT
147   dnl (note, LIBAVCODEC_VERSION also changes from a quoted string to unquoted)
148   dnl see http://lists.mplayerhq.hu/pipermail/ffmpeg-cvslog/2005-July/000570.html
149   dnl
150   dnl
151   dnl This changed from the above to
152   dnl #define LIBAVCODEC_VERSION_MAJOR 51
153   dnl #define LIBAVCODEC_VERSION_MINOR 54
154   dnl #define LIBAVCODEC_VERSION_MICRO  0
155   dnl 
156   dnl #define LIBAVCODEC_VERSION_INT  AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
157   dnl                                                LIBAVCODEC_VERSION_MINOR, \
158   dnl                                                LIBAVCODEC_VERSION_MICRO)
159   dnl #define LIBAVCODEC_VERSION      AV_VERSION(LIBAVCODEC_VERSION_MAJOR,    \
160   dnl                                            LIBAVCODEC_VERSION_MINOR,    \
161   dnl                                            LIBAVCODEC_VERSION_MICRO)
162   
163   dnl Those deb-heads at Debian redefine LIBAVCODEC_VERSION in their versions to
164   dnl (e.g.) 1d.51.38.0 or dnl 0d.51.11.0 - we need to discard the prefixed
165   dnl rubbish.
166   dnl
167   dnl Other values or LIBAVCODEC_VERSION spotted in the wild:
168   dnl 50.0.0  50.5.0  51.7.0  51.8.0  0d.51.8.0  51.40.4
169   dnl presumably this will change to 52.0.0 at some point...
170   dnl
171   dnl We can ignore the very early versions because 51.10.0 is necessary to decode
172   dnl Flash video at all. However the current solution will incorrectly succeed
173   dnl on early debian/ubuntu 1d.* version numbers and incorrectly fail
174   dnl when 52.0.0 happens.
175   dnl
176   dnl The most reliable way is to compile a test program to print the value of
177   dnl LIBAVCODEC_BUILD, which got up to dnl 4718 at version 0.4.9-pre1,
178   dnl then changed to (major<<16 + minor<<8 + micro) from then on.
179   dnl There is code to do this in transcode's configure.in, but when
180   dnl cross-compiling we cannot run a test program, which suggests that
181   dnl a modified form of grepping may be better, making sure all old kinds of
182   dnl version numbering fail gracefully.
184   dnl Check avcodec version number, if it was found
185   if test x"${avcodec_h}" != x; then
187     AC_MSG_CHECKING([ffmpeg version])
189     ffmpeg_major_version=`$EGREP "define LIBAVCODEC_VERSION_MAJOR " ${avcodec_h} | sed -e "s%[[^0-9]]%%g"`
190     ffmpeg_minor_version=`$EGREP "define LIBAVCODEC_VERSION_MINOR " ${avcodec_h} | sed -e "s%[[^0-9]]%%g"`
191     ffmpeg_micro_version=`$EGREP "define LIBAVCODEC_VERSION_MICRO " ${avcodec_h} | sed -e "s%[[^0-9]]%%g"`
193     if test x"${ffmpeg_major_version}" != x ; then
195       ffmpeg_version="${ffmpeg_major_version}.${ffmpeg_minor_version}.${ffmpeg_micro_version}"
197     else
199       dnl #define LIBAVCODEC_VERSION_TRIPLET 51,50,1
200       ffmpeg_version=`$EGREP "define LIBAVCODEC_VERSION_TRIPLET " ${avcodec_h} | awk '{print $'3'}' | sed -e "s%,%.%g"`
202       if test x"${ffmpeg_version}" = x ; then
204         dnl NOTE: the [0-9]*d. pattern discards deb-heads rubbish prefix
205         ffmpeg_version=`$EGREP "define LIBAVCODEC_VERSION " ${avcodec_h} | awk '{print $'3'}' | sed -e "s%^[[0-9]]d\.%%"` 
207         if test x"${ffmpeg_version}" = x ; then
208           ffmpeg_version=`$EGREP "define LIBAVCODEC_BUILD " ${avcodec_h} | awk '{print $'3'}'`
209         fi
210       fi
212       if test x"${ffmpeg_version}" != x ; then
213         ffmpeg_major_version=`echo ${ffmpeg_version} | cut -d. -f1`
214         ffmpeg_minor_version=`echo ${ffmpeg_version} | cut -d. -f2`
215         ffmpeg_micro_version=`echo ${ffmpeg_version} | cut -d. -f3`
216       fi
218     fi
220     ffmpeg_num_version=`printf %02d%02d%02d $ffmpeg_major_version $ffmpeg_minor_version $ffmpeg_micro_version`
222     AC_MSG_RESULT($ffmpeg_version ($ffmpeg_num_version))
225 dnl   AC_EGREP_HEADER(avcodec_decode_audio2, ${avcodec_h}, [avfound=yes], [avfound=no])
226   
227     if test -z "$ffmpeg_num_version" -o "$ffmpeg_num_version" -lt 512800; then
228       AC_MSG_WARN([Wrong ffmpeg/libavcodec version! 51.28.0 or greater required, $ffmpeg_version detected.])
229     else
230       ffmpeg_version_check=ok
231     fi
233     if test -z "$ffmpeg_num_version" -o "$ffmpeg_num_version" -lt 514900; then
234       dnl 51.49.0 or higher required
235       AC_MSG_WARN([This version of ffmpeg/libavcodec ($ffmpeg_version) is not able to play VP6A encoded video: 51.49.0 or higher required!])
236     else
237       AC_DEFINE(FFMPEG_VP6A, 1, [Define if ffmpeg can play VP6A.])
238     fi
240     if test -z "$ffmpeg_num_version" -o "$ffmpeg_num_version" -lt 514600; then
241       dnl 51.46.0 (r10741) or higher required for CODEC_ID_NELLYMOSER
242       AC_MSG_WARN([This version of ffmpeg/libavcodec ($ffmpeg_version) is not able to decode NELLYMOSER encoded audio: 51.46.0 (r10741) or higher required!])
243     else
244       AC_DEFINE(FFMPEG_NELLYMOSER, 1, [Define if ffmpeg can decode NELLYMOSER audio])
245     fi
246   else
247     AC_MSG_WARN([Could not check ffmpeg version (can't find avcodec.h file)])
248     # ffmpeg_version_check=ok # this is NOT ok, why would it be ?! 
249   fi
251   LIBAVCODEC_IDENT=${ffmpeg_version}
252   FFMPEG_CFLAGS="-D__STDC_CONSTANT_MACROS ${ac_cv_path_ffmpeg_incl}"
254   AC_MSG_CHECKING([for avformat.h])
255   if test -f "${ffmpeg_top_incl}/avformat.h"; then
256     AC_DEFINE(HAVE_FFMPEG_AVFORMAT_H, 1, [Define if avformat.h is found])
257     avformat_h="${ffmpeg_top_incl}/avformat.h"
258   else
259     if test -f "${ffmpeg_top_incl}/libavformat/avformat.h"; then
260       AC_DEFINE(HAVE_LIBAVFORMAT_AVFORMAT_H, 1, [Define if avformat.h is found])
261       avformat_h="${ffmpeg_top_incl}/libavformat/avformat.h"
262     else
263       avformat_h=""
264     fi
265   fi
266   AC_MSG_RESULT($avformat_h)
268   AC_MSG_CHECKING([for swscale.h])
269   have_ffmpeg_swscale=no
270   if test -f "${ffmpeg_top_incl}/ffmpeg/swscale.h"; then
271     have_ffmpeg_swscale=yes
272     AC_DEFINE(HAVE_FFMPEG_SWSCALE_H, 1, [Define if swscale.h is found])
273   fi
274   if test -f "${ffmpeg_top_incl}/libswscale/swscale.h"; then
275     have_ffmpeg_swscale=yes
276     AC_DEFINE(HAVE_LIBSWSCALE_SWSCALE_H, 1, [Define if swscale.h is found])
277   fi
278   if test -f "${ffmpeg_top_incl}/swscale.h"; then
279     have_ffmpeg_swscale=yes
280     AC_DEFINE(HAVE_SWSCALE_H, 1, [Define if swscale.h is found])
281   fi
282   AC_MSG_RESULT($have_ffmpeg_swscale)
284   if test x"$have_ffmpeg_swscale" = "xno" -a 1$ffmpeg_num_version -ge 1"520000"; then
285      AC_MSG_WARN([Cannot find swscale.h, required for ffmpeg versions >= 52.0.0 (detected version: $ffmpeg_version)])
286      ffmpeg_version_check=
287   fi
289   AC_MSG_CHECKING([for libavcodec/vaapi.h])
290   have_ffmpeg_vaapi="no"
291   if test -f "${ffmpeg_top_incl}/ffmpeg/vaapi.h"; then
292     have_ffmpeg_vaapi="yes"
293     AC_DEFINE(HAVE_FFMPEG_VAAPI_H, 1, [Defined if ffmpeg/vaapi.h is found])
294   fi
295   if test -f "${ffmpeg_top_incl}/libavcodec/vaapi.h"; then
296     have_ffmpeg_vaapi="yes"
297     AC_DEFINE(HAVE_LIBAVCODEC_VAAPI_H, 1, [Defined if libavcodec/vaapi.h is found])
298   fi
299   AC_MSG_RESULT($have_ffmpeg_vaapi)
301   dnl ---------------------------------
302   dnl
303   dnl FFMPEG libs checking
304   dnl
305   dnl ---------------------------------
307   top_lib_dir=""
309   dnl Did they tell us where the libs are ?
310   AC_ARG_WITH(ffmpeg_lib, AC_HELP_STRING([--with-ffmpeg-lib], [directory where ffmpeg libraries are]), with_ffmpeg_lib=${withval})
311   AC_CACHE_VAL(ac_cv_path_ffmpeg_lib, [
312     if test x"${with_ffmpeg_lib}" != x ; then
313       if test -f ${with_ffmpeg_lib}/libavcodec.a -o -f ${with_ffmpeg_lib}/libavcodec.${shlibext}; then
314               ac_cv_path_ffmpeg_lib="-L`(cd ${with_ffmpeg_lib}; pwd)`"
315           libavcodec="-lavcodec"
316           LIBS="${ac_cv_path_ffmpeg_lib} $LIBS" dnl <-- What is this needed for ?
317           top_lib_dir=${with_ffmpeg_lib}
318       else
319               AC_MSG_ERROR([${with_ffmpeg_lib} directory doesn't contain libavcodec libraries.])
320       fi
321       if test -f ${with_ffmpeg_lib}/libavformat.a -o -f ${with_ffmpeg_lib}/libavformat.${shlibext}; then
322               ac_cv_path_ffmpeg_lib="-L`(cd ${with_ffmpeg_lib}; pwd)`"
323           libavformat="-lavformat"
324           top_lib_dir=${with_ffmpeg_lib}
325       else
326               AC_MSG_ERROR([${with_ffmpeg_lib} directory doesn't contain libavformat libraries.])
327       fi
328     fi
329   ])
331   dnl Look for the AVCODEC library
333   dnl Try with pkg-config (if not cross-compiling)
334   if test x"${cross_compiling}" = xno; then
335     if test x"$PKG_CONFIG" != x -a x"${libavcodec}" = x; then
336       $PKG_CONFIG --exists libavcodec && libavcodec=`$PKG_CONFIG --libs libavcodec`
337       dnl
338       dnl WARNING: we won't be able to set top_lib_dir here, as pkg-config doesn't
339       dnl          return any -L when not neeed.
340       dnl          We won't need top_lib_dir either, as the only use for it
341       dnl          is to look for other required libraries, while pkg-config 
342       dnl          probably include them all, so not a big deal.
343       dnl
344     fi
345   fi
347   if test x"${libavcodec}" != x; then
348     ac_cv_path_ffmpeg_lib="${ac_cv_path_ffmpeg_lib} ${libavcodec}"
349   else
350     AC_MSG_CHECKING([for libavcodec library])
351     for i in $libslist; do
352       if test -f $i/libavcodec.a -o -f $i/libavcodec.${shlibext}; then
353         if test x${top_lib_dir} = x; then top_lib_dir=$i; fi
354         AC_MSG_RESULT(${top_lib_dir}/libavcodec)
355             if test ! x"$i" = x"/usr/lib" -a ! x"$i" = x"/usr/lib64"; then
356           ac_cv_path_ffmpeg_lib="-L$i -lavcodec"
357           break
358         else
359           ac_cv_path_ffmpeg_lib="-lavcodec"
360               break
361         fi
362       fi
363     done
365     if test x"${libavcodec}" = x; then
366       AC_MSG_RESULT(no)
367       if test x${cross_compiling} = xno; then
368         dnl avcodec_decode_audio2 starts 51.29.0
369         AC_CHECK_LIB(avcodec, ff_eval, [ac_cv_path_ffmpeg_lib="${ac_cv_path_ffmpeg_lib} -lavcodec"])
370       fi
371     fi
372   fi
374   if test x$top_lib_dir != x; then
375     AC_MSG_NOTICE([ffmpeg top lib dir is $top_lib_dir])
376   fi
378   dnl Start of all optional library tests {
379   dnl
380   dnl TODO: skip these tests if we got ac_cv_path_ffmpeg_lib
381   dnl       from pkg-config, as it would likely bring all
382   dnl       required libs in. 
383   dnl
384   if test x"${ac_cv_path_ffmpeg_lib}" != x; then
386     dnl Look for the DTS library, which is required on some systems. {
387     dnl
388     dnl TODO: skip this if -ldts is already in due to pkg-config 
389     dnl
390     AC_MSG_CHECKING([for libdts library])
391     if test x"$PKG_CONFIG" != x -a x${cross_compiling} = xno; then
392       $PKG_CONFIG --exists libdts && libdts=`$PKG_CONFIG --libs-only-l libdts`
393     else
394       libdts=""
395     fi
396     if test x"${libdts}" = x; then
397       if test -f ${top_lib_dir}/libdts.a -o -f ${top_lib_dir}/libdts.${shlibext}; then
398         ac_cv_path_ffmpeg_lib="${ac_cv_path_ffmpeg_lib} -ldts"
399         AC_MSG_RESULT(${top_lib_dir}/libdts)
400       else
401         AC_MSG_RESULT(no)
402         if test x${cross_compiling} = xno; then
403           AC_CHECK_LIB(dts, dts_init, [ac_cv_path_ffmpeg_lib="${ac_cv_path_ffmpeg_lib} -ldts"])
404         fi
405       fi
406     else
407       AC_MSG_RESULT(${libdts})
408       ac_cv_path_ffmpeg_lib="${ac_cv_path_ffmpeg_lib} ${libdts}"      
409     fi
410     dnl End of DTS library looking }
411         
412     dnl Look for the VORBISENC library, which is required on some systems. {
413     AC_MSG_CHECKING([for libvorbisenc library])
414     if test x"$PKG_CONFIG" != x -a x${cross_compiling} = xno; then
415       $PKG_CONFIG --exists vorbisenc && libvorbisenc=`$PKG_CONFIG --libs-only-l vorbisenc`
416     else
417       libvorbisenc=""
418     fi
419     if test x"${libvorbisenc}" = x; then
420       if test -f ${top_lib_dir}/libvorbisenc.a -o -f ${top_lib_dir}/libvorbisenc.${shlibext}; then
421         ac_cv_path_ffmpeg_lib="${ac_cv_path_ffmpeg_lib} -lvorbisenc"
422         AC_MSG_RESULT(${top_lib_dir}/libvorbisenc)
423       else
424         AC_MSG_RESULT(no)
425         if test x${cross_compiling} = xno; then
426           AC_CHECK_LIB(vorbisenc, vorbis_encode_init, [ac_cv_path_ffmpeg_lib="${ac_cv_path_ffmpeg_lib} -lvorbisenc"])
427         fi
428       fi
429     else
430       AC_MSG_RESULT(${libvorbisenc})
431       ac_cv_path_ffmpeg_lib="${ac_cv_path_ffmpeg_lib} ${libvorbisenc}"
432     fi
433     dnl End of VORBINSEC library looking }
434         
436     dnl Look for the AVFORMAT library {
437     dnl
438     dnl TODO: libavformat be mandatory, thus linked in already ?
439     dnl
441     AC_MSG_CHECKING([for libavformat library])
443     dnl Try with pkg-config (if not cross-compiling)
444     if test x"${cross_compiling}" = xno; then
445       if test x"$PKG_CONFIG" != x -a x${libavformat} = x; then
446         $PKG_CONFIG --exists libavformat && libavformat=`$PKG_CONFIG --libs-only-l libavformat`
447       fi
448     fi
450     if test x"${libavformat}" = x; then
451       if test -f ${top_lib_dir}/libavformat.a -o -f ${top_lib_dir}/libavformat.${shlibext}; then
452         ac_cv_path_ffmpeg_lib="-lavformat ${ac_cv_path_ffmpeg_lib}" 
453         AC_MSG_RESULT(${top_lib_dir}/libavformat)
454       else
455         AC_MSG_RESULT(no)
456         if test x${cross_compiling} = xno; then
457           AC_CHECK_LIB(libavformat, av_open_input_file, [ac_cv_path_ffmpeg_lib="${ac_cv_path_ffmpeg_lib} -lavformat"])
458         fi
459       fi
460     else
461       AC_MSG_RESULT(${libavformat})
462       ac_cv_path_ffmpeg_lib="${ac_cv_path_ffmpeg_lib} ${libavformat}"      
463     fi
465     dnl End of AVFORMAT library looking }
467     dnl Look for the AVUTIL library, which is required on some systems. {
468     dnl
469     dnl TODO: skip this if -lavutil is already in due to pkg-config 
470     dnl
471     AC_MSG_CHECKING([for libavutil library])
472     if test x"$PKG_CONFIG" != x -a x${cross_compiling} = xno; then
473       $PKG_CONFIG --exists libavutil && libavutil=`$PKG_CONFIG --libs-only-l libavutil`
474     else
475       libavutil=""
476     fi
477     if test x"${libavutil}" = x; then
478       if test -f ${top_lib_dir}/libavutil.a -o -f ${top_lib_dir}/libavutil.${shlibext}; then
479         ac_cv_path_ffmpeg_lib="${ac_cv_path_ffmpeg_lib} -lavutil"
480         AC_MSG_RESULT(${top_lib_dir}/libavutil)
481       else
482         AC_MSG_RESULT(no)
483         if test x${cross_compiling} = xno; then
484            AC_CHECK_LIB(avutil, av_log, [ac_cv_path_ffmpeg_lib="${ac_cv_path_ffmpeg_lib} -lavutil"])
485         fi
486       fi
487     else
488       AC_MSG_RESULT(${libavutil})
489       ac_cv_path_ffmpeg_lib="${ac_cv_path_ffmpeg_lib} ${libavutil}"
490     fi
491     dnl End of AVUTIL library looking }
492         
493     dnl Look for the THEORA library, which is required on some systems. {
494     dnl
495     dnl TODO: skip this if -ltheora is already in due to pkg-config 
496     dnl
497     AC_MSG_CHECKING([for libtheora library])
498     if test x"$PKG_CONFIG" != x -a x${cross_compiling} = xno; then
499       $PKG_CONFIG --exists theora && libtheora=`$PKG_CONFIG --libs-only-l theora`
500     else
501       libtheora=""
502     fi
503     if test x"${libtheora}" = x; then
504       if test -f ${top_lib_dir}/libtheora.a -o -f ${top_lib_dir}/libtheora.${shlibext}; then
505         ac_cv_path_ffmpeg_lib="${ac_cv_path_ffmpeg_lib} -ltheora"
506         AC_MSG_RESULT(${top_lib_dir}/libtheora)
507       else
508         AC_MSG_RESULT(no)
509         if test x${cross_compiling} = xno; then
510           AC_CHECK_LIB(theora, theora_encode_init, [ac_cv_path_ffmpeg_lib="${ac_cv_path_ffmpeg_lib} -ltheora"])
511         fi
512       fi
513     else
514       AC_MSG_RESULT(${libtheora})
515       ac_cv_path_ffmpeg_lib="${ac_cv_path_ffmpeg_lib} ${libtheora}"      
516     fi
517     dnl End of THEORA library looking }
519     dnl Look for the GSM library, which is required on some systems. {
520     AC_MSG_CHECKING([for libgsm library])
521     if test x"$PKG_CONFIG" != x -a x${cross_compiling} = xno; then
522       $PKG_CONFIG --exists gsm && libgsm=`$PKG_CONFIG --libs-only-l gsm`
523     else
524       libgsm=""
525     fi
527     dnl OpenBSD seems to have a problem with libgsm.
528     if test x$openbsd_os != xopenbsd; then
529       if test x"${libgsm}" = x; then
530         if test -f ${top_lib_dir}/libgsm.a -o -f ${top_lib_dir}/libgsm.${shlibext}; then
531           ac_cv_path_ffmpeg_lib="${ac_cv_path_ffmpeg_lib} -lgsm"
532           AC_MSG_RESULT(${top_lib_dir}/libgsm)
533         else
534           AC_MSG_RESULT(no)
535           if test x${cross_compiling} = xno; then
536             AC_CHECK_LIB(gsm, gsm_destroy, [ac_cv_path_ffmpeg_lib="${ac_cv_path_ffmpeg_lib} -lgsm"])
537           fi
538         fi
539       fi
540     else
541       AC_MSG_RESULT(${libgsm})
542       ac_cv_path_ffmpeg_lib="${ac_cv_path_ffmpeg_lib} ${libgsm}"      
543     fi
544     dnl End of GSM library looking }
545     
546     dnl Look for the DC1394 library, which is required on some systems. {
547     dnl
548     dnl TODO: skip this if -ldc1394 is already in due to pkg-config 
549     dnl
550     AC_MSG_CHECKING([for libdc1394 library])
551     if test x"$PKG_CONFIG" != x -a x${cross_compiling} = xno; then
552       $PKG_CONFIG --exists libdc  && libdc=`$PKG_CONFIG --libs-only-l libdc1394`
553     else
554       libtdc=""
555     fi
556     if test x"${libdc}" = x; then
557       if test -f ${top_lib_dir}/libdc1394.a -o -f ${top_lib_dir}/libdc1394.${shlibext}; then
558         ac_cv_path_ffmpeg_lib="${ac_cv_path_ffmpeg_lib} -ldc1394"
559         AC_MSG_RESULT(${top_lib_dir}/libdc1394)
560       else
561         AC_MSG_RESULT(no)
562         if test x${cross_compiling} = xno; then
563           AC_CHECK_LIB(dc1394_control, dc1394_is_camera, [ac_cv_path_ffmpeg_lib="${ac_cv_path_ffmpeg_lib} -ldc1394_control"])
564         fi
565       fi
566     else
567       AC_MSG_RESULT(${libdc})
568       ac_cv_path_ffmpeg_lib="${ac_cv_path_ffmpeg_lib} ${libdc}"
569     fi
570     dnl End of DC1394 library looking }
572     dnl Look for the SWSCALE library {
573     dnl
574     dnl This is required on some system if ffmpeg is
575     dnl configured with --enable-gpl --enable-swscale.
576     AC_MSG_CHECKING([for libswscale library])
577     if test x"$PKG_CONFIG" != x -a x${cross_compiling} = xno; then
578       $PKG_CONFIG --exists libswscale  && libsws=`$PKG_CONFIG --libs-only-l libswscale`
579     else
580       libsws=""
581     fi
582     if test x"${libsws}" = x; then
583       if test -f ${top_lib_dir}/libswscale.a -o -f ${top_lib_dir}/libswscale.${shlibext}; then
584         ac_cv_path_ffmpeg_lib="${ac_cv_path_ffmpeg_lib} -lswscale"
585         AC_MSG_RESULT(yes)
586       else
587         AC_MSG_RESULT(no)
588         if test x${cross_compiling} = xno; then
589           AC_CHECK_LIB(swscale, sws_scale, [ac_cv_path_ffmpeg_lib="${ac_cv_path_ffmpeg_lib} -lswscale"])
590         fi
591       fi
592     else
593       AC_MSG_RESULT(${libsws})
594       ac_cv_path_ffmpeg_lib="${ac_cv_path_ffmpeg_lib} ${libsws}"
595     fi
596     dnl End of SWSCALE library looking }
598   fi
599   dnl End of all optional library tests }
601   # Set final compilation flags, eliminating the pointless "-I/usr/include"
602   if test x"${ac_cv_path_ffmpeg_lib}" != x ; then
603     FFMPEG_LIBS="${ac_cv_path_ffmpeg_lib}"
604   else
605     FFMPEG_LIBS=""
606   fi
608   AC_SUBST(LIBAVCODEC_IDENT)
609   AC_SUBST(FFMPEG_CFLAGS)  
610   AC_SUBST(FFMPEG_LIBS)
612   LIBS="$backupLIBS"
613   CFLAGS="$backupCFLAGS"
616 # Local Variables:
617 # c-basic-offset: 2
618 # tab-width: 2
619 # indent-tabs-mode: nil
620 # End: