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