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