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