]> git.sesse.net Git - ffmpeg/blob - configure
64f351c3415ee1c01857837f670956c3f7a03d40
[ffmpeg] / configure
1 #!/bin/sh
2 #
3 # FFmpeg configure script
4 #
5 # Copyright (c) 2000, 2001, 2002 Fabrice Bellard
6 # Copyright (c) 2005-2006 Diego Biurrun
7 # Copyright (c) 2005-2006 Mans Rullgard
8 #
9
10 # make sure we are running under a compatible shell
11 # try to make this part work with most shells
12
13 try_exec(){
14     echo "Trying shell $1"
15     type "$1" >/dev/null 2>&1 && exec "$@"
16 }
17
18 unset foo
19 (: ${foo%%bar}) 2>/dev/null
20 E1="$?"
21
22 (: ${foo?}) 2>/dev/null
23 E2="$?"
24
25 if test "$E1" != 0 || test "$E2" = 0; then
26     echo "Broken shell detected.  Trying alternatives."
27     export FF_CONF_EXEC
28     if test "0$FF_CONF_EXEC" -lt 1; then
29         FF_CONF_EXEC=1
30         try_exec bash "$0" "$@"
31     fi
32     if test "0$FF_CONF_EXEC" -lt 2; then
33         FF_CONF_EXEC=2
34         try_exec ksh "$0" "$@"
35     fi
36     if test "0$FF_CONF_EXEC" -lt 3; then
37         FF_CONF_EXEC=3
38         try_exec /usr/xpg4/bin/sh "$0" "$@"
39     fi
40     echo "No compatible shell script interpreter found."
41     echo "This configure script requires a POSIX-compatible shell"
42     echo "such as bash or ksh."
43     echo "THIS IS NOT A BUG IN FFMPEG, DO NOT REPORT IT AS SUCH."
44     echo "Instead, install a working POSIX-compatible shell."
45     echo "Disabling this configure test will create a broken FFmpeg."
46     if test "$BASH_VERSION" = '2.04.0(1)-release'; then
47         echo "This bash version ($BASH_VERSION) is broken on your platform."
48         echo "Upgrade to a later version if available."
49     fi
50     exit 1
51 fi
52
53 show_help(){
54   echo "Usage: configure [options]"
55   echo "Options: [defaults in brackets after descriptions]"
56   echo
57   echo "Standard options:"
58   echo "  --help                   print this message"
59   echo "  --logfile=FILE           log tests and output to FILE [config.err]"
60   echo "  --disable-logging        do not log configure debug information"
61   echo "  --prefix=PREFIX          install in PREFIX [$prefix]"
62   echo "  --libdir=DIR             install libs in DIR [PREFIX/lib]"
63   echo "  --shlibdir=DIR           install shared libs in DIR [PREFIX/lib]"
64   echo "  --incdir=DIR             install includes in DIR [PREFIX/include]"
65   echo "  --mandir=DIR             install man page in DIR [PREFIX/share/man]"
66   echo "  --enable-static          build static libraries [default=yes]"
67   echo "  --disable-static         do not build static libraries [default=no]"
68   echo "  --enable-shared          build shared libraries [default=no]"
69   echo "  --disable-shared         do not build shared libraries [default=yes]"
70   echo "  --enable-gpl             allow use of GPL code, the resulting libav*"
71   echo "                           and ffmpeg will be under GPL [default=no]"
72   echo "  --enable-nonfree         allow use of nonfree code, the resulting libav*"
73   echo "                           and ffmpeg will be unredistributable [default=no]"
74   echo "  --enable-postproc        enable GPLed postprocessing support [default=no]"
75   echo "  --enable-swscale         software scaler support [default=no]"
76   echo "  --enable-avfilter        video filter support (replaces vhook) [default=no]"
77   echo "  --enable-avfilter-lavf   video filters dependant on avformat [default=no]"
78   echo "  --enable-beosthreads     use BeOS threads [default=no]"
79   echo "  --enable-os2threads      use OS/2 threads [default=no]"
80   echo "  --enable-pthreads        use pthreads [default=no]"
81   echo "  --enable-w32threads      use Win32 threads [default=no]"
82   echo "  --enable-x11grab         enable X11 grabbing [default=no]"
83   echo
84   echo "External library support:"
85   echo "  --enable-mlib            use Sun medialib [default=no]"
86   echo "  --enable-liba52          enable GPLed liba52 support [default=no]"
87   echo "  --enable-liba52bin       open liba52.so.0 at runtime [default=no]"
88   echo "  --enable-avisynth        allow reading AVISynth script files [default=no]"
89   echo "  --enable-libamr-nb       enable libamr-nb floating point audio codec"
90   echo "  --enable-libamr-wb       enable libamr-wb floating point audio codec"
91   echo "  --enable-libdc1394       enable IIDC-1394 grabbing using libdc1394"
92   echo "                           and libraw1394 [default=no]"
93   echo "  --enable-libdirac        enable Dirac support via libdirac [default=no]"
94   echo "  --enable-libfaac         enable FAAC support via libfaac [default=no]"
95   echo "  --enable-libfaad         enable FAAD support via libfaad [default=no]"
96   echo "  --enable-libfaadbin      open libfaad.so.0 at runtime [default=no]"
97   echo "  --enable-libgsm          enable GSM support via libgsm [default=no]"
98   echo "  --enable-libmp3lame      enable MP3 encoding via libmp3lame [default=no]"
99   echo "  --enable-libnut          enable NUT (de)muxing via libnut,"
100   echo "                           native demuxer exists [default=no]"
101   echo "  --enable-libtheora       enable Theora encoding via libtheora [default=no]"
102   echo "  --enable-libvorbis       enable Vorbis encoding via libvorbis,"
103   echo "                           native implementation exists [default=no]"
104   echo "  --enable-libx264         enable H.264 encoding via x264 [default=no]"
105   echo "  --enable-libxvid         enable Xvid encoding via xvidcore,"
106   echo "                           native MPEG-4/Xvid encoder exists [default=no]"
107   echo ""
108   echo "Advanced options (experts only):"
109   echo "  --source-path=PATH       path to source code [$source_path]"
110   echo "  --cross-prefix=PREFIX    use PREFIX for compilation tools [$cross_prefix]"
111   echo "  --enable-cross-compile   assume a cross-compiler is used"
112   echo "  --target-os=OS           compiler targets OS [$target_os]"
113   echo "  --cc=CC                  use C compiler CC [$cc]"
114   echo "  --extra-cflags=ECFLAGS   add ECFLAGS to CFLAGS [$CFLAGS]"
115   echo "  --extra-ldflags=ELDFLAGS add ELDFLAGS to LDFLAGS [$LDFLAGS]"
116   echo "  --extra-libs=ELIBS       add ELIBS [$ELIBS]"
117   echo "  --build-suffix=SUFFIX    suffix for application specific build []"
118   echo "  --arch=ARCH              select architecture  [$arch]"
119   echo "  --cpu=CPU                selects the minimum cpu required (affects"
120   echo "                           instruction selection, may crash on older CPUs)"
121   echo "  --enable-powerpc-perf    enable performance report on PPC"
122   echo "                           (requires enabling PMC)"
123   echo "  --disable-mmx            disable MMX usage"
124   echo "  --disable-mmx2           disable MMX2 usage"
125   echo "  --disable-ssse3          disable SSSE3 usage"
126   echo "  --disable-armv5te        disable armv5te usage"
127   echo "  --disable-armv6          disable armv6 usage"
128   echo "  --disable-armvfp         disable ARM VFP usage"
129   echo "  --disable-iwmmxt         disable iwmmxt usage"
130   echo "  --disable-altivec        disable AltiVec usage"
131   echo "  --disable-network        disable network support [default=no]"
132   echo "  --disable-ipv6           disable ipv6 support [default=no]"
133   echo "  --disable-zlib           disable zlib [default=no]"
134   echo "  --disable-vhook          disable video hooking support"
135   echo "  --disable-debug          disable debugging symbols"
136   echo "  --disable-mpegaudio-hp   faster (but less accurate)"
137   echo "                           MPEG audio decoding [default=no]"
138   echo "  --enable-gray            enable full grayscale support (slower color)"
139   echo "  --disable-ffmpeg         disable ffmpeg build"
140   echo "  --disable-ffserver       disable ffserver build"
141   echo "  --disable-ffplay         disable ffplay build"
142   echo "  --enable-small           optimize for size instead of speed"
143   echo "  --enable-hardcoded-tables use hardcoded tables instead of runtime generation"
144   echo "  --enable-memalign-hack   emulate memalign, interferes with memory debuggers"
145   echo "  --disable-encoder=NAME   disables encoder NAME"
146   echo "  --enable-encoder=NAME    enables encoder NAME"
147   echo "  --disable-decoder=NAME   disables decoder NAME"
148   echo "  --enable-decoder=NAME    enables decoder NAME"
149   echo "  --disable-encoders       disables all encoders"
150   echo "  --disable-decoders       disables all decoders"
151   echo "  --disable-muxer=NAME     disables muxer NAME"
152   echo "  --enable-muxer=NAME      enables muxer NAME"
153   echo "  --disable-muxers         disables all muxers"
154   echo "  --disable-demuxer=NAME   disables demuxer NAME"
155   echo "  --enable-demuxer=NAME    enables demuxer NAME"
156   echo "  --disable-demuxers       disables all demuxers"
157   echo "  --enable-parser=NAME     enables parser NAME"
158   echo "  --disable-parser=NAME    disables parser NAME"
159   echo "  --disable-parsers        disables all parsers"
160   echo "  --enable-bsf=NAME        enables bitstream filter NAME"
161   echo "  --disable-bsf=NAME       disables bitstream filter NAME"
162   echo "  --disable-bsfs           disables all bitstream filters"
163   echo "  --enable-protocol=NAME   enables protocol NAME"
164   echo "  --disable-protocol=NAME  disables protocol NAME"
165   echo "  --disable-protocols      disables all protocols"
166   echo "  --disable-devices        disables all devices"
167   echo "  --list-decoders          show all available decoders"
168   echo "  --list-encoders          show all available encoders"
169   echo "  --list-muxers            show all available muxers"
170   echo "  --list-demuxers          show all available demuxers"
171   echo "  --list-parsers           show all available parsers"
172   echo "  --list-protocols         show all available protocols"
173   echo "  --list-bsfs              show all available bitstream filters"
174   echo "  --list-indevs            show all available input devices"
175   echo "  --list-outdevs           show all available output devices"
176   echo
177   echo "Developer options (useful when working on FFmpeg itself):"
178   echo "  --enable-gprof           enable profiling with gprof [$gprof]"
179   echo "  --disable-optimizations  disable compiler optimizations"
180   echo "  --enable-extra-warnings  enable more compiler warnings"
181   echo "  --disable-stripping      disable stripping of executables and shared libraries"
182   echo ""
183   echo "NOTE: Object files are built at the place where configure is launched."
184   exit 1
185 }
186
187 log(){
188     echo "$@" >>$logfile
189 }
190
191 log_file(){
192     log BEGIN $1
193     pr -n -t $1 >>$logfile
194     log END $1
195 }
196
197 echolog(){
198     log "$@"
199     echo "$@"
200 }
201
202 die(){
203     echolog "$@"
204     cat <<EOF
205 If you think configure made a mistake, make sure you are using the latest
206 version from SVN.  If the latest version fails, report the problem to the
207 ffmpeg-user@mplayerhq.hu mailing list or IRC #ffmpeg on irc.freenode.net.
208 EOF
209     if disabled logging; then
210         cat <<EOF
211 Rerun configure with logging enabled (do not use --disable-logging), and
212 include the log this produces with your report.
213 EOF
214     else
215 cat <<EOF
216 Include the log file "$logfile" produced by configure as this will help
217 solving the problem.
218 EOF
219     fi
220     rm -f $TMPC $TMPE $TMPH $TMPO $TMPS $TMPSH
221     exit 1
222 }
223
224 # Avoid locale weirdness, besides we really just want to translate ASCII.
225 toupper(){
226     echo "$@" | tr abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ
227 }
228
229 tolower(){
230     echo "$@" | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz
231 }
232
233 set_all(){
234     value=$1
235     shift
236     for var in $*; do
237         eval $var=$value
238     done
239 }
240
241 pushvar(){
242     for var in $*; do
243         eval level=\${${var}_level:=0}
244         eval ${var}_${level}="\$$var"
245         eval ${var}_level=$(($level+1))
246     done
247 }
248
249 popvar(){
250     for var in $*; do
251         eval level=\${${var}_level:-0}
252         test $level = 0 && continue
253         eval level=$(($level-1))
254         eval $var="\${${var}_${level}}"
255         eval ${var}_level=$level
256         eval unset ${var}_${level}
257     done
258 }
259
260 enable(){
261     set_all yes $*
262 }
263
264 disable(){
265     set_all no $*
266 }
267
268 enabled(){
269     eval test "x\$$1" = "xyes"
270 }
271
272 disabled(){
273     eval test "x\$$1" = "xno"
274 }
275
276 enabled_all(){
277     for opt; do
278         enabled $opt || return 1
279     done
280 }
281
282 disabled_all(){
283     for opt; do
284         disabled $opt || return 1
285     done
286 }
287
288 enabled_any(){
289     for opt; do
290         enabled $opt && return 0
291     done
292 }
293
294 disabled_any(){
295     for opt; do
296         disabled $opt && return 0
297     done
298 }
299
300 is_in(){
301     value=$1
302     shift
303     for var in $*; do
304         [ $var = $value ] && return 0
305     done
306     return 1
307 }
308
309 check_deps(){
310     for cfg; do
311         enabled ${cfg}_checking && die "Circular dependency for $cfg."
312         disabled ${cfg}_checking && continue
313         enable ${cfg}_checking
314
315         eval dep_all="\$${cfg}_deps"
316         eval dep_any="\$${cfg}_deps_any"
317
318         pushvar cfg dep_all dep_any
319         check_deps $dep_all $dep_any
320         popvar cfg dep_all dep_any
321
322         enabled_all $dep_all || disable $cfg
323         enabled_any $dep_any || disable $cfg
324
325         if enabled $cfg; then
326             eval dep_extralibs="\$${cfg}_extralibs"
327             test -n "$dep_extralibs" && add_extralibs $dep_extralibs
328         fi
329
330         disable ${cfg}_checking
331     done
332 }
333
334 print_config(){
335     pfx=$1
336     header=$2
337     makefile=$3
338     shift 3
339     for cfg; do
340         ucname="`toupper $cfg`"
341         if enabled $cfg; then
342             echo "#define ${pfx}${ucname} 1" >> $header
343             echo "#define ENABLE_${ucname} 1" >> $header
344             echo "${pfx}${ucname}=yes" >> $makefile
345         else
346             echo "#define ENABLE_${ucname} 0" >> $header
347         fi
348     done
349 }
350
351 flags_saved(){
352     (: ${SAVE_CFLAGS?}) 2>/dev/null
353 }
354
355 save_flags(){
356     flags_saved && return
357     SAVE_CFLAGS="$CFLAGS"
358     SAVE_LDFLAGS="$LDFLAGS"
359     SAVE_extralibs="$extralibs"
360 }
361
362 restore_flags(){
363     flags_saved || return
364     CFLAGS="$SAVE_CFLAGS"
365     LDFLAGS="$SAVE_LDFLAGS"
366     extralibs="$SAVE_extralibs"
367     unset SAVE_CFLAGS
368     unset SAVE_LDFLAGS
369     unset SAVE_extralibs
370 }
371
372 temp_cflags(){
373     save_flags
374     CFLAGS="$CFLAGS $*"
375 }
376
377 temp_ldflags(){
378     save_flags
379     LDFLAGS="$LDFLAGS $*"
380 }
381
382 temp_extralibs(){
383     save_flags
384     extralibs="$extralibs $*"
385 }
386
387 append(){
388     var=$1
389     shift
390     flags_saved && eval "SAVE_$var=\"\$SAVE_$var $*\""
391     eval "$var=\"\$$var $*\""
392 }
393
394 add_cflags(){
395     append CFLAGS "$@"
396 }
397
398 add_ldflags(){
399     append LDFLAGS "$@"
400 }
401
402 add_extralibs(){
403     append extralibs "$@"
404 }
405
406 check_cmd(){
407     log "$@"
408     "$@" >>$logfile 2>&1
409 }
410
411 check_cc(){
412     log check_cc "$@"
413     cat >$TMPC
414     log_file $TMPC
415     check_cmd $cc $CFLAGS "$@" -c -o $TMPO $TMPC
416 }
417
418 check_cpp(){
419     log check_cpp "$@"
420     cat >$TMPC
421     log_file $TMPC
422     check_cmd $cc $CFLAGS "$@" -E -o $TMPO $TMPC
423 }
424
425 check_asm(){
426     log check_asm "$@"
427     name="$1"
428     asm="$2"
429     shift 2
430     check_cc "$@" <<EOF && enable $name || disable $name
431 int foo(void){ asm volatile($asm); }
432 EOF
433 }
434
435 check_ld(){
436     log check_ld "$@"
437     check_cc || return
438     flags=''
439     libs=''
440     for f; do
441         test "${f}" = "${f#-l}" && flags="$flags $f" || libs="$libs $f"
442     done
443     check_cmd $cc $LDFLAGS $flags -o $TMPE $TMPO $extralibs $libs
444 }
445
446 check_cflags(){
447     log check_cflags "$@"
448     check_cc "$@" <<EOF && add_cflags "$@"
449 int x;
450 EOF
451 }
452
453 check_ldflags(){
454     log check_ldflags "$@"
455     check_ld "$@" <<EOF && add_ldflags "$@"
456 int main(void){ return 0; }
457 EOF
458 }
459
460 check_header(){
461     log check_header "$@"
462     header=$1
463     shift
464     var=`echo $header | sed 's/[^A-Za-z0-9_]/_/g'`
465     disable $var
466     check_cpp "$@" <<EOF && enable $var
467 #include <$header>
468 int x;
469 EOF
470 }
471
472 check_func(){
473     log check_func "$@"
474     func=$1
475     shift
476     disable $func
477     check_ld "$@" <<EOF && enable $func
478 extern int $func();
479 int main(void){ $func(); }
480 EOF
481 }
482
483 check_func2(){
484     log check_func2 "$@"
485     headers=$1
486     func=$2
487     shift 2
488     disable $func
489     incs=""
490     for hdr in $headers; do
491         incs="$incs
492 #include <$hdr>"
493     done
494     check_ld "$@" <<EOF && enable $func
495 $incs
496 int main(int argc, char **argv){
497     (void) $func;
498     return 0;
499 }
500 EOF
501 }
502
503 check_lib(){
504     log check_lib "$@"
505     header="$1"
506     func="$2"
507     shift 2
508     temp_extralibs "$@"
509     check_header $header && check_func $func && add_extralibs "$@"
510     err=$?
511     restore_flags
512     return $err
513 }
514
515 check_lib2(){
516     log check_lib2 "$@"
517     headers="$1"
518     func="$2"
519     shift 2
520     temp_extralibs "$@"
521     check_func2 "$headers" $func && add_extralibs "$@"
522     err=$?
523     restore_flags
524     return $err
525 }
526
527 check_exec(){
528     check_ld "$@" && { enabled cross_compile || $TMPE >>$logfile 2>&1; }
529 }
530
531 check_exec_crash(){
532     code=`cat`
533
534     # exit() is not async signal safe.  _Exit (C99) and _exit (POSIX)
535     # are safe but may not be available everywhere.  Thus we use
536     # raise(SIGTERM) instead.  The check is run in a subshell so we
537     # can redirect the "Terminated" message from the shell.  SIGBUS
538     # is not defined by standard C so it is used conditionally.
539
540     (check_exec "$@") >>$logfile 2>&1 <<EOF
541 #include <signal.h>
542 static void sighandler(int sig){
543     raise(SIGTERM);
544 }
545 int main(void){
546     signal(SIGILL, sighandler);
547     signal(SIGFPE, sighandler);
548     signal(SIGSEGV, sighandler);
549 #ifdef SIGBUS
550     signal(SIGBUS, sighandler);
551 #endif
552     { $code }
553 }
554 EOF
555 }
556
557 check_type(){
558     log check_type "$@"
559     headers=$1
560     type=$2
561     shift 2
562     disable $type
563     incs=""
564     for hdr in $headers; do
565         incs="$incs
566 #include <$hdr>"
567     done
568     check_cc "$@" <<EOF && enable $type
569 $incs
570 $type v;
571 EOF
572 }
573
574 require(){
575     name="$1"
576     header="$2"
577     func="$3"
578     shift 3
579     check_lib $header $func "$@" || die "ERROR: $name not found"
580 }
581
582 require2(){
583     name="$1"
584     headers="$2"
585     func="$3"
586     shift 3
587     check_lib2 "$headers" $func "$@" || die "ERROR: $name not found"
588 }
589
590 check_foo_config(){
591     cfg=$1
592     pkg=$2
593     header=$3
594     func=$4
595     shift 4
596     disable $cfg
597     check_cmd ${pkg}-config --version
598     err=$?
599     if test "$err" = 0; then
600         temp_cflags `${pkg}-config --cflags`
601         temp_extralibs `${pkg}-config --libs`
602         check_lib "$@" $header $func && enable $cfg
603     fi
604     return $err
605 }
606
607 apply(){
608     file=$1
609     shift
610     "$@" < "$file" > "$file.tmp" && mv "$file.tmp" "$file" || rm "$file.tmp"
611 }
612
613 COMPONENT_LIST="
614     bsfs
615     decoders
616     demuxers
617     encoders
618     filters
619     indevs
620     muxers
621     outdevs
622     parsers
623     protocols
624 "
625
626 CONFIG_LIST="
627     $COMPONENT_LIST
628     avfilter
629     avfilter_lavf
630     avisynth
631     beos_netserver
632     ffmpeg
633     ffplay
634     ffserver
635     gpl
636     gprof
637     gray
638     hardcoded_tables
639     ipv6
640     liba52
641     liba52bin
642     libamr_nb
643     libamr_wb
644     libdc1394
645     libdirac
646     libfaac
647     libfaad
648     libfaadbin
649     libgsm
650     libmp3lame
651     libnut
652     libtheora
653     libvorbis
654     libx264
655     libxvid
656     memalign_hack
657     mlib
658     mpegaudio_hp
659     network
660     nonfree
661     postproc
662     powerpc_perf
663     small
664     swscale
665     vhook
666     x11grab
667     zlib
668 "
669
670 THREADS_LIST='
671     beosthreads
672     os2threads
673     pthreads
674     w32threads
675 '
676
677 ARCH_LIST='
678     alpha
679     armv4l
680     bfin
681     ia64
682     m68k
683     mips
684     parisc
685     powerpc
686     s390
687     sh4
688     sparc
689     sparc64
690     x86
691     x86_32
692     x86_64
693 '
694
695 ARCH_EXT_LIST='
696     altivec
697     armv5te
698     armv6
699     armvfp
700     iwmmxt
701     mmi
702     mmx
703     mmx2
704     ssse3
705     vis
706 '
707
708 HAVE_LIST="
709     $ARCH_EXT_LIST
710     $THREADS_LIST
711     altivec_h
712     arpa_inet_h
713     bswap
714     byteswap_h
715     closesocket
716     cmov
717     conio_h
718     dcbzl
719     dev_bktr_ioctl_bt848_h
720     dev_bktr_ioctl_meteor_h
721     dev_ic_bt8xx_h
722     dev_video_meteor_ioctl_meteor_h
723     dev_video_bktr_ioctl_bt848_h
724     dlfcn_h
725     dlopen
726     ebp_available
727     ebx_available
728     fast_64bit
729     fast_cmov
730     fast_unaligned
731     fork
732     freetype2
733     gethrtime
734     GetProcessTimes
735     getrusage
736     imlib2
737     inet_aton
738     inline_asm
739     libdc1394_1
740     libdc1394_2
741     llrint
742     lrint
743     lrintf
744     machine_ioctl_bt848_h
745     machine_ioctl_meteor_h
746     malloc_h
747     memalign
748     mkstemp
749     pld
750     ppc64
751     round
752     roundf
753     sdl
754     sdl_video_size
755     socklen_t
756     soundcard_h
757     poll_h
758     sys_mman_h
759     sys_select_h
760     sys_soundcard_h
761     termios_h
762     threads
763     winsock2_h
764 "
765
766 CMDLINE_SELECT="
767     $ARCH_EXT_LIST
768     $CONFIG_LIST
769     $THREADS_LIST
770     cross_compile
771     debug
772     extra_warnings
773     logging
774     optimizations
775     shared
776     static
777     stripping
778 "
779 CMDLINE_SET='
780     arch
781     build_suffix
782     cc
783     cpu
784     cross_prefix
785     incdir
786     libdir
787     logfile
788     mandir
789     prefix
790     shlibdir
791     source_path
792     target_os
793 '
794
795 # code dependency declarations
796
797 # architecture extensions
798 altivec_deps="powerpc"
799 armv5te_deps="armv4l"
800 armv6_deps="armv4l"
801 armvfp_deps="armv4l"
802 iwmmxt_deps="armv4l"
803 mmi_deps="mips"
804 mmx_deps="x86"
805 mmx2_deps="x86 mmx"
806 ssse3_deps="x86"
807 vis_deps="sparc"
808
809 # decoders / encoders
810 ac3_decoder_deps="gpl"
811 dxa_decoder_deps="zlib"
812 flashsv_decoder_deps="zlib"
813 flashsv_encoder_deps="zlib"
814 mpeg_xvmc_decoder_deps="xvmc"
815 png_decoder_deps="zlib"
816 png_encoder_deps="zlib"
817 zmbv_decoder_deps="zlib"
818 zmbv_encoder_deps="zlib"
819
820 # external libraries
821 liba52_decoder_deps="liba52"
822 liba52bin_decoder_extralibs='$ldl'
823 libamr_nb_decoder_deps="libamr_nb"
824 libamr_nb_encoder_deps="libamr_nb"
825 libamr_wb_decoder_deps="libamr_wb"
826 libamr_wb_encoder_deps="libamr_wb"
827 libdirac_decoder_deps="libdirac"
828 libdirac_encoder_deps="libdirac"
829 libfaac_encoder_deps="libfaac"
830 libfaad_decoder_deps="libfaad"
831 libfaadbin_decoder_extralibs='$ldl'
832 libgsm_decoder_deps="libgsm"
833 libgsm_encoder_deps="libgsm"
834 libgsm_ms_decoder_deps="libgsm"
835 libgsm_ms_encoder_deps="libgsm"
836 libmp3lame_encoder_deps="libmp3lame"
837 libtheora_encoder_deps="libtheora"
838 libvorbis_encoder_deps="libvorbis"
839 libx264_encoder_deps="libx264"
840 libxvid_encoder_deps="libxvid"
841 mpeg4aac_decoder_deps="libfaad"
842
843 # demuxers / muxers
844 ac3_demuxer_deps="ac3_parser"
845 audio_beos_demuxer_deps="audio_beos"
846 audio_beos_demuxer_extralibs="-lmedia -lbe"
847 audio_beos_muxer_deps="audio_beos"
848 audio_beos_muxer_extralibs="-lmedia -lbe"
849 avisynth_demuxer_deps="avisynth"
850 bktr_demuxer_deps_any="dev_bktr_ioctl_bt848_h machine_ioctl_bt848_h dev_video_bktr_ioctl_bt848_h dev_ic_bt8xx_h"
851 dirac_demuxer_deps="dirac_parser"
852 dv1394_demuxer_deps="dv1394 dv_demuxer"
853 libdc1394_demuxer_deps="libdc1394"
854 libnut_demuxer_deps="libnut"
855 libnut_muxer_deps="libnut"
856 mp3_demuxer_deps="mpegaudio_parser"
857 oss_demuxer_deps_any="soundcard_h sys_soundcard_h"
858 oss_muxer_deps_any="soundcard_h sys_soundcard_h"
859 redir_demuxer_deps="network"
860 rtp_muxer_deps="network rtp_protocol"
861 rtsp_demuxer_deps="sdp_demuxer"
862 sdp_demuxer_deps="rtp_protocol mpegts_demuxer"
863 v4l_demuxer_deps="linux_videodev_h"
864 v4l2_demuxer_deps="linux_videodev2_h"
865 vfwcap_demuxer_deps="capCreateCaptureWindow"
866 vfwcap_demuxer_extralibs="-lvfw32"
867 x11_grab_device_demuxer_deps="x11grab XShmCreateImage"
868 x11_grab_device_demuxer_extralibs="-lX11 -lXext"
869
870 # protocols
871 http_protocol_deps="network"
872 rtp_protocol_deps="udp_protocol"
873 tcp_protocol_deps="network"
874 udp_protocol_deps="network"
875
876 # filters
877 movie_filter_deps="avfilter_lavf"
878
879 # programs
880 ffplay_deps="sdl"
881 ffserver_deps="ffm_muxer rtp_protocol rtsp_demuxer"
882 ffserver_extralibs='$ldl'
883 vhook_extralibs='$ldl'
884
885
886 # default parameters
887
888 logfile="config.err"
889
890 # installation paths
891 prefix="/usr/local"
892 libdir='$(PREFIX)/lib'
893 shlibdir="$libdir"
894 incdir='$(PREFIX)/include'
895 mandir='$(PREFIX)/share/man'
896 bindir='$(PREFIX)/bin'
897
898 # toolchain
899 cc="gcc"
900 ar="ar"
901 nm="nm"
902 ranlib="ranlib"
903 strip="strip"
904 asmalign_pot="unknown"
905 ln_s="ln -sf"
906
907 # machine
908 arch=`uname -m`
909 cpu="generic"
910
911 # OS
912 target_os=$(tolower $(uname -s))
913
914 # libraries
915 enable zlib
916
917 # configurable options
918 enable debug
919 enable ffmpeg
920 enable ffplay
921 enable ffserver
922 enable ipv6
923 enable mpegaudio_hp
924 enable network
925 enable optimizations
926 enable protocols
927 enable static
928 enable stripping
929 vhook="default"
930
931 # build settings
932 SHFLAGS='-shared -Wl,-soname,$$(@F)'
933 VHOOKSHFLAGS='$(SHFLAGS)'
934 LDLATEFLAGS='-Wl,-rpath-link,\$(BUILD_ROOT)/libavcodec -Wl,-rpath-link,\$(BUILD_ROOT)/libavformat -Wl,-rpath-link,\$(BUILD_ROOT)/libavutil'
935 FFSERVERLDFLAGS=-Wl,-E
936 LIBPREF="lib"
937 LIBSUF=".a"
938 FULLNAME='$(NAME)$(BUILDSUF)'
939 LIBNAME='$(LIBPREF)$(FULLNAME)$(LIBSUF)'
940 SLIBPREF="lib"
941 SLIBSUF=".so"
942 SLIBNAME='$(SLIBPREF)$(FULLNAME)$(SLIBSUF)'
943 SLIBNAME_WITH_VERSION='$(SLIBNAME).$(LIBVERSION)'
944 SLIBNAME_WITH_MAJOR='$(SLIBNAME).$(LIBMAJOR)'
945 LIB_INSTALL_EXTRA_CMD='$(RANLIB) "$(LIBDIR)/$(LIBNAME)"'
946
947 # gcc stupidly only outputs the basename of targets with -MM
948 DEPEND_CMD='$(CC) $(CFLAGS) -MM -MG $< | sed "1s,^,$(@D)/,"'
949
950 # find source path
951 source_path="`dirname \"$0\"`"
952 enable source_path_used
953 if test -z "$source_path" -o "$source_path" = "." ; then
954     source_path="`pwd`"
955     disable source_path_used
956 else
957     source_path="`cd \"$source_path\"; pwd`"
958     echo "$source_path" | grep -q '[[:blank:]]' &&
959         die "Out of tree builds are impossible with whitespace in source path."
960 fi
961
962 FFMPEG_CONFIGURATION="$@"
963
964 find_things(){
965     thing=$1
966     pattern=$2
967     file=$source_path/$3
968     sed -n "s/^[^#]*$pattern.*([^,]*, *\([^,]*\)\(,.*\)*).*/\1_$thing/p" "$file"
969 }
970
971 ENCODER_LIST=$(find_things  encoder  ENC      libavcodec/allcodecs.c)
972 DECODER_LIST=$(find_things  decoder  DEC      libavcodec/allcodecs.c)
973 PARSER_LIST=$(find_things   parser   PARSER   libavcodec/allcodecs.c)
974 BSF_LIST=$(find_things      bsf      BSF      libavcodec/allcodecs.c)
975 MUXER_LIST=$(find_things    muxer    _MUX     libavformat/allformats.c)
976 DEMUXER_LIST=$(find_things  demuxer  DEMUX    libavformat/allformats.c)
977 OUTDEV_LIST=$(find_things   muxer    _MUX     libavdevice/alldevices.c)
978 INDEV_LIST=$(find_things    demuxer  DEMUX    libavdevice/alldevices.c)
979 PROTOCOL_LIST=$(find_things protocol PROTOCOL libavformat/allformats.c)
980 FILTER_LIST=$(find_things   filter   FILTER   libavfilter/allfilters.c)
981
982 enable $ARCH_EXT_LIST \
983        $DECODER_LIST \
984        $ENCODER_LIST \
985        $PARSER_LIST \
986        $BSF_LIST \
987        $DEMUXER_LIST \
988        $MUXER_LIST \
989        $FILTER_LIST \
990        $PROTOCOL_LIST \
991        $INDEV_LIST \
992        $OUTDEV_LIST \
993
994 die_unknown(){
995     echo "Unknown option \"$1\"."
996     echo "See $0 --help for available options."
997     exit 1
998 }
999
1000 show_list() {
1001     suffix=_$1
1002     shift
1003     echo $* | sed s/$suffix//g | tr ' ' '\n' | sort
1004     exit 0
1005 }
1006
1007 for opt do
1008     optval="${opt#*=}"
1009     case "$opt" in
1010     --extra-cflags=*) add_cflags "$optval"
1011     ;;
1012     --extra-ldflags=*) add_ldflags "$optval"
1013     ;;
1014     --extra-libs=*) add_extralibs "$optval"
1015     ;;
1016     --disable-devices) disable $INDEV_LIST $OUTDEV_LIST
1017     ;;
1018     --enable-debug=*) debuglevel="$optval"
1019     ;;
1020     --enable-*=*|--disable-*=*)
1021     eval `echo "$opt" | sed 's/=/-/;s/--/action=/;s/-/ thing=/;s/-/ name=/'`
1022     case "$thing" in
1023         encoder|decoder|muxer|demuxer|parser|bsf|protocol|filter) $action ${optval}_${thing} ;;
1024         *) die_unknown "$opt" ;;
1025     esac
1026     ;;
1027     --enable-?*|--disable-?*)
1028     eval `echo "$opt" | sed 's/--/action=/;s/-/ option=/;s/-/_/g'`
1029     if is_in $option $COMPONENT_LIST; then
1030         eval $action \$$(toupper ${option%s})_LIST
1031     elif is_in $option $CMDLINE_SELECT; then
1032         $action $option
1033     else
1034         die_unknown $opt
1035     fi
1036     ;;
1037     --list-*)
1038         NAME="${opt#--list-}"
1039         is_in $NAME $COMPONENT_LIST || die_unknown $opt
1040         NAME=${NAME%s}
1041         eval show_list $NAME \$$(toupper $NAME)_LIST
1042     ;;
1043     --help|-h) show_help
1044     ;;
1045     *)
1046     optname="${opt%=*}"
1047     optname="${optname#--}"
1048     optname=$(echo "$optname" | sed 's/-/_/g')
1049     is_in $optname $CMDLINE_SET || die_unknown $opt
1050     eval $optname='$optval'
1051     ;;
1052     esac
1053 done
1054
1055 # OS specific
1056 case $target_os in
1057     beos|haiku|zeta)
1058         prefix="$HOME/config"
1059         # helps building libavcodec
1060         add_cflags "-DPIC -fomit-frame-pointer"
1061         # 3 gcc releases known for BeOS, each with ugly bugs
1062         gcc_version="`$cc -v 2>&1 | grep version | cut -d ' ' -f3-`"
1063         case "$gcc_version" in
1064           2.9-beos-991026*|2.9-beos-000224*) echo "R5/GG gcc"
1065             disable mmx
1066             ;;
1067           *20010315*) echo "BeBits gcc"
1068             add_cflags "-fno-expensive-optimizations"
1069             ;;
1070         esac
1071         SHFLAGS=-nostart
1072         # enable BeOS things
1073         enable audio_beos
1074         # no need for libm, but the inet stuff
1075         # Check for BONE
1076         # XXX: actually should check for NOT net_server
1077         if echo $BEINCLUDES | grep -q 'headers/be/bone'; then
1078             network_extralibs="-lbind -lsocket"
1079         else
1080             enable beos_netserver
1081             network_extralibs="-lnet"
1082         fi ;;
1083     sunos)
1084         FFSERVERLDFLAGS=""
1085         SHFLAGS='-shared -Wl,-h,$$(@F)'
1086         network_extralibs="-lsocket -lnsl"
1087         ;;
1088     netbsd)
1089         oss_demuxer_extralibs="-lossaudio"
1090         oss_muxer_extralibs="-lossaudio"
1091         ;;
1092     openbsd)
1093         disable need_memalign
1094         LIBOBJFLAGS='$(PIC)'
1095         SHFLAGS='-shared'
1096         SLIBNAME='$(SLIBPREF)$(FULLNAME)$(SLIBSUF).$(LIBVERSION)'
1097         SLIBNAME_WITH_VERSION='$(SLIBNAME)'
1098         SLIBNAME_WITH_MAJOR='$(SLIBNAME)'
1099         oss_demuxer_extralibs="-lossaudio"
1100         oss_muxer_extralibs="-lossaudio"
1101         ;;
1102     freebsd)
1103         disable need_memalign
1104         ;;
1105     bsd/os)
1106         osextralibs="-lpoll -lgnugetopt"
1107         strip="strip -d"
1108         ;;
1109     darwin)
1110         disable need_memalign
1111         SHFLAGS='-dynamiclib -Wl,-single_module -Wl,-install_name,$(SHLIBDIR)/$(SLIBNAME),-current_version,$(LIBVERSION),-compatibility_version,$(LIBMAJOR) -Wl,-read_only_relocs,suppress'
1112         VHOOKSHFLAGS='-dynamiclib -Wl,-single_module -flat_namespace -undefined suppress -Wl,-install_name,$(SHLIBDIR)/vhook/$$(@F)'
1113         strip="strip -x"
1114         FFLDFLAGS="-Wl,-dynamic,-search_paths_first"
1115         SLIBSUF=".dylib"
1116         SLIBNAME_WITH_VERSION='$(SLIBPREF)$(FULLNAME).$(LIBVERSION)$(SLIBSUF)'
1117         SLIBNAME_WITH_MAJOR='$(SLIBPREF)$(FULLNAME).$(LIBMAJOR)$(SLIBSUF)'
1118         FFSERVERLDFLAGS=-Wl,-bind_at_load
1119         ;;
1120     mingw32*)
1121         target_os=mingw32
1122         shlibdir="$bindir"
1123         VHOOKSHFLAGS='-shared -L$(BUILD_ROOT)/libavformat -L$(BUILD_ROOT)/libavcodec -L$(BUILD_ROOT)/libavutil'
1124         VHOOKLIBS='-lavformat$(BUILDSUF) -lavcodec$(BUILDSUF) -lavutil$(BUILDSUF) $(EXTRALIBS)'
1125         if enabled swscale; then
1126             VHOOKSHFLAGS="$VHOOKSHFLAGS -L\$(BUILD_ROOT)/libswscale"
1127             VHOOKLIBS="$VHOOKLIBS -lswscale\$(BUILDSUF)"
1128         fi
1129         disable ffserver
1130         SLIBPREF=""
1131         SLIBSUF=".dll"
1132         EXESUF=".exe"
1133         SLIBNAME_WITH_VERSION='$(SLIBPREF)$(FULLNAME)-$(LIBVERSION)$(SLIBSUF)'
1134         SLIBNAME_WITH_MAJOR='$(SLIBPREF)$(FULLNAME)-$(LIBMAJOR)$(SLIBSUF)'
1135         SLIB_EXTRA_CMD='-lib /machine:i386 /def:$$(@:$(SLIBSUF)=.def)'
1136         SLIB_INSTALL_EXTRA_CMD='-install -m 644 $(SUBDIR)$(SLIBNAME_WITH_MAJOR:$(SLIBSUF)=.lib) "$(SHLIBDIR)/$(SLIBNAME:$(SLIBSUF)=.lib)"'
1137         SLIB_UNINSTALL_EXTRA_CMD='rm -f "$(SHLIBDIR)/$(SLIBNAME:$(SLIBSUF)=.lib)"'
1138         SHFLAGS='-shared -Wl,--output-def,$$(@:$(SLIBSUF)=.def) -Wl,--enable-runtime-pseudo-reloc -Wl,--enable-auto-image-base'
1139         ;;
1140     cygwin*)
1141         target_os=cygwin
1142         shlibdir="$bindir"
1143         VHOOKSHFLAGS='-shared -L$(BUILD_ROOT)/libavformat -L$(BUILD_ROOT)/libavcodec -L$(BUILD_ROOT)/libavutil'
1144         VHOOKLIBS='-lavformat$(BUILDSUF) -lavcodec$(BUILDSUF) -lavutil$(BUILDSUF) $(EXTRALIBS)'
1145         if enabled swscale; then
1146             VHOOKSHFLAGS="$VHOOKSHFLAGS -L\$(BUILD_ROOT)/libswscale"
1147             VHOOKLIBS="$VHOOKLIBS -lswscale\$(BUILDSUF)"
1148         fi
1149         EXESUF=".exe"
1150         SLIBPREF="cyg"
1151         SLIBSUF=".dll"
1152         SLIBNAME_WITH_VERSION='$(SLIBPREF)$(FULLNAME)-$(LIBVERSION)$(SLIBSUF)'
1153         SLIBNAME_WITH_MAJOR='$(SLIBPREF)$(FULLNAME)-$(LIBMAJOR)$(SLIBSUF)'
1154         SHFLAGS='-shared -Wl,--enable-auto-image-base'
1155         ;;
1156     *-dos|freedos|opendos)
1157         disable ffplay ffserver vhook
1158         disable $INDEV_LIST $OUTDEV_LIST
1159         network_extralibs="-lsocket"
1160         EXESUF=".exe"
1161         ;;
1162     linux)
1163         LDLATEFLAGS="-Wl,--as-needed $LDLATEFLAGS"
1164         enable dv1394
1165         ;;
1166     irix*)
1167         target_os=irix
1168         ranlib="echo ignoring ranlib"
1169         ;;
1170     os/2*)
1171         strip="lxlite"
1172         ln_s="cp -f"
1173         EXESUF=".exe"
1174         FFLDFLAGS="-Zomf -Zbin-files -Zargs-wild -Zmap"
1175         SHFLAGS='$(SUBDIR)$(NAME).def -Zdll -Zomf'
1176         FFSERVERLDFLAGS=""
1177         LIBSUF="_s.a"
1178         SLIBPREF=""
1179         SLIBSUF=".dll"
1180         SLIBNAME_WITH_VERSION='$(SLIBPREF)$(NAME)-$(LIBVERSION)$(SLIBSUF)'
1181         SLIBNAME_WITH_MAJOR='$(SLIBPREF)$(shell echo $(NAME) | cut -c1-6)$(LIBMAJOR)$(SLIBSUF)'
1182         SLIB_CREATE_DEF_CMD='echo LIBRARY $(SLIBNAME_WITH_MAJOR) INITINSTANCE TERMINSTANCE > $(SUBDIR)$(NAME).def; \
1183           echo PROTMODE >> $(SUBDIR)$(NAME).def; \
1184           echo CODE PRELOAD MOVEABLE DISCARDABLE >> $(SUBDIR)$(NAME).def; \
1185           echo DATA PRELOAD MOVEABLE MULTIPLE NONSHARED >> $(SUBDIR)$(NAME).def; \
1186           echo EXPORTS >> $(SUBDIR)$(NAME).def; \
1187           emxexp -o $(OBJS) >> $(SUBDIR)$(NAME).def'
1188         SLIB_EXTRA_CMD='emximp -o $(SUBDIR)$(LIBPREF)$(NAME)_dll.a $(SUBDIR)$(NAME).def; \
1189           emximp -o $(SUBDIR)$(LIBPREF)$(NAME)_dll.lib $(SUBDIR)$(NAME).def;'
1190         SLIB_INSTALL_EXTRA_CMD='install -m 644 $(SUBDIR)$(LIBPREF)$(NAME)_dll.a $(SUBDIR)$(LIBPREF)$(NAME)_dll.lib "$(LIBDIR)"'
1191         SLIB_UNINSTALL_EXTRA_CMD='rm -f "$(LIBDIR)"/$(LIBPREF)$(NAME)_dll.a "$(LIBDIR)"/$(LIBPREF)$(NAME)_dll.lib'
1192         disable vhook
1193         ;;
1194     interix)
1195         disable vhook
1196         ;;
1197
1198     *)
1199         target_os="${target_os}-UNKNOWN"
1200         ;;
1201 esac
1202
1203 # set temporary file name
1204 if test ! -z "$TMPDIR" ; then
1205     TMPDIR1="${TMPDIR}"
1206 elif test ! -z "$TEMPDIR" ; then
1207     TMPDIR1="${TEMPDIR}"
1208 else
1209     TMPDIR1="/tmp"
1210 fi
1211
1212 TMPC="${TMPDIR1}/ffmpeg-conf-${RANDOM}-$$-${RANDOM}.c"
1213 TMPE="${TMPDIR1}/ffmpeg-conf-${RANDOM}-$$-${RANDOM}${EXESUF}"
1214 TMPH="${TMPDIR1}/ffmpeg-conf-${RANDOM}-$$-${RANDOM}.h"
1215 TMPO="${TMPDIR1}/ffmpeg-conf-${RANDOM}-$$-${RANDOM}.o"
1216 TMPS="${TMPDIR1}/ffmpeg-conf-${RANDOM}-$$-${RANDOM}.S"
1217 TMPSH="${TMPDIR1}/ffmpeg-conf-${RANDOM}-$$-${RANDOM}.sh"
1218
1219
1220 add_extralibs $osextralibs
1221
1222 disabled logging && logfile=/dev/null
1223
1224 echo "# $0 $@" >$logfile
1225 set >>$logfile
1226
1227 case "$arch" in
1228     i386|i486|i586|i686|i86pc|BePC)
1229         arch="x86_32"
1230         enable fast_unaligned
1231     ;;
1232     x86_64|amd64)
1233         arch="x86_32"
1234         enable fast_unaligned
1235         check_cc <<EOF && enable fast_64bit && arch="x86_64"
1236         int test[sizeof(char*) - 7];
1237 EOF
1238     ;;
1239     # armv4l is a subset of armv[567]*l
1240     arm|armv[4567]*l)
1241         arch="armv4l"
1242     ;;
1243     alpha)
1244         arch="alpha"
1245         enable fast_64bit
1246     ;;
1247     "Power Macintosh"|ppc|powerpc)
1248         arch="powerpc"
1249     ;;
1250     ppc64)
1251         arch="powerpc"
1252         enable fast_64bit
1253     ;;
1254     mips|mipsel|IP*)
1255         arch="mips"
1256     ;;
1257     sun4u|sparc64)
1258         arch="sparc64"
1259         enable fast_64bit
1260     ;;
1261     sparc)
1262         arch="sparc"
1263     ;;
1264     sh4)
1265         arch="sh4"
1266     ;;
1267     parisc)
1268         arch="parisc"
1269     ;;
1270     parisc64)
1271         arch="parisc"
1272         enable fast_64bit
1273     ;;
1274     s390|s390x)
1275         arch="s390"
1276     ;;
1277     m68k)
1278         arch="m68k"
1279     ;;
1280     ia64)
1281         arch="ia64"
1282         enable fast_64bit
1283     ;;
1284     bfin)
1285         arch="bfin"
1286     ;;
1287     *)
1288         arch="unknown"
1289     ;;
1290 esac
1291
1292 enable $arch
1293 enabled_any x86_32 x86_64 && enable x86
1294 enabled     sparc64       && enable sparc
1295
1296 # Combine FFLDFLAGS and the LDFLAGS environment variable.
1297 LDFLAGS="$FFLDFLAGS $LDFLAGS"
1298
1299 test -n "$cross_prefix" && enable cross_compile
1300 cc="${cross_prefix}${cc}"
1301 ar="${cross_prefix}${ar}"
1302 nm="${cross_prefix}${nm}"
1303 ranlib="${cross_prefix}${ranlib}"
1304 strip="${cross_prefix}${strip}"
1305
1306 # we need to build at least one lib type
1307 if ! enabled_any static shared; then
1308     cat <<EOF
1309 At least one library type must be built.
1310 Specify --enable-static to build the static libraries or --enable-shared to
1311 build the shared libraries as well. To only build the shared libraries specify
1312 --disable-static in addition to --enable-shared.
1313 EOF
1314     exit 1;
1315 fi
1316
1317 disabled static && LIBNAME=""
1318
1319 if enabled_any libfaad libfaadbin ; then
1320     if check_header faad.h; then
1321         check_cc << EOF
1322 #include <faad.h>
1323 #ifndef FAAD2_VERSION
1324 ok faad1
1325 #endif
1326 int main(void) { return 0; }
1327 EOF
1328         test $? = 0 && enable libfaad2
1329     else
1330         die "FAAD test failed."
1331     fi
1332 fi
1333
1334
1335 if ! enabled gpl; then
1336     die_gpl_disabled(){
1337         name=$1
1338         shift
1339         enabled_any $@ && die "$name is under GPL and --enable-gpl is not specified."
1340     }
1341     die_gpl_disabled "The Postprocessing code" postproc
1342     die_gpl_disabled "liba52"                  liba52
1343     die_gpl_disabled "libx264"                 libx264
1344     die_gpl_disabled "libxvidcore"             libxvid
1345     die_gpl_disabled "FAAD2"                   libfaad2
1346     die_gpl_disabled "The X11 grabber"         x11grab
1347     die_gpl_disabled "The software scaler"     swscale
1348 fi
1349
1350 if ! enabled nonfree && enabled_any libamr_nb libamr_wb; then
1351     die "libamr is nonfree and --enable-nonfree is not specified."
1352 fi
1353
1354 check_deps $ARCH_EXT_LIST
1355
1356 test -z "$need_memalign" && need_memalign="$mmx"
1357
1358 #Darwin CC versions
1359 if test $target_os = darwin; then
1360     if $cc -v 2>&1 | grep -q xlc; then
1361         add_cflags "-qpdf2 -qlanglvl=extc99 -qmaxmem=-1 -qarch=auto -qtune=auto"
1362     else
1363         add_cflags "-pipe"
1364         check_cflags "-force_cpusubtype_ALL"
1365         check_cflags "-Wno-sign-compare"
1366         enabled shared || check_cflags -mdynamic-no-pic
1367     fi
1368 fi
1369
1370 disabled optimizations || add_cflags -fomit-frame-pointer
1371
1372 # Add processor-specific flags
1373 if test $cpu != "generic"; then
1374     warn_altivec(){
1375         $1 altivec && echo "WARNING: Tuning for $2 but AltiVec $1.";
1376     }
1377     case $cpu in
1378         601|ppc601|PowerPC601)
1379             add_cflags "-mcpu=601"
1380             warn_altivec enabled PPC601
1381         ;;
1382         603*|ppc603*|PowerPC603*)
1383             add_cflags "-mcpu=603"
1384             warn_altivec enabled PPC603
1385         ;;
1386         604*|ppc604*|PowerPC604*)
1387             add_cflags "-mcpu=604"
1388             warn_altivec enabled PPC604
1389         ;;
1390         G3|g3|75*|ppc75*|PowerPC75*)
1391             add_cflags "-mcpu=750 -mpowerpc-gfxopt"
1392             warn_altivec enabled PPC75x
1393         ;;
1394         G4|g4|745*|ppc745*|PowerPC745*)
1395             add_cflags "-mcpu=7450 -mpowerpc-gfxopt"
1396             warn_altivec disabled PPC745x
1397         ;;
1398         74*|ppc74*|PowerPC74*)
1399             add_cflags "-mcpu=7400 -mpowerpc-gfxopt"
1400             warn_altivec disabled PPC74xx
1401         ;;
1402         G5|g5|970|ppc970|PowerPC970|power4*|Power4*)
1403             add_cflags "-mcpu=970 -mpowerpc-gfxopt -mpowerpc64"
1404             warn_altivec disabled PPC970
1405             enable ppc64
1406         ;;
1407         Cell|CELL|cell)
1408             add_cflags "-mcpu=cell"
1409             warn_altivec disabled Cell
1410             enable ppc64
1411         ;;
1412         # targets that do NOT support conditional mov (cmov)
1413         i[345]86|pentium|pentium-mmx|k6|k6-[23]|winchip-c6|winchip2|c3)
1414             add_cflags "-march=$cpu"
1415             disable cmov
1416         ;;
1417         # targets that do support conditional mov (cmov)
1418         i686|pentiumpro|pentium[23]|pentium-m|athlon|athlon-tbird|athlon-4|athlon-[mx]p|athlon64|k8|opteron|athlon-fx|core2)
1419             add_cflags "-march=$cpu"
1420             enable cmov
1421             enable fast_cmov
1422         ;;
1423         # targets that do support conditional mov but on which it's slow
1424         pentium4|pentium4m|prescott|nocona)
1425             add_cflags "-march=$cpu"
1426             enable cmov
1427             disable fast_cmov
1428         ;;
1429         sparc64)
1430             add_cflags "-mcpu=v9"
1431         ;;
1432         arm*)
1433             add_cflags "-mcpu=$cpu"
1434         ;;
1435         *)
1436             echo "WARNING: Unknown CPU \"$cpu\", ignored."
1437         ;;
1438     esac
1439 fi
1440
1441 # make sure we can execute files in $TMPDIR
1442 cat >$TMPSH 2>>$logfile <<EOF
1443 #! /bin/sh
1444 EOF
1445 chmod +x $TMPSH >>$logfile 2>&1
1446 if ! $TMPSH >>$logfile 2>&1; then
1447     cat <<EOF
1448 Unable to create and execute files in $TMPDIR1.  Set the TMPDIR environment
1449 variable to another directory and make sure that $TMPDIR1 is not mounted
1450 noexec.
1451 EOF
1452     die "Sanity test failed."
1453 fi
1454 rm $TMPSH
1455
1456 # compiler sanity check
1457 check_exec <<EOF
1458 int main(void){ return 0; }
1459 EOF
1460 if test "$?" != 0; then
1461     echo "$cc is unable to create an executable file."
1462     if test -z "$cross_prefix" && ! enabled cross_compile ; then
1463         echo "If $cc is a cross-compiler, use the --enable-cross-compile option."
1464         echo "Only do this if you know what cross compiling means."
1465     fi
1466     die "C compiler test failed."
1467 fi
1468
1469 check_cc <<EOF || die "Symbol mangling check failed."
1470 int ff_extern;
1471 EOF
1472 sym=$($nm -P -g $TMPO)
1473 extern_prefix=${sym%%ff_extern*}
1474
1475 check_asm inline_asm '""'
1476
1477 if enabled x86; then
1478     # check whether EBP is available on x86
1479     # As 'i' is stored on the stack, this program will crash
1480     # if the base pointer is used to access it because the
1481     # base pointer is cleared in the inline assembly code.
1482     check_exec_crash <<EOF && enable ebp_available
1483     volatile int i=0;
1484     asm volatile (
1485         "xorl %%ebp, %%ebp"
1486     ::: "%ebp");
1487     return i;
1488 EOF
1489
1490     # check wether EBX is available on x86
1491     check_asm ebx_available '"":::"%ebx"'
1492
1493     # check whether binutils is new enough to compile SSSE3/MMX2
1494     enabled ssse3 && check_asm ssse3 '"pabsw %xmm0, %xmm0"'
1495     enabled mmx2  && check_asm mmx2  '"movss %xmm0, %xmm0"'
1496
1497     check_asm bswap '"bswap %%eax" ::: "%eax"'
1498 fi
1499
1500 # check for assembler specific support
1501
1502 if test $arch = "powerpc"; then
1503 check_cc <<EOF && enable dcbzl
1504 int main(void) {
1505     register long zero = 0;
1506     char data[1024];
1507     asm volatile("dcbzl %0, %1" : : "b" (data), "r" (zero));
1508 return 0;
1509 }
1510 EOF
1511 fi
1512
1513 # check for SIMD availability
1514
1515 # AltiVec flags: The FSF version of GCC differs from the Apple version
1516 if enabled altivec; then
1517     check_cflags -maltivec -mabi=altivec &&
1518         check_header altivec.h ||
1519         check_cflags -faltivec
1520
1521     # check if our compiler supports Motorola AltiVec C API
1522     enabled altivec_h &&
1523         inc_altivec_h="#include <altivec.h>" ||
1524         inc_altivec_h=
1525     check_cc <<EOF || disable altivec
1526 $inc_altivec_h
1527 int main(void) {
1528     vector signed int v1, v2, v3;
1529     v1 = vec_add(v2,v3);
1530     return 0;
1531 }
1532 EOF
1533 fi
1534
1535 # We have to check if pld is a nop and disable it.
1536 enabled armv4l  && check_asm pld     '"pld [r0]"'
1537 enabled armv5te && check_asm armv5te '"qadd r0, r0, r0"'
1538 enabled armv6   && check_asm armv6   '"sadd16 r0, r0, r0"'
1539 enabled armvfp  && check_asm armvfp  '"fadds s0, s0, s0"'
1540 enabled iwmmxt  && check_asm iwmmxt  '"wunpckelub wr6, wr4"'
1541 enabled mmi     && check_asm mmi     '"lq $2, 0($2)"'
1542 enabled vis     && check_asm vis     '"pdist %f0, %f0, %f0"' -mcpu=ultrasparc
1543
1544 enabled vis && add_cflags "-mcpu=ultrasparc -mtune=ultrasparc"
1545
1546 # ---
1547 # big/little-endian test
1548 check_cc <<EOF || die "endian test failed"
1549 unsigned int endian = 'B' << 24 | 'I' << 16 | 'G' << 8 | 'E';
1550 EOF
1551 od -A n -t x1 $TMPO | grep -q '42 *49 *47 *45' && enable bigendian
1552
1553 # ---
1554 # check availability of some header files
1555
1556 if check_func dlopen; then
1557     ldl=
1558 elif check_func dlopen -ldl; then
1559     ldl=-ldl
1560 fi
1561
1562 check_func  fork
1563 check_func  gethrtime
1564 check_func  getrusage
1565 check_func  inet_aton $network_extralibs
1566 check_func  memalign
1567 check_func  mkstemp
1568 check_func2 windows.h GetProcessTimes
1569
1570 check_header byteswap.h
1571 check_header conio.h
1572 check_header dlfcn.h
1573 check_header malloc.h
1574 check_header sys/mman.h
1575 check_header termios.h
1576
1577 if ! enabled_any memalign memalign_hack && enabled need_memalign ; then
1578     die "Error, no memalign() but SSE enabled, disable it or use --enable-memalign-hack."
1579 fi
1580
1581 enabled zlib && check_lib zlib.h zlibVersion -lz || disable zlib
1582
1583 # ffserver uses poll(),
1584 # if it's not found we can emulate it using select().
1585 if enabled ffserver; then
1586     check_header poll.h
1587     check_header sys/select.h
1588 fi
1589
1590 # check for some common methods of building with pthread support
1591 # do this before the optional library checks as some of them require pthreads
1592 if enabled pthreads; then
1593     if check_func pthread_create; then
1594         :
1595     elif check_func pthread_create -pthread; then
1596         add_cflags -pthread
1597         add_extralibs -pthread
1598     elif check_func pthread_create -pthreads; then
1599         add_cflags -pthreads
1600         add_extralibs -pthreads
1601     elif check_func pthread_create -lpthreadGC2; then
1602         add_extralibs -lpthreadGC2
1603     elif ! check_lib pthread.h pthread_create -lpthread; then
1604         die "ERROR: can't find pthreads library"
1605     fi
1606 fi
1607
1608 for thread in $THREADS_LIST; do
1609     if enabled $thread; then
1610         test -n "$thread_type" &&
1611             die "ERROR: Only one thread type must be selected." ||
1612             thread_type="$thread"
1613     fi
1614 done
1615
1616 check_lib math.h sin -lm
1617
1618 # test for C99 functions in math.h
1619 for func in llrint lrint lrintf round roundf; do
1620     check_exec <<EOF && enable $func || disable $func
1621 #define _ISOC9X_SOURCE  1
1622 #include <math.h>
1623 int main(void) { return ($func(3.999f) > 0)?0:1; }
1624 EOF
1625 done
1626
1627 # these are off by default, so fail if requested and not available
1628 enabled avisynth   && require2 vfw32 "windows.h vfw.h" AVIFileInit -lvfw32
1629 enabled liba52     && require  liba52 a52dec/a52.h a52_init -la52
1630 enabled libamr_nb  && require  libamrnb amrnb/interf_dec.h Speech_Decode_Frame_init -lamrnb -lm
1631 enabled libamr_wb  && require  libamrwb amrwb/dec_if.h D_IF_init -lamrwb -lm
1632 enabled libdirac   && add_cflags "$(pkg-config --cflags dirac)" \
1633                    && require  libdirac libdirac_decoder/dirac_parser.h dirac_decoder_init -ldirac_decoder \
1634                    && require  libdirac libdirac_encoder/dirac_encoder.h dirac_encoder_init -ldirac_encoder
1635 enabled libfaac    && require2 libfaac "stdint.h faac.h" faacEncGetVersion -lfaac
1636 enabled libfaad    && require2 libfaad faad.h faacDecOpen -lfaad
1637 enabled libgsm     && require  libgsm gsm.h gsm_create -lgsm
1638 enabled libmp3lame && require  LAME lame/lame.h lame_init -lmp3lame -lm
1639 enabled libnut     && require  libnut libnut.h nut_demuxer_init -lnut
1640 enabled libtheora  && require  libtheora theora/theora.h theora_info_init -ltheora -logg
1641 enabled libvorbis  && require  libvorbis vorbis/vorbisenc.h vorbis_info_init -lvorbisenc -lvorbis -logg
1642 enabled libx264    && require  x264 x264.h x264_encoder_open -lx264 -lm
1643 enabled libxvid    && require  Xvid xvid.h xvid_global -lxvidcore
1644 enabled mlib       && require  mediaLib mlib_types.h mlib_VectorSub_S16_U8_Mod -lmlib
1645
1646 # disable the native AC-3 decoder if liba52 is enabled
1647 enabled liba52 && disable ac3_decoder
1648
1649 # libdc1394 check
1650 if enabled libdc1394; then
1651     { check_lib dc1394/dc1394.h dc1394_new -ldc1394 -lraw1394 &&
1652         enable libdc1394_2; } ||
1653     { check_lib libdc1394/dc1394_control.h dc1394_create_handle -ldc1394_control -lraw1394 &&
1654         enable libdc1394_1; } ||
1655     die "ERROR: No version of libdc1394 found "
1656 fi
1657
1658
1659 _restrict=
1660 for restrict_keyword in restrict __restrict__ __restrict; do
1661     check_cc <<EOF && _restrict=$restrict_keyword && break
1662 void foo(char * $restrict_keyword p);
1663 EOF
1664 done
1665
1666 test "$vhook" = "default" && vhook="$dlopen"
1667
1668 if test "$target_os" = cygwin -o "$target_os" = mingw32 && enabled_all static vhook ; then
1669     disable vhook
1670     echo
1671     echo "At the moment vhooks don't work on Cygwin or MinGW static builds."
1672     echo "Patches welcome."
1673     echo
1674 fi
1675
1676 if enabled vhook; then
1677     check_ldflags -rdynamic
1678     check_ldflags -export-dynamic
1679 fi
1680
1681 check_foo_config imlib2 imlib2 Imlib2.h imlib_load_font
1682 check_foo_config freetype2 freetype ft2build.h FT_Init_FreeType
1683
1684 ##########################################
1685 # SDL check
1686
1687 disable sdl_too_old
1688 disable sdl
1689 SDL_CONFIG="${cross_prefix}sdl-config"
1690 if "${SDL_CONFIG}" --version >/dev/null 2>&1; then
1691     sdl_cflags=`"${SDL_CONFIG}" --cflags`
1692     temp_cflags $sdl_cflags
1693     temp_extralibs `"${SDL_CONFIG}" --libs`
1694     if check_lib2 SDL.h SDL_Init; then
1695         _sdlversion=`"${SDL_CONFIG}" --version | sed 's/[^0-9]//g'`
1696         if test "$_sdlversion" -lt 121 ; then
1697             enable sdl_too_old
1698         else
1699             enable sdl
1700             check_cc $sdl_cflags <<EOF && enable sdl_video_size
1701 #include <SDL.h>
1702 int main(int argc, char **argv){
1703     const SDL_VideoInfo *vi = SDL_GetVideoInfo();
1704     int w = vi->current_w;
1705     return 0;
1706 }
1707 EOF
1708         fi
1709     fi
1710     restore_flags
1711 fi
1712
1713 texi2html -version >/dev/null 2>&1 && enable texi2html || disable texi2html
1714
1715 check_type sys/socket.h socklen_t
1716
1717 ##########################################
1718 # Network check
1719
1720 if enabled network; then
1721     # Prefer arpa/inet.h over winsock2
1722     if check_header arpa/inet.h ; then
1723         check_func closesocket
1724     elif check_header winsock2.h ; then
1725         network_extralibs="-lws2_32"
1726         check_type ws2tcpip.h socklen_t
1727         check_func2 winsock2.h closesocket
1728     fi
1729 fi
1730
1731 ##########################################
1732 # IPv6 check
1733
1734 enabled network && enabled ipv6 && check_ld <<EOF && enable ipv6 || disable ipv6
1735 #include <sys/types.h>
1736 #include <sys/socket.h>
1737 #include <netinet/in.h>
1738 #include <netdb.h>
1739 int main(void) {
1740     struct sockaddr_storage saddr;
1741     struct ipv6_mreq mreq6;
1742     getaddrinfo(0,0,0,0);
1743     getnameinfo(0,0,0,0,0,0,0);
1744     IN6_IS_ADDR_MULTICAST((const struct in6_addr *)0);
1745 }
1746 EOF
1747
1748 check_header linux/videodev.h
1749 check_header linux/videodev2.h
1750
1751 check_func2 "windows.h vfw.h" capCreateCaptureWindow -lvfw32
1752
1753 # check for ioctl_meteor.h, ioctl_bt848.h and alternatives
1754 { check_header dev/bktr/ioctl_meteor.h &&
1755   check_header dev/bktr/ioctl_bt848.h; } ||
1756 { check_header machine/ioctl_meteor.h &&
1757   check_header machine/ioctl_bt848.h; } ||
1758 { check_header dev/video/meteor/ioctl_meteor.h &&
1759   check_header dev/video/bktr/ioctl_bt848.h; } ||
1760 check_header dev/ic/bt8xx.h
1761
1762 check_header sys/soundcard.h
1763 check_header soundcard.h
1764
1765 # deal with the X11 frame grabber
1766 enabled x11grab                         &&
1767 check_header X11/Xlib.h                 &&
1768 check_header X11/extensions/XShm.h      &&
1769 check_func XOpenDisplay -lX11           &&
1770 check_func XShmCreateImage -lX11 -lXext
1771
1772 enabled debug && add_cflags -g"$debuglevel"
1773
1774 # add some useful compiler flags if supported
1775 check_cflags -Wdeclaration-after-statement
1776 check_cflags -Wall
1777 check_cflags -Wno-switch
1778 check_cflags -Wdisabled-optimization
1779 check_cflags -Wpointer-arith
1780 check_cflags -Wredundant-decls
1781 check_cflags -Wno-pointer-sign
1782 check_cflags -Wcast-qual
1783 check_cflags -Wwrite-strings
1784 check_cflags -Wtype-limits
1785 enabled extra_warnings && check_cflags -Winline
1786
1787 # add some linker flags
1788 check_ldflags -Wl,--warn-common
1789 check_ldflags $LDLATEFLAGS
1790 check_ldflags -Wl,-Bsymbolic
1791
1792 if enabled small; then
1793     check_cflags -Os            # not all compilers support -Os
1794     optimizations="small"
1795 elif enabled optimizations; then
1796     if $cc -v 2>&1 | grep -q xlc; then
1797         add_cflags  "-O5"
1798         add_ldflags "-O5"
1799     else
1800         add_cflags "-O3"
1801     fi
1802 fi
1803 check_cflags -fno-math-errno
1804 check_cflags -fno-signed-zeros
1805
1806 # PIC flags for shared library objects where they are needed
1807 if enabled shared; then
1808     # LIBOBJFLAGS may have already been set in the OS configuration
1809     if test -z "$LIBOBJFLAGS" ; then
1810         case "$arch" in
1811             x86_64|ia64|alpha|sparc*|power*) LIBOBJFLAGS='$(PIC)' ;;
1812         esac
1813     fi
1814 fi
1815
1816 if enabled gprof; then
1817     add_cflags  "-p"
1818     add_ldflags "-p"
1819 fi
1820
1821 VHOOKCFLAGS="-fPIC"
1822
1823 # Find out if the .align argument is a power of two or not.
1824 if test $asmalign_pot = "unknown"; then
1825     disable asmalign_pot
1826     echo 'asm (".align 3");' | check_cc && enable asmalign_pot
1827 fi
1828
1829 enabled_any $DECODER_LIST      && enable decoders
1830 enabled_any $ENCODER_LIST      && enable encoders
1831 enabled_any $BSF_LIST          && enable bsfs
1832 enabled_any $DEMUXER_LIST      && enable demuxers
1833 enabled_any $MUXER_LIST        && enable muxers
1834 enabled_any $FILTER_LIST       && enable filters
1835 enabled_any $INDEV_LIST        && enable demuxers
1836 enabled_any $OUTDEV_LIST       && enable muxers
1837 enabled_any $PROTOCOL_LIST     && enable protocols
1838
1839 enabled_any $THREADS_LIST      && enable threads
1840
1841 check_deps $CONFIG_LIST       \
1842            $HAVE_LIST         \
1843            $DECODER_LIST      \
1844            $ENCODER_LIST      \
1845            $PARSER_LIST       \
1846            $BSF_LIST          \
1847            $DEMUXER_LIST      \
1848            $MUXER_LIST        \
1849            $FILTER_LIST       \
1850            $INDEV_LIST        \
1851            $OUTDEV_LIST       \
1852            $PROTOCOL_LIST     \
1853
1854 enabled libdc1394 && append pkg_requires "libraw1394"
1855 enabled libdirac  && append pkg_requires "dirac"
1856 enabled libtheora && append pkg_requires "theora"
1857 enabled libvorbis && append pkg_requires "vorbisenc"
1858
1859 echo "install prefix            $prefix"
1860 echo "source path               $source_path"
1861 echo "C compiler                $cc"
1862 echo ".align is power-of-two    $asmalign_pot"
1863 echo "ARCH                      $arch ($cpu)"
1864 if test "$build_suffix" != ""; then
1865     echo "build suffix              $build_suffix"
1866 fi
1867 echo "big-endian                ${bigendian-no}"
1868 if test $arch = "x86_32" -o $arch = "x86_64"; then
1869     echo "MMX enabled               ${mmx-no}"
1870     echo "CMOV enabled              ${cmov-no}"
1871     echo "CMOV is fast              ${fast_cmov-no}"
1872     echo "EBX available             ${ebx_available-no}"
1873     echo "EBP available             ${ebp_available-no}"
1874 fi
1875 if test $arch = "armv4l"; then
1876     echo "ARMv5TE enabled           ${armv5te-no}"
1877     echo "ARMv6 enabled             ${armv6-no}"
1878     echo "ARM VFP enabled           ${armvfp-no}"
1879     echo "IWMMXT enabled            ${iwmmxt-no}"
1880 fi
1881 if test $arch = "mips"; then
1882     echo "MMI enabled               ${mmi-no}"
1883 fi
1884 if test $arch = "powerpc"; then
1885     echo "AltiVec enabled           ${altivec-no}"
1886     echo "dcbzl available           ${dcbzl-no}"
1887 fi
1888 echo "gprof enabled             ${gprof-no}"
1889 echo "debug symbols             ${debug-no}"
1890 echo "strip symbols             ${stripping-no}"
1891 echo "optimizations             ${optimizations-no}"
1892 echo "static                    ${static-no}"
1893 echo "shared                    ${shared-no}"
1894 echo "postprocessing support    ${postproc-no}"
1895 echo "software scaler enabled   ${swscale-no}"
1896 echo "new filter support        ${avfilter-no}"
1897 echo "filters using lavformat   ${avfilter_lavf-no}"
1898 echo "video hooking             ${vhook-no}"
1899 if enabled vhook; then
1900     echo "Imlib2 support            ${imlib2-no}"
1901     echo "FreeType support          ${freetype2-no}"
1902 fi
1903 echo "network support           ${network-no}"
1904 if enabled network; then
1905     echo "IPv6 support              ${ipv6-no}"
1906 fi
1907 echo "threading support         ${thread_type-no}"
1908 echo "SDL support               ${sdl-no}"
1909 if enabled sdl_too_old; then
1910     echo "-> Your SDL version is too old - please upgrade to have FFplay/SDL support."
1911 fi
1912 echo "Sun medialib support      ${mlib-no}"
1913 echo "AVISynth enabled          ${avisynth-no}"
1914 echo "liba52 support            ${liba52-no}"
1915 echo "liba52 dlopened           ${liba52bin-no}"
1916 echo "libamr-nb support         ${libamr_nb-no}"
1917 echo "libamr-wb support         ${libamr_wb-no}"
1918 echo "libdc1394 support         ${libdc1394-no}"
1919 echo "libdirac enabled          ${libdirac-no}"
1920 echo "libfaac enabled           ${libfaac-no}"
1921 echo "libfaad enabled           ${libfaad-no}"
1922 echo "libfaad dlopened          ${libfaadbin-no}"
1923 echo "libgsm enabled            ${libgsm-no}"
1924 echo "libmp3lame enabled        ${libmp3lame-no}"
1925 echo "libnut enabled            ${libnut-no}"
1926 echo "libtheora enabled         ${libtheora-no}"
1927 echo "libvorbis enabled         ${libvorbis-no}"
1928 echo "x264 enabled              ${libx264-no}"
1929 echo "XviD enabled              ${libxvid-no}"
1930 echo "zlib enabled              ${zlib-no}"
1931 echo
1932
1933 for type in decoder encoder parser demuxer muxer protocol filter bsf indev outdev; do
1934     echo "Enabled ${type}s:"
1935     eval list=\$$(toupper $type)_LIST
1936     for part in $list; do
1937         enabled $part && echo ${part%_*}
1938     done | sort | pr -3 -t
1939     echo
1940 done
1941
1942 enabled nonfree &&
1943     echo "License: unredistributable" ||
1944     (enabled gpl &&
1945         echo "License: GPL" ||
1946         echo "License: LGPL")
1947
1948 echo "Creating config.mak and config.h..."
1949
1950 echo "# Automatically generated by configure - do not modify!" > config.mak
1951 echo "/* Automatically generated by configure - do not modify! */" > $TMPH
1952 echo "#ifndef FFMPEG_CONFIG_H" >> $TMPH
1953 echo "#define FFMPEG_CONFIG_H" >> $TMPH
1954 echo "#define FFMPEG_CONFIGURATION \"$FFMPEG_CONFIGURATION\"" >> $TMPH
1955
1956 echo "PREFIX=$prefix" >> config.mak
1957 echo "prefix=\$(DESTDIR)\$(PREFIX)" >> config.mak
1958 echo "LIBDIR=\$(DESTDIR)$libdir" >> config.mak
1959 echo "SHLIBDIR=\$(DESTDIR)$shlibdir" >> config.mak
1960 echo "INCDIR=\$(DESTDIR)$incdir" >> config.mak
1961 echo "BINDIR=\$(DESTDIR)$bindir" >> config.mak
1962 echo "MANDIR=\$(DESTDIR)$mandir" >> config.mak
1963 echo "CC=$cc" >> config.mak
1964 echo "AR=$ar" >> config.mak
1965 echo "RANLIB=$ranlib" >> config.mak
1966 echo "LN_S=$ln_s" >> config.mak
1967 enabled stripping &&
1968     echo "STRIP=$strip" >> config.mak ||
1969     echo "STRIP=echo ignoring strip" >> config.mak
1970
1971 echo "OPTFLAGS=$CFLAGS" >> config.mak
1972 echo "VHOOKCFLAGS=$VHOOKCFLAGS">>config.mak
1973 echo "LDFLAGS=$LDFLAGS" >> config.mak
1974 echo "FFSERVERLDFLAGS=$FFSERVERLDFLAGS" >> config.mak
1975 echo "SHFLAGS=$SHFLAGS" >> config.mak
1976 echo "VHOOKSHFLAGS=$VHOOKSHFLAGS" >> config.mak
1977 echo "VHOOKLIBS=$VHOOKLIBS" >> config.mak
1978 echo "LIBOBJFLAGS=$LIBOBJFLAGS" >> config.mak
1979 echo "BUILD_STATIC=$static" >> config.mak
1980 echo "BUILDSUF=$build_suffix" >> config.mak
1981 echo "FULLNAME=$FULLNAME" >> config.mak
1982 echo "LIBPREF=$LIBPREF" >> config.mak
1983 echo "LIBSUF=$LIBSUF" >> config.mak
1984 echo "LIBNAME=$LIBNAME" >> config.mak
1985 echo "SLIBPREF=$SLIBPREF" >> config.mak
1986 echo "SLIBSUF=$SLIBSUF" >> config.mak
1987 echo "EXESUF=$EXESUF" >> config.mak
1988 echo "DEPEND_CMD=$DEPEND_CMD" >> config.mak
1989
1990 if enabled bigendian; then
1991     echo "WORDS_BIGENDIAN=yes" >> config.mak
1992     echo "#define WORDS_BIGENDIAN 1" >> $TMPH
1993 fi
1994
1995 if enabled sdl; then
1996     echo "SDL_LIBS=`"${SDL_CONFIG}" --libs`" >> config.mak
1997     echo "SDL_CFLAGS=`"${SDL_CONFIG}" --cflags`" >> config.mak
1998 fi
1999 if enabled texi2html; then
2000     echo "BUILD_DOC=yes" >> config.mak
2001 fi
2002
2003 get_version(){
2004     name=$1
2005     file=$source_path/$2
2006     eval $(grep "#define ${name}_VERSION_M" "$file" | awk '{ print $2"="$3 }')
2007     eval ${name}_VERSION=\$${name}_VERSION_MAJOR.\$${name}_VERSION_MINOR.\$${name}_VERSION_MICRO
2008     lcname=$(tolower $name)
2009     eval echo "${lcname}_VERSION=\$${name}_VERSION" >> config.mak
2010     eval echo "${lcname}_VERSION_MAJOR=\$${name}_VERSION_MAJOR" >> config.mak
2011 }
2012
2013 get_version LIBSWSCALE  libswscale/swscale.h
2014 get_version LIBPOSTPROC libpostproc/postprocess.h
2015 get_version LIBAVCODEC  libavcodec/avcodec.h
2016 get_version LIBAVDEVICE libavdevice/avdevice.h
2017 get_version LIBAVFORMAT libavformat/avformat.h
2018 get_version LIBAVUTIL   libavutil/avutil.h
2019 get_version LIBAVFILTER libavfilter/avfilter.h
2020
2021 if enabled shared; then
2022     echo "BUILD_SHARED=yes" >> config.mak
2023     echo "PIC=-fPIC -DPIC" >> config.mak
2024     echo "SLIBNAME=${SLIBNAME}" >> config.mak
2025     echo "SLIBNAME_WITH_VERSION=${SLIBNAME_WITH_VERSION}" >> config.mak
2026     echo "SLIBNAME_WITH_MAJOR=${SLIBNAME_WITH_MAJOR}" >> config.mak
2027     echo "SLIB_CREATE_DEF_CMD=${SLIB_CREATE_DEF_CMD}" >> config.mak
2028     echo "SLIB_EXTRA_CMD=${SLIB_EXTRA_CMD}" >> config.mak
2029     echo "SLIB_INSTALL_EXTRA_CMD=${SLIB_INSTALL_EXTRA_CMD}" >> config.mak
2030     echo "SLIB_UNINSTALL_EXTRA_CMD=${SLIB_UNINSTALL_EXTRA_CMD}" >> config.mak
2031 fi
2032 echo "LIB_INSTALL_EXTRA_CMD=${LIB_INSTALL_EXTRA_CMD}" >> config.mak
2033 echo "EXTRALIBS=$extralibs" >> config.mak
2034
2035 print_config ARCH_   $TMPH config.mak $ARCH_LIST
2036 print_config HAVE_   $TMPH config.mak $HAVE_LIST
2037 print_config CONFIG_ $TMPH config.mak $CONFIG_LIST       \
2038                                       $DECODER_LIST      \
2039                                       $ENCODER_LIST      \
2040                                       $PARSER_LIST       \
2041                                       $BSF_LIST          \
2042                                       $DEMUXER_LIST      \
2043                                       $MUXER_LIST        \
2044                                       $FILTER_LIST       \
2045                                       $PROTOCOL_LIST     \
2046                                       $INDEV_LIST        \
2047                                       $OUTDEV_LIST       \
2048
2049 echo "#define restrict $_restrict" >> $TMPH
2050
2051 if enabled small; then
2052     echo "#define av_always_inline"  >> $TMPH
2053 fi
2054
2055 echo "SRC_PATH=\"$source_path\"" >> config.mak
2056 echo "SRC_PATH_BARE=$source_path" >> config.mak
2057 echo "BUILD_ROOT=\"$PWD\"" >> config.mak
2058
2059 # Apparently it's not possible to portably echo a backslash.
2060 enabled asmalign_pot &&
2061     printf '#define ASMALIGN(ZEROBITS) ".align " #ZEROBITS "\\n\\t"\n' >> $TMPH ||
2062     printf '#define ASMALIGN(ZEROBITS) ".align 1<<" #ZEROBITS "\\n\\t"\n' >> $TMPH
2063
2064 echo "#define EXTERN_PREFIX \"${extern_prefix}\"" >> $TMPH
2065
2066 echo "#endif /* FFMPEG_CONFIG_H */" >> $TMPH
2067
2068 # Do not overwrite an unchanged config.h to avoid superfluous rebuilds.
2069 cmp -s $TMPH config.h &&
2070     echo "config.h is unchanged" ||
2071     mv -f $TMPH config.h
2072
2073 rm -f $TMPC $TMPE $TMPH $TMPO $TMPS $TMPSH
2074
2075 # build tree in object directory if source path is different from current one
2076 if enabled source_path_used; then
2077     DIRS="\
2078         doc               \
2079         libavcodec        \
2080         libavcodec/alpha  \
2081         libavcodec/armv4l \
2082         libavcodec/bfin   \
2083         libavcodec/i386   \
2084         libavcodec/mlib   \
2085         libavcodec/ppc    \
2086         libavcodec/sh4    \
2087         libavcodec/sparc  \
2088         libavdevice       \
2089         libavfilter       \
2090         libavformat       \
2091         libavutil         \
2092         libpostproc       \
2093         libswscale        \
2094         tests             \
2095         tools             \
2096         vhook             \
2097         "
2098     FILES="\
2099         Makefile             \
2100         common.mak           \
2101         subdir.mak           \
2102         doc/texi2pod.pl      \
2103         libavcodec/Makefile  \
2104         libavdevice/Makefile \
2105         libavfilter/Makefile \
2106         libavformat/Makefile \
2107         libavutil/Makefile   \
2108         libpostproc/Makefile \
2109         libswscale/Makefile  \
2110         "
2111     for dir in $DIRS ; do
2112         mkdir -p $dir
2113     done
2114     for f in $FILES ; do
2115         $ln_s "$source_path/$f" $f
2116     done
2117 fi
2118
2119
2120 # build pkg-config files
2121
2122 pkgconfig_generate(){
2123 name=$1
2124 comment=$2
2125 version=$3
2126 libs=$4
2127 requires=$5
2128 cat <<EOF >$name.pc
2129 prefix=$prefix
2130 exec_prefix=\${prefix}
2131 libdir=$libdir
2132 includedir=$incdir
2133
2134 Name: $name
2135 Description: $comment
2136 Version: $version
2137 Requires: $requires
2138 Conflicts:
2139 Libs: -L\${libdir} $libs
2140 Cflags: -I\${includedir}
2141 EOF
2142 }
2143
2144 pkgconfig_generate_uninstalled(){
2145 name=$1
2146 shortname=${name#lib}
2147 comment=$2
2148 version=$3
2149 libs=$4
2150 requires=$5
2151 cat <<EOF >$name-uninstalled.pc
2152 prefix=
2153 exec_prefix=
2154 libdir=\${pcfiledir}/$name
2155 includedir=\${pcfiledir}
2156
2157 Name: $name
2158 Description: $comment
2159 Version: $version
2160 Requires: $requires
2161 Conflicts:
2162 Libs: \${libdir}/${LIBPREF}${shortname}${LIBSUF} $libs
2163 Cflags: -I\${includedir}
2164 EOF
2165 }
2166
2167 pkgconfig_generate libavutil "FFmpeg utility library" "$LIBAVUTIL_VERSION" -lavutil ""
2168 pkgconfig_generate_uninstalled libavutil "FFmpeg utility library" "$LIBAVUTIL_VERSION"
2169
2170 pkgconfig_generate libavcodec "FFmpeg codec library" "$LIBAVCODEC_VERSION" "-lavcodec $extralibs" "$pkg_requires libavutil = $LIBAVUTIL_VERSION"
2171 pkgconfig_generate_uninstalled libavcodec "FFmpeg codec library" "$LIBAVCODEC_VERSION" "$extralibs" "$pkg_requires libavutil = $LIBAVUTIL_VERSION"
2172
2173 pkgconfig_generate libavformat "FFmpeg container format library" "$LIBAVFORMAT_VERSION" "-lavformat $extralibs" "$pkg_requires libavcodec = $LIBAVCODEC_VERSION"
2174 pkgconfig_generate_uninstalled libavformat "FFmpeg container format library" "$LIBAVFORMAT_VERSION" "$extralibs" "$pkg_requires libavcodec = $LIBAVCODEC_VERSION"
2175
2176 pkgconfig_generate libavdevice "FFmpeg device handling library" "$LIBAVDEVICE_VERSION" "-lavdevice $extralibs" "$pkg_requires libavformat = $LIBAVFORMAT_VERSION"
2177 pkgconfig_generate_uninstalled libavdevice "FFmpeg device handling library" "$LIBAVDEVICE_VERSION" "$extralibs" "$pkg_requires libavformat = $LIBAVFORMAT_VERSION"
2178 if enabled postproc; then
2179     pkgconfig_generate libpostproc "FFmpeg post processing library" "$LIBPOSTPROC_VERSION" -lpostproc ""
2180     pkgconfig_generate_uninstalled libpostproc "FFmpeg post processing library" "$LIBPOSTPROC_VERSION"
2181 fi
2182
2183 if enabled swscale; then
2184     pkgconfig_generate libswscale "FFmpeg image rescaling library" "$LIBSWSCALE_VERSION" -lswscale "libavutil = $LIBAVUTIL_VERSION"
2185     pkgconfig_generate_uninstalled libswscale "FFmpeg image rescaling library" "$LIBSWSCALE_VERSION" "" "libavutil = $LIBAVUTIL_VERSION"
2186 else
2187     pkgconfig_generate libswscale "FFmpeg image rescaling library" "$LIBSWSCALE_VERSION" "" "$pkg_requires libavcodec = $LIBAVCODEC_VERSION"
2188     pkgconfig_generate_uninstalled libswscale "FFmpeg image rescaling library" "$LIBSWSCALE_VERSION" "" "$pkg_requires libavcodec = $LIBAVCODEC_VERSION"
2189     apply libswscale.pc sed s/^Libs:.*$/Libs:/
2190     apply libswscale-uninstalled.pc sed s/^Libs:.*$/Libs:/
2191 fi
2192
2193 if enabled avfilter; then
2194   pkgconfig_generate libavfilter "FFmpeg video filtering library" "$LIBAVFILTER_VERSION" "-lavfilter $extralibs" "$pkg_requires libavutil = $LIBAVUTIL_VERSION" ffmpeg
2195   pkgconfig_generate_uninstalled libavfilter "FFmpeg video filtering library" "$LIBAVFILTER_VERSION" "$extralibs" "$pkg_requires libavutil = $LIBAVUTIL_VERSION"
2196 fi