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