Use table to speedup access to non_zero_count in MBAFF with differing interlacing.
[libav.git] / configure
1 #!/bin/sh
2 #
3 # FFmpeg configure script
4 #
5 # Copyright (c) 2000-2002 Fabrice Bellard
6 # Copyright (c) 2005-2008 Diego Biurrun
7 # Copyright (c) 2005-2008 Mans Rullgard
8 #
9
10 # Prevent locale nonsense from breaking basic text processing.
11 LC_ALL=C
12 export LC_ALL
13
14 # make sure we are running under a compatible shell
15 # try to make this part work with most shells
16
17 try_exec(){
18 echo "Trying shell $1"
19 type "$1" > /dev/null 2>&1 && exec "$@"
20 }
21
22 unset foo
23 (: ${foo%%bar}) 2> /dev/null
24 E1="$?"
25
26 (: ${foo?}) 2> /dev/null
27 E2="$?"
28
29 if test "$E1" != 0 || test "$E2" = 0; then
30 echo "Broken shell detected. Trying alternatives."
31 export FF_CONF_EXEC
32 if test "0$FF_CONF_EXEC" -lt 1; then
33 FF_CONF_EXEC=1
34 try_exec bash "$0" "$@"
35 fi
36 if test "0$FF_CONF_EXEC" -lt 2; then
37 FF_CONF_EXEC=2
38 try_exec ksh "$0" "$@"
39 fi
40 if test "0$FF_CONF_EXEC" -lt 3; then
41 FF_CONF_EXEC=3
42 try_exec /usr/xpg4/bin/sh "$0" "$@"
43 fi
44 echo "No compatible shell script interpreter found."
45 echo "This configure script requires a POSIX-compatible shell"
46 echo "such as bash or ksh."
47 echo "THIS IS NOT A BUG IN FFMPEG, DO NOT REPORT IT AS SUCH."
48 echo "Instead, install a working POSIX-compatible shell."
49 echo "Disabling this configure test will create a broken FFmpeg."
50 if test "$BASH_VERSION" = '2.04.0(1)-release'; then
51 echo "This bash version ($BASH_VERSION) is broken on your platform."
52 echo "Upgrade to a later version if available."
53 fi
54 exit 1
55 fi
56
57 show_help(){
58 cat <<EOF
59 Usage: configure [options]
60 Options: [defaults in brackets after descriptions]
61
62 Standard options:
63 --help print this message
64 --logfile=FILE log tests and output to FILE [config.err]
65 --disable-logging do not log configure debug information
66 --prefix=PREFIX install in PREFIX [$prefix]
67 --bindir=DIR install binaries in DIR [PREFIX/bin]
68 --datadir=DIR install data files in DIR [PREFIX/share/ffmpeg]
69 --libdir=DIR install libs in DIR [PREFIX/lib]
70 --shlibdir=DIR install shared libs in DIR [PREFIX/lib]
71 --incdir=DIR install includes in DIR [PREFIX/include]
72 --mandir=DIR install man page in DIR [PREFIX/share/man]
73
74 Configuration options:
75 --disable-static do not build static libraries [no]
76 --enable-shared build shared libraries [no]
77 --enable-gpl allow use of GPL code, the resulting libs
78 and binaries will be under GPL [no]
79 --enable-version3 upgrade (L)GPL to version 3 [no]
80 --enable-nonfree allow use of nonfree code, the resulting libs
81 and binaries will be unredistributable [no]
82 --disable-doc do not build documentation
83 --disable-ffmpeg disable ffmpeg build
84 --disable-ffplay disable ffplay build
85 --disable-ffserver disable ffserver build
86 --disable-avdevice disable libavdevice build
87 --disable-avcodec disable libavcodec build
88 --disable-avformat disable libavformat build
89 --disable-swscale disable libswscale build
90 --enable-postproc enable GPLed postprocessing support [no]
91 --enable-avfilter video filter support [no]
92 --enable-avfilter-lavf video filters dependent on avformat [no]
93 --enable-beosthreads use BeOS threads [no]
94 --enable-os2threads use OS/2 threads [no]
95 --enable-pthreads use pthreads [no]
96 --enable-w32threads use Win32 threads [no]
97 --enable-x11grab enable X11 grabbing [no]
98 --disable-network disable network support [no]
99 --disable-mpegaudio-hp faster (but less accurate) MPEG audio decoding [no]
100 --enable-gray enable full grayscale support (slower color)
101 --disable-swscale-alpha disable alpha channel support in swscale
102 --disable-fastdiv disable table-based division
103 --enable-small optimize for size instead of speed
104 --disable-aandct disable AAN DCT code
105 --disable-dct disable DCT code
106 --disable-fft disable FFT code
107 --disable-golomb disable Golomb code
108 --disable-lpc disable LPC code
109 --disable-mdct disable MDCT code
110 --disable-rdft disable RDFT code
111 --disable-vaapi disable VAAPI code
112 --disable-vdpau disable VDPAU code
113 --disable-dxva2 disable DXVA2 code
114 --enable-runtime-cpudetect detect cpu capabilities at runtime (bigger binary)
115 --enable-hardcoded-tables use hardcoded tables instead of runtime generation
116 --enable-memalign-hack emulate memalign, interferes with memory debuggers
117 --enable-beos-netserver enable BeOS netserver
118 --disable-encoder=NAME disable encoder NAME
119 --enable-encoder=NAME enable encoder NAME
120 --disable-encoders disable all encoders
121 --disable-decoder=NAME disable decoder NAME
122 --enable-decoder=NAME enable decoder NAME
123 --disable-decoders disable all decoders
124 --disable-hwaccel=NAME disable hwaccel NAME
125 --enable-hwaccel=NAME enable hwaccel NAME
126 --disable-hwaccels disable all hwaccels
127 --disable-muxer=NAME disable muxer NAME
128 --enable-muxer=NAME enable muxer NAME
129 --disable-muxers disable all muxers
130 --disable-demuxer=NAME disable demuxer NAME
131 --enable-demuxer=NAME enable demuxer NAME
132 --disable-demuxers disable all demuxers
133 --enable-parser=NAME enable parser NAME
134 --disable-parser=NAME disable parser NAME
135 --disable-parsers disable all parsers
136 --enable-bsf=NAME enable bitstream filter NAME
137 --disable-bsf=NAME disable bitstream filter NAME
138 --disable-bsfs disable all bitstream filters
139 --enable-protocol=NAME enable protocol NAME
140 --disable-protocol=NAME disable protocol NAME
141 --disable-protocols disable all protocols
142 --disable-indev=NAME disable input device NAME
143 --disable-outdev=NAME disable output device NAME
144 --disable-indevs disable input devices
145 --disable-outdevs disable output devices
146 --disable-devices disable all devices
147 --enable-filter=NAME enable filter NAME
148 --disable-filter=NAME disable filter NAME
149 --disable-filters disable all filters
150 --list-decoders show all available decoders
151 --list-encoders show all available encoders
152 --list-hwaccels show all available hardware accelerators
153 --list-muxers show all available muxers
154 --list-demuxers show all available demuxers
155 --list-parsers show all available parsers
156 --list-protocols show all available protocols
157 --list-bsfs show all available bitstream filters
158 --list-indevs show all available input devices
159 --list-outdevs show all available output devices
160 --list-filters show all available filters
161
162 External library support:
163 --enable-avisynth enable reading of AVISynth script files [no]
164 --enable-bzlib enable bzlib [autodetect]
165 --enable-libopencore-amrnb enable AMR-NB de/encoding via libopencore-amrnb [no]
166 --enable-libopencore-amrwb enable AMR-WB decoding via libopencore-amrwb [no]
167 --enable-libdc1394 enable IIDC-1394 grabbing using libdc1394
168 and libraw1394 [no]
169 --enable-libdirac enable Dirac support via libdirac [no]
170 --enable-libfaac enable FAAC support via libfaac [no]
171 --enable-libfaad enable FAAD support via libfaad [no]
172 --enable-libfaadbin open libfaad.so.0 at runtime [no]
173 --enable-libgsm enable GSM support via libgsm [no]
174 --enable-libmp3lame enable MP3 encoding via libmp3lame [no]
175 --enable-libnut enable NUT (de)muxing via libnut,
176 native (de)muxer exists [no]
177 --enable-libopenjpeg enable JPEG 2000 decoding via OpenJPEG [no]
178 --enable-libschroedinger enable Dirac support via libschroedinger [no]
179 --enable-libspeex enable Speex decoding via libspeex [no]
180 --enable-libtheora enable Theora encoding via libtheora [no]
181 --enable-libvorbis enable Vorbis encoding via libvorbis,
182 native implementation exists [no]
183 --enable-libx264 enable H.264 encoding via x264 [no]
184 --enable-libxvid enable Xvid encoding via xvidcore,
185 native MPEG-4/Xvid encoder exists [no]
186 --enable-mlib enable Sun medialib [no]
187 --enable-zlib enable zlib [autodetect]
188
189 Advanced options (experts only):
190 --source-path=PATH path to source code [$source_path]
191 --cross-prefix=PREFIX use PREFIX for compilation tools [$cross_prefix]
192 --enable-cross-compile assume a cross-compiler is used
193 --sysroot=PATH root of cross-build tree
194 --sysinclude=PATH location of cross-build system headers
195 --target-os=OS compiler targets OS [$target_os]
196 --target-exec=CMD command to run executables on target
197 --target-path=DIR path to view of build directory on target
198 --nm=NM use nm tool
199 --as=AS use assembler AS [$as_default]
200 --cc=CC use C compiler CC [$cc_default]
201 --ld=LD use linker LD
202 --host-cc=HOSTCC use host C compiler HOSTCC
203 --host-cflags=HCFLAGS use HCFLAGS when compiling for host
204 --host-ldflags=HLDFLAGS use HLDFLAGS when linking for host
205 --host-libs=HLIBS use libs HLIBS when linking for host
206 --extra-cflags=ECFLAGS add ECFLAGS to CFLAGS [$CFLAGS]
207 --extra-ldflags=ELDFLAGS add ELDFLAGS to LDFLAGS [$LDFLAGS]
208 --extra-libs=ELIBS add ELIBS [$ELIBS]
209 --extra-version=STRING version string suffix []
210 --build-suffix=SUFFIX library name suffix []
211 --arch=ARCH select architecture [$arch]
212 --cpu=CPU select the minimum required CPU (affects
213 instruction selection, may crash on older CPUs)
214 --enable-powerpc-perf enable performance report on PPC
215 (requires enabling PMC)
216 --disable-asm disable all assembler optimizations
217 --disable-altivec disable AltiVec optimizations
218 --disable-amd3dnow disable 3DNow! optimizations
219 --disable-amd3dnowext disable 3DNow! extended optimizations
220 --disable-mmx disable MMX optimizations
221 --disable-mmx2 disable MMX2 optimizations
222 --disable-sse disable SSE optimizations
223 --disable-ssse3 disable SSSE3 optimizations
224 --disable-armv5te disable armv5te optimizations
225 --disable-armv6 disable armv6 optimizations
226 --disable-armv6t2 disable armv6t2 optimizations
227 --disable-armvfp disable ARM VFP optimizations
228 --disable-iwmmxt disable iwmmxt optimizations
229 --disable-mmi disable MMI optimizations
230 --disable-neon disable neon optimizations
231 --disable-vis disable VIS optimizations
232 --disable-yasm disable use of yasm assembler
233 --enable-pic build position-independent code
234
235 Developer options (useful when working on FFmpeg itself):
236 --disable-debug disable debugging symbols
237 --enable-debug=LEVEL set the debug level [$debuglevel]
238 --enable-gprof enable profiling with gprof [$gprof]
239 --disable-optimizations disable compiler optimizations
240 --enable-extra-warnings enable more compiler warnings
241 --disable-stripping disable stripping of executables and shared libraries
242
243 NOTE: Object files are built at the place where configure is launched.
244 EOF
245 exit 0
246 }
247
248 log(){
249 echo "$@" >> $logfile
250 }
251
252 log_file(){
253 log BEGIN $1
254 pr -n -t $1 >> $logfile
255 log END $1
256 }
257
258 echolog(){
259 log "$@"
260 echo "$@"
261 }
262
263 die(){
264 echolog "$@"
265 cat <<EOF
266
267 If you think configure made a mistake, make sure you are using the latest
268 version from SVN. If the latest version fails, report the problem to the
269 ffmpeg-user@mplayerhq.hu mailing list or IRC #ffmpeg on irc.freenode.net.
270 EOF
271 if disabled logging; then
272 cat <<EOF
273 Rerun configure with logging enabled (do not use --disable-logging), and
274 include the log this produces with your report.
275 EOF
276 else
277 cat <<EOF
278 Include the log file "$logfile" produced by configure as this will help
279 solving the problem.
280 EOF
281 fi
282 exit 1
283 }
284
285 # Avoid locale weirdness, besides we really just want to translate ASCII.
286 toupper(){
287 echo "$@" | tr abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ
288 }
289
290 tolower(){
291 echo "$@" | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz
292 }
293
294 c_escape(){
295 echo "$*" | sed 's/["\\]/\\\0/g'
296 }
297
298 sh_quote(){
299 v=$(echo "$1" | sed "s/'/'\\\\''/g")
300 test "$v" = "${v#*[ |&;<>()$\`\\\"\'*?\[\]#~=%]}" || v="'$v'"
301 echo "$v"
302 }
303
304 filter(){
305 pat=$1
306 shift
307 for v; do
308 eval "case $v in $pat) echo $v ;; esac"
309 done
310 }
311
312 set_all(){
313 value=$1
314 shift
315 for var in $*; do
316 eval $var=$value
317 done
318 }
319
320 set_weak(){
321 value=$1
322 shift
323 for var; do
324 eval : \${$var:=$value}
325 done
326 }
327
328 pushvar(){
329 for var in $*; do
330 eval level=\${${var}_level:=0}
331 eval ${var}_${level}="\$$var"
332 eval ${var}_level=$(($level+1))
333 done
334 }
335
336 popvar(){
337 for var in $*; do
338 eval level=\${${var}_level:-0}
339 test $level = 0 && continue
340 eval level=$(($level-1))
341 eval $var="\${${var}_${level}}"
342 eval ${var}_level=$level
343 eval unset ${var}_${level}
344 done
345 }
346
347 enable(){
348 set_all yes $*
349 }
350
351 disable(){
352 set_all no $*
353 }
354
355 enable_weak(){
356 set_weak yes $*
357 }
358
359 disable_weak(){
360 set_weak no $*
361 }
362
363 enable_safe(){
364 for var; do
365 enable $(echo "$var" | sed 's/[^A-Za-z0-9_]/_/g')
366 done
367 }
368
369 disable_safe(){
370 for var; do
371 disable $(echo "$var" | sed 's/[^A-Za-z0-9_]/_/g')
372 done
373 }
374
375 do_enable_deep(){
376 for var; do
377 enabled $var && continue
378 eval sel="\$${var}_select"
379 eval sgs="\$${var}_suggest"
380 pushvar var sgs
381 enable_deep $sel
382 popvar sgs
383 enable_deep_weak $sgs
384 popvar var
385 done
386 }
387
388 enable_deep(){
389 do_enable_deep $*
390 enable $*
391 }
392
393 enable_deep_weak(){
394 do_enable_deep $*
395 enable_weak $*
396 }
397
398 enabled(){
399 test "${1#!}" = "$1" && op== || op=!=
400 eval test "x\$${1#!}" $op "xyes"
401 }
402
403 disabled(){
404 test "${1#!}" = "$1" && op== || op=!=
405 eval test "x\$${1#!}" $op "xno"
406 }
407
408 enabled_all(){
409 for opt; do
410 enabled $opt || return 1
411 done
412 }
413
414 disabled_all(){
415 for opt; do
416 disabled $opt || return 1
417 done
418 }
419
420 enabled_any(){
421 for opt; do
422 enabled $opt && return 0
423 done
424 }
425
426 disabled_any(){
427 for opt; do
428 disabled $opt && return 0
429 done
430 return 1
431 }
432
433 set_default(){
434 for opt; do
435 eval : \${$opt:=\$${opt}_default}
436 done
437 }
438
439 is_in(){
440 value=$1
441 shift
442 for var in $*; do
443 [ $var = $value ] && return 0
444 done
445 return 1
446 }
447
448 check_deps(){
449 for cfg; do
450 cfg="${cfg#!}"
451 enabled ${cfg}_checking && die "Circular dependency for $cfg."
452 disabled ${cfg}_checking && continue
453 enable ${cfg}_checking
454
455 eval dep_all="\$${cfg}_deps"
456 eval dep_any="\$${cfg}_deps_any"
457 eval dep_sel="\$${cfg}_select"
458 eval dep_sgs="\$${cfg}_suggest"
459 eval dep_ifa="\$${cfg}_if"
460 eval dep_ifn="\$${cfg}_if_any"
461
462 pushvar cfg dep_all dep_any dep_sel dep_sgs dep_ifa dep_ifn
463 check_deps $dep_all $dep_any $dep_sel $dep_sgs $dep_ifa $dep_ifn
464 popvar cfg dep_all dep_any dep_sel dep_sgs dep_ifa dep_ifn
465
466 [ -n "$dep_ifa" ] && { enabled_all $dep_ifa && enable_weak $cfg; }
467 [ -n "$dep_ifn" ] && { enabled_any $dep_ifn && enable_weak $cfg; }
468 enabled_all $dep_all || disable $cfg
469 enabled_any $dep_any || disable $cfg
470 disabled_any $dep_sel && disable $cfg
471
472 if enabled $cfg; then
473 eval dep_extralibs="\$${cfg}_extralibs"
474 test -n "$dep_extralibs" && add_extralibs $dep_extralibs
475 enable_deep $dep_sel
476 enable_deep_weak $dep_sgs
477 fi
478
479 disable ${cfg}_checking
480 done
481 }
482
483 print_config(){
484 pfx=$1
485 header=$2
486 makefile=$3
487 shift 3
488 for cfg; do
489 ucname="$(toupper $cfg)"
490 if enabled $cfg; then
491 echo "#define ${pfx}${ucname} 1" >> $header
492 echo "${pfx}${ucname}=yes" >> $makefile
493 else
494 echo "#define ${pfx}${ucname} 0" >> $header
495 echo "!${pfx}${ucname}=yes" >> $makefile
496 fi
497 done
498 }
499
500 flags_saved(){
501 (: ${SAVE_CFLAGS?}) 2> /dev/null
502 }
503
504 save_flags(){
505 flags_saved && return
506 SAVE_CFLAGS="$CFLAGS"
507 SAVE_LDFLAGS="$LDFLAGS"
508 SAVE_extralibs="$extralibs"
509 }
510
511 restore_flags(){
512 flags_saved || return
513 CFLAGS="$SAVE_CFLAGS"
514 LDFLAGS="$SAVE_LDFLAGS"
515 extralibs="$SAVE_extralibs"
516 unset SAVE_CFLAGS
517 unset SAVE_LDFLAGS
518 unset SAVE_extralibs
519 }
520
521 temp_cflags(){
522 save_flags
523 CFLAGS="$CFLAGS $*"
524 }
525
526 temp_ldflags(){
527 save_flags
528 LDFLAGS="$LDFLAGS $*"
529 }
530
531 temp_extralibs(){
532 save_flags
533 extralibs="$extralibs $*"
534 }
535
536 append(){
537 var=$1
538 shift
539 flags_saved && eval "SAVE_$var=\"\$SAVE_$var $*\""
540 eval "$var=\"\$$var $*\""
541 }
542
543 add_cppflags(){
544 append CPPFLAGS $($filter_cppflags "$@")
545 }
546
547 add_cflags(){
548 append CFLAGS $($filter_cflags "$@")
549 }
550
551 add_asflags(){
552 append ASFLAGS $($filter_asflags "$@")
553 }
554
555 add_ldflags(){
556 append LDFLAGS "$@"
557 }
558
559 add_extralibs(){
560 append extralibs "$@"
561 }
562
563 check_cmd(){
564 log "$@"
565 "$@" >> $logfile 2>&1
566 }
567
568 check_cc(){
569 log check_cc "$@"
570 cat > $TMPC
571 log_file $TMPC
572 check_cmd $cc $CPPFLAGS $CFLAGS "$@" -c -o $TMPO $TMPC
573 }
574
575 check_cpp(){
576 log check_cpp "$@"
577 cat > $TMPC
578 log_file $TMPC
579 check_cmd $cc $CPPFLAGS $CFLAGS "$@" -E -o $TMPO $TMPC
580 }
581
582 check_as(){
583 log check_as "$@"
584 cat > $TMPC
585 log_file $TMPC
586 check_cmd $as $CPPFLAGS $ASFLAGS "$@" -c -o $TMPO $TMPC
587 }
588
589 check_asm(){
590 log check_asm "$@"
591 name="$1"
592 code="$2"
593 shift 2
594 disable $name
595 check_as "$@" <<EOF && enable $name
596 void foo(void){ __asm__ volatile($code); }
597 EOF
598 }
599
600 check_yasm(){
601 log check_yasm "$@"
602 echo "$1" > $TMPS
603 log_file $TMPS
604 shift 1
605 check_cmd $yasmexe $YASMFLAGS "$@" -o $TMPO $TMPS
606 }
607
608 check_ld(){
609 log check_ld "$@"
610 flags=''
611 libs=''
612 for f; do
613 test "${f}" = "${f#-l}" && flags="$flags $f" || libs="$libs $f"
614 done
615 check_cc $($filter_cflags $flags) || return
616 check_cmd $ld $LDFLAGS $flags -o $TMPE $TMPO $extralibs $libs
617 }
618
619 check_cppflags(){
620 log check_cppflags "$@"
621 set -- $($filter_cppflags "$@")
622 check_cc "$@" <<EOF && append CPPFLAGS "$@"
623 int x;
624 EOF
625 }
626
627 check_cflags(){
628 log check_cflags "$@"
629 set -- $($filter_cflags "$@")
630 check_cc "$@" <<EOF && append CFLAGS "$@"
631 int x;
632 EOF
633 }
634
635 test_ldflags(){
636 log test_ldflags "$@"
637 check_ld "$@" <<EOF
638 int main(void){ return 0; }
639 EOF
640 }
641
642 check_ldflags(){
643 log check_ldflags "$@"
644 test_ldflags "$@" && add_ldflags "$@"
645 }
646
647 check_header(){
648 log check_header "$@"
649 header=$1
650 shift
651 disable_safe $header
652 check_cpp "$@" <<EOF && enable_safe $header
653 #include <$header>
654 int x;
655 EOF
656 }
657
658 check_func(){
659 log check_func "$@"
660 func=$1
661 shift
662 disable $func
663 check_ld "$@" <<EOF && enable $func
664 extern int $func();
665 int main(void){ $func(); }
666 EOF
667 }
668
669 check_func_headers(){
670 log check_func_headers "$@"
671 headers=$1
672 func=$2
673 shift 2
674 disable $func
675 incs=""
676 for hdr in $headers; do
677 incs="$incs
678 #include <$hdr>"
679 done
680 check_ld "$@" <<EOF && enable $func && enable_safe $headers
681 $incs
682 int main(int argc, char **argv){
683 return (long) $func;
684 }
685 EOF
686 }
687
688 check_cpp_condition(){
689 log check_cpp_condition "$@"
690 header=$1
691 condition=$2
692 shift 2
693 check_cpp $($filter_cppflags "$@") <<EOF
694 #include <$header>
695 #if !($condition)
696 #error "unsatisfied condition: $condition"
697 #endif
698 EOF
699 }
700
701 check_lib(){
702 log check_lib "$@"
703 header="$1"
704 func="$2"
705 shift 2
706 temp_extralibs "$@"
707 check_header $header && check_func $func && add_extralibs "$@"
708 err=$?
709 restore_flags
710 return $err
711 }
712
713 check_lib2(){
714 log check_lib2 "$@"
715 headers="$1"
716 func="$2"
717 shift 2
718 check_func_headers "$headers" $func "$@" && add_extralibs "$@"
719 }
720
721 check_exec(){
722 check_ld "$@" && { enabled cross_compile || $TMPE >> $logfile 2>&1; }
723 }
724
725 check_exec_crash(){
726 code=$(cat)
727
728 # exit() is not async signal safe. _Exit (C99) and _exit (POSIX)
729 # are safe but may not be available everywhere. Thus we use
730 # raise(SIGTERM) instead. The check is run in a subshell so we
731 # can redirect the "Terminated" message from the shell. SIGBUS
732 # is not defined by standard C so it is used conditionally.
733
734 (check_exec "$@") >> $logfile 2>&1 <<EOF
735 #include <signal.h>
736 static void sighandler(int sig){
737 raise(SIGTERM);
738 }
739 int main(void){
740 signal(SIGILL, sighandler);
741 signal(SIGFPE, sighandler);
742 signal(SIGSEGV, sighandler);
743 #ifdef SIGBUS
744 signal(SIGBUS, sighandler);
745 #endif
746 { $code }
747 }
748 EOF
749 }
750
751 check_type(){
752 log check_type "$@"
753 headers=$1
754 type=$2
755 shift 2
756 disable_safe "$type"
757 incs=""
758 for hdr in $headers; do
759 incs="$incs
760 #include <$hdr>"
761 done
762 check_cc "$@" <<EOF && enable_safe "$type"
763 $incs
764 $type v;
765 EOF
766 }
767
768 check_struct(){
769 log check_type "$@"
770 headers=$1
771 struct=$2
772 member=$3
773 shift 3
774 disable_safe "${struct}_${member}"
775 incs=""
776 for hdr in $headers; do
777 incs="$incs
778 #include <$hdr>"
779 done
780 check_cc "$@" <<EOF && enable_safe "${struct}_${member}"
781 $incs
782 const void *p = &(($struct *)0)->$member;
783 EOF
784 }
785
786 require(){
787 name="$1"
788 header="$2"
789 func="$3"
790 shift 3
791 check_lib $header $func "$@" || die "ERROR: $name not found"
792 }
793
794 require2(){
795 name="$1"
796 headers="$2"
797 func="$3"
798 shift 3
799 check_lib2 "$headers" $func "$@" || die "ERROR: $name not found"
800 }
801
802 check_foo_config(){
803 cfg=$1
804 pkg=$2
805 header=$3
806 func=$4
807 shift 4
808 disable $cfg
809 check_cmd ${pkg}-config --version
810 err=$?
811 if test "$err" = 0; then
812 temp_cflags $(${pkg}-config --cflags)
813 temp_extralibs $(${pkg}-config --libs)
814 check_lib "$@" $header $func && enable $cfg
815 fi
816 return $err
817 }
818
819 check_host_cc(){
820 log check_host_cc "$@"
821 cat > $TMPC
822 log_file $TMPC
823 check_cmd $host_cc $host_cflags "$@" -c -o $TMPO $TMPC
824 }
825
826 check_host_cflags(){
827 log check_host_cflags "$@"
828 check_host_cc "$@" <<EOF && append host_cflags "$@"
829 int x;
830 EOF
831 }
832
833 apply(){
834 file=$1
835 shift
836 "$@" < "$file" > "$file.tmp" && mv "$file.tmp" "$file" || rm "$file.tmp"
837 }
838
839 cp_if_changed(){
840 cmp -s "$1" "$2" &&
841 echo "$2 is unchanged" ||
842 cp -f "$1" "$2"
843 }
844
845 # CONFIG_LIST contains configurable options, while HAVE_LIST is for
846 # system-dependent things.
847
848 COMPONENT_LIST="
849 bsfs
850 decoders
851 demuxers
852 encoders
853 filters
854 hwaccels
855 indevs
856 muxers
857 outdevs
858 parsers
859 protocols
860 "
861
862 CONFIG_LIST="
863 $COMPONENT_LIST
864 aandct
865 avcodec
866 avdevice
867 avfilter
868 avfilter_lavf
869 avformat
870 avisynth
871 beos_netserver
872 bzlib
873 dct
874 doc
875 dxva2
876 fastdiv
877 ffmpeg
878 ffplay
879 ffserver
880 fft
881 golomb
882 gpl
883 gprof
884 gray
885 hardcoded_tables
886 libdc1394
887 libdirac
888 libfaac
889 libfaad
890 libfaadbin
891 libgsm
892 libmp3lame
893 libnut
894 libopencore_amrnb
895 libopencore_amrwb
896 libopenjpeg
897 libschroedinger
898 libspeex
899 libtheora
900 libvorbis
901 libx264
902 libxvid
903 lpc
904 mdct
905 memalign_hack
906 mlib
907 mpegaudio_hp
908 network
909 nonfree
910 pic
911 postproc
912 powerpc_perf
913 rdft
914 runtime_cpudetect
915 shared
916 small
917 static
918 swscale
919 swscale_alpha
920 vaapi
921 vdpau
922 version3
923 x11grab
924 zlib
925 "
926
927 THREADS_LIST='
928 beosthreads
929 os2threads
930 pthreads
931 w32threads
932 '
933
934 ARCH_LIST='
935 alpha
936 arm
937 avr32
938 avr32_ap
939 avr32_uc
940 bfin
941 ia64
942 m68k
943 mips
944 mips64
945 parisc
946 ppc
947 ppc64
948 s390
949 sh4
950 sparc
951 sparc64
952 x86
953 x86_32
954 x86_64
955 '
956
957 ARCH_EXT_LIST='
958 altivec
959 amd3dnow
960 amd3dnowext
961 armv5te
962 armv6
963 armv6t2
964 armvfp
965 iwmmxt
966 mmi
967 mmx
968 mmx2
969 neon
970 ppc4xx
971 sse
972 ssse3
973 vis
974 '
975
976 HAVE_LIST_PUB='
977 bigendian
978 '
979
980 HAVE_LIST="
981 $ARCH_EXT_LIST
982 $HAVE_LIST_PUB
983 $THREADS_LIST
984 alsa_asoundlib_h
985 altivec_h
986 arpa_inet_h
987 attribute_packed
988 bswap
989 closesocket
990 cmov
991 conio_h
992 dcbzl
993 dev_bktr_ioctl_bt848_h
994 dev_bktr_ioctl_meteor_h
995 dev_ic_bt8xx_h
996 dev_video_meteor_ioctl_meteor_h
997 dev_video_bktr_ioctl_bt848_h
998 dlfcn_h
999 dlopen
1000 dos_paths
1001 ebp_available
1002 ebx_available
1003 exp2
1004 exp2f
1005 fast_64bit
1006 fast_clz
1007 fast_cmov
1008 fast_unaligned
1009 fork
1010 getaddrinfo
1011 gethrtime
1012 GetProcessTimes
1013 getrusage
1014 inet_aton
1015 inline_asm
1016 isatty
1017 ldbrx
1018 libdc1394_1
1019 libdc1394_2
1020 llrint
1021 log2
1022 log2f
1023 loongson
1024 lrint
1025 lrintf
1026 lzo1x_999_compress
1027 machine_ioctl_bt848_h
1028 machine_ioctl_meteor_h
1029 malloc_h
1030 memalign
1031 mkstemp
1032 pld
1033 posix_memalign
1034 round
1035 roundf
1036 sdl
1037 sdl_video_size
1038 setmode
1039 socklen_t
1040 soundcard_h
1041 poll_h
1042 struct_addrinfo
1043 struct_ipv6_mreq
1044 struct_sockaddr_in6
1045 struct_sockaddr_sa_len
1046 struct_sockaddr_storage
1047 sys_mman_h
1048 sys_resource_h
1049 sys_select_h
1050 sys_soundcard_h
1051 sys_videoio_h
1052 ten_operands
1053 termios_h
1054 threads
1055 truncf
1056 vfp_args
1057 VirtualAlloc
1058 winsock2_h
1059 xform_asm
1060 yasm
1061 "
1062
1063 # options emitted with CONFIG_ prefix but not available on command line
1064 CONFIG_EXTRA="
1065 gplv3
1066 lgplv3
1067 "
1068
1069 CMDLINE_SELECT="
1070 $ARCH_EXT_LIST
1071 $CONFIG_LIST
1072 $THREADS_LIST
1073 asm
1074 cross_compile
1075 debug
1076 extra_warnings
1077 logging
1078 optimizations
1079 stripping
1080 yasm
1081 "
1082
1083 PATHS_LIST='
1084 bindir
1085 datadir
1086 incdir
1087 libdir
1088 mandir
1089 prefix
1090 shlibdir
1091 '
1092
1093 CMDLINE_SET="
1094 $PATHS_LIST
1095 arch
1096 as
1097 build_suffix
1098 cc
1099 cpu
1100 cross_prefix
1101 dep_cc
1102 extra_version
1103 host_cc
1104 host_cflags
1105 host_ldflags
1106 host_libs
1107 host_os
1108 ld
1109 logfile
1110 nm
1111 source_path
1112 sysinclude
1113 sysroot
1114 target_exec
1115 target_os
1116 target_path
1117 "
1118
1119 CMDLINE_APPEND="
1120 extra_cflags
1121 "
1122
1123 # code dependency declarations
1124
1125 # architecture extensions
1126
1127 armv5te_deps="arm"
1128 armv6_deps="arm"
1129 armv6t2_deps="arm"
1130 armvfp_deps="arm"
1131 iwmmxt_deps="arm"
1132 neon_deps="arm"
1133
1134 mmi_deps="mips"
1135
1136 altivec_deps="ppc"
1137 ppc4xx_deps="ppc"
1138
1139 vis_deps="sparc"
1140
1141 x86_64_suggest="cmov fast_cmov"
1142 amd3dnow_deps="mmx"
1143 amd3dnowext_deps="amd3dnow"
1144 mmx_deps="x86"
1145 mmx2_deps="mmx"
1146 sse_deps="mmx"
1147 ssse3_deps="sse"
1148
1149 fast_64bit_if_any="alpha ia64 mips64 parisc64 ppc64 sparc64 x86_64"
1150 fast_clz_if_any="alpha armv5te avr32 mips ppc x86"
1151 fast_unaligned_if_any="armv6 ppc x86"
1152
1153 need_memalign="altivec neon sse"
1154 inline_asm_deps="!tms470"
1155
1156 # decoders / encoders / hardware accelerators
1157 aac_decoder_select="fft mdct aac_parser"
1158 aac_encoder_select="fft mdct"
1159 ac3_decoder_select="fft mdct ac3_parser"
1160 alac_encoder_select="lpc"
1161 atrac3_decoder_select="fft mdct"
1162 cavs_decoder_select="golomb"
1163 cook_decoder_select="fft mdct"
1164 cscd_decoder_suggest="zlib"
1165 dca_decoder_select="fft mdct"
1166 dnxhd_encoder_select="aandct"
1167 dxa_decoder_select="zlib"
1168 eac3_decoder_select="ac3_decoder"
1169 eamad_decoder_select="aandct"
1170 eatgq_decoder_select="aandct"
1171 eatqi_decoder_select="aandct"
1172 ffv1_decoder_select="golomb"
1173 flac_decoder_select="golomb"
1174 flac_encoder_select="golomb lpc"
1175 flashsv_decoder_select="zlib"
1176 flashsv_encoder_select="zlib"
1177 flv_decoder_select="h263_decoder"
1178 flv_encoder_select="h263_encoder"
1179 h261_encoder_select="aandct"
1180 h263_decoder_select="h263_parser"
1181 h263_encoder_select="aandct"
1182 h263_vaapi_hwaccel_deps="va_va_h"
1183 h263_vaapi_hwaccel_select="vaapi h263_decoder"
1184 h263i_decoder_select="h263_decoder"
1185 h263p_encoder_select="h263_encoder"
1186 h264_decoder_select="golomb"
1187 h264_dxva2_hwaccel_deps="dxva2api_h"
1188 h264_dxva2_hwaccel_select="dxva2 h264_decoder"
1189 h264_vaapi_hwaccel_deps="va_va_h"
1190 h264_vaapi_hwaccel_select="vaapi"
1191 h264_vdpau_decoder_deps="vdpau_vdpau_h vdpau_vdpau_x11_h"
1192 h264_vdpau_decoder_select="vdpau h264_decoder"
1193 imc_decoder_select="fft mdct"
1194 jpegls_decoder_select="golomb"
1195 jpegls_encoder_select="golomb"
1196 ljpeg_encoder_select="aandct"
1197 loco_decoder_select="golomb"
1198 mjpeg_encoder_select="aandct"
1199 mlp_decoder_select="mlp_parser"
1200 mpeg1video_encoder_select="aandct"
1201 mpeg2video_encoder_select="aandct"
1202 mpeg4_decoder_select="h263_decoder mpeg4video_parser"
1203 mpeg4_encoder_select="h263_encoder"
1204 mpeg_vdpau_decoder_deps="vdpau_vdpau_h vdpau_vdpau_x11_h"
1205 mpeg_vdpau_decoder_select="vdpau mpegvideo_decoder"
1206 mpeg1_vdpau_decoder_deps="vdpau_vdpau_h vdpau_vdpau_x11_h"
1207 mpeg1_vdpau_decoder_select="vdpau mpeg1video_decoder"
1208 mpeg2_vaapi_hwaccel_deps="va_va_h"
1209 mpeg2_vaapi_hwaccel_select="vaapi mpeg2video_decoder"
1210 mpeg4_vaapi_hwaccel_deps="va_va_h"
1211 mpeg4_vaapi_hwaccel_select="vaapi mpeg4_decoder"
1212 mpeg4_vdpau_decoder_deps="vdpau_vdpau_h vdpau_vdpau_x11_h"
1213 mpeg4_vdpau_decoder_select="vdpau mpeg4_decoder"
1214 mpeg_xvmc_decoder_deps="X11_extensions_XvMClib_h"
1215 mpeg_xvmc_decoder_select="mpegvideo_decoder"
1216 msmpeg4v1_decoder_select="h263_decoder"
1217 msmpeg4v1_encoder_select="h263_encoder"
1218 msmpeg4v2_decoder_select="h263_decoder"
1219 msmpeg4v2_encoder_select="h263_encoder"
1220 msmpeg4v3_decoder_select="h263_decoder"
1221 msmpeg4v3_encoder_select="h263_encoder"
1222 nellymoser_decoder_select="fft mdct"
1223 nellymoser_encoder_select="fft mdct"
1224 png_decoder_select="zlib"
1225 png_encoder_select="zlib"
1226 qdm2_decoder_select="fft mdct rdft"
1227 rv10_decoder_select="h263_decoder"
1228 rv10_encoder_select="h263_encoder"
1229 rv20_decoder_select="h263_decoder"
1230 rv20_encoder_select="h263_encoder"
1231 rv30_decoder_select="golomb"
1232 rv40_decoder_select="golomb"
1233 shorten_decoder_select="golomb"
1234 sonic_decoder_select="golomb"
1235 sonic_encoder_select="golomb"
1236 sonic_ls_encoder_select="golomb"
1237 svq3_decoder_select="golomb"
1238 svq3_decoder_suggest="zlib"
1239 theora_decoder_select="vp3_decoder"
1240 tiff_decoder_suggest="zlib"
1241 tiff_encoder_suggest="zlib"
1242 truehd_decoder_select="mlp_decoder"
1243 tscc_decoder_select="zlib"
1244 vc1_decoder_select="h263_decoder"
1245 vc1_dxva2_hwaccel_deps="dxva2api_h DXVA_PictureParameters_wDecodedPictureIndex"
1246 vc1_dxva2_hwaccel_select="dxva2 vc1_decoder"
1247 vc1_vaapi_hwaccel_deps="va_va_h"
1248 vc1_vaapi_hwaccel_select="vaapi vc1_decoder"
1249 vc1_vdpau_decoder_deps="vdpau_vdpau_h vdpau_vdpau_x11_h"
1250 vc1_vdpau_decoder_select="vdpau vc1_decoder"
1251 vorbis_decoder_select="fft mdct"
1252 vorbis_encoder_select="fft mdct"
1253 vp6a_decoder_select="vp6_decoder"
1254 vp6f_decoder_select="vp6_decoder"
1255 wmav1_decoder_select="fft mdct"
1256 wmav1_encoder_select="fft mdct"
1257 wmav2_decoder_select="fft mdct"
1258 wmav2_encoder_select="fft mdct"
1259 wmv1_decoder_select="h263_decoder"
1260 wmv1_encoder_select="h263_encoder"
1261 wmv2_decoder_select="h263_decoder"
1262 wmv2_encoder_select="h263_encoder"
1263 wmv3_decoder_select="vc1_decoder"
1264 wmv3_dxva2_hwaccel_select="vc1_dxva2_hwaccel"
1265 wmv3_vaapi_hwaccel_select="vc1_vaapi_hwaccel"
1266 wmv3_vdpau_decoder_select="vc1_vdpau_decoder"
1267 zlib_decoder_select="zlib"
1268 zlib_encoder_select="zlib"
1269 zmbv_decoder_select="zlib"
1270 zmbv_encoder_select="zlib"
1271
1272 # parsers
1273 h264_parser_select="golomb"
1274
1275 # bitstream_filters
1276 aac_adtstoasc_bsf_select="aac_parser"
1277
1278 # external libraries
1279 libdirac_decoder_deps="libdirac !libschroedinger"
1280 libdirac_encoder_deps="libdirac"
1281 libfaac_encoder_deps="libfaac"
1282 libfaad_decoder_deps="libfaad"
1283 libfaadbin_decoder_extralibs='$ldl'
1284 libgsm_decoder_deps="libgsm"
1285 libgsm_encoder_deps="libgsm"
1286 libgsm_ms_decoder_deps="libgsm"
1287 libgsm_ms_encoder_deps="libgsm"
1288 libmp3lame_encoder_deps="libmp3lame"
1289 libopencore_amrnb_decoder_deps="libopencore_amrnb"
1290 libopencore_amrnb_encoder_deps="libopencore_amrnb"
1291 libopencore_amrwb_decoder_deps="libopencore_amrwb"
1292 libopenjpeg_decoder_deps="libopenjpeg"
1293 libschroedinger_decoder_deps="libschroedinger"
1294 libschroedinger_encoder_deps="libschroedinger"
1295 libspeex_decoder_deps="libspeex"
1296 libtheora_encoder_deps="libtheora"
1297 libvorbis_encoder_deps="libvorbis"
1298 libx264_encoder_deps="libx264"
1299 libxvid_encoder_deps="libxvid"
1300
1301 # demuxers / muxers
1302 ac3_demuxer_deps="ac3_parser"
1303 asf_stream_muxer_select="asf_muxer"
1304 avisynth_demuxer_deps="avisynth"
1305 dirac_demuxer_deps="dirac_parser"
1306 eac3_demuxer_select="ac3_parser"
1307 ipod_muxer_select="mov_muxer"
1308 libnut_demuxer_deps="libnut"
1309 libnut_muxer_deps="libnut"
1310 matroska_audio_muxer_select="matroska_muxer"
1311 matroska_demuxer_suggest="zlib bzlib"
1312 mov_demuxer_suggest="zlib"
1313 mp3_demuxer_deps="mpegaudio_parser"
1314 mp4_muxer_select="mov_muxer"
1315 mpegtsraw_demuxer_select="mpegts_demuxer"
1316 mxf_d10_muxer_select="mxf_muxer"
1317 ogg_demuxer_select="golomb"
1318 psp_muxer_select="mov_muxer"
1319 rtsp_demuxer_deps="sdp_demuxer"
1320 sdp_demuxer_deps="rtp_protocol mpegts_demuxer"
1321 spdif_muxer_select="aac_parser"
1322 tg2_muxer_select="mov_muxer"
1323 tgp_muxer_select="mov_muxer"
1324 w64_demuxer_deps="wav_demuxer"
1325
1326 # indevs / outdevs
1327 alsa_indev_deps="alsa_asoundlib_h snd_pcm_htimestamp"
1328 alsa_indev_extralibs="-lasound"
1329 alsa_outdev_deps="alsa_asoundlib_h"
1330 alsa_outdev_extralibs="-lasound"
1331 audio_beos_indev_deps="audio_beos"
1332 audio_beos_indev_extralibs="-lmedia -lbe"
1333 audio_beos_outdev_deps="audio_beos"
1334 audio_beos_outdev_extralibs="-lmedia -lbe"
1335 bktr_indev_deps_any="dev_bktr_ioctl_bt848_h machine_ioctl_bt848_h dev_video_bktr_ioctl_bt848_h dev_ic_bt8xx_h"
1336 dv1394_indev_deps="dv1394 dv_demuxer"
1337 jack_indev_deps="jack_jack_h"
1338 jack_indev_extralibs="-ljack"
1339 libdc1394_indev_deps="libdc1394"
1340 oss_indev_deps_any="soundcard_h sys_soundcard_h"
1341 oss_outdev_deps_any="soundcard_h sys_soundcard_h"
1342 v4l_indev_deps="linux_videodev_h"
1343 v4l2_indev_deps_any="linux_videodev2_h sys_videoio_h"
1344 vfwcap_indev_deps="capCreateCaptureWindow"
1345 vfwcap_indev_extralibs="-lavicap32"
1346 x11_grab_device_indev_deps="x11grab XShmCreateImage"
1347 x11_grab_device_indev_extralibs="-lX11 -lXext -lXfixes"
1348
1349 # protocols
1350 gopher_protocol_deps="network"
1351 http_protocol_deps="network"
1352 rtmp_protocol_deps="tcp_protocol"
1353 rtp_protocol_deps="udp_protocol"
1354 tcp_protocol_deps="network"
1355 udp_protocol_deps="network"
1356
1357 # filters
1358 movie_filter_deps="avfilter_lavf"
1359 avfilter_lavf_deps="avformat"
1360
1361 # libraries
1362 avdevice_deps="avcodec avformat"
1363 avformat_deps="avcodec"
1364
1365 # programs
1366 ffmpeg_deps="avcodec avformat swscale"
1367 ffplay_deps="avcodec avformat swscale sdl"
1368 ffserver_deps="avformat ffm_muxer rtp_protocol rtsp_demuxer"
1369 ffserver_extralibs='$ldl'
1370
1371 doc_deps="texi2html"
1372
1373 # default parameters
1374
1375 logfile="config.err"
1376
1377 # installation paths
1378 prefix_default="/usr/local"
1379 bindir_default='${prefix}/bin'
1380 datadir_default='${prefix}/share/ffmpeg'
1381 incdir_default='${prefix}/include'
1382 libdir_default='${prefix}/lib'
1383 mandir_default='${prefix}/share/man'
1384 shlibdir_default="$libdir_default"
1385
1386 # toolchain
1387 ar="ar"
1388 cc_default="gcc"
1389 cc_version=\"unknown\"
1390 host_cc_default="gcc"
1391 ln_s="ln -sf"
1392 nm_default="nm"
1393 objformat="elf"
1394 ranlib="ranlib"
1395 strip="strip"
1396 yasmexe="yasm"
1397
1398 nm_opts='-g'
1399
1400 # machine
1401 arch=$(uname -m)
1402 cpu="generic"
1403
1404 # OS
1405 target_os=$(tolower $(uname -s))
1406 host_os=$target_os
1407
1408 # configurable options
1409 enable avcodec
1410 enable avdevice
1411 enable avformat
1412 enable asm
1413 enable debug
1414 enable doc
1415 enable fastdiv
1416 enable ffmpeg
1417 enable ffplay
1418 enable ffserver
1419 enable mpegaudio_hp
1420 enable network
1421 enable optimizations
1422 enable protocols
1423 enable static
1424 enable stripping
1425 enable swscale
1426 enable swscale_alpha
1427
1428 # build settings
1429 SHFLAGS='-shared -Wl,-soname,$$(@F)'
1430 FFSERVERLDFLAGS=-Wl,-E
1431 LIBPREF="lib"
1432 LIBSUF=".a"
1433 FULLNAME='$(NAME)$(BUILDSUF)'
1434 LIBNAME='$(LIBPREF)$(FULLNAME)$(LIBSUF)'
1435 SLIBPREF="lib"
1436 SLIBSUF=".so"
1437 SLIBNAME='$(SLIBPREF)$(FULLNAME)$(SLIBSUF)'
1438 SLIBNAME_WITH_VERSION='$(SLIBNAME).$(LIBVERSION)'
1439 SLIBNAME_WITH_MAJOR='$(SLIBNAME).$(LIBMAJOR)'
1440 LIB_INSTALL_EXTRA_CMD='$(RANLIB) "$(LIBDIR)/$(LIBNAME)"'
1441
1442 CC_O='-o $@'
1443
1444 host_cflags='-D_ISOC99_SOURCE -D_POSIX_C_SOURCE=200112 -O3 -g -Wall'
1445 host_libs='-lm'
1446
1447 target_path='.'
1448
1449 # gcc stupidly only outputs the basename of targets with -MM, but we need the
1450 # full relative path for objects in subdirectories for non-recursive Make.
1451 DEPEND_CMD='$(DEPCC) $(DEPFLAGS) $< | sed -e "/^\#.*/d" -e "s,^[[:space:]]*$(*F)\\.o,$(@D)/$(*F).o," > $(@:.o=.d)'
1452 DEPFLAGS='$(CPPFLAGS) $(CFLAGS) -MM'
1453
1454 # find source path
1455 source_path="$(dirname "$0")"
1456 enable source_path_used
1457 if test -f configure; then
1458 source_path="$(pwd)"
1459 disable source_path_used
1460 else
1461 source_path="$(cd "$source_path"; pwd)"
1462 echo "$source_path" | grep -q '[[:blank:]]' &&
1463 die "Out of tree builds are impossible with whitespace in source path."
1464 test -e "$source_path/config.h" &&
1465 die "Out of tree builds are impossible with config.h in source dir."
1466 fi
1467
1468 for v in "$@"; do
1469 r=${v#*=}
1470 l=${v%"$r"}
1471 r=$(sh_quote "$r")
1472 FFMPEG_CONFIGURATION="${FFMPEG_CONFIGURATION# } ${l}${r}"
1473 done
1474
1475 find_things(){
1476 thing=$1
1477 pattern=$2
1478 file=$source_path/$3
1479 sed -n "s/^[^#]*$pattern.*([^,]*, *\([^,]*\)\(,.*\)*).*/\1_$thing/p" "$file"
1480 }
1481
1482 ENCODER_LIST=$(find_things encoder ENC libavcodec/allcodecs.c)
1483 DECODER_LIST=$(find_things decoder DEC libavcodec/allcodecs.c)
1484 HWACCEL_LIST=$(find_things hwaccel HWACCEL libavcodec/allcodecs.c)
1485 PARSER_LIST=$(find_things parser PARSER libavcodec/allcodecs.c)
1486 BSF_LIST=$(find_things bsf BSF libavcodec/allcodecs.c)
1487 MUXER_LIST=$(find_things muxer _MUX libavformat/allformats.c)
1488 DEMUXER_LIST=$(find_things demuxer DEMUX libavformat/allformats.c)
1489 OUTDEV_LIST=$(find_things outdev OUTDEV libavdevice/alldevices.c)
1490 INDEV_LIST=$(find_things indev _IN libavdevice/alldevices.c)
1491 PROTOCOL_LIST=$(find_things protocol PROTOCOL libavformat/allformats.c)
1492 FILTER_LIST=$(find_things filter FILTER libavfilter/allfilters.c)
1493
1494 enable $ARCH_EXT_LIST \
1495 $DECODER_LIST \
1496 $ENCODER_LIST \
1497 $HWACCEL_LIST \
1498 $PARSER_LIST \
1499 $BSF_LIST \
1500 $DEMUXER_LIST \
1501 $MUXER_LIST \
1502 $FILTER_LIST \
1503 $PROTOCOL_LIST \
1504 $INDEV_LIST \
1505 $OUTDEV_LIST \
1506
1507 die_unknown(){
1508 echo "Unknown option \"$1\"."
1509 echo "See $0 --help for available options."
1510 exit 1
1511 }
1512
1513 show_list() {
1514 suffix=_$1
1515 shift
1516 echo $* | sed s/$suffix//g | tr ' ' '\n' | sort | pr -3 -t
1517 exit 0
1518 }
1519
1520 for opt do
1521 optval="${opt#*=}"
1522 case "$opt" in
1523 --extra-ldflags=*) add_ldflags $optval
1524 ;;
1525 --extra-libs=*) add_extralibs $optval
1526 ;;
1527 --disable-devices) disable $INDEV_LIST $OUTDEV_LIST
1528 ;;
1529 --enable-debug=*) debuglevel="$optval"
1530 ;;
1531 --enable-*=*|--disable-*=*)
1532 eval $(echo "${opt%%=*}" | sed 's/--/action=/;s/-/ thing=/')
1533 is_in "${thing}s" $COMPONENT_LIST || die_unknown "$opt"
1534 eval list=\$$(toupper $thing)_LIST
1535 name=$(echo "${optval}" | sed "s/,/_${thing}|/g")_${thing}
1536 $action $(filter "$name" $list)
1537 ;;
1538 --enable-?*|--disable-?*)
1539 eval $(echo "$opt" | sed 's/--/action=/;s/-/ option=/;s/-/_/g')
1540 if is_in $option $COMPONENT_LIST; then
1541 test $action = disable && action=unset
1542 eval $action \$$(toupper ${option%s})_LIST
1543 elif is_in $option $CMDLINE_SELECT; then
1544 $action $option
1545 else
1546 die_unknown $opt
1547 fi
1548 ;;
1549 --list-*)
1550 NAME="${opt#--list-}"
1551 is_in $NAME $COMPONENT_LIST || die_unknown $opt
1552 NAME=${NAME%s}
1553 eval show_list $NAME \$$(toupper $NAME)_LIST
1554 ;;
1555 --help|-h) show_help
1556 ;;
1557 *)
1558 optname="${opt%%=*}"
1559 optname="${optname#--}"
1560 optname=$(echo "$optname" | sed 's/-/_/g')
1561 if is_in $optname $CMDLINE_SET; then
1562 eval $optname='$optval'
1563 elif is_in $optname $CMDLINE_APPEND; then
1564 append $optname "$optval"
1565 else
1566 die_unknown $opt
1567 fi
1568 ;;
1569 esac
1570 done
1571
1572 disabled logging && logfile=/dev/null
1573
1574 echo "# $0 $FFMPEG_CONFIGURATION" > $logfile
1575 set >> $logfile
1576
1577 test -n "$cross_prefix" && enable cross_compile
1578
1579 ar="${cross_prefix}${ar}"
1580 cc_default="${cross_prefix}${cc_default}"
1581 nm_default="${cross_prefix}${nm_default}"
1582 ranlib="${cross_prefix}${ranlib}"
1583 strip="${cross_prefix}${strip}"
1584
1585 sysinclude_default="${sysroot}/usr/include"
1586
1587 set_default cc nm sysinclude
1588 enabled cross_compile || host_cc_default=$cc
1589 set_default host_cc
1590
1591 exesuf() {
1592 case $1 in
1593 mingw32*|cygwin*|*-dos|freedos|opendos|os/2*) echo .exe ;;
1594 esac
1595 }
1596
1597 EXESUF=$(exesuf $target_os)
1598 HOSTEXESUF=$(exesuf $host_os)
1599
1600 # set temporary file name
1601 : ${TMPDIR:=$TEMPDIR}
1602 : ${TMPDIR:=$TMP}
1603 : ${TMPDIR:=/tmp}
1604
1605 if ! check_cmd type mktemp; then
1606 # simple replacement for missing mktemp
1607 # NOT SAFE FOR GENERAL USE
1608 mktemp(){
1609 echo "${2%XXX*}.${HOSTNAME}.${UID}.$$"
1610 }
1611 fi
1612
1613 tmpfile(){
1614 tmp=$(mktemp -u "${TMPDIR}/ffconf.XXXXXXXX")$2 &&
1615 (set -C; exec > $tmp) 2>/dev/null ||
1616 die "Unable to create temporary file in $TMPDIR."
1617 append TMPFILES $tmp
1618 eval $1=$tmp
1619 }
1620
1621 trap 'rm -f -- $TMPFILES' EXIT
1622 trap exit HUP INT TERM
1623
1624 tmpfile TMPC .c
1625 tmpfile TMPE $EXESUF
1626 tmpfile TMPH .h
1627 tmpfile TMPO .o
1628 tmpfile TMPS .S
1629 tmpfile TMPV .ver
1630 tmpfile TMPSH .sh
1631
1632 unset -f mktemp
1633
1634 # make sure we can execute files in $TMPDIR
1635 cat > $TMPSH 2>> $logfile <<EOF
1636 #! /bin/sh
1637 EOF
1638 chmod +x $TMPSH >> $logfile 2>&1
1639 if ! $TMPSH >> $logfile 2>&1; then
1640 cat <<EOF
1641 Unable to create and execute files in $TMPDIR. Set the TMPDIR environment
1642 variable to another directory and make sure that it is not mounted noexec.
1643 EOF
1644 die "Sanity test failed."
1645 fi
1646
1647 filter_cflags=echo
1648 filter_cppflags=echo
1649 filter_asflags=echo
1650
1651 if $cc -v 2>&1 | grep -qi ^gcc; then
1652 cc_type=gcc
1653 cc_version=__VERSION__
1654 if ! $cc -dumpversion | grep -q '^2\.'; then
1655 CC_DEPFLAGS='-MMD -MF $(@:.o=.d) -MT $@'
1656 AS_DEPFLAGS='-MMD -MF $(@:.o=.d) -MT $@'
1657 fi
1658 elif $cc --version 2>/dev/null | grep -q Intel; then
1659 cc_type=icc
1660 cc_version="AV_STRINGIFY(__INTEL_COMPILER)"
1661 CC_DEPFLAGS='-MMD'
1662 AS_DEPFLAGS='-MMD'
1663 elif $cc -v 2>&1 | grep -q xlc; then
1664 cc_type=xlc
1665 cc_version="AV_STRINGIFY(__IBMC__)"
1666 elif $cc -V 2>/dev/null | grep -q Compaq; then
1667 cc_type=ccc
1668 cc_version="AV_STRINGIFY(__DECC_VER)"
1669 DEPFLAGS='$(CPPFLAGS) $(CFLAGS) -M'
1670 debuglevel=3
1671 add_ldflags -Wl,-z,now # calls to libots crash without this
1672 elif $cc --vsn 2>/dev/null | grep -q "ARM C/C++ Compiler"; then
1673 test -d "$sysroot" || die "No valid sysroot specified."
1674 cc_type=armcc
1675 cc_version="AV_STRINGIFY(__ARMCC_VERSION)"
1676 armcc_conf="$PWD/armcc.conf"
1677 $cc --arm_linux_configure \
1678 --arm_linux_config_file="$armcc_conf" \
1679 --configure_sysroot="$sysroot" \
1680 --configure_cpp_headers="$sysinclude" >>$logfile 2>&1 ||
1681 die "Error creating armcc configuration file."
1682 cc="$cc --arm_linux_config_file=$armcc_conf --translate_gcc"
1683 as_default="${cross_prefix}gcc"
1684 CC_DEPFLAGS='-MMD'
1685 AS_DEPFLAGS='-MMD'
1686 elif $cc -version 2>/dev/null | grep -q TMS470; then
1687 cc_type=tms470
1688 cc_version="AV_STRINGIFY(__TI_COMPILER_VERSION__)"
1689 cc="$cc --gcc --abi=eabi -eo=.o -mc -me"
1690 CC_O='-fr=$(@D)'
1691 as_default="${cross_prefix}gcc"
1692 ld_default="${cross_prefix}gcc"
1693 TMPO=$(basename $TMPC .c).o
1694 append TMPFILES $TMPO
1695 add_cflags -D__gnuc_va_list=va_list -D__USER_LABEL_PREFIX__=
1696 CC_DEPFLAGS='-ppa -ppd=$(@:.o=.d)'
1697 AS_DEPFLAGS='-MMD'
1698 filter_cflags=tms470_flags
1699 tms470_flags(){
1700 for flag; do
1701 case $flag in
1702 -march=*|-mcpu=*)
1703 case "${flag#*=}" in
1704 armv7-a|cortex-a*) echo -mv=7a8 ;;
1705 armv7-r|cortex-r*) echo -mv=7r4 ;;
1706 armv7-m|cortex-m*) echo -mv=7m3 ;;
1707 armv6*|arm11*) echo -mv=6 ;;
1708 armv5*e|arm[79]*e*|arm9[24]6*|arm96*|arm102[26])
1709 echo -mv=5e ;;
1710 armv4*|arm7*|arm9[24]*) echo -mv=4 ;;
1711 esac
1712 ;;
1713 -mfpu=neon) echo --float_support=vfpv3 --neon ;;
1714 -mfpu=vfp) echo --float_support=vfpv2 ;;
1715 -mfpu=vfpv3) echo --float_support=vfpv3 ;;
1716 -msoft-float) echo --float_support=vfplib ;;
1717 -Os) echo -O3 -mf=2 ;;
1718 -O[0-3]) echo $flag -mf=5 ;;
1719 -g) echo -g -mn ;;
1720 -pds=*) echo $flag ;;
1721 esac
1722 done
1723 }
1724 elif $cc -v 2>&1 | grep -q clang; then
1725 cc_type=clang
1726 cc_version=__VERSION__
1727 CC_DEPFLAGS='-MMD'
1728 AS_DEPFLAGS='-MMD'
1729 elif $cc -V 2>&1 | grep -q Sun; then
1730 cc_type=suncc
1731 cc_version="AV_STRINGIFY(__SUNPRO_C)"
1732 DEPEND_CMD='$(DEPCC) $(DEPFLAGS) $< | sed -e "1s,^.*: ,$@: ," -e "\$$!s,\$$, \\\," -e "1!s,^.*: , ," > $(@:.o=.d)'
1733 DEPFLAGS='$(CPPFLAGS) $(CFLAGS) -xM1'
1734 filter_cflags=suncc_flags
1735 suncc_flags(){
1736 for flag; do
1737 case $flag in
1738 -march=*|-mcpu=*)
1739 case "${flag#*=}" in
1740 native) echo -xtarget=native ;;
1741 v9) echo -xarch=sparc ;;
1742 ultrasparc) echo -xarch=sparcvis ;;
1743 ultrasparc3|niagara*) echo -xarch=sparcvis2 ;;
1744 i586|pentium) echo -xchip=pentium ;;
1745 i686|pentiumpro|pentium2) echo -xtarget=pentium_pro ;;
1746 pentium3*|c3-2) echo -xtarget=pentium3 ;;
1747 pentium-m) echo -xarch=sse2 -xchip=pentium3 ;;
1748 pentium4*) echo -xtarget=pentium4 ;;
1749 prescott|nocona) echo -xarch=sse3 -xchip=pentium4 ;;
1750 *-sse3) echo -xarch=sse3 ;;
1751 core2) echo -xarch=ssse3 -xchip=core2 ;;
1752 amdfam10|barcelona) echo -xarch=sse4_1 ;;
1753 athlon-4|athlon-[mx]p) echo -xarch=ssea ;;
1754 k8|opteron|athlon64|athlon-fx)
1755 echo -xarch=sse2a ;;
1756 athlon*) echo -xarch=pentium_proa ;;
1757 esac
1758 ;;
1759 -std=c99) echo -xc99 ;;
1760 -fomit-frame-pointer) echo -xregs=frameptr ;;
1761 -fPIC) echo -KPIC -xcode=pic32 ;;
1762 -Os) echo -O5 -xspace ;;
1763 -W*,*) echo $flag ;;
1764 -f*-*|-W*) ;;
1765 *) echo $flag ;;
1766 esac
1767 done
1768 }
1769 fi
1770
1771 test -n "$cc_type" && enable $cc_type || echolog "Unknown C compiler $cc"
1772
1773 : ${as_default:=$cc}
1774 : ${dep_cc_default:=$cc}
1775 : ${ld_default:=$cc}
1776 set_default as dep_cc ld
1777
1778 test -n "$CC_DEPFLAGS" || CCDEP=$DEPEND_CMD
1779 test -n "$AS_DEPFLAGS" || ASDEP=$DEPEND_CMD
1780
1781 add_cflags $extra_cflags
1782 add_asflags $extra_cflags
1783
1784 if test -n "$sysroot"; then
1785 case "$cc_type" in
1786 gcc)
1787 add_cppflags --sysroot="$sysroot"
1788 add_ldflags --sysroot="$sysroot"
1789 ;;
1790 tms470)
1791 add_cppflags -I"$sysinclude"
1792 add_ldflags --sysroot="$sysroot"
1793 ;;
1794 clang)
1795 add_cppflags -isysroot="$sysroot"
1796 add_ldflags -isysroot="$sysroot"
1797 ;;
1798 esac
1799 fi
1800
1801 if test "$cpu" = host; then
1802 enabled cross_compile && die "--cpu=host makes no sense when cross-compiling."
1803
1804 case "$cc_type" in
1805 gcc)
1806 check_native(){
1807 $cc $1=native -v -c -o $TMPO $TMPC >$TMPE 2>&1 || return
1808 sed -n "/$1=/{
1809 s/.*$1=\\([^ ]*\\).*/\\1/
1810 p
1811 q
1812 }" $TMPE
1813 }
1814 cpu=$(check_native -march || check_native -mcpu)
1815 ;;
1816 esac
1817
1818 test "${cpu:-host}" = host && die "--cpu=host not supported with compiler $cc"
1819 fi
1820
1821 # Deal with common $arch aliases
1822 case "$arch" in
1823 arm*)
1824 arch="arm"
1825 ;;
1826 mips|mipsel|IP*)
1827 arch="mips"
1828 ;;
1829 mips64)
1830 arch="mips"
1831 subarch="mips64"
1832 ;;
1833 parisc|hppa)
1834 arch="parisc"
1835 ;;
1836 parisc64|hppa64)
1837 arch="parisc"
1838 subarch="parisc64"
1839 ;;
1840 "Power Macintosh"|ppc|powerpc)
1841 arch="ppc"
1842 ;;
1843 ppc64)
1844 arch="ppc"
1845 subarch="ppc64"
1846 ;;
1847 s390|s390x)
1848 arch="s390"
1849 ;;
1850 sh4|sh)
1851 arch="sh4"
1852 ;;
1853 sun4u|sparc64)
1854 arch="sparc"
1855 subarch="sparc64"
1856 ;;
1857 i[3-6]86|i86pc|BePC|x86_64|amd64)
1858 arch="x86"
1859 ;;
1860 esac
1861
1862 is_in $arch $ARCH_LIST || echo "WARNING: unknown arch $arch"
1863 enable $arch
1864
1865 # Add processor-specific flags
1866 if test "$cpu" = generic; then
1867 : do nothing
1868 elif enabled ppc; then
1869
1870 case $cpu in
1871 601|ppc601|PowerPC601)
1872 cpuflags="-mcpu=601"
1873 ;;
1874 603*|ppc603*|PowerPC603*)
1875 cpuflags="-mcpu=603"
1876 ;;
1877 604*|ppc604*|PowerPC604*)
1878 cpuflags="-mcpu=604"
1879 ;;
1880 G3|g3|75*|ppc75*|PowerPC75*)
1881 cpuflags="-mcpu=750 -mpowerpc-gfxopt"
1882 ;;
1883 G4|g4|745*|ppc745*|PowerPC745*)
1884 cpuflags="-mcpu=7450 -mpowerpc-gfxopt"
1885 ;;
1886 74*|ppc74*|PowerPC74*)
1887 cpuflags="-mcpu=7400 -mpowerpc-gfxopt"
1888 ;;
1889 G5|g5|970|ppc970|PowerPC970|power4*|Power4*)
1890 cpuflags="-mcpu=970 -mpowerpc-gfxopt -mpowerpc64"
1891 ;;
1892 Cell|CELL|cell)
1893 cpuflags="-mcpu=cell"
1894 enable ldbrx
1895 ;;
1896 esac
1897
1898 elif enabled x86; then
1899
1900 case $cpu in
1901 i[345]86|pentium)
1902 cpuflags="-march=$cpu"
1903 disable mmx
1904 ;;
1905 # targets that do NOT support conditional mov (cmov)
1906 pentium-mmx|k6|k6-[23]|winchip-c6|winchip2|c3)
1907 cpuflags="-march=$cpu"
1908 disable cmov
1909 ;;
1910 # targets that do support conditional mov (cmov)
1911 i686|pentiumpro|pentium[23]|pentium-m|athlon|athlon-tbird|athlon-4|athlon-[mx]p|athlon64|k8|opteron|athlon-fx|core2|amdfam10)
1912 cpuflags="-march=$cpu"
1913 enable cmov
1914 enable fast_cmov
1915 ;;
1916 # targets that do support conditional mov but on which it's slow
1917 pentium4|pentium4m|prescott|nocona)
1918 cpuflags="-march=$cpu"
1919 enable cmov
1920 disable fast_cmov
1921 ;;
1922 esac
1923
1924 elif enabled sparc; then
1925
1926 case $cpu in
1927 sparc64)
1928 cpuflags="-mcpu=v9"
1929 ;;
1930 esac
1931
1932 elif enabled arm; then
1933
1934 case $cpu in
1935 armv*)
1936 cpuflags="-march=$cpu"
1937 ;;
1938 *)
1939 cpuflags="-mcpu=$cpu"
1940 ;;
1941 esac
1942
1943 elif enabled alpha; then
1944
1945 enabled ccc && cpuflags="-arch $cpu" || cpuflags="-mcpu=$cpu"
1946
1947 elif enabled bfin; then
1948
1949 cpuflags="-mcpu=$cpu"
1950
1951 elif enabled mips; then
1952
1953 cpuflags="-march=$cpu"
1954
1955 elif enabled avr32; then
1956
1957 case $cpu in
1958 ap7[02]0[0-2])
1959 subarch="avr32_ap"
1960 cpuflags="-mpart=$cpu"
1961 ;;
1962 ap)
1963 subarch="avr32_ap"
1964 cpuflags="-march=$cpu"
1965 ;;
1966 uc3[ab]*)
1967 subarch="avr32_uc"
1968 cpuflags="-mcpu=$cpu"
1969 ;;
1970 uc)
1971 subarch="avr32_uc"
1972 cpuflags="-march=$cpu"
1973 ;;
1974 esac
1975
1976 fi
1977
1978 add_cflags $cpuflags
1979 add_asflags $cpuflags
1980
1981 # compiler sanity check
1982 check_exec <<EOF
1983 int main(void){ return 0; }
1984 EOF
1985 if test "$?" != 0; then
1986 echo "$cc is unable to create an executable file."
1987 if test -z "$cross_prefix" && ! enabled cross_compile ; then
1988 echo "If $cc is a cross-compiler, use the --enable-cross-compile option."
1989 echo "Only do this if you know what cross compiling means."
1990 fi
1991 die "C compiler test failed."
1992 fi
1993
1994 add_cppflags -D_ISOC99_SOURCE -D_POSIX_C_SOURCE=200112
1995 check_cflags -std=c99
1996 check_cc -D_FILE_OFFSET_BITS=64 <<EOF && add_cppflags -D_FILE_OFFSET_BITS=64
1997 #include <stdlib.h>
1998 EOF
1999 check_cc -D_LARGEFILE_SOURCE <<EOF && add_cppflags -D_LARGEFILE_SOURCE
2000 #include <stdlib.h>
2001 EOF
2002
2003 check_host_cflags -std=c99
2004
2005 case "$arch" in
2006 alpha|ia64|mips|parisc|sparc)
2007 spic=$shared
2008 ;;
2009 x86)
2010 subarch="x86_32"
2011 check_cc <<EOF && subarch="x86_64"
2012 int test[(int)sizeof(char*) - 7];
2013 EOF
2014 if test "$subarch" = "x86_64"; then
2015 spic=$shared
2016 fi
2017 ;;
2018 esac
2019
2020 enable $subarch
2021 enabled spic && enable pic
2022 check_cpp_condition stdlib.h "defined(__PIC__) || defined(__pic__) || defined(PIC)" && enable pic
2023
2024 # OS specific
2025 case $target_os in
2026 beos|haiku|zeta)
2027 prefix_default="$HOME/config"
2028 # 3 gcc releases known for BeOS, each with ugly bugs
2029 gcc_version="$($cc -v 2>&1 | grep version | cut -d ' ' -f3-)"
2030 case "$gcc_version" in
2031 2.9-beos-991026*|2.9-beos-000224*) echo "R5/GG gcc"
2032 disable mmx
2033 ;;
2034 *20010315*) echo "BeBits gcc"
2035 add_cflags -fno-expensive-optimizations
2036 ;;
2037 esac
2038 SHFLAGS=-nostart
2039 # enable BeOS things
2040 enable audio_beos
2041 # no need for libm, but the inet stuff
2042 # Check for BONE
2043 # XXX: actually should check for NOT net_server
2044 if echo $BEINCLUDES | grep -q 'headers/be/bone'; then
2045 network_extralibs="-lbind -lsocket"
2046 else
2047 enable beos_netserver
2048 network_extralibs="-lnet"
2049 fi ;;
2050 sunos)
2051 FFSERVERLDFLAGS=""
2052 SHFLAGS='-shared -Wl,-h,$$(@F)'
2053 enabled x86 && SHFLAGS="-mimpure-text $SHFLAGS"
2054 network_extralibs="-lsocket -lnsl"
2055 add_cppflags -D__EXTENSIONS__
2056 nm_opts='-P -g'
2057 ;;
2058 netbsd)
2059 oss_indev_extralibs="-lossaudio"
2060 oss_outdev_extralibs="-lossaudio"
2061 ;;
2062 openbsd)
2063 enable malloc_aligned
2064 # On OpenBSD 4.5. the compiler does not use PIC unless
2065 # explicitly using -fPIC. FFmpeg builds fine without PIC,
2066 # however the generated executable will not do anything
2067 # (simply quits with exit-code 1, no crash, no output).
2068 # Thus explicitly enable PIC here.
2069 enable pic
2070 SHFLAGS='-shared'
2071 oss_indev_extralibs="-lossaudio"
2072 oss_outdev_extralibs="-lossaudio"
2073 ;;
2074 freebsd|dragonfly)
2075 enable malloc_aligned
2076 ;;
2077 bsd/os)
2078 osextralibs="-lpoll -lgnugetopt"
2079 strip="strip -d"
2080 ;;
2081 darwin)
2082 enable malloc_aligned
2083 SHFLAGS='-dynamiclib -Wl,-single_module -Wl,-install_name,$(SHLIBDIR)/$(SLIBNAME),-current_version,$(LIBVERSION),-compatibility_version,$(LIBMAJOR) -Wl,-read_only_relocs,suppress'
2084 strip="strip -x"
2085 FFLDFLAGS="-Wl,-dynamic,-search_paths_first"
2086 SLIBSUF=".dylib"
2087 SLIBNAME_WITH_VERSION='$(SLIBPREF)$(FULLNAME).$(LIBVERSION)$(SLIBSUF)'
2088 SLIBNAME_WITH_MAJOR='$(SLIBPREF)$(FULLNAME).$(LIBMAJOR)$(SLIBSUF)'
2089 FFSERVERLDFLAGS=-Wl,-bind_at_load
2090 objformat="macho"
2091 enabled x86_64 && objformat="macho64"
2092 enabled_any pic shared ||
2093 { check_cflags -mdynamic-no-pic && add_asflags -mdynamic-no-pic; }
2094 ;;
2095 mingw32*)
2096 # Adding _WIN32_WINNT=0x0501 makes functions that require
2097 # XP visible and thus may make it binary incompatible with
2098 # earlier versions. Set --target-os=mingw32-prexp if this
2099 # isn't desired.
2100 test $target_os = "mingw32" && add_cflags -D_WIN32_WINNT=0x0501
2101 if test $target_os = "mingw32ce"; then
2102 disable network
2103 else
2104 target_os=mingw32
2105 fi
2106 LIBTARGET=i386
2107 if enabled x86_64; then
2108 enable malloc_aligned
2109 LIBTARGET=x64
2110 elif enabled arm; then
2111 LIBTARGET=arm
2112 fi
2113 shlibdir_default="$bindir_default"
2114 disable ffserver
2115 SLIBPREF=""
2116 SLIBSUF=".dll"
2117 SLIBNAME_WITH_VERSION='$(SLIBPREF)$(FULLNAME)-$(LIBVERSION)$(SLIBSUF)'
2118 SLIBNAME_WITH_MAJOR='$(SLIBPREF)$(FULLNAME)-$(LIBMAJOR)$(SLIBSUF)'
2119 SLIB_EXTRA_CMD='-lib.exe /machine:$(LIBTARGET) /def:$$(@:$(SLIBSUF)=.def) /out:$(SUBDIR)$(SLIBNAME_WITH_MAJOR:$(SLIBSUF)=.lib)'
2120 SLIB_INSTALL_EXTRA_CMD='-install -m 644 $(SUBDIR)$(SLIBNAME_WITH_MAJOR:$(SLIBSUF)=.lib) "$(SHLIBDIR)/$(SLIBNAME:$(SLIBSUF)=.lib)"; \
2121 install -m 644 $(SUBDIR)$(SLIBNAME_WITH_MAJOR:$(SLIBSUF)=.lib) "$(SHLIBDIR)/$(SLIBNAME_WITH_MAJOR:$(SLIBSUF)=.lib)"; \
2122 install -d "$(LIBDIR)"; \
2123 install -m 644 $(SUBDIR)lib$(SLIBNAME:$(SLIBSUF)=.dll.a) "$(LIBDIR)/lib$(SLIBNAME:$(SLIBSUF)=.dll.a)"'
2124 SLIB_UNINSTALL_EXTRA_CMD='rm -f "$(SHLIBDIR)/$(SLIBNAME:$(SLIBSUF)=.lib)"'
2125 SHFLAGS='-shared -Wl,--output-def,$$(@:$(SLIBSUF)=.def) -Wl,--out-implib,$(SUBDIR)lib$(SLIBNAME:$(SLIBSUF)=.dll.a) -Wl,--enable-runtime-pseudo-reloc -Wl,--enable-auto-image-base'
2126 objformat="win32"
2127 enable dos_paths
2128 check_cflags -fno-common
2129 if ! enabled x86_64; then
2130 check_cpp_condition _mingw.h "(__MINGW32_MAJOR_VERSION > 3) || (__MINGW32_MAJOR_VERSION == 3 && __MINGW32_MINOR_VERSION >= 15)" ||
2131 die "ERROR: MinGW runtime version must be >= 3.15."
2132 enabled_any avisynth vfwcap_indev &&
2133 { check_cpp_condition w32api.h "(__W32API_MAJOR_VERSION > 3) || (__W32API_MAJOR_VERSION == 3 && __W32API_MINOR_VERSION >= 13)" ||
2134 die "ERROR: avisynth and vfwcap_indev require w32api version 3.13 or later."; }
2135 fi
2136 ;;
2137 cygwin*)
2138 target_os=cygwin
2139 shlibdir_default="$bindir_default"
2140 SLIBPREF="cyg"
2141 SLIBSUF=".dll"
2142 SLIBNAME_WITH_VERSION='$(SLIBPREF)$(FULLNAME)-$(LIBVERSION)$(SLIBSUF)'
2143 SLIBNAME_WITH_MAJOR='$(SLIBPREF)$(FULLNAME)-$(LIBMAJOR)$(SLIBSUF)'
2144 SHFLAGS='-shared -Wl,--enable-auto-image-base'
2145 objformat="win32"
2146 enable dos_paths
2147 check_cflags -fno-common
2148 ;;
2149 *-dos|freedos|opendos)
2150 disable ffplay ffserver
2151 disable $INDEV_LIST $OUTDEV_LIST
2152 network_extralibs="-lsocket"
2153 objformat="coff"
2154 enable dos_paths
2155 ;;
2156 linux)
2157 enable dv1394
2158 ;;
2159 irix*)
2160 target_os=irix
2161 ranlib="echo ignoring ranlib"
2162 ;;
2163 os/2*)
2164 strip="lxlite"
2165 ln_s="cp -f"
2166 FFLDFLAGS="-Zomf -Zbin-files -Zargs-wild -Zmap"
2167 SHFLAGS='$(SUBDIR)$(NAME).def -Zdll -Zomf'
2168 FFSERVERLDFLAGS=""
2169 LIBSUF="_s.a"
2170 SLIBPREF=""
2171 SLIBSUF=".dll"
2172 SLIBNAME_WITH_VERSION='$(SLIBPREF)$(NAME)-$(LIBVERSION)$(SLIBSUF)'
2173 SLIBNAME_WITH_MAJOR='$(SLIBPREF)$(shell echo $(NAME) | cut -c1-6)$(LIBMAJOR)$(SLIBSUF)'
2174 SLIB_CREATE_DEF_CMD='echo LIBRARY $(SLIBNAME_WITH_MAJOR) INITINSTANCE TERMINSTANCE > $(SUBDIR)$(NAME).def; \
2175 echo PROTMODE >> $(SUBDIR)$(NAME).def; \
2176 echo CODE PRELOAD MOVEABLE DISCARDABLE >> $(SUBDIR)$(NAME).def; \
2177 echo DATA PRELOAD MOVEABLE MULTIPLE NONSHARED >> $(SUBDIR)$(NAME).def; \
2178 echo EXPORTS >> $(SUBDIR)$(NAME).def; \
2179 emxexp -o $(OBJS) >> $(SUBDIR)$(NAME).def'
2180 SLIB_EXTRA_CMD='emximp -o $(SUBDIR)$(LIBPREF)$(NAME)_dll.a $(SUBDIR)$(NAME).def; \
2181 emximp -o $(SUBDIR)$(LIBPREF)$(NAME)_dll.lib $(SUBDIR)$(NAME).def;'
2182 SLIB_INSTALL_EXTRA_CMD='install -m 644 $(SUBDIR)$(LIBPREF)$(NAME)_dll.a $(SUBDIR)$(LIBPREF)$(NAME)_dll.lib "$(LIBDIR)"'
2183 SLIB_UNINSTALL_EXTRA_CMD='rm -f "$(LIBDIR)"/$(LIBPREF)$(NAME)_dll.a "$(LIBDIR)"/$(LIBPREF)$(NAME)_dll.lib'
2184 enable dos_paths
2185 ;;
2186 gnu/kfreebsd)
2187 ;;
2188 gnu)
2189 ;;
2190
2191 *)
2192 die "Unknown OS '$target_os'."
2193 ;;
2194 esac
2195
2196 set_default $PATHS_LIST
2197
2198 add_extralibs $osextralibs
2199
2200 # Combine FFLDFLAGS and the LDFLAGS environment variable.
2201 LDFLAGS="$FFLDFLAGS $LDFLAGS"
2202
2203 # we need to build at least one lib type
2204 if ! enabled_any static shared; then
2205 cat <<EOF
2206 At least one library type must be built.
2207 Specify --enable-static to build the static libraries or --enable-shared to
2208 build the shared libraries as well. To only build the shared libraries specify
2209 --disable-static in addition to --enable-shared.
2210 EOF
2211 exit 1;
2212 fi
2213
2214 disabled static && LIBNAME=""
2215
2216 if enabled_any libfaad libfaadbin ; then
2217 if check_header faad.h; then
2218 check_cc <<EOF
2219 #include <faad.h>
2220 #ifndef FAAD2_VERSION
2221 ok faad1
2222 #endif
2223 int main(void) { return 0; }
2224 EOF
2225 test $? = 0 && enable libfaad2
2226 else
2227 die "FAAD test failed."
2228 fi
2229 fi
2230
2231
2232 die_license_disabled() {
2233 enabled $1 || { enabled $2 && die "$2 is $1 and --enable-$1 is not specified."; }
2234 }
2235
2236 die_license_disabled gpl libfaad2
2237 die_license_disabled gpl libx264
2238 die_license_disabled gpl libxvid
2239 die_license_disabled gpl postproc
2240 die_license_disabled gpl x11grab
2241
2242 die_license_disabled nonfree libfaac
2243
2244 die_license_disabled version3 libopencore_amrnb
2245 die_license_disabled version3 libopencore_amrwb
2246
2247 enabled version3 && { enabled gpl && enable gplv3 || enable lgplv3; }
2248
2249 check_deps $ARCH_EXT_LIST
2250
2251 disabled optimizations || check_cflags -fomit-frame-pointer
2252
2253 enable_pic() {
2254 enable pic
2255 add_cppflags -DPIC
2256 add_cflags -fPIC
2257 add_asflags -fPIC
2258 }
2259
2260 enabled pic && enable_pic
2261
2262 check_cc <<EOF || die "Symbol mangling check failed."
2263 int ff_extern;
2264 EOF
2265 sym=$($nm $nm_opts $TMPO | awk '/ff_extern/{ print substr($0, match($0, /[^ \t]*ff_extern/)) }')
2266 extern_prefix=${sym%%ff_extern*}
2267
2268 check_cc <<EOF && enable inline_asm
2269 void foo(void) { __asm__ volatile ("" ::); }
2270 EOF
2271
2272 _restrict=
2273 for restrict_keyword in restrict __restrict__ __restrict; do
2274 check_cc <<EOF && _restrict=$restrict_keyword && break
2275 void foo(char * $restrict_keyword p);
2276 EOF
2277 done
2278
2279 check_cc <<EOF && enable attribute_packed
2280 struct { int x; } __attribute__((packed)) x;
2281 EOF
2282
2283 check_cc <<EOF || die "endian test failed"
2284 unsigned int endian = 'B' << 24 | 'I' << 16 | 'G' << 8 | 'E';
2285 EOF
2286 od -t x1 $TMPO | grep -q '42 *49 *47 *45' && enable bigendian
2287
2288 if enabled alpha; then
2289
2290 check_cflags -mieee
2291
2292 elif enabled arm; then
2293
2294 check_cflags -marm
2295
2296 check_ld <<EOF && enable vfp_args
2297 __asm__ (".eabi_attribute 28, 1");
2298 int main(void) { return 0; }
2299 EOF
2300
2301 # We have to check if pld is a nop and disable it.
2302 check_asm pld '"pld [r0]"'
2303
2304 enabled armv5te && check_asm armv5te '"qadd r0, r0, r0"'
2305 enabled armv6 && check_asm armv6 '"sadd16 r0, r0, r0"'
2306 enabled armv6t2 && check_asm armv6t2 '"movt r0, #0"'
2307 enabled armvfp && check_asm armvfp '"fadds s0, s0, s0"'
2308 enabled iwmmxt && check_asm iwmmxt '"wunpckelub wr6, wr4"'
2309 enabled neon && check_asm neon '"vadd.i16 q0, q0, q0"'
2310
2311 enabled_all armv6t2 shared !pic && enable_pic
2312
2313 elif enabled ia64; then
2314
2315 # HACK: currently fails to build if .bss is > 4MB and shared libs are built
2316 enabled shared && enable_weak hardcoded_tables
2317
2318 elif enabled mips; then
2319
2320 check_asm loongson '"dmult.g $1, $2, $3"'
2321 enabled mmi && check_asm mmi '"lq $2, 0($2)"'
2322
2323 elif enabled ppc; then
2324
2325 check_asm dcbzl '"dcbzl 0, 1"'
2326 check_asm ppc4xx '"maclhw r10, r11, r12"'
2327 check_asm xform_asm '"lwzx %1, %y0" :: "Z"(*(int*)0), "r"(0)'
2328
2329 # AltiVec flags: The FSF version of GCC differs from the Apple version
2330 if enabled altivec; then
2331 check_cflags -maltivec -mabi=altivec &&
2332 { check_header altivec.h && inc_altivec_h="#include <altivec.h>" ; } ||
2333 check_cflags -faltivec
2334
2335 # check if our compiler supports Motorola AltiVec C API
2336 check_cc <<EOF || disable altivec
2337 $inc_altivec_h
2338 int main(void) {
2339 vector signed int v1, v2, v3;
2340 v1 = vec_add(v2,v3);
2341 return 0;
2342 }
2343 EOF
2344
2345 # check if our compiler supports braces for vector declarations
2346 check_cc <<EOF || die "You need a compiler that supports {} in AltiVec vector declarations."
2347 $inc_altivec_h
2348 int main (void) { (vector int) {1}; return 0; }
2349 EOF
2350 fi
2351
2352 elif enabled sparc; then
2353
2354 enabled vis && check_asm vis '"pdist %f0, %f0, %f0"' -mcpu=ultrasparc &&
2355 add_cflags -mcpu=ultrasparc -mtune=ultrasparc
2356
2357 elif enabled x86; then
2358
2359 # check whether EBP is available on x86
2360 # As 'i' is stored on the stack, this program will crash
2361 # if the base pointer is used to access it because the
2362 # base pointer is cleared in the inline assembly code.
2363 check_exec_crash <<EOF && enable ebp_available
2364 volatile int i=0;
2365 __asm__ volatile (
2366 "xorl %%ebp, %%ebp"
2367 ::: "%ebp");
2368 return i;
2369 EOF
2370
2371 # check whether EBX is available on x86
2372 check_asm ebx_available '""::"b"(0)' &&
2373 check_asm ebx_available '"":::"%ebx"'
2374
2375 # check whether more than 10 operands are supported
2376 check_cc <<EOF && enable ten_operands
2377 int main(void) {
2378 int x=0;
2379 __asm__ volatile(
2380 ""
2381 :"+&rm"(x), "+&rm"(x), "+&rm"(x), "+&rm"(x), "+&rm"(x), "+&rm"(x)
2382 );
2383 return 0;
2384 }
2385 EOF
2386
2387 # check whether binutils is new enough to compile SSSE3/MMX2
2388 enabled ssse3 && check_asm ssse3 '"pabsw %xmm0, %xmm0"'
2389 enabled mmx2 && check_asm mmx2 '"pmaxub %mm0, %mm1"'
2390
2391 check_asm bswap '"bswap %%eax" ::: "%eax"'
2392
2393 YASMFLAGS="-f $objformat -DARCH_$(toupper $subarch)"
2394 enabled x86_64 && append YASMFLAGS "-m amd64"
2395 enabled pic && append YASMFLAGS "-DPIC"
2396 test -n "$extern_prefix" && append YASMFLAGS "-DPREFIX"
2397 case "$objformat" in
2398 elf) enabled debug && append YASMFLAGS "-g dwarf2" ;;
2399 esac
2400 disabled yasm || { check_yasm "pabsw xmm0, xmm0" && enable yasm; }
2401
2402 case "$cpu" in
2403 athlon*|opteron*|k8*|pentium|pentium-mmx|prescott|nocona|atom|geode)
2404 disable fast_clz
2405 ;;
2406 esac
2407
2408 fi
2409
2410 if check_func dlopen; then
2411 ldl=
2412 elif check_func dlopen -ldl; then
2413 ldl=-ldl
2414 fi
2415
2416 # Solaris has nanosleep in -lrt, OpenSolaris no longer needs that
2417 check_func nanosleep || { check_func nanosleep -lrt && add_extralibs -lrt; }
2418
2419 check_func fork
2420 check_func getaddrinfo $network_extralibs
2421 check_func gethrtime
2422 check_func getrusage
2423 check_func inet_aton $network_extralibs
2424 check_func isatty
2425 check_func memalign
2426 check_func mkstemp
2427 check_func posix_memalign
2428 check_func_headers io.h setmode
2429 check_func_headers lzo/lzo1x.h lzo1x_999_compress
2430 check_func_headers windows.h GetProcessTimes
2431 check_func_headers windows.h VirtualAlloc
2432
2433 check_header conio.h
2434 check_header dlfcn.h
2435 check_header dxva2api.h
2436 check_header malloc.h
2437 check_header poll.h
2438 check_header sys/mman.h
2439 check_header sys/resource.h
2440 check_header sys/select.h
2441 check_header termios.h
2442 check_header vdpau/vdpau.h
2443 check_header vdpau/vdpau_x11.h
2444 check_header X11/extensions/XvMClib.h
2445
2446 check_struct dxva2api.h DXVA_PictureParameters wDecodedPictureIndex
2447
2448 if ! enabled_any memalign memalign_hack posix_memalign malloc_aligned &&
2449 enabled_any $need_memalign ; then
2450 die "Error, no aligned memory allocator but SSE enabled, disable it or use --enable-memalign-hack."
2451 fi
2452
2453 disabled zlib || check_lib zlib.h zlibVersion -lz || disable zlib
2454 disabled bzlib || check_lib2 bzlib.h BZ2_bzlibVersion -lbz2 || disable bzlib
2455
2456 # check for some common methods of building with pthread support
2457 # do this before the optional library checks as some of them require pthreads
2458 if enabled pthreads; then
2459 if check_func pthread_create; then
2460 :
2461 elif check_func pthread_create -pthread; then
2462 add_cflags -pthread
2463 add_extralibs -pthread
2464 elif check_func pthread_create -pthreads; then
2465 add_cflags -pthreads
2466 add_extralibs -pthreads
2467 elif check_func pthread_create -lpthreadGC2; then
2468 add_extralibs -lpthreadGC2
2469 elif ! check_lib pthread.h pthread_create -lpthread; then
2470 die "ERROR: can't find pthreads library"
2471 fi
2472 fi
2473
2474 for thread in $THREADS_LIST; do
2475 if enabled $thread; then
2476 test -n "$thread_type" &&
2477 die "ERROR: Only one thread type must be selected." ||
2478 thread_type="$thread"
2479 fi
2480 done
2481
2482 check_lib math.h sin -lm
2483 check_lib va/va.h vaInitialize -lva
2484
2485 check_func exp2
2486 check_func exp2f
2487 check_func llrint
2488 check_func log2
2489 check_func log2f
2490 check_func lrint
2491 check_func lrintf
2492 check_func round
2493 check_func roundf
2494 check_func truncf
2495
2496 # these are off by default, so fail if requested and not available
2497 enabled avisynth && require2 vfw32 "windows.h vfw.h" AVIFileInit -lavifil32
2498 enabled libdirac && add_cflags $(pkg-config --cflags dirac) &&
2499 require libdirac libdirac_decoder/dirac_parser.h dirac_decoder_init $(pkg-config --libs dirac) &&
2500 require libdirac libdirac_encoder/dirac_encoder.h dirac_encoder_init $(pkg-config --libs dirac)
2501 enabled libfaac && require2 libfaac "stdint.h faac.h" faacEncGetVersion -lfaac
2502 enabled libfaad && require2 libfaad faad.h faacDecOpen -lfaad
2503 enabled libgsm && require libgsm gsm.h gsm_create -lgsm
2504 enabled libmp3lame && require libmp3lame lame/lame.h lame_init -lmp3lame -lm
2505 enabled libnut && require libnut libnut.h nut_demuxer_init -lnut
2506 enabled libopencore_amrnb && require libopencore_amrnb opencore-amrnb/interf_dec.h Decoder_Interface_init -lopencore-amrnb -lm
2507 enabled libopencore_amrwb && require libopencore_amrwb opencore-amrwb/dec_if.h D_IF_init -lopencore-amrwb -lm
2508 enabled libopenjpeg && require libopenjpeg openjpeg.h opj_version -lopenjpeg
2509 enabled libschroedinger && add_cflags $(pkg-config --cflags schroedinger-1.0) &&
2510 require libschroedinger schroedinger/schro.h schro_init $(pkg-config --libs schroedinger-1.0)
2511 enabled libspeex && require libspeex speex/speex.h speex_decoder_init -lspeex
2512 enabled libtheora && require libtheora theora/theoraenc.h th_info_init -ltheoraenc -ltheoradec -logg
2513 enabled libvorbis && require libvorbis vorbis/vorbisenc.h vorbis_info_init -lvorbisenc -lvorbis -logg
2514 enabled libx264 && require libx264 x264.h x264_encoder_encode -lx264 -lm &&
2515 { check_cpp_condition x264.h "X264_BUILD >= 83" ||
2516 die "ERROR: libx264 version must be >= 0.83."; }
2517 enabled libxvid && require libxvid xvid.h xvid_global -lxvidcore
2518 enabled mlib && require mediaLib mlib_types.h mlib_VectorSub_S16_U8_Mod -lmlib
2519
2520 # libdc1394 check
2521 if enabled libdc1394; then
2522 { check_lib dc1394/dc1394.h dc1394_new -ldc1394 -lraw1394 &&
2523 enable libdc1394_2; } ||
2524 { check_lib libdc1394/dc1394_control.h dc1394_create_handle -ldc1394_control -lraw1394 &&
2525 enable libdc1394_1; } ||
2526 die "ERROR: No version of libdc1394 found "
2527 fi
2528
2529 SDL_CONFIG="${cross_prefix}sdl-config"
2530 if "${SDL_CONFIG}" --version > /dev/null 2>&1; then
2531 sdl_cflags=$("${SDL_CONFIG}" --cflags)
2532 sdl_libs=$("${SDL_CONFIG}" --libs)
2533 check_func_headers SDL.h SDL_Init $sdl_cflags $sdl_libs &&
2534 check_cpp_condition SDL.h "(SDL_MAJOR_VERSION<<16 | SDL_MINOR_VERSION<<8 | SDL_PATCHLEVEL) >= 0x010201" $sdl_cflags &&
2535 enable sdl &&
2536 check_struct SDL.h SDL_VideoInfo current_w $sdl_cflags && enable sdl_video_size
2537 fi
2538
2539 texi2html -version > /dev/null 2>&1 && enable texi2html || disable texi2html
2540
2541 if enabled network; then
2542 check_type "sys/types.h sys/socket.h" socklen_t
2543 check_type netdb.h "struct addrinfo"
2544 check_type netinet/in.h "struct ipv6_mreq"
2545 check_type netinet/in.h "struct sockaddr_in6"
2546 check_type "sys/types.h sys/socket.h" "struct sockaddr_storage"
2547 check_struct "sys/types.h sys/socket.h" "struct sockaddr" sa_len
2548 # Prefer arpa/inet.h over winsock2
2549 if check_header arpa/inet.h ; then
2550 check_func closesocket
2551 elif check_header winsock2.h ; then
2552 check_func_headers winsock2.h closesocket -lws2 && \
2553 network_extralibs="-lws2" || \
2554 { check_func_headers winsock2.h closesocket -lws2_32 && \
2555 network_extralibs="-lws2_32"; }
2556 # getaddrinfo is available if _WIN32_WINNT >= 0x0501 is defined
2557 check_func_headers ws2tcpip.h getaddrinfo $network_extralibs
2558 check_type ws2tcpip.h socklen_t
2559 check_type ws2tcpip.h "struct addrinfo"
2560 check_type ws2tcpip.h "struct ipv6_mreq"
2561 check_type ws2tcpip.h "struct sockaddr_in6"
2562 check_type ws2tcpip.h "struct sockaddr_storage"
2563 check_struct winsock2.h "struct sockaddr" sa_len
2564 else
2565 disable network
2566 fi
2567 fi
2568
2569 check_header linux/videodev.h
2570 check_header linux/videodev2.h
2571 check_header sys/videoio.h
2572
2573 check_func_headers "windows.h vfw.h" capCreateCaptureWindow "$vfwcap_indev_extralibs"
2574
2575 # check for ioctl_meteor.h, ioctl_bt848.h and alternatives
2576 { check_header dev/bktr/ioctl_meteor.h &&
2577 check_header dev/bktr/ioctl_bt848.h; } ||
2578 { check_header machine/ioctl_meteor.h &&
2579 check_header machine/ioctl_bt848.h; } ||
2580 { check_header dev/video/meteor/ioctl_meteor.h &&
2581 check_header dev/video/bktr/ioctl_bt848.h; } ||
2582 check_header dev/ic/bt8xx.h
2583
2584 check_header sys/soundcard.h
2585 check_header soundcard.h
2586
2587 enabled_any alsa_indev alsa_outdev && check_lib2 alsa/asoundlib.h snd_pcm_htimestamp -lasound
2588
2589 enabled jack_indev && check_lib2 jack/jack.h jack_client_open -ljack
2590
2591 enabled x11grab &&
2592 check_header X11/Xlib.h &&
2593 check_header X11/extensions/XShm.h &&
2594 check_header X11/extensions/Xfixes.h &&
2595 check_func XOpenDisplay -lX11 &&
2596 check_func XShmCreateImage -lX11 -lXext &&
2597 check_func XFixesGetCursorImage -lX11 -lXext -lXfixes
2598
2599 if ! disabled vdpau && enabled vdpau_vdpau_h; then
2600 check_cpp_condition \
2601 vdpau/vdpau.h "defined VDP_DECODER_PROFILE_MPEG4_PART2_ASP" ||
2602 { echolog "Please upgrade to libvdpau >= 0.2 if you would like vdpau support." &&
2603 disable vdpau; }
2604 fi
2605
2606 enabled debug && add_cflags -g"$debuglevel" && add_asflags -g"$debuglevel"
2607
2608 # add some useful compiler flags if supported
2609 check_cflags -Wdeclaration-after-statement
2610 check_cflags -Wall
2611 check_cflags -Wno-switch
2612 check_cflags -Wdisabled-optimization
2613 check_cflags -Wpointer-arith
2614 check_cflags -Wredundant-decls
2615 check_cflags -Wno-pointer-sign
2616 check_cflags -Wcast-qual
2617 check_cflags -Wwrite-strings
2618 check_cflags -Wtype-limits
2619 check_cflags -Wundef
2620 enabled extra_warnings && check_cflags -Winline
2621
2622 # add some linker flags
2623 check_ldflags -Wl,--warn-common
2624 check_ldflags -Wl,--as-needed
2625 check_ldflags '-Wl,-rpath-link,\$(BUILD_ROOT)/libpostproc -Wl,-rpath-link,\$(BUILD_ROOT)/libswscale -Wl,-rpath-link,\$(BUILD_ROOT)/libavfilter -Wl,-rpath-link,\$(BUILD_ROOT)/libavdevice -Wl,-rpath-link,\$(BUILD_ROOT)/libavformat -Wl,-rpath-link,\$(BUILD_ROOT)/libavcodec -Wl,-rpath-link,\$(BUILD_ROOT)/libavutil'
2626 check_ldflags -Wl,-Bsymbolic
2627
2628 echo "X{};" > $TMPV
2629 test_ldflags -Wl,--version-script,$TMPV &&
2630 append SHFLAGS '-Wl,--version-script,\$(SUBDIR)lib\$(NAME).ver'
2631
2632 if enabled small; then
2633 check_cflags -Os # not all compilers support -Os
2634 optimizations="small"
2635 elif enabled optimizations; then
2636 if enabled xlc; then
2637 add_cflags -O5
2638 add_ldflags -O5
2639 elif enabled suncc; then
2640 add_cflags -O5
2641 elif enabled ccc; then
2642 add_cflags -fast
2643 else
2644 add_cflags -O3
2645 fi
2646 fi
2647 check_cflags -fno-math-errno
2648 check_cflags -fno-signed-zeros
2649
2650 if enabled icc; then
2651 # Just warnings, no remarks
2652 check_cflags -w1
2653 # -wd: Disable following warnings
2654 # 144, 167, 556: -Wno-pointer-sign
2655 # 10006: ignoring unknown option -fno-signed-zeros
2656 # 10156: ignoring option '-W'; no argument required
2657 check_cflags -wd144,167,556,10006,10156
2658 # 11030: Warning unknown option --as-needed
2659 # 10156: ignoring option '-export'; no argument required
2660 check_ldflags -wd10156,11030
2661 # Allow to compile with optimizations
2662 check_ldflags -march=$cpu
2663 # icc 11.0 and 11.1 work with ebp_available, but don't pass the test
2664 enable ebp_available
2665 elif enabled ccc; then
2666 # disable some annoying warnings
2667 add_cflags -msg_disable cvtu32to64
2668 add_cflags -msg_disable embedcomment
2669 add_cflags -msg_disable needconstext
2670 add_cflags -msg_disable nomainieee
2671 add_cflags -msg_disable ptrmismatch1
2672 add_cflags -msg_disable unreachcode
2673 elif enabled gcc; then
2674 check_cflags -fno-tree-vectorize
2675 elif enabled clang; then
2676 check_cflags -Qunused-arguments
2677 elif enabled armcc; then
2678 # 2523: use of inline assembler is deprecated
2679 add_cflags -Wrvct,--diag_suppress=2523
2680 elif enabled tms470; then
2681 add_cflags -pds=824 -pds=837
2682 fi
2683
2684 if enabled gprof; then
2685 add_cflags -p
2686 add_ldflags -p
2687 fi
2688
2689 # Find out if the .align argument is a power of two or not.
2690 check_asm asmalign_pot '".align 3"'
2691
2692 enabled_any $DECODER_LIST && enable decoders
2693 enabled_any $ENCODER_LIST && enable encoders
2694 enabled_any $HWACCEL_LIST && enable hwaccels
2695 enabled_any $BSF_LIST && enable bsfs
2696 enabled_any $DEMUXER_LIST && enable demuxers
2697 enabled_any $MUXER_LIST && enable muxers
2698 enabled_any $FILTER_LIST && enable filters
2699 enabled_any $INDEV_LIST && enable indevs
2700 enabled_any $OUTDEV_LIST && enable outdevs
2701 enabled_any $PROTOCOL_LIST && enable protocols
2702
2703 enabled_any $THREADS_LIST && enable threads
2704
2705 check_deps $CONFIG_LIST \
2706 $CONFIG_EXTRA \
2707 $HAVE_LIST \
2708 $DECODER_LIST \
2709 $ENCODER_LIST \
2710 $HWACCEL_LIST \
2711 $PARSER_LIST \
2712 $BSF_LIST \
2713 $DEMUXER_LIST \
2714 $MUXER_LIST \
2715 $FILTER_LIST \
2716 $INDEV_LIST \
2717 $OUTDEV_LIST \
2718 $PROTOCOL_LIST \
2719
2720 enabled asm || disable $ARCH_LIST $ARCH_EXT_LIST
2721
2722 echo "install prefix $prefix"
2723 echo "source path $source_path"
2724 echo "C compiler $cc"
2725 echo ".align is power-of-two $asmalign_pot"
2726 echo "ARCH $arch ($cpu)"
2727 if test "$build_suffix" != ""; then
2728 echo "build suffix $build_suffix"
2729 fi
2730 if test "$extra_version" != ""; then
2731 echo "version string suffix $extra_version"
2732 fi
2733 echo "big-endian ${bigendian-no}"
2734 echo "runtime cpu detection ${runtime_cpudetect-no}"
2735 if enabled x86; then
2736 echo "yasm ${yasm-no}"
2737 echo "MMX enabled ${mmx-no}"
2738 echo "MMX2 enabled ${mmx2-no}"
2739 echo "3DNow! enabled ${amd3dnow-no}"
2740 echo "3DNow! extended enabled ${amd3dnowext-no}"
2741 echo "SSE enabled ${sse-no}"
2742 echo "SSSE3 enabled ${ssse3-no}"
2743 echo "CMOV enabled ${cmov-no}"
2744 echo "CMOV is fast ${fast_cmov-no}"
2745 echo "EBX available ${ebx_available-no}"
2746 echo "EBP available ${ebp_available-no}"
2747 echo "10 operands supported ${ten_operands-no}"
2748 fi
2749 if enabled arm; then
2750 echo "ARMv5TE enabled ${armv5te-no}"
2751 echo "ARMv6 enabled ${armv6-no}"
2752 echo "ARMv6T2 enabled ${armv6t2-no}"
2753 echo "ARM VFP enabled ${armvfp-no}"
2754 echo "IWMMXT enabled ${iwmmxt-no}"
2755 echo "NEON enabled ${neon-no}"
2756 fi
2757 if enabled mips; then
2758 echo "MMI enabled ${mmi-no}"
2759 fi
2760 if enabled ppc; then
2761 echo "AltiVec enabled ${altivec-no}"
2762 echo "PPC 4xx optimizations ${ppc4xx-no}"
2763 echo "dcbzl available ${dcbzl-no}"
2764 echo "performance report ${powerpc_perf-no}"
2765 fi
2766 if enabled sparc; then
2767 echo "VIS enabled ${vis-no}"
2768 fi
2769 echo "gprof enabled ${gprof-no}"
2770 echo "debug symbols ${debug-no}"
2771 echo "strip symbols ${stripping-no}"
2772 echo "optimizations ${optimizations-no}"
2773 echo "static ${static-no}"
2774 echo "shared ${shared-no}"
2775 echo "postprocessing support ${postproc-no}"
2776 echo "new filter support ${avfilter-no}"
2777 echo "filters using lavformat ${avfilter_lavf-no}"
2778 echo "network support ${network-no}"
2779 echo "threading support ${thread_type-no}"
2780 echo "SDL support ${sdl-no}"
2781 echo "Sun medialib support ${mlib-no}"
2782 echo "AVISynth enabled ${avisynth-no}"
2783 echo "libdc1394 support ${libdc1394-no}"
2784 echo "libdirac enabled ${libdirac-no}"
2785 echo "libfaac enabled ${libfaac-no}"
2786 echo "libfaad enabled ${libfaad-no}"
2787 echo "libfaad dlopened ${libfaadbin-no}"
2788 echo "libgsm enabled ${libgsm-no}"
2789 echo "libmp3lame enabled ${libmp3lame-no}"
2790 echo "libnut enabled ${libnut-no}"
2791 echo "libopencore-amrnb support ${libopencore_amrnb-no}"
2792 echo "libopencore-amrwb support ${libopencore_amrwb-no}"
2793 echo "libopenjpeg enabled ${libopenjpeg-no}"
2794 echo "libschroedinger enabled ${libschroedinger-no}"
2795 echo "libspeex enabled ${libspeex-no}"
2796 echo "libtheora enabled ${libtheora-no}"
2797 echo "libvorbis enabled ${libvorbis-no}"
2798 echo "libx264 enabled ${libx264-no}"
2799 echo "libxvid enabled ${libxvid-no}"
2800 echo "zlib enabled ${zlib-no}"
2801 echo "bzlib enabled ${bzlib-no}"
2802 echo
2803
2804 for type in decoder encoder hwaccel parser demuxer muxer protocol filter bsf indev outdev; do
2805 echo "Enabled ${type}s:"
2806 eval list=\$$(toupper $type)_LIST
2807 for part in $list; do
2808 enabled $part && echo ${part%_*}
2809 done | sort | pr -3 -t
2810 echo
2811 done
2812
2813 license="LGPL version 2.1 or later"
2814 if enabled nonfree; then
2815 license="nonfree and unredistributable"
2816 elif enabled gplv3; then
2817 license="GPL version 3 or later"
2818 elif enabled lgplv3; then
2819 license="LGPL version 3 or later"
2820 elif enabled gpl; then
2821 license="GPL version 2 or later"
2822 fi
2823
2824 echo "License: $license"
2825
2826 echo "Creating config.mak and config.h..."
2827
2828 # build tree in object directory if source path is different from current one
2829 if enabled source_path_used; then
2830 DIRS="
2831 doc
2832 libavcodec
2833 libavcodec/$arch
2834 libavdevice
2835 libavfilter
2836 libavformat
2837 libavutil
2838 libavutil/$arch
2839 libpostproc
2840 libswscale
2841 libswscale/$arch
2842 tests
2843 tools
2844 "
2845 FILES="
2846 Makefile
2847 common.mak
2848 subdir.mak
2849 doc/texi2pod.pl
2850 libavcodec/Makefile
2851 libavdevice/Makefile
2852 libavfilter/Makefile
2853 libavformat/Makefile
2854 libavutil/Makefile
2855 libpostproc/Makefile
2856 libswscale/Makefile
2857 "
2858 for dir in $DIRS ; do
2859 mkdir -p $dir
2860 done
2861 for f in $FILES ; do
2862 $ln_s "$source_path/$f" $f
2863 done
2864 fi
2865
2866 enabled stripping || strip="echo skipping strip"
2867
2868 cat > config.mak <<EOF
2869 # Automatically generated by configure - do not modify!
2870 ifndef FFMPEG_CONFIG_MAK
2871 FFMPEG_CONFIG_MAK=1
2872 FFMPEG_CONFIGURATION=$FFMPEG_CONFIGURATION
2873 prefix=$prefix
2874 LIBDIR=\$(DESTDIR)$libdir
2875 SHLIBDIR=\$(DESTDIR)$shlibdir
2876 INCDIR=\$(DESTDIR)$incdir
2877 BINDIR=\$(DESTDIR)$bindir
2878 DATADIR=\$(DESTDIR)$datadir
2879 MANDIR=\$(DESTDIR)$mandir
2880 SRC_PATH="$source_path"
2881 SRC_PATH_BARE=$source_path
2882 BUILD_ROOT="$PWD"
2883 ARCH=$arch
2884 CC=$cc
2885 AS=$as
2886 LD=$ld
2887 DEPCC=$dep_cc
2888 YASM=$yasmexe
2889 AR=$ar
2890 RANLIB=$ranlib
2891 LN_S=$ln_s
2892 STRIP=$strip
2893 CPPFLAGS=$CPPFLAGS
2894 CFLAGS=$CFLAGS
2895 ASFLAGS=$ASFLAGS
2896 CC_O=$CC_O
2897 LDFLAGS=$LDFLAGS
2898 FFSERVERLDFLAGS=$FFSERVERLDFLAGS
2899 SHFLAGS=$SHFLAGS
2900 YASMFLAGS=$YASMFLAGS
2901 BUILDSUF=$build_suffix
2902 FULLNAME=$FULLNAME
2903 LIBPREF=$LIBPREF
2904 LIBSUF=$LIBSUF
2905 LIBNAME=$LIBNAME
2906 SLIBPREF=$SLIBPREF
2907 SLIBSUF=$SLIBSUF
2908 EXESUF=$EXESUF
2909 EXTRA_VERSION=$extra_version
2910 DEPFLAGS=$DEPFLAGS
2911 CCDEP=$CCDEP
2912 ASDEP=$ASDEP
2913 CC_DEPFLAGS=$CC_DEPFLAGS
2914 AS_DEPFLAGS=$AS_DEPFLAGS
2915 HOSTCC=$host_cc
2916 HOSTCFLAGS=$host_cflags
2917 HOSTEXESUF=$HOSTEXESUF
2918 HOSTLDFLAGS=$host_ldflags
2919 HOSTLIBS=$host_libs
2920 TARGET_EXEC=$target_exec
2921 TARGET_PATH=$target_path
2922 SDL_LIBS=$sdl_libs
2923 SDL_CFLAGS=$sdl_cflags
2924 LIB_INSTALL_EXTRA_CMD=$LIB_INSTALL_EXTRA_CMD
2925 EXTRALIBS=$extralibs
2926 EOF
2927
2928 get_version(){
2929 name=$1
2930 file=$source_path/$2
2931 eval $(grep "#define ${name}_VERSION_M" "$file" | awk '{ print $2"="$3 }')
2932 eval ${name}_VERSION=\$${name}_VERSION_MAJOR.\$${name}_VERSION_MINOR.\$${name}_VERSION_MICRO
2933 lcname=$(tolower $name)
2934 eval echo "${lcname}_VERSION=\$${name}_VERSION" >> config.mak
2935 eval echo "${lcname}_VERSION_MAJOR=\$${name}_VERSION_MAJOR" >> config.mak
2936 }
2937
2938 get_version LIBSWSCALE libswscale/swscale.h
2939 get_version LIBPOSTPROC libpostproc/postprocess.h
2940 get_version LIBAVCODEC libavcodec/avcodec.h
2941 get_version LIBAVDEVICE libavdevice/avdevice.h
2942 get_version LIBAVFORMAT libavformat/avformat.h
2943 get_version LIBAVUTIL libavutil/avutil.h
2944 get_version LIBAVFILTER libavfilter/avfilter.h
2945
2946 enabled shared && cat >> config.mak <<EOF
2947 LIBTARGET=${LIBTARGET}
2948 SLIBNAME=${SLIBNAME}
2949 SLIBNAME_WITH_VERSION=${SLIBNAME_WITH_VERSION}
2950 SLIBNAME_WITH_MAJOR=${SLIBNAME_WITH_MAJOR}
2951 SLIB_CREATE_DEF_CMD=${SLIB_CREATE_DEF_CMD}
2952 SLIB_EXTRA_CMD=${SLIB_EXTRA_CMD}
2953 SLIB_INSTALL_EXTRA_CMD=${SLIB_INSTALL_EXTRA_CMD}
2954 SLIB_UNINSTALL_EXTRA_CMD=${SLIB_UNINSTALL_EXTRA_CMD}
2955 EOF
2956
2957 enabled asmalign_pot || align_shift="1 <<"
2958
2959 cat > $TMPH <<EOF
2960 /* Automatically generated by configure - do not modify! */
2961 #ifndef FFMPEG_CONFIG_H
2962 #define FFMPEG_CONFIG_H
2963 #define FFMPEG_CONFIGURATION "$(c_escape $FFMPEG_CONFIGURATION)"
2964 #define FFMPEG_LICENSE "$(c_escape $license)"
2965 #define FFMPEG_DATADIR "$(eval c_escape $datadir)"
2966 #define CC_TYPE "$cc_type"
2967 #define CC_VERSION $cc_version
2968 #define restrict $_restrict
2969 #define ASMALIGN(ZEROBITS) ".align $align_shift " #ZEROBITS "\\n\\t"
2970 #define EXTERN_PREFIX "${extern_prefix}"
2971 #define EXTERN_ASM ${extern_prefix}
2972 EOF
2973
2974 if enabled small || disabled optimizations; then
2975 echo "#define av_always_inline" >> $TMPH
2976 fi
2977
2978 print_config ARCH_ $TMPH config.mak $ARCH_LIST
2979 print_config HAVE_ $TMPH config.mak $HAVE_LIST
2980 print_config CONFIG_ $TMPH config.mak $CONFIG_LIST \
2981 $CONFIG_EXTRA \
2982 $DECODER_LIST \
2983 $ENCODER_LIST \
2984 $HWACCEL_LIST \
2985 $PARSER_LIST \
2986 $BSF_LIST \
2987 $DEMUXER_LIST \
2988 $MUXER_LIST \
2989 $FILTER_LIST \
2990 $PROTOCOL_LIST \
2991 $INDEV_LIST \
2992 $OUTDEV_LIST \
2993
2994 echo "#endif /* FFMPEG_CONFIG_H */" >> $TMPH
2995 echo "endif # FFMPEG_CONFIG_MAK" >> config.mak
2996
2997 # Do not overwrite an unchanged config.h to avoid superfluous rebuilds.
2998 cp_if_changed $TMPH config.h
2999
3000 cat > $TMPH <<EOF
3001 /* Generated by ffconf */
3002 #ifndef AVUTIL_AVCONFIG_H
3003 #define AVUTIL_AVCONFIG_H
3004 EOF
3005
3006 print_config AV_HAVE_ $TMPH /dev/null $HAVE_LIST_PUB
3007
3008 echo "#endif /* AVUTIL_AVCONFIG_H */" >> $TMPH
3009
3010 cp_if_changed $TMPH libavutil/avconfig.h
3011
3012 # build pkg-config files
3013
3014 pkgconfig_generate(){
3015 name=$1
3016 shortname=${name#lib}${build_suffix}
3017 comment=$2
3018 version=$3
3019 libs=$4
3020 requires=$5
3021 cat <<EOF > $name/$name.pc
3022 prefix=$prefix
3023 exec_prefix=\${prefix}
3024 libdir=$libdir
3025 includedir=$incdir
3026
3027 Name: $name
3028 Description: $comment
3029 Version: $version
3030 Requires: $(enabled shared || echo $requires)
3031 Requires.private: $(enabled shared && echo $requires)
3032 Conflicts:
3033 Libs: -L\${libdir} -l${shortname} $(enabled shared || echo $libs)
3034 Libs.private: $(enabled shared && echo $libs)
3035 Cflags: -I\${includedir}
3036 EOF
3037 cat <<EOF > $name/$name-uninstalled.pc
3038 prefix=
3039 exec_prefix=
3040 libdir=\${pcfiledir}
3041 includedir=${source_path}
3042
3043 Name: $name
3044 Description: $comment
3045 Version: $version
3046 Requires: $requires
3047 Conflicts:
3048 Libs: \${libdir}/${LIBPREF}${shortname}${LIBSUF} $libs
3049 Cflags: -I\${includedir}
3050 EOF
3051 }
3052
3053 pkgconfig_generate libavutil "FFmpeg utility library" "$LIBAVUTIL_VERSION"
3054 pkgconfig_generate libavcodec "FFmpeg codec library" "$LIBAVCODEC_VERSION" "$extralibs" "libavutil = $LIBAVUTIL_VERSION"
3055 pkgconfig_generate libavformat "FFmpeg container format library" "$LIBAVFORMAT_VERSION" "$extralibs" "libavcodec = $LIBAVCODEC_VERSION"
3056 pkgconfig_generate libavdevice "FFmpeg device handling library" "$LIBAVDEVICE_VERSION" "$extralibs" "libavformat = $LIBAVFORMAT_VERSION"
3057 enabled avfilter &&
3058 pkgconfig_generate libavfilter "FFmpeg video filtering library" "$LIBAVFILTER_VERSION" "$extralibs" "libavutil = $LIBAVUTIL_VERSION"
3059 enabled postproc &&
3060 pkgconfig_generate libpostproc "FFmpeg post processing library" "$LIBPOSTPROC_VERSION"
3061 pkgconfig_generate libswscale "FFmpeg image rescaling library" "$LIBSWSCALE_VERSION" "" "libavutil = $LIBAVUTIL_VERSION"