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