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