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