Make less verbose a sentence in the preset system documentation.
[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.
460a4fb9 11export LC_ALL=C
31e647f8 12
cde2d79a 13# make sure we are running under a compatible shell
c21d6325
MR
14# try to make this part work with most shells
15
16try_exec(){
0dbe81bb 17 echo "Trying shell $1"
2270b4b2 18 type "$1" > /dev/null 2>&1 && exec "$@"
c21d6325
MR
19}
20
5237ce67 21unset foo
2270b4b2 22(: ${foo%%bar}) 2> /dev/null
0dbe81bb
MR
23E1="$?"
24
2270b4b2 25(: ${foo?}) 2> /dev/null
0dbe81bb
MR
26E2="$?"
27
28if test "$E1" != 0 || test "$E2" = 0; then
29 echo "Broken shell detected. Trying alternatives."
c21d6325
MR
30 export FF_CONF_EXEC
31 if test "0$FF_CONF_EXEC" -lt 1; then
32 FF_CONF_EXEC=1
33 try_exec bash "$0" "$@"
34 fi
35 if test "0$FF_CONF_EXEC" -lt 2; then
36 FF_CONF_EXEC=2
37 try_exec ksh "$0" "$@"
38 fi
39 if test "0$FF_CONF_EXEC" -lt 3; then
40 FF_CONF_EXEC=3
41 try_exec /usr/xpg4/bin/sh "$0" "$@"
cde2d79a
MR
42 fi
43 echo "No compatible shell script interpreter found."
fc53da20 44 echo "This configure script requires a POSIX-compatible shell"
c21d6325 45 echo "such as bash or ksh."
505dfb09
DB
46 echo "THIS IS NOT A BUG IN FFMPEG, DO NOT REPORT IT AS SUCH."
47 echo "Instead, install a working POSIX-compatible shell."
48 echo "Disabling this configure test will create a broken FFmpeg."
c21d6325
MR
49 if test "$BASH_VERSION" = '2.04.0(1)-release'; then
50 echo "This bash version ($BASH_VERSION) is broken on your platform."
51 echo "Upgrade to a later version if available."
52 fi
cde2d79a
MR
53 exit 1
54fi
55
74c53c2d
MR
56show_help(){
57 echo "Usage: configure [options]"
58 echo "Options: [defaults in brackets after descriptions]"
59 echo
60 echo "Standard options:"
61 echo " --help print this message"
8c6afa4d
DB
62 echo " --logfile=FILE log tests and output to FILE [config.err]"
63 echo " --disable-logging do not log configure debug information"
3e89171a 64 echo " --prefix=PREFIX install in PREFIX [$prefix]"
d156bede 65 echo " --bindir=DIR install binaries in DIR [PREFIX/bin]"
74c53c2d 66 echo " --libdir=DIR install libs in DIR [PREFIX/lib]"
84c22efd 67 echo " --shlibdir=DIR install shared libs in DIR [PREFIX/lib]"
5341d856 68 echo " --incdir=DIR install includes in DIR [PREFIX/include]"
4ca5ece5 69 echo " --mandir=DIR install man page in DIR [PREFIX/share/man]"
74c53c2d
MR
70 echo " --enable-static build static libraries [default=yes]"
71 echo " --disable-static do not build static libraries [default=no]"
72 echo " --enable-shared build shared libraries [default=no]"
73 echo " --disable-shared do not build shared libraries [default=yes]"
0a622b98
MR
74 echo " --enable-gpl allow use of GPL code, the resulting libav*"
75 echo " and ffmpeg will be under GPL [default=no]"
3fe142e2
DB
76 echo " --enable-nonfree allow use of nonfree code, the resulting libav*"
77 echo " and ffmpeg will be unredistributable [default=no]"
4a24ab64 78 echo " --enable-postproc enable GPLed postprocessing support [default=no]"
13ca50f3 79 echo " --enable-swscale software scaler support [default=no]"
f7679c54
VS
80 echo " --enable-avfilter video filter support (replaces vhook) [default=no]"
81 echo " --enable-avfilter-lavf video filters dependant on avformat [default=no]"
e5f94c2b 82 echo " --enable-beosthreads use BeOS threads [default=no]"
d22e8442 83 echo " --enable-os2threads use OS/2 threads [default=no]"
74c53c2d 84 echo " --enable-pthreads use pthreads [default=no]"
eb113804 85 echo " --enable-w32threads use Win32 threads [default=no]"
56a059ac 86 echo " --enable-x11grab enable X11 grabbing [default=no]"
0a622b98
MR
87 echo
88 echo "External library support:"
5ce265a1 89 echo " --enable-mlib use Sun medialib [default=no]"
e2745046
MR
90 echo " --enable-liba52 enable GPLed liba52 support [default=no]"
91 echo " --enable-liba52bin open liba52.so.0 at runtime [default=no]"
8ac17293 92 echo " --enable-avisynth allow reading AVISynth script files [default=no]"
f5a756ef
DB
93 echo " --enable-libamr-nb enable libamr-nb floating point audio codec"
94 echo " --enable-libamr-wb enable libamr-wb floating point audio codec"
f7b8bffe
RP
95 echo " --enable-libdc1394 enable IIDC-1394 grabbing using libdc1394"
96 echo " and libraw1394 [default=no]"
690bfceb 97 echo " --enable-libdirac enable Dirac support via libdirac [default=no]"
e2745046
MR
98 echo " --enable-libfaac enable FAAC support via libfaac [default=no]"
99 echo " --enable-libfaad enable FAAD support via libfaad [default=no]"
06f32b26 100 echo " --enable-libfaadbin open libfaad.so.0 at runtime [default=no]"
dc922953 101 echo " --enable-libgsm enable GSM support via libgsm [default=no]"
e2745046 102 echo " --enable-libmp3lame enable MP3 encoding via libmp3lame [default=no]"
31235134
DB
103 echo " --enable-libnut enable NUT (de)muxing via libnut,"
104 echo " native demuxer exists [default=no]"
f7cd9eed 105 echo " --enable-libschroedinger enable Dirac support via libschroedinger [default=no]"
71757822 106 echo " --enable-libtheora enable Theora encoding via libtheora [default=no]"
f9def9cc
DB
107 echo " --enable-libvorbis enable Vorbis encoding via libvorbis,"
108 echo " native implementation exists [default=no]"
1cc60c47
DB
109 echo " --enable-libx264 enable H.264 encoding via x264 [default=no]"
110 echo " --enable-libxvid enable Xvid encoding via xvidcore,"
31235134 111 echo " native MPEG-4/Xvid encoder exists [default=no]"
74c53c2d
MR
112 echo ""
113 echo "Advanced options (experts only):"
114 echo " --source-path=PATH path to source code [$source_path]"
115 echo " --cross-prefix=PREFIX use PREFIX for compilation tools [$cross_prefix]"
db6107b6 116 echo " --enable-cross-compile assume a cross-compiler is used"
4f854758 117 echo " --target-os=OS compiler targets OS [$target_os]"
74c53c2d 118 echo " --cc=CC use C compiler CC [$cc]"
74c53c2d
MR
119 echo " --extra-cflags=ECFLAGS add ECFLAGS to CFLAGS [$CFLAGS]"
120 echo " --extra-ldflags=ELDFLAGS add ELDFLAGS to LDFLAGS [$LDFLAGS]"
121 echo " --extra-libs=ELIBS add ELIBS [$ELIBS]"
ac63af34 122 echo " --extra-version=STRING version string suffix []"
74c53c2d 123 echo " --build-suffix=SUFFIX suffix for application specific build []"
cc6a90dd 124 echo " --arch=ARCH select architecture [$arch]"
7c758d33
DB
125 echo " --cpu=CPU selects the minimum cpu required (affects"
126 echo " instruction selection, may crash on older CPUs)"
2b4c3615 127 echo " --enable-powerpc-perf enable performance report on PPC"
74c53c2d
MR
128 echo " (requires enabling PMC)"
129 echo " --disable-mmx disable MMX usage"
064df5a9
PI
130 echo " --disable-mmx2 disable MMX2 usage"
131 echo " --disable-ssse3 disable SSSE3 usage"
1839e854 132 echo " --disable-armv5te disable armv5te usage"
edab3048 133 echo " --disable-armv6 disable armv6 usage"
f55b299a 134 echo " --disable-armvfp disable ARM VFP usage"
74c53c2d
MR
135 echo " --disable-iwmmxt disable iwmmxt usage"
136 echo " --disable-altivec disable AltiVec usage"
74c53c2d 137 echo " --disable-network disable network support [default=no]"
0c7bb0e5 138 echo " --disable-ipv6 disable ipv6 support [default=no]"
74c53c2d 139 echo " --disable-zlib disable zlib [default=no]"
f402916e 140 echo " --disable-bzlib disable bzlib [default=no]"
74c53c2d 141 echo " --disable-vhook disable video hooking support"
74c53c2d
MR
142 echo " --disable-mpegaudio-hp faster (but less accurate)"
143 echo " MPEG audio decoding [default=no]"
cde9e780 144 echo " --enable-gray enable full grayscale support (slower color)"
786b30af 145 echo " --disable-ffmpeg disable ffmpeg build"
74c53c2d
MR
146 echo " --disable-ffserver disable ffserver build"
147 echo " --disable-ffplay disable ffplay build"
148 echo " --enable-small optimize for size instead of speed"
3abe5fbd 149 echo " --enable-hardcoded-tables use hardcoded tables instead of runtime generation"
74c53c2d 150 echo " --enable-memalign-hack emulate memalign, interferes with memory debuggers"
74c53c2d
MR
151 echo " --disable-encoder=NAME disables encoder NAME"
152 echo " --enable-encoder=NAME enables encoder NAME"
153 echo " --disable-decoder=NAME disables decoder NAME"
154 echo " --enable-decoder=NAME enables decoder NAME"
155 echo " --disable-encoders disables all encoders"
156 echo " --disable-decoders disables all decoders"
ff70e601
MR
157 echo " --disable-muxer=NAME disables muxer NAME"
158 echo " --enable-muxer=NAME enables muxer NAME"
74c53c2d 159 echo " --disable-muxers disables all muxers"
ff70e601
MR
160 echo " --disable-demuxer=NAME disables demuxer NAME"
161 echo " --enable-demuxer=NAME enables demuxer NAME"
74c53c2d 162 echo " --disable-demuxers disables all demuxers"
af9e7d18
MR
163 echo " --enable-parser=NAME enables parser NAME"
164 echo " --disable-parser=NAME disables parser NAME"
165 echo " --disable-parsers disables all parsers"
cd61e407
JM
166 echo " --enable-bsf=NAME enables bitstream filter NAME"
167 echo " --disable-bsf=NAME disables bitstream filter NAME"
168 echo " --disable-bsfs disables all bitstream filters"
c08fb000
AB
169 echo " --enable-protocol=NAME enables protocol NAME"
170 echo " --disable-protocol=NAME disables protocol NAME"
171 echo " --disable-protocols disables all protocols"
10d46dd0 172 echo " --disable-devices disables all devices"
794f8e97
PI
173 echo " --list-decoders show all available decoders"
174 echo " --list-encoders show all available encoders"
175 echo " --list-muxers show all available muxers"
176 echo " --list-demuxers show all available demuxers"
177 echo " --list-parsers show all available parsers"
178 echo " --list-protocols show all available protocols"
179 echo " --list-bsfs show all available bitstream filters"
c552605c
DB
180 echo " --list-indevs show all available input devices"
181 echo " --list-outdevs show all available output devices"
0a622b98
MR
182 echo
183 echo "Developer options (useful when working on FFmpeg itself):"
9c56a1f9 184 echo " --disable-debug disable debugging symbols"
b7d49373 185 echo " --enable-debug=LEVEL set the debug level [$debuglevel]"
0a622b98 186 echo " --enable-gprof enable profiling with gprof [$gprof]"
d2bbb2f7 187 echo " --disable-optimizations disable compiler optimizations"
0a622b98 188 echo " --enable-extra-warnings enable more compiler warnings"
87a0fb62 189 echo " --disable-stripping disable stripping of executables and shared libraries"
74c53c2d
MR
190 echo ""
191 echo "NOTE: Object files are built at the place where configure is launched."
192 exit 1
193}
cf9d24ad 194
57bd82d4 195log(){
2270b4b2 196 echo "$@" >> $logfile
57bd82d4
MR
197}
198
720c69da 199log_file(){
c8e9f801 200 log BEGIN $1
2270b4b2 201 pr -n -t $1 >> $logfile
c8e9f801
MR
202 log END $1
203}
204
2ba042a7 205echolog(){
c8e9f801 206 log "$@"
57bd82d4 207 echo "$@"
2ba042a7
MR
208}
209
210die(){
211 echolog "$@"
212 cat <<EOF
213If you think configure made a mistake, make sure you are using the latest
214version from SVN. If the latest version fails, report the problem to the
e5d8ccd7 215ffmpeg-user@mplayerhq.hu mailing list or IRC #ffmpeg on irc.freenode.net.
2ba042a7 216EOF
e155a21a 217 if disabled logging; then
2ba042a7 218 cat <<EOF
e155a21a
DB
219Rerun configure with logging enabled (do not use --disable-logging), and
220include the log this produces with your report.
2ba042a7
MR
221EOF
222 else
223cat <<EOF
e155a21a
DB
224Include the log file "$logfile" produced by configure as this will help
225solving the problem.
2ba042a7
MR
226EOF
227 fi
cea0ac52 228 rm -f $TMPC $TMPE $TMPH $TMPO $TMPS $TMPSH
57bd82d4
MR
229 exit 1
230}
231
6c6007d6 232# Avoid locale weirdness, besides we really just want to translate ASCII.
44161118 233toupper(){
6c6007d6 234 echo "$@" | tr abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ
44161118
MR
235}
236
4a5444db 237tolower(){
6c6007d6 238 echo "$@" | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz
4a5444db
MR
239}
240
a8d04fba
MR
241set_all(){
242 value=$1
243 shift
244 for var in $*; do
245 eval $var=$value
246 done
247}
248
799c9e9b
MR
249pushvar(){
250 for var in $*; do
251 eval level=\${${var}_level:=0}
252 eval ${var}_${level}="\$$var"
253 eval ${var}_level=$(($level+1))
254 done
255}
256
257popvar(){
258 for var in $*; do
259 eval level=\${${var}_level:-0}
260 test $level = 0 && continue
261 eval level=$(($level-1))
262 eval $var="\${${var}_${level}}"
263 eval ${var}_level=$level
264 eval unset ${var}_${level}
265 done
266}
267
a8d04fba
MR
268enable(){
269 set_all yes $*
270}
271
272disable(){
273 set_all no $*
274}
275
57bd82d4 276enabled(){
3250003c
MR
277 test "${1#!}" = "$1" && op== || op=!=
278 eval test "x\$${1#!}" $op "xyes"
44161118
MR
279}
280
37970ebf 281disabled(){
3250003c
MR
282 test "${1#!}" = "$1" && op== || op=!=
283 eval test "x\$${1#!}" $op "xno"
37970ebf
RP
284}
285
44161118
MR
286enabled_all(){
287 for opt; do
288 enabled $opt || return 1
289 done
290}
291
85bca2c5
DB
292disabled_all(){
293 for opt; do
294 disabled $opt || return 1
295 done
296}
297
44161118
MR
298enabled_any(){
299 for opt; do
300 enabled $opt && return 0
301 done
302}
303
85bca2c5
DB
304disabled_any(){
305 for opt; do
306 disabled $opt && return 0
307 done
308}
309
c9d19248
MR
310set_default(){
311 for opt; do
312 eval test -z "\$$opt" && eval $opt=\$${opt}_default
313 done
314}
315
4a0d6686
AJ
316is_in(){
317 value=$1
318 shift
319 for var in $*; do
320 [ $var = $value ] && return 0
321 done
322 return 1
323}
324
30fd06be
MR
325check_deps(){
326 for cfg; do
3250003c 327 cfg="${cfg#!}"
799c9e9b
MR
328 enabled ${cfg}_checking && die "Circular dependency for $cfg."
329 disabled ${cfg}_checking && continue
330 enable ${cfg}_checking
331
30fd06be
MR
332 eval dep_all="\$${cfg}_deps"
333 eval dep_any="\$${cfg}_deps_any"
799c9e9b
MR
334
335 pushvar cfg dep_all dep_any
336 check_deps $dep_all $dep_any
337 popvar cfg dep_all dep_any
338
30fd06be
MR
339 enabled_all $dep_all || disable $cfg
340 enabled_any $dep_any || disable $cfg
799c9e9b 341
4ec45764
RP
342 if enabled $cfg; then
343 eval dep_extralibs="\$${cfg}_extralibs"
344 test -n "$dep_extralibs" && add_extralibs $dep_extralibs
345 fi
346
799c9e9b 347 disable ${cfg}_checking
30fd06be
MR
348 done
349}
350
44161118
MR
351print_config(){
352 pfx=$1
353 header=$2
354 makefile=$3
355 shift 3
356 for cfg; do
3d907e22 357 ucname="`toupper $cfg`"
44161118 358 if enabled $cfg; then
3d907e22
MR
359 echo "#define ${pfx}${ucname} 1" >> $header
360 echo "#define ENABLE_${ucname} 1" >> $header
361 echo "${pfx}${ucname}=yes" >> $makefile
362 else
363 echo "#define ENABLE_${ucname} 0" >> $header
44161118
MR
364 fi
365 done
57bd82d4
MR
366}
367
368flags_saved(){
2270b4b2 369 (: ${SAVE_CFLAGS?}) 2> /dev/null
57bd82d4
MR
370}
371
dcd479c0 372save_flags(){
57bd82d4 373 flags_saved && return
dcd479c0
MR
374 SAVE_CFLAGS="$CFLAGS"
375 SAVE_LDFLAGS="$LDFLAGS"
376 SAVE_extralibs="$extralibs"
377}
378
379restore_flags(){
f5d28d10 380 flags_saved || return
dcd479c0
MR
381 CFLAGS="$SAVE_CFLAGS"
382 LDFLAGS="$SAVE_LDFLAGS"
383 extralibs="$SAVE_extralibs"
384 unset SAVE_CFLAGS
385 unset SAVE_LDFLAGS
386 unset SAVE_extralibs
387}
388
389temp_cflags(){
390 save_flags
391 CFLAGS="$CFLAGS $*"
392}
393
394temp_ldflags(){
395 save_flags
396 LDFLAGS="$LDFLAGS $*"
397}
398
399temp_extralibs(){
400 save_flags
401 extralibs="$extralibs $*"
402}
403
57bd82d4
MR
404append(){
405 var=$1
406 shift
407 flags_saved && eval "SAVE_$var=\"\$SAVE_$var $*\""
408 eval "$var=\"\$$var $*\""
409}
410
411add_cflags(){
412 append CFLAGS "$@"
413}
414
415add_ldflags(){
416 append LDFLAGS "$@"
417}
418
419add_extralibs(){
420 append extralibs "$@"
421}
422
b0cfb663 423check_cmd(){
b3cb5d51 424 log "$@"
2270b4b2 425 "$@" >> $logfile 2>&1
b0cfb663
MR
426}
427
dcd479c0 428check_cc(){
57bd82d4 429 log check_cc "$@"
2270b4b2 430 cat > $TMPC
720c69da 431 log_file $TMPC
b0cfb663 432 check_cmd $cc $CFLAGS "$@" -c -o $TMPO $TMPC
57bd82d4
MR
433}
434
435check_cpp(){
436 log check_cpp "$@"
2270b4b2 437 cat > $TMPC
720c69da 438 log_file $TMPC
b0cfb663 439 check_cmd $cc $CFLAGS "$@" -E -o $TMPO $TMPC
dcd479c0
MR
440}
441
940f335a
MR
442check_asm(){
443 log check_asm "$@"
444 name="$1"
445 asm="$2"
446 shift 2
447 check_cc "$@" <<EOF && enable $name || disable $name
c23a0ac8 448int foo(void){ asm volatile($asm); }
940f335a
MR
449EOF
450}
451
304d586d
LM
452check_yasm(){
453 log check_yasm "$@"
454 echo "$1" > $TMPS
455 log_file $TMPS
456 shift 1
457 check_cmd $yasmexe $YASMFLAGS "$@" -o $TMPO $TMPS
458}
459
dcd479c0 460check_ld(){
57bd82d4 461 log check_ld "$@"
0607887f 462 check_cc || return
3155a644
MR
463 flags=''
464 libs=''
465 for f; do
466 test "${f}" = "${f#-l}" && flags="$flags $f" || libs="$libs $f"
467 done
468 check_cmd $cc $LDFLAGS $flags -o $TMPE $TMPO $extralibs $libs
dcd479c0
MR
469}
470
471check_cflags(){
57bd82d4
MR
472 log check_cflags "$@"
473 check_cc "$@" <<EOF && add_cflags "$@"
dcd479c0
MR
474int x;
475EOF
476}
477
478check_ldflags(){
57bd82d4
MR
479 log check_ldflags "$@"
480 check_ld "$@" <<EOF && add_ldflags "$@"
c23a0ac8 481int main(void){ return 0; }
dcd479c0
MR
482EOF
483}
484
485check_header(){
57bd82d4 486 log check_header "$@"
dcd479c0
MR
487 header=$1
488 shift
d8bc5f06
MR
489 var=`echo $header | sed 's/[^A-Za-z0-9_]/_/g'`
490 disable $var
491 check_cpp "$@" <<EOF && enable $var
dcd479c0
MR
492#include <$header>
493int x;
494EOF
495}
496
497check_func(){
57bd82d4 498 log check_func "$@"
dcd479c0
MR
499 func=$1
500 shift
d8bc5f06
MR
501 disable $func
502 check_ld "$@" <<EOF && enable $func
dcd479c0 503extern int $func();
c23a0ac8 504int main(void){ $func(); }
dcd479c0
MR
505EOF
506}
507
2446d3d6
DB
508check_func_headers(){
509 log check_func_headers "$@"
f8d7b072
MR
510 headers=$1
511 func=$2
512 shift 2
513 disable $func
514 incs=""
515 for hdr in $headers; do
516 incs="$incs
517#include <$hdr>"
518 done
519 check_ld "$@" <<EOF && enable $func
520$incs
d6773f56 521int main(int argc, char **argv){
f8d7b072
MR
522 (void) $func;
523 return 0;
524}
525EOF
526}
527
57bd82d4
MR
528check_lib(){
529 log check_lib "$@"
530 header="$1"
531 func="$2"
532 shift 2
fcfcde17
MR
533 temp_extralibs "$@"
534 check_header $header && check_func $func && add_extralibs "$@"
535 err=$?
536 restore_flags
537 return $err
57bd82d4
MR
538}
539
f8d7b072
MR
540check_lib2(){
541 log check_lib2 "$@"
542 headers="$1"
543 func="$2"
544 shift 2
545 temp_extralibs "$@"
2446d3d6 546 check_func_headers "$headers" $func && add_extralibs "$@"
f8d7b072
MR
547 err=$?
548 restore_flags
549 return $err
550}
551
dcd479c0 552check_exec(){
2270b4b2 553 check_ld "$@" && { enabled cross_compile || $TMPE >> $logfile 2>&1; }
57bd82d4
MR
554}
555
7dfef245
MR
556check_exec_crash(){
557 code=`cat`
558
559 # exit() is not async signal safe. _Exit (C99) and _exit (POSIX)
560 # are safe but may not be available everywhere. Thus we use
561 # raise(SIGTERM) instead. The check is run in a subshell so we
562 # can redirect the "Terminated" message from the shell. SIGBUS
563 # is not defined by standard C so it is used conditionally.
564
2270b4b2 565 (check_exec "$@") >> $logfile 2>&1 <<EOF
7dfef245
MR
566#include <signal.h>
567static void sighandler(int sig){
568 raise(SIGTERM);
569}
e5af4a11 570int main(void){
7dfef245
MR
571 signal(SIGILL, sighandler);
572 signal(SIGFPE, sighandler);
573 signal(SIGSEGV, sighandler);
574#ifdef SIGBUS
575 signal(SIGBUS, sighandler);
576#endif
577 { $code }
578}
579EOF
580}
581
72be9e73
DY
582check_type(){
583 log check_type "$@"
584 headers=$1
585 type=$2
586 shift 2
587 disable $type
588 incs=""
589 for hdr in $headers; do
590 incs="$incs
591#include <$hdr>"
592 done
593 check_cc "$@" <<EOF && enable $type
594$incs
595$type v;
596EOF
597}
598
57bd82d4
MR
599require(){
600 name="$1"
601 header="$2"
602 func="$3"
603 shift 3
604 check_lib $header $func "$@" || die "ERROR: $name not found"
dcd479c0
MR
605}
606
f8d7b072
MR
607require2(){
608 name="$1"
609 headers="$2"
610 func="$3"
611 shift 3
612 check_lib2 "$headers" $func "$@" || die "ERROR: $name not found"
613}
614
eea50282
MR
615check_foo_config(){
616 cfg=$1
617 pkg=$2
618 header=$3
619 func=$4
620 shift 4
621 disable $cfg
622 check_cmd ${pkg}-config --version
623 err=$?
624 if test "$err" = 0; then
625 temp_cflags `${pkg}-config --cflags`
626 temp_extralibs `${pkg}-config --libs`
627 check_lib "$@" $header $func && enable $cfg
628 fi
629 return $err
630}
631
c505dd31
MR
632apply(){
633 file=$1
634 shift
635 "$@" < "$file" > "$file.tmp" && mv "$file.tmp" "$file" || rm "$file.tmp"
636}
637
dcd61286
DB
638# CONFIG_LIST contains configurable options, while HAVE_LIST is for
639# system-dependent things.
640
4a0d6686
AJ
641COMPONENT_LIST="
642 bsfs
643 decoders
644 demuxers
645 encoders
3cde40aa 646 filters
c552605c 647 indevs
4a0d6686 648 muxers
c552605c 649 outdevs
4a0d6686
AJ
650 parsers
651 protocols
652"
653
654CONFIG_LIST="
655 $COMPONENT_LIST
f7679c54
VS
656 avfilter
657 avfilter_lavf
c88f5d72
MR
658 avisynth
659 beos_netserver
f402916e 660 bzlib
c88f5d72
MR
661 ffmpeg
662 ffplay
663 ffserver
664 gpl
ecfc4f44 665 gprof
d8d0d0b2 666 gray
3abe5fbd 667 hardcoded_tables
c88f5d72 668 ipv6
7bc5f2a8 669 liba52
f8904fd9 670 liba52bin
f5a756ef
DB
671 libamr_nb
672 libamr_wb
f7b8bffe 673 libdc1394
690bfceb 674 libdirac
2eed5a46
DB
675 libfaac
676 libfaad
677 libfaadbin
c88f5d72 678 libgsm
6ebe07fb 679 libmp3lame
c88f5d72 680 libnut
f7cd9eed 681 libschroedinger
150d2772 682 libtheora
c88f5d72 683 libvorbis
1cc60c47
DB
684 libx264
685 libxvid
c88f5d72 686 memalign_hack
a8150374 687 mlib
c88f5d72
MR
688 mpegaudio_hp
689 network
3fe142e2 690 nonfree
4a24ab64 691 postproc
2b4c3615 692 powerpc_perf
bd2216e4 693 small
13ca50f3 694 swscale
c88f5d72 695 vhook
56a059ac 696 x11grab
c88f5d72 697 zlib
4a0d6686 698"
c88f5d72 699
8eee7025
DB
700THREADS_LIST='
701 beosthreads
d22e8442 702 os2threads
8eee7025
DB
703 pthreads
704 w32threads
705'
706
3f5b56e5
MR
707ARCH_LIST='
708 alpha
709 armv4l
710 bfin
711 ia64
712 m68k
713 mips
714 parisc
715 powerpc
716 s390
717 sh4
718 sparc
719 sparc64
720 x86
721 x86_32
722 x86_64
723'
724
725ARCH_EXT_LIST='
1ac9331a 726 altivec
1ac9331a 727 armv5te
edab3048 728 armv6
f55b299a 729 armvfp
3f5b56e5
MR
730 iwmmxt
731 mmi
732 mmx
d7f0920b 733 mmx2
6b18d278 734 neon
9eeed841 735 ssse3
bd9d34a0 736 vis
3f5b56e5
MR
737'
738
739HAVE_LIST="
740 $ARCH_EXT_LIST
741 $THREADS_LIST
742 altivec_h
c9fdab0d 743 arpa_inet_h
6bd859d6 744 bswap
c88f5d72 745 byteswap_h
ecf97f22 746 closesocket
1ac9331a 747 cmov
e16e49ac 748 conio_h
c88f5d72 749 dcbzl
f8aa696f
DB
750 dev_bktr_ioctl_bt848_h
751 dev_bktr_ioctl_meteor_h
752 dev_ic_bt8xx_h
753 dev_video_meteor_ioctl_meteor_h
754 dev_video_bktr_ioctl_bt848_h
18b67ae5 755 dlfcn_h
c88f5d72 756 dlopen
245626d0
DB
757 ebp_available
758 ebx_available
c2a29455 759 fast_64bit
7073e9fc 760 fast_cmov
7b829d2a 761 fast_unaligned
9d99cc5a 762 fork
c88f5d72 763 freetype2
da9e86f8 764 gethrtime
4e68cb8a 765 GetProcessTimes
66be5b45 766 getrusage
c88f5d72 767 imlib2
2e1913b1 768 inet_aton
61d251db 769 inline_asm
0b4a1821
AS
770 libdc1394_1
771 libdc1394_2
a33cab3a
MK
772 llrint
773 lrint
c88f5d72 774 lrintf
f8aa696f
DB
775 machine_ioctl_bt848_h
776 machine_ioctl_meteor_h
c88f5d72
MR
777 malloc_h
778 memalign
6ffa87d3 779 mkstemp
b4e806b2 780 pld
9cafbd6c 781 ppc64
a33cab3a
MK
782 round
783 roundf
c88f5d72
MR
784 sdl
785 sdl_video_size
72be9e73 786 socklen_t
deb29777 787 soundcard_h
f8cda19e 788 poll_h
b58412f1 789 sys_mman_h
b091aa44 790 sys_resource_h
81644c2e 791 sys_select_h
deb29777 792 sys_soundcard_h
1b6e8b73 793 sys_videoio_h
e16e49ac 794 termios_h
b265431e 795 threads
6ff3f3e7 796 winsock2_h
304d586d 797 yasm
0cb78cef 798"
44161118 799
520cc7f1 800CMDLINE_SELECT="
3f5b56e5 801 $ARCH_EXT_LIST
520cc7f1 802 $CONFIG_LIST
8eee7025 803 $THREADS_LIST
db6107b6 804 cross_compile
520cc7f1
MR
805 debug
806 extra_warnings
8c6afa4d 807 logging
d2bbb2f7 808 optimizations
520cc7f1
MR
809 shared
810 static
87a0fb62 811 stripping
520cc7f1 812"
426be5dc
DB
813
814PATHS_LIST='
d156bede 815 bindir
26759c44
MR
816 incdir
817 libdir
26759c44
MR
818 mandir
819 prefix
820 shlibdir
426be5dc
DB
821'
822
823CMDLINE_SET="
824 $PATHS_LIST
825 arch
826 build_suffix
827 cc
828 cpu
829 cross_prefix
ac63af34 830 extra_version
426be5dc 831 logfile
26759c44
MR
832 source_path
833 target_os
426be5dc 834"
520cc7f1 835
912f3148
DB
836# code dependency declarations
837
9eeed841
MR
838# architecture extensions
839altivec_deps="powerpc"
840armv5te_deps="armv4l"
841armv6_deps="armv4l"
f55b299a 842armvfp_deps="armv4l"
9eeed841 843iwmmxt_deps="armv4l"
e241ba14 844mmi_deps="mips"
9eeed841 845mmx_deps="x86"
fbef871d 846mmx2_deps="x86 mmx"
6b18d278 847neon_deps="armv4l"
9eeed841 848ssse3_deps="x86"
bd9d34a0 849vis_deps="sparc"
9eeed841 850
de0e19cc
MR
851# system headers and functions
852byteswap_h_deps="!armv4l"
853
912f3148 854# decoders / encoders
1b71f045 855ac3_decoder_deps="gpl !liba52"
33a0dd37 856dxa_decoder_deps="zlib"
406ab5cc 857eac3_decoder_deps="gpl"
30fd06be 858flashsv_decoder_deps="zlib"
773be23a 859flashsv_encoder_deps="zlib"
b517af05 860mlp_decoder_deps="mlp_parser"
30fd06be
MR
861mpeg_xvmc_decoder_deps="xvmc"
862png_decoder_deps="zlib"
863png_encoder_deps="zlib"
30fd06be
MR
864zmbv_decoder_deps="zlib"
865zmbv_encoder_deps="zlib"
866
912f3148 867# external libraries
7bc5f2a8 868liba52_decoder_deps="liba52"
4ec45764 869liba52bin_decoder_extralibs='$ldl'
f5a756ef
DB
870libamr_nb_decoder_deps="libamr_nb"
871libamr_nb_encoder_deps="libamr_nb"
872libamr_wb_decoder_deps="libamr_wb"
873libamr_wb_encoder_deps="libamr_wb"
1b71f045 874libdirac_decoder_deps="libdirac !libschroedinger"
690bfceb 875libdirac_encoder_deps="libdirac"
c9171a83 876libfaac_encoder_deps="libfaac"
69ddbd1d 877libfaad_decoder_deps="libfaad"
4ec45764 878libfaadbin_decoder_extralibs='$ldl'
299c77d5
MR
879libgsm_decoder_deps="libgsm"
880libgsm_encoder_deps="libgsm"
8ffed8d8
MR
881libgsm_ms_decoder_deps="libgsm"
882libgsm_ms_encoder_deps="libgsm"
1cc60c47 883libmp3lame_encoder_deps="libmp3lame"
f7cd9eed
AS
884libschroedinger_decoder_deps="libschroedinger"
885libschroedinger_encoder_deps="libschroedinger"
150d2772 886libtheora_encoder_deps="libtheora"
b0caf888 887libvorbis_encoder_deps="libvorbis"
1cc60c47
DB
888libx264_encoder_deps="libx264"
889libxvid_encoder_deps="libxvid"
13566c31 890mpeg4aac_decoder_deps="libfaad"
30fd06be 891
912f3148 892# demuxers / muxers
03a76ba9 893ac3_demuxer_deps="ac3_parser"
50383e88 894audio_beos_demuxer_deps="audio_beos"
4ec45764 895audio_beos_demuxer_extralibs="-lmedia -lbe"
50383e88 896audio_beos_muxer_deps="audio_beos"
4ec45764 897audio_beos_muxer_extralibs="-lmedia -lbe"
53b73365 898avisynth_demuxer_deps="avisynth"
73483024 899bktr_demuxer_deps_any="dev_bktr_ioctl_bt848_h machine_ioctl_bt848_h dev_video_bktr_ioctl_bt848_h dev_ic_bt8xx_h"
17ac9f1c 900dirac_demuxer_deps="dirac_parser"
fe9bb347 901dv1394_demuxer_deps="dv1394 dv_demuxer"
f7b8bffe 902libdc1394_demuxer_deps="libdc1394"
d7c59247
DB
903libnut_demuxer_deps="libnut"
904libnut_muxer_deps="libnut"
4bd8e17c 905mp3_demuxer_deps="mpegaudio_parser"
c7682de0
RP
906oss_demuxer_deps_any="soundcard_h sys_soundcard_h"
907oss_muxer_deps_any="soundcard_h sys_soundcard_h"
30fd06be 908redir_demuxer_deps="network"
8eb793c4 909rtp_muxer_deps="network rtp_protocol"
95c21842
LA
910rtsp_demuxer_deps="sdp_demuxer"
911sdp_demuxer_deps="rtp_protocol mpegts_demuxer"
06e31011 912v4l_demuxer_deps="linux_videodev_h"
1b6e8b73 913v4l2_demuxer_deps_any="linux_videodev2_h sys_videoio_h"
c2345207
RP
914vfwcap_demuxer_deps="capCreateCaptureWindow"
915vfwcap_demuxer_extralibs="-lvfw32"
06eab4ba 916x11_grab_device_demuxer_deps="x11grab XShmCreateImage"
4ec45764 917x11_grab_device_demuxer_extralibs="-lX11 -lXext"
30fd06be 918
912f3148 919# protocols
c08fb000
AB
920http_protocol_deps="network"
921rtp_protocol_deps="udp_protocol"
922tcp_protocol_deps="network"
923udp_protocol_deps="network"
924
f7679c54 925# filters
81124ba0 926movie_filter_deps="avfilter_lavf"
f7679c54 927
912f3148 928# programs
fa859b4d 929ffplay_deps="sdl"
6ad42348 930ffserver_deps="ffm_muxer rtp_protocol rtsp_demuxer"
4ec45764
RP
931ffserver_extralibs='$ldl'
932vhook_extralibs='$ldl'
a2830dca 933
912f3148 934
de6d9b64 935# default parameters
8a608357 936
2ba042a7 937logfile="config.err"
8a608357
MR
938
939# installation paths
c9d19248
MR
940prefix_default="/usr/local"
941bindir_default='${prefix}/bin'
942incdir_default='${prefix}/include'
943libdir_default='${prefix}/lib'
944mandir_default='${prefix}/share/man'
945shlibdir_default="$libdir_default"
8a608357
MR
946
947# toolchain
de6d9b64 948cc="gcc"
304d586d 949yasmexe="yasm"
de6d9b64 950ar="ar"
503d5b58 951nm="nm"
be7109c1 952ranlib="ranlib"
0f3cb305 953strip="strip"
8a608357 954asmalign_pot="unknown"
20369773 955ln_s="ln -sf"
304d586d 956objformat="elf"
8a608357
MR
957
958# machine
cc6a90dd 959arch=`uname -m`
38d0a8aa 960cpu="generic"
8a608357 961
8a608357 962# OS
4f854758 963target_os=$(tolower $(uname -s))
8a608357 964
8a608357 965# libraries
f402916e 966enable bzlib
497237c7 967enable zlib
8a608357
MR
968
969# configurable options
497237c7 970enable debug
497237c7
RP
971enable ffmpeg
972enable ffplay
973enable ffserver
974enable ipv6
497237c7
RP
975enable mpegaudio_hp
976enable network
8400d6b8 977enable optimizations
497237c7 978enable protocols
530dc538 979enable static
87a0fb62 980enable stripping
8a608357
MR
981vhook="default"
982
8a608357 983# build settings
11a9d3e8 984add_cflags -D_ISOC99_SOURCE -D_POSIX_C_SOURCE=200112
9987769a 985SHFLAGS='-shared -Wl,-soname,$$(@F)'
cab3ef82 986VHOOKSHFLAGS='$(SHFLAGS)'
c536cb09 987FFSERVERLDFLAGS=-Wl,-E
f3ec2d46
SG
988LIBPREF="lib"
989LIBSUF=".a"
c5f14466
RP
990FULLNAME='$(NAME)$(BUILDSUF)'
991LIBNAME='$(LIBPREF)$(FULLNAME)$(LIBSUF)'
f3ec2d46
SG
992SLIBPREF="lib"
993SLIBSUF=".so"
c5f14466 994SLIBNAME='$(SLIBPREF)$(FULLNAME)$(SLIBSUF)'
b29bddab
DB
995SLIBNAME_WITH_VERSION='$(SLIBNAME).$(LIBVERSION)'
996SLIBNAME_WITH_MAJOR='$(SLIBNAME).$(LIBMAJOR)'
24743a76 997LIB_INSTALL_EXTRA_CMD='$(RANLIB) "$(LIBDIR)/$(LIBNAME)"'
ef0bc4c9 998
315c741d 999# gcc stupidly only outputs the basename of targets with -MM
18c64005 1000DEPEND_CMD='$(CC) $(CFLAGS) -MM -MG $< | sed -e "/^\#.*/d" -e "1s,^,$(@D)/," -e "s,\\([[:space:]]\\)\\(version\\.h\\),\\1\$$(BUILD_ROOT_REL)/\\2,"'
315c741d 1001
c597172e
MR
1002# find source path
1003source_path="`dirname \"$0\"`"
497237c7 1004enable source_path_used
c597172e
MR
1005if test -z "$source_path" -o "$source_path" = "." ; then
1006 source_path="`pwd`"
497237c7 1007 disable source_path_used
c597172e
MR
1008else
1009 source_path="`cd \"$source_path\"; pwd`"
1010 echo "$source_path" | grep -q '[[:blank:]]' &&
7483e694 1011 die "Out of tree builds are impossible with whitespace in source path."
c597172e
MR
1012fi
1013
c597172e
MR
1014FFMPEG_CONFIGURATION="$@"
1015
73ef8980
MR
1016find_things(){
1017 thing=$1
1018 pattern=$2
1019 file=$source_path/$3
932ccf39 1020 sed -n "s/^[^#]*$pattern.*([^,]*, *\([^,]*\)\(,.*\)*).*/\1_$thing/p" "$file"
73ef8980
MR
1021}
1022
1023ENCODER_LIST=$(find_things encoder ENC libavcodec/allcodecs.c)
1024DECODER_LIST=$(find_things decoder DEC libavcodec/allcodecs.c)
1025PARSER_LIST=$(find_things parser PARSER libavcodec/allcodecs.c)
1026BSF_LIST=$(find_things bsf BSF libavcodec/allcodecs.c)
1027MUXER_LIST=$(find_things muxer _MUX libavformat/allformats.c)
1028DEMUXER_LIST=$(find_things demuxer DEMUX libavformat/allformats.c)
1029OUTDEV_LIST=$(find_things muxer _MUX libavdevice/alldevices.c)
1030INDEV_LIST=$(find_things demuxer DEMUX libavdevice/alldevices.c)
1031PROTOCOL_LIST=$(find_things protocol PROTOCOL libavformat/allformats.c)
81124ba0 1032FILTER_LIST=$(find_things filter FILTER libavfilter/allfilters.c)
c597172e 1033
7483e694
DB
1034enable $ARCH_EXT_LIST \
1035 $DECODER_LIST \
1036 $ENCODER_LIST \
1037 $PARSER_LIST \
1038 $BSF_LIST \
1039 $DEMUXER_LIST \
1040 $MUXER_LIST \
f7679c54 1041 $FILTER_LIST \
7483e694
DB
1042 $PROTOCOL_LIST \
1043 $INDEV_LIST \
1044 $OUTDEV_LIST \
c597172e
MR
1045
1046die_unknown(){
1047 echo "Unknown option \"$1\"."
1048 echo "See $0 --help for available options."
1049 exit 1
1050}
1051
794f8e97 1052show_list() {
bf0c4afa
RP
1053 suffix=_$1
1054 shift
1055 echo $* | sed s/$suffix//g | tr ' ' '\n' | sort
794f8e97
PI
1056 exit 0
1057}
1058
c597172e 1059for opt do
7483e694
DB
1060 optval="${opt#*=}"
1061 case "$opt" in
7483e694
DB
1062 --extra-cflags=*) add_cflags "$optval"
1063 ;;
1064 --extra-ldflags=*) add_ldflags "$optval"
1065 ;;
1066 --extra-libs=*) add_extralibs "$optval"
1067 ;;
8fb1cb58 1068 --disable-devices) disable $INDEV_LIST $OUTDEV_LIST
9aa8ed9d 1069 ;;
40bcf4c7
BL
1070 --enable-debug=*) debuglevel="$optval"
1071 ;;
7483e694
DB
1072 --enable-*=*|--disable-*=*)
1073 eval `echo "$opt" | sed 's/=/-/;s/--/action=/;s/-/ thing=/;s/-/ name=/'`
1074 case "$thing" in
81124ba0 1075 encoder|decoder|muxer|demuxer|parser|bsf|protocol|filter) $action ${optval}_${thing} ;;
7483e694
DB
1076 *) die_unknown "$opt" ;;
1077 esac
1078 ;;
1079 --enable-?*|--disable-?*)
1080 eval `echo "$opt" | sed 's/--/action=/;s/-/ option=/;s/-/_/g'`
e3773a55
MR
1081 if is_in $option $COMPONENT_LIST; then
1082 eval $action \$$(toupper ${option%s})_LIST
1083 elif is_in $option $CMDLINE_SELECT; then
1084 $action $option
1085 else
1086 die_unknown $opt
1087 fi
7483e694
DB
1088 ;;
1089 --list-*)
1090 NAME="${opt#--list-}"
1091 is_in $NAME $COMPONENT_LIST || die_unknown $opt
1092 NAME=${NAME%s}
1093 eval show_list $NAME \$$(toupper $NAME)_LIST
1094 ;;
1095 --help|-h) show_help
1096 ;;
1097 *)
26759c44
MR
1098 optname="${opt%=*}"
1099 optname="${optname#--}"
1100 optname=$(echo "$optname" | sed 's/-/_/g')
1101 is_in $optname $CMDLINE_SET || die_unknown $opt
1102 eval $optname='$optval'
7483e694
DB
1103 ;;
1104 esac
c597172e
MR
1105done
1106
bcea99bb
MR
1107disabled logging && logfile=/dev/null
1108
1109echo "# $0 $@" > $logfile
1110set >> $logfile
1111
adb2b908 1112cc="${cross_prefix}${cc}"
304d586d 1113yasmexe="${cross_prefix}${yasmexe}"
adb2b908
RP
1114ar="${cross_prefix}${ar}"
1115nm="${cross_prefix}${nm}"
1116ranlib="${cross_prefix}${ranlib}"
1117strip="${cross_prefix}${strip}"
1118
e4e69e0b
MR
1119# set temporary file name
1120if test ! -z "$TMPDIR" ; then
1121 TMPDIR1="${TMPDIR}"
1122elif test ! -z "$TEMPDIR" ; then
1123 TMPDIR1="${TEMPDIR}"
1124else
1125 TMPDIR1="/tmp"
1126fi
1127
1128TMPC="${TMPDIR1}/ffmpeg-conf-${RANDOM}-$$-${RANDOM}.c"
1129TMPE="${TMPDIR1}/ffmpeg-conf-${RANDOM}-$$-${RANDOM}${EXESUF}"
1130TMPH="${TMPDIR1}/ffmpeg-conf-${RANDOM}-$$-${RANDOM}.h"
1131TMPO="${TMPDIR1}/ffmpeg-conf-${RANDOM}-$$-${RANDOM}.o"
1132TMPS="${TMPDIR1}/ffmpeg-conf-${RANDOM}-$$-${RANDOM}.S"
1133TMPSH="${TMPDIR1}/ffmpeg-conf-${RANDOM}-$$-${RANDOM}.sh"
1134
e9b9a2f8
MN
1135check_cflags -fasm
1136check_cflags -std=c99
1137
b24dbcbd
RP
1138case "$arch" in
1139 i386|i486|i586|i686|i86pc|BePC)
1140 arch="x86_32"
1141 enable fast_unaligned
1142 ;;
1143 x86_64|amd64)
1144 arch="x86_32"
1145 enable fast_unaligned
1146 check_cc <<EOF && enable fast_64bit && arch="x86_64"
1147 int test[sizeof(char*) - 7];
1148EOF
1149 ;;
1150 # armv4l is a subset of armv[567]*l
1151 arm|armv[4567]*l)
1152 arch="armv4l"
1153 ;;
1154 alpha)
1155 arch="alpha"
1156 enable fast_64bit
1157 ;;
1158 "Power Macintosh"|ppc|powerpc)
1159 arch="powerpc"
1160 ;;
1161 ppc64)
1162 arch="powerpc"
1163 enable fast_64bit
1164 ;;
1165 mips|mipsel|IP*)
1166 arch="mips"
1167 ;;
1168 sun4u|sparc64)
1169 arch="sparc64"
1170 enable fast_64bit
1171 ;;
1172 sparc)
1173 arch="sparc"
1174 ;;
1175 sh4)
1176 arch="sh4"
1177 ;;
1178 parisc)
1179 arch="parisc"
1180 ;;
1181 parisc64)
1182 arch="parisc"
1183 enable fast_64bit
1184 ;;
1185 s390|s390x)
1186 arch="s390"
1187 ;;
1188 m68k)
1189 arch="m68k"
1190 ;;
1191 ia64)
1192 arch="ia64"
1193 enable fast_64bit
1194 ;;
1195 bfin)
1196 arch="bfin"
1197 ;;
1198 *)
1199 arch="unknown"
1200 ;;
1201esac
1202
1203enable $arch
1204enabled_any x86_32 x86_64 && enable x86
1205enabled sparc64 && enable sparc
1206
7483e694 1207# OS specific
4f854758 1208case $target_os in
7483e694 1209 beos|haiku|zeta)
c9d19248 1210 prefix_default="$HOME/config"
7483e694
DB
1211 # helps building libavcodec
1212 add_cflags "-DPIC -fomit-frame-pointer"
1213 # 3 gcc releases known for BeOS, each with ugly bugs
1214 gcc_version="`$cc -v 2>&1 | grep version | cut -d ' ' -f3-`"
1215 case "$gcc_version" in
1216 2.9-beos-991026*|2.9-beos-000224*) echo "R5/GG gcc"
1217 disable mmx
1218 ;;
1219 *20010315*) echo "BeBits gcc"
1220 add_cflags "-fno-expensive-optimizations"
1221 ;;
1222 esac
7483e694
DB
1223 SHFLAGS=-nostart
1224 # enable BeOS things
1225 enable audio_beos
1226 # no need for libm, but the inet stuff
1227 # Check for BONE
1228 # XXX: actually should check for NOT net_server
78fe7631 1229 if echo $BEINCLUDES | grep -q 'headers/be/bone'; then
7483e694
DB
1230 network_extralibs="-lbind -lsocket"
1231 else
1232 enable beos_netserver
1233 network_extralibs="-lnet"
1234 fi ;;
1235 sunos)
1236 FFSERVERLDFLAGS=""
9987769a 1237 SHFLAGS='-shared -Wl,-h,$$(@F)'
7483e694
DB
1238 network_extralibs="-lsocket -lnsl"
1239 ;;
1240 netbsd)
1241 oss_demuxer_extralibs="-lossaudio"
1242 oss_muxer_extralibs="-lossaudio"
1243 ;;
1244 openbsd)
1245 disable need_memalign
1246 LIBOBJFLAGS='$(PIC)'
7483e694
DB
1247 SHFLAGS='-shared'
1248 SLIBNAME='$(SLIBPREF)$(FULLNAME)$(SLIBSUF).$(LIBVERSION)'
1249 SLIBNAME_WITH_VERSION='$(SLIBNAME)'
1250 SLIBNAME_WITH_MAJOR='$(SLIBNAME)'
1251 oss_demuxer_extralibs="-lossaudio"
1252 oss_muxer_extralibs="-lossaudio"
1253 ;;
1254 freebsd)
1255 disable need_memalign
1256 ;;
1257 bsd/os)
1258 osextralibs="-lpoll -lgnugetopt"
1259 strip="strip -d"
1260 ;;
1261 darwin)
1262 disable need_memalign
0138c54e 1263 SHFLAGS='-dynamiclib -Wl,-single_module -Wl,-install_name,$(SHLIBDIR)/$(SLIBNAME),-current_version,$(LIBVERSION),-compatibility_version,$(LIBMAJOR) -Wl,-read_only_relocs,suppress'
9987769a 1264 VHOOKSHFLAGS='-dynamiclib -Wl,-single_module -flat_namespace -undefined suppress -Wl,-install_name,$(SHLIBDIR)/vhook/$$(@F)'
7483e694
DB
1265 strip="strip -x"
1266 FFLDFLAGS="-Wl,-dynamic,-search_paths_first"
1267 SLIBSUF=".dylib"
1268 SLIBNAME_WITH_VERSION='$(SLIBPREF)$(FULLNAME).$(LIBVERSION)$(SLIBSUF)'
1269 SLIBNAME_WITH_MAJOR='$(SLIBPREF)$(FULLNAME).$(LIBMAJOR)$(SLIBSUF)'
1270 FFSERVERLDFLAGS=-Wl,-bind_at_load
304d586d 1271 objformat="macho"
1b0f6fb8 1272 enabled x86_64 && objformat="macho64"
7483e694
DB
1273 ;;
1274 mingw32*)
4f854758 1275 target_os=mingw32
dcc01c06
RP
1276 LIBTARGET=i386
1277 if test $arch = x86_64; then
1278 disable need_memalign
1279 LIBTARGET=x64
1280 fi
fbd971a4 1281 shlibdir_default="$bindir_default"
7483e694
DB
1282 VHOOKSHFLAGS='-shared -L$(BUILD_ROOT)/libavformat -L$(BUILD_ROOT)/libavcodec -L$(BUILD_ROOT)/libavutil'
1283 VHOOKLIBS='-lavformat$(BUILDSUF) -lavcodec$(BUILDSUF) -lavutil$(BUILDSUF) $(EXTRALIBS)'
13ca50f3 1284 if enabled swscale; then
7483e694
DB
1285 VHOOKSHFLAGS="$VHOOKSHFLAGS -L\$(BUILD_ROOT)/libswscale"
1286 VHOOKLIBS="$VHOOKLIBS -lswscale\$(BUILDSUF)"
1287 fi
1288 disable ffserver
1289 SLIBPREF=""
1290 SLIBSUF=".dll"
1291 EXESUF=".exe"
1292 SLIBNAME_WITH_VERSION='$(SLIBPREF)$(FULLNAME)-$(LIBVERSION)$(SLIBSUF)'
1293 SLIBNAME_WITH_MAJOR='$(SLIBPREF)$(FULLNAME)-$(LIBMAJOR)$(SLIBSUF)'
dcc01c06 1294 SLIB_EXTRA_CMD='-lib /machine:$(LIBTARGET) /def:$$(@:$(SLIBSUF)=.def) /out:$(SUBDIR)$(SLIBNAME_WITH_MAJOR:$(SLIBSUF)=.lib)'
4c25d159
RP
1295 SLIB_INSTALL_EXTRA_CMD='-install -m 644 $(SUBDIR)$(SLIBNAME_WITH_MAJOR:$(SLIBSUF)=.lib) "$(SHLIBDIR)/$(SLIBNAME:$(SLIBSUF)=.lib)"; \
1296 install -m 644 $(SUBDIR)$(SLIBNAME_WITH_MAJOR:$(SLIBSUF)=.lib) "$(SHLIBDIR)/$(SLIBNAME_WITH_MAJOR:$(SLIBSUF)=.lib)"'
7483e694 1297 SLIB_UNINSTALL_EXTRA_CMD='rm -f "$(SHLIBDIR)/$(SLIBNAME:$(SLIBSUF)=.lib)"'
71c61f62 1298 SHFLAGS='-shared -Wl,--output-def,$$(@:$(SLIBSUF)=.def) -Wl,--enable-runtime-pseudo-reloc -Wl,--enable-auto-image-base'
304d586d 1299 objformat="win32"
7483e694
DB
1300 ;;
1301 cygwin*)
4f854758 1302 target_os=cygwin
fbd971a4 1303 shlibdir_default="$bindir_default"
7483e694
DB
1304 VHOOKSHFLAGS='-shared -L$(BUILD_ROOT)/libavformat -L$(BUILD_ROOT)/libavcodec -L$(BUILD_ROOT)/libavutil'
1305 VHOOKLIBS='-lavformat$(BUILDSUF) -lavcodec$(BUILDSUF) -lavutil$(BUILDSUF) $(EXTRALIBS)'
13ca50f3 1306 if enabled swscale; then
7483e694
DB
1307 VHOOKSHFLAGS="$VHOOKSHFLAGS -L\$(BUILD_ROOT)/libswscale"
1308 VHOOKLIBS="$VHOOKLIBS -lswscale\$(BUILDSUF)"
1309 fi
1310 EXESUF=".exe"
1311 SLIBPREF="cyg"
1312 SLIBSUF=".dll"
1313 SLIBNAME_WITH_VERSION='$(SLIBPREF)$(FULLNAME)-$(LIBVERSION)$(SLIBSUF)'
1314 SLIBNAME_WITH_MAJOR='$(SLIBPREF)$(FULLNAME)-$(LIBMAJOR)$(SLIBSUF)'
1315 SHFLAGS='-shared -Wl,--enable-auto-image-base'
304d586d 1316 objformat="win32"
7483e694 1317 ;;
4f365f37 1318 *-dos|freedos|opendos)
4f365f37
MK
1319 disable ffplay ffserver vhook
1320 disable $INDEV_LIST $OUTDEV_LIST
1321 network_extralibs="-lsocket"
1322 EXESUF=".exe"
304d586d 1323 objformat="win32"
4f365f37 1324 ;;
7483e694 1325 linux)
7483e694
DB
1326 enable dv1394
1327 ;;
1328 irix*)
4f854758 1329 target_os=irix
7483e694
DB
1330 ranlib="echo ignoring ranlib"
1331 ;;
d22e8442 1332 os/2*)
d22e8442
DY
1333 strip="lxlite"
1334 ln_s="cp -f"
d22e8442
DY
1335 EXESUF=".exe"
1336 FFLDFLAGS="-Zomf -Zbin-files -Zargs-wild -Zmap"
71c61f62 1337 SHFLAGS='$(SUBDIR)$(NAME).def -Zdll -Zomf'
d22e8442 1338 FFSERVERLDFLAGS=""
287d3b13 1339 LIBSUF="_s.a"
d22e8442
DY
1340 SLIBPREF=""
1341 SLIBSUF=".dll"
1342 SLIBNAME_WITH_VERSION='$(SLIBPREF)$(NAME)-$(LIBVERSION)$(SLIBSUF)'
1343 SLIBNAME_WITH_MAJOR='$(SLIBPREF)$(shell echo $(NAME) | cut -c1-6)$(LIBMAJOR)$(SLIBSUF)'
71c61f62
MR
1344 SLIB_CREATE_DEF_CMD='echo LIBRARY $(SLIBNAME_WITH_MAJOR) INITINSTANCE TERMINSTANCE > $(SUBDIR)$(NAME).def; \
1345 echo PROTMODE >> $(SUBDIR)$(NAME).def; \
1346 echo CODE PRELOAD MOVEABLE DISCARDABLE >> $(SUBDIR)$(NAME).def; \
1347 echo DATA PRELOAD MOVEABLE MULTIPLE NONSHARED >> $(SUBDIR)$(NAME).def; \
1348 echo EXPORTS >> $(SUBDIR)$(NAME).def; \
1349 emxexp -o $(OBJS) >> $(SUBDIR)$(NAME).def'
1350 SLIB_EXTRA_CMD='emximp -o $(SUBDIR)$(LIBPREF)$(NAME)_dll.a $(SUBDIR)$(NAME).def; \
1351 emximp -o $(SUBDIR)$(LIBPREF)$(NAME)_dll.lib $(SUBDIR)$(NAME).def;'
1352 SLIB_INSTALL_EXTRA_CMD='install -m 644 $(SUBDIR)$(LIBPREF)$(NAME)_dll.a $(SUBDIR)$(LIBPREF)$(NAME)_dll.lib "$(LIBDIR)"'
d22e8442 1353 SLIB_UNINSTALL_EXTRA_CMD='rm -f "$(LIBDIR)"/$(LIBPREF)$(NAME)_dll.a "$(LIBDIR)"/$(LIBPREF)$(NAME)_dll.lib'
c6eed369 1354 disable vhook
d22e8442 1355 ;;
269820f1
PR
1356 interix)
1357 disable vhook
1358 ;;
d22e8442 1359
7483e694 1360 *)
4f854758 1361 target_os="${target_os}-UNKNOWN"
7483e694
DB
1362 ;;
1363esac
1364
c9d19248
MR
1365set_default $PATHS_LIST
1366
c597172e 1367add_extralibs $osextralibs
de6d9b64 1368
28d8e661
DB
1369# Combine FFLDFLAGS and the LDFLAGS environment variable.
1370LDFLAGS="$FFLDFLAGS $LDFLAGS"
e89b8b0a 1371
497237c7 1372test -n "$cross_prefix" && enable cross_compile
1ea46bed 1373
320d060a 1374# we need to build at least one lib type
93b3c083 1375if ! enabled_any static shared; then
320d060a
DB
1376 cat <<EOF
1377At least one library type must be built.
1378Specify --enable-static to build the static libraries or --enable-shared to
1379build the shared libraries as well. To only build the shared libraries specify
1380--disable-static in addition to --enable-shared.
1381EOF
1382 exit 1;
1383fi
1384
abc4e572 1385disabled static && LIBNAME=""
2a320695 1386
a2234ceb
RP
1387if enabled_any libfaad libfaadbin ; then
1388 if check_header faad.h; then
295b8c70 1389 check_cc <<EOF
a2234ceb
RP
1390#include <faad.h>
1391#ifndef FAAD2_VERSION
1392ok faad1
1393#endif
db817cf3 1394int main(void) { return 0; }
a2234ceb
RP
1395EOF
1396 test $? = 0 && enable libfaad2
1397 else
ff3dac65 1398 die "FAAD test failed."
a2234ceb
RP
1399 fi
1400fi
1401
1402
93b3c083 1403if ! enabled gpl; then
54118497
RP
1404 die_gpl_disabled(){
1405 name=$1
1406 shift
1407 enabled_any $@ && die "$name is under GPL and --enable-gpl is not specified."
1408 }
4a24ab64 1409 die_gpl_disabled "The Postprocessing code" postproc
7bc5f2a8 1410 die_gpl_disabled "liba52" liba52
1cc60c47
DB
1411 die_gpl_disabled "libx264" libx264
1412 die_gpl_disabled "libxvidcore" libxvid
54118497
RP
1413 die_gpl_disabled "FAAD2" libfaad2
1414 die_gpl_disabled "The X11 grabber" x11grab
13ca50f3 1415 die_gpl_disabled "The software scaler" swscale
ebb810d9 1416fi
b2e3c528 1417
3fe142e2
DB
1418if ! enabled nonfree && enabled_any libamr_nb libamr_wb; then
1419 die "libamr is nonfree and --enable-nonfree is not specified."
1420fi
1421
9eeed841 1422check_deps $ARCH_EXT_LIST
0f3cb305 1423
5d323602
MR
1424test -z "$need_memalign" && need_memalign="$mmx"
1425
cf9d24ad 1426#Darwin CC versions
4f854758 1427if test $target_os = darwin; then
3dddba4b 1428 if $cc -v 2>&1 | grep -q xlc; then
30a3e5d4 1429 add_cflags "-qpdf2 -qlanglvl=extc99 -qmaxmem=-1 -qarch=auto -qtune=auto"
cf9d24ad 1430 else
8541cc27 1431 add_cflags "-pipe"
26c1b3be
DB
1432 check_cflags "-force_cpusubtype_ALL"
1433 check_cflags "-Wno-sign-compare"
f946a9a4 1434 enabled shared || check_cflags -mdynamic-no-pic
cf9d24ad 1435 fi
2a1a6b64
MN
1436fi
1437
40617a6d 1438disabled optimizations || check_cflags -fomit-frame-pointer
cf9d24ad 1439
a4adb608 1440# Add processor-specific flags
38d0a8aa 1441if test $cpu != "generic"; then
bc8ec47b
MR
1442 warn_altivec(){
1443 $1 altivec && echo "WARNING: Tuning for $2 but AltiVec $1.";
1658bc4f 1444 }
38d0a8aa 1445 case $cpu in
bb270c08 1446 601|ppc601|PowerPC601)
1c5d830c 1447 add_cflags "-mcpu=601"
bc8ec47b 1448 warn_altivec enabled PPC601
bb270c08
DB
1449 ;;
1450 603*|ppc603*|PowerPC603*)
1c5d830c 1451 add_cflags "-mcpu=603"
bc8ec47b 1452 warn_altivec enabled PPC603
bb270c08
DB
1453 ;;
1454 604*|ppc604*|PowerPC604*)
1c5d830c 1455 add_cflags "-mcpu=604"
bc8ec47b 1456 warn_altivec enabled PPC604
bb270c08
DB
1457 ;;
1458 G3|g3|75*|ppc75*|PowerPC75*)
1c5d830c 1459 add_cflags "-mcpu=750 -mpowerpc-gfxopt"
bc8ec47b 1460 warn_altivec enabled PPC75x
bb270c08
DB
1461 ;;
1462 G4|g4|745*|ppc745*|PowerPC745*)
1c5d830c 1463 add_cflags "-mcpu=7450 -mpowerpc-gfxopt"
bc8ec47b 1464 warn_altivec disabled PPC745x
bb270c08
DB
1465 ;;
1466 74*|ppc74*|PowerPC74*)
1c5d830c 1467 add_cflags "-mcpu=7400 -mpowerpc-gfxopt"
bc8ec47b 1468 warn_altivec disabled PPC74xx
bb270c08
DB
1469 ;;
1470 G5|g5|970|ppc970|PowerPC970|power4*|Power4*)
1c5d830c 1471 add_cflags "-mcpu=970 -mpowerpc-gfxopt -mpowerpc64"
bc8ec47b 1472 warn_altivec disabled PPC970
9cafbd6c 1473 enable ppc64
bb270c08 1474 ;;
e07e357d
LB
1475 Cell|CELL|cell)
1476 add_cflags "-mcpu=cell"
1477 warn_altivec disabled Cell
9cafbd6c 1478 enable ppc64
e07e357d 1479 ;;
e7768fc5
GP
1480 # targets that do NOT support conditional mov (cmov)
1481 i[345]86|pentium|pentium-mmx|k6|k6-[23]|winchip-c6|winchip2|c3)
38d0a8aa 1482 add_cflags "-march=$cpu"
497237c7 1483 disable cmov
e7768fc5
GP
1484 ;;
1485 # targets that do support conditional mov (cmov)
416519dd 1486 i686|pentiumpro|pentium[23]|pentium-m|athlon|athlon-tbird|athlon-4|athlon-[mx]p|athlon64|k8|opteron|athlon-fx|core2)
e7768fc5 1487 add_cflags "-march=$cpu"
497237c7
RP
1488 enable cmov
1489 enable fast_cmov
94e4c3a3
GP
1490 ;;
1491 # targets that do support conditional mov but on which it's slow
800a5a19 1492 pentium4|pentium4m|prescott|nocona)
94e4c3a3 1493 add_cflags "-march=$cpu"
497237c7
RP
1494 enable cmov
1495 disable fast_cmov
bb270c08 1496 ;;
d7b34d08 1497 sparc64)
1c5d830c 1498 add_cflags "-mcpu=v9"
d7b34d08 1499 ;;
265de665 1500 arm*|cortex*)
6b19786b
MR
1501 add_cflags "-mcpu=$cpu"
1502 ;;
bb270c08 1503 *)
7483e694 1504 echo "WARNING: Unknown CPU \"$cpu\", ignored."
bb270c08 1505 ;;
a4adb608
MN
1506 esac
1507fi
1508
be0d52ab 1509# make sure we can execute files in $TMPDIR
2270b4b2 1510cat > $TMPSH 2>> $logfile <<EOF
be0d52ab
MR
1511#! /bin/sh
1512EOF
2270b4b2
DB
1513chmod +x $TMPSH >> $logfile 2>&1
1514if ! $TMPSH >> $logfile 2>&1; then
be0d52ab
MR
1515 cat <<EOF
1516Unable to create and execute files in $TMPDIR1. Set the TMPDIR environment
68300911
DB
1517variable to another directory and make sure that $TMPDIR1 is not mounted
1518noexec.
be0d52ab
MR
1519EOF
1520 die "Sanity test failed."
1521fi
edd08265 1522rm $TMPSH
be0d52ab 1523
1a268acc
MR
1524# compiler sanity check
1525check_exec <<EOF
c23a0ac8 1526int main(void){ return 0; }
1a268acc
MR
1527EOF
1528if test "$?" != 0; then
1529 echo "$cc is unable to create an executable file."
93b3c083 1530 if test -z "$cross_prefix" && ! enabled cross_compile ; then
db6107b6 1531 echo "If $cc is a cross-compiler, use the --enable-cross-compile option."
c7ae6345 1532 echo "Only do this if you know what cross compiling means."
1a268acc
MR
1533 fi
1534 die "C compiler test failed."
1535fi
1536
b4d96ba2
MR
1537check_cc <<EOF || die "Symbol mangling check failed."
1538int ff_extern;
1539EOF
2f05d9c1 1540sym=$($nm -P -g $TMPO | grep ff_extern)
b4d96ba2
MR
1541extern_prefix=${sym%%ff_extern*}
1542
61d251db
MR
1543check_asm inline_asm '""'
1544
9eeed841 1545if enabled x86; then
44965991
PI
1546 # check whether EBP is available on x86
1547 # As 'i' is stored on the stack, this program will crash
1548 # if the base pointer is used to access it because the
1549 # base pointer is cleared in the inline assembly code.
7dfef245 1550 check_exec_crash <<EOF && enable ebp_available
44965991
PI
1551 volatile int i=0;
1552 asm volatile (
1553 "xorl %%ebp, %%ebp"
1554 ::: "%ebp");
1555 return i;
44965991
PI
1556EOF
1557
1558 # check wether EBX is available on x86
940f335a 1559 check_asm ebx_available '"":::"%ebx"'
8e380710 1560
d7f0920b 1561 # check whether binutils is new enough to compile SSSE3/MMX2
940f335a 1562 enabled ssse3 && check_asm ssse3 '"pabsw %xmm0, %xmm0"'
d7f0920b 1563 enabled mmx2 && check_asm mmx2 '"movss %xmm0, %xmm0"'
6bd859d6
MR
1564
1565 check_asm bswap '"bswap %%eax" ::: "%eax"'
304d586d
LM
1566
1567 YASMFLAGS="-f $objformat -DARCH_$(toupper $arch)"
1568 enabled x86_64 && append YASMFLAGS "-m amd64"
1569 enabled_all x86_64 shared && append YASMFLAGS "-DPIC"
1570 case "$objformat" in
1571 elf) enabled debug && append YASMFLAGS "-g dwarf2" ;;
1b0f6fb8 1572 macho64) append YASMFLAGS "-DPIC -DPREFIX" ;;
304d586d
LM
1573 *) append YASMFLAGS "-DPREFIX" ;;
1574 esac
1575 check_yasm "pabsw xmm0, xmm0" && enable yasm
44965991
PI
1576fi
1577
87ea51e0
LB
1578# check for assembler specific support
1579
cc6a90dd 1580if test $arch = "powerpc"; then
497237c7 1581check_cc <<EOF && enable dcbzl
87ea51e0
LB
1582int main(void) {
1583 register long zero = 0;
1584 char data[1024];
1585 asm volatile("dcbzl %0, %1" : : "b" (data), "r" (zero));
1586return 0;
1587}
1588EOF
1589fi
1590
57bd82d4
MR
1591# check for SIMD availability
1592
115329f1 1593# AltiVec flags: The FSF version of GCC differs from the Apple version
9eeed841 1594if enabled altivec; then
3ed1a2ee
DB
1595 check_cflags -maltivec -mabi=altivec &&
1596 { check_header altivec.h && inc_altivec_h="#include <altivec.h>" ; } ||
4477b9f4 1597 check_cflags -faltivec
b6e52719 1598
0182fee8 1599 # check if our compiler supports Motorola AltiVec C API
497237c7 1600 check_cc <<EOF || disable altivec
dcd479c0 1601$inc_altivec_h
a9a07762
MN
1602int main(void) {
1603 vector signed int v1, v2, v3;
1604 v1 = vec_add(v2,v3);
1605 return 0;
1606}
1607EOF
b006b26c
DB
1608
1609 # check if our compiler supports braces for vector declarations
80a61f08 1610 check_cc <<EOF || die "You need a compiler that supports {} in AltiVec vector declarations."
b006b26c 1611$inc_altivec_h
80a61f08 1612int main (void) { (vector int) {1}; return 0; }
b006b26c 1613EOF
a9a07762 1614fi
ab6c65f6 1615
b4e806b2
MC
1616# We have to check if pld is a nop and disable it.
1617enabled armv4l && check_asm pld '"pld [r0]"'
940f335a
MR
1618enabled armv5te && check_asm armv5te '"qadd r0, r0, r0"'
1619enabled armv6 && check_asm armv6 '"sadd16 r0, r0, r0"'
f55b299a 1620enabled armvfp && check_asm armvfp '"fadds s0, s0, s0"'
940f335a
MR
1621enabled iwmmxt && check_asm iwmmxt '"wunpckelub wr6, wr4"'
1622enabled mmi && check_asm mmi '"lq $2, 0($2)"'
6b18d278 1623enabled neon && check_asm neon '"vadd.i16 q0, q0, q0"'
940f335a 1624enabled vis && check_asm vis '"pdist %f0, %f0, %f0"' -mcpu=ultrasparc
bd9d34a0 1625
8b03def6
DB
1626enabled vis && add_cflags "-mcpu=ultrasparc -mtune=ultrasparc"
1627
57bd82d4
MR
1628# ---
1629# big/little-endian test
9eebe687
MR
1630check_cc <<EOF || die "endian test failed"
1631unsigned int endian = 'B' << 24 | 'I' << 16 | 'G' << 8 | 'E';
a3999908 1632EOF
d04d9e16 1633od -A n -t x1 $TMPO | grep -q '42 *49 *47 *45' && enable bigendian
487a54d7 1634
a3999908 1635# ---
3d204385
NK
1636# check availability of some header files
1637
a98bb16d
RP
1638if check_func dlopen; then
1639 ldl=
1640elif check_func dlopen -ldl; then
1641 ldl=-ldl
8bf5d58f
MN
1642fi
1643
7483e694
DB
1644check_func fork
1645check_func gethrtime
1646check_func getrusage
094c09bb 1647check_func inet_aton $network_extralibs
7483e694
DB
1648check_func memalign
1649check_func mkstemp
2446d3d6 1650check_func_headers windows.h GetProcessTimes
6ffa87d3 1651
a98bb16d 1652check_header byteswap.h
e16e49ac 1653check_header conio.h
a98bb16d
RP
1654check_header dlfcn.h
1655check_header malloc.h
bf6ce82d 1656check_header poll.h
b58412f1 1657check_header sys/mman.h
b091aa44 1658check_header sys/resource.h
bf6ce82d 1659check_header sys/select.h
a98bb16d
RP
1660check_header termios.h
1661
1662if ! enabled_any memalign memalign_hack && enabled need_memalign ; then
1663 die "Error, no memalign() but SSE enabled, disable it or use --enable-memalign-hack."
1664fi
e16e49ac 1665
e8214e0e 1666enabled zlib && check_lib zlib.h zlibVersion -lz || disable zlib
f402916e 1667enabled bzlib && check_lib bzlib.h BZ2_bzlibVersion -lbz2 || disable bzlib
57bd82d4
MR
1668
1669# check for some common methods of building with pthread support
1670# do this before the optional library checks as some of them require pthreads
1671if enabled pthreads; then
9e7fd101
MR
1672 if check_func pthread_create; then
1673 :
1674 elif check_func pthread_create -pthread; then
1675 add_cflags -pthread
afc9aee2 1676 add_extralibs -pthread
9e7fd101
MR
1677 elif check_func pthread_create -pthreads; then
1678 add_cflags -pthreads
afc9aee2 1679 add_extralibs -pthreads
8d94f606
GT
1680 elif check_func pthread_create -lpthreadGC2; then
1681 add_extralibs -lpthreadGC2
9e7fd101
MR
1682 elif ! check_lib pthread.h pthread_create -lpthread; then
1683 die "ERROR: can't find pthreads library"
1684 fi
57bd82d4
MR
1685fi
1686
8eee7025 1687for thread in $THREADS_LIST; do
e5f94c2b 1688 if enabled $thread; then
3ae3b721
RP
1689 test -n "$thread_type" &&
1690 die "ERROR: Only one thread type must be selected." ||
e5f94c2b 1691 thread_type="$thread"
e5f94c2b
RP
1692 fi
1693done
1694
fdf88598
MR
1695check_lib math.h sin -lm
1696
a33cab3a
MK
1697# test for C99 functions in math.h
1698for func in llrint lrint lrintf round roundf; do
1699 check_exec <<EOF && enable $func || disable $func
f32adb22 1700#include <math.h>
a33cab3a 1701int main(void) { return ($func(3.999f) > 0)?0:1; }
f32adb22 1702EOF
a33cab3a 1703done
f32adb22 1704
57bd82d4 1705# these are off by default, so fail if requested and not available
79fda097 1706enabled avisynth && require2 vfw32 "windows.h vfw.h" AVIFileInit -lvfw32
7483e694
DB
1707enabled liba52 && require liba52 a52dec/a52.h a52_init -la52
1708enabled libamr_nb && require libamrnb amrnb/interf_dec.h Speech_Decode_Frame_init -lamrnb -lm
1709enabled libamr_wb && require libamrwb amrwb/dec_if.h D_IF_init -lamrwb -lm
690bfceb
AS
1710enabled libdirac && add_cflags "$(pkg-config --cflags dirac)" \
1711 && require libdirac libdirac_decoder/dirac_parser.h dirac_decoder_init -ldirac_decoder \
1712 && require libdirac libdirac_encoder/dirac_encoder.h dirac_encoder_init -ldirac_encoder
79fda097
DB
1713enabled libfaac && require2 libfaac "stdint.h faac.h" faacEncGetVersion -lfaac
1714enabled libfaad && require2 libfaad faad.h faacDecOpen -lfaad
7483e694
DB
1715enabled libgsm && require libgsm gsm.h gsm_create -lgsm
1716enabled libmp3lame && require LAME lame/lame.h lame_init -lmp3lame -lm
1717enabled libnut && require libnut libnut.h nut_demuxer_init -lnut
f7cd9eed 1718enabled libschroedinger && add_cflags $(pkg-config --cflags schroedinger-1.0) \
0eeb52f9 1719 && require libschroedinger schroedinger/schro.h schro_init $(pkg-config --libs schroedinger-1.0)
7483e694
DB
1720enabled libtheora && require libtheora theora/theora.h theora_info_init -ltheora -logg
1721enabled libvorbis && require libvorbis vorbis/vorbisenc.h vorbis_info_init -lvorbisenc -lvorbis -logg
18ee626c 1722enabled libx264 && require x264 x264.h x264_encoder_open -lx264 -lm
7483e694
DB
1723enabled libxvid && require Xvid xvid.h xvid_global -lxvidcore
1724enabled mlib && require mediaLib mlib_types.h mlib_VectorSub_S16_U8_Mod -lmlib
8ac17293 1725
0b4a1821
AS
1726# libdc1394 check
1727if enabled libdc1394; then
1728 { check_lib dc1394/dc1394.h dc1394_new -ldc1394 -lraw1394 &&
1729 enable libdc1394_2; } ||
1730 { check_lib libdc1394/dc1394_control.h dc1394_create_handle -ldc1394_control -lraw1394 &&
1731 enable libdc1394_1; } ||
1732 die "ERROR: No version of libdc1394 found "
1733fi
1734
1735
c13e1abd
FH
1736_restrict=
1737for restrict_keyword in restrict __restrict__ __restrict; do
57bd82d4 1738 check_cc <<EOF && _restrict=$restrict_keyword && break
dcd479c0
MR
1739void foo(char * $restrict_keyword p);
1740EOF
c13e1abd
FH
1741done
1742
703afd07 1743test "$vhook" = "default" && vhook="$dlopen"
a8721c09 1744
4f854758 1745if test "$target_os" = cygwin -o "$target_os" = mingw32 && enabled_all static vhook ; then
497237c7 1746 disable vhook
fbb9d104 1747 echo
b0268cc0 1748 echo "At the moment vhooks don't work on Cygwin or MinGW static builds."
fbb9d104
VP
1749 echo "Patches welcome."
1750 echo
1751fi
1752
8d923001
MR
1753if enabled vhook; then
1754 check_ldflags -rdynamic
1755 check_ldflags -export-dynamic
1756fi
bfd2edeb 1757
eea50282
MR
1758check_foo_config imlib2 imlib2 Imlib2.h imlib_load_font
1759check_foo_config freetype2 freetype ft2build.h FT_Init_FreeType
04511d53 1760
a86b921c 1761##########################################
29799f8b 1762# SDL check
a86b921c 1763
497237c7
RP
1764disable sdl_too_old
1765disable sdl
6a1a892f 1766SDL_CONFIG="${cross_prefix}sdl-config"
2270b4b2 1767if "${SDL_CONFIG}" --version > /dev/null 2>&1; then
225e21ef
MR
1768 sdl_cflags=`"${SDL_CONFIG}" --cflags`
1769 temp_cflags $sdl_cflags
dcd479c0 1770 temp_extralibs `"${SDL_CONFIG}" --libs`
1ca5d97f 1771 if check_lib2 SDL.h SDL_Init; then
dcd479c0 1772 _sdlversion=`"${SDL_CONFIG}" --version | sed 's/[^0-9]//g'`
29f3b38a 1773 if test "$_sdlversion" -lt 121 ; then
497237c7 1774 enable sdl_too_old
dcd479c0 1775 else
497237c7 1776 enable sdl
225e21ef 1777 check_cc $sdl_cflags <<EOF && enable sdl_video_size
29f3b38a 1778#include <SDL.h>
d6773f56 1779int main(int argc, char **argv){
29f3b38a
MR
1780 const SDL_VideoInfo *vi = SDL_GetVideoInfo();
1781 int w = vi->current_w;
1782 return 0;
1783}
1784EOF
dcd479c0
MR
1785 fi
1786 fi
29f3b38a 1787 restore_flags
c3f6b472 1788fi
57bd82d4 1789
2270b4b2 1790texi2html -version > /dev/null 2>&1 && enable texi2html || disable texi2html
146ea952 1791
7a91333f 1792##########################################
73b46a95
RP
1793# Network check
1794
1795if enabled network; then
668b65bd 1796 check_type sys/socket.h socklen_t
73b46a95
RP
1797 # Prefer arpa/inet.h over winsock2
1798 if check_header arpa/inet.h ; then
1799 check_func closesocket
1800 elif check_header winsock2.h ; then
ea10ddde 1801 network_extralibs="-lws2_32"
72be9e73 1802 check_type ws2tcpip.h socklen_t
2446d3d6 1803 check_func_headers winsock2.h closesocket
73b46a95
RP
1804 fi
1805fi
1806
1807##########################################
29799f8b 1808# IPv6 check
7a91333f 1809
497237c7 1810enabled network && enabled ipv6 && check_ld <<EOF && enable ipv6 || disable ipv6
7a91333f
HZ
1811#include <sys/types.h>
1812#include <sys/socket.h>
1813#include <netinet/in.h>
1814#include <netdb.h>
db817cf3 1815int main(void) {
7483e694
DB
1816 struct sockaddr_storage saddr;
1817 struct ipv6_mreq mreq6;
1818 getaddrinfo(0,0,0,0);
1819 getnameinfo(0,0,0,0,0,0,0);
1820 IN6_IS_ADDR_MULTICAST((const struct in6_addr *)0);
7a91333f
HZ
1821}
1822EOF
1823
06e31011
RP
1824check_header linux/videodev.h
1825check_header linux/videodev2.h
1b6e8b73 1826check_header sys/videoio.h
47f38850 1827
2446d3d6 1828check_func_headers "windows.h vfw.h" capCreateCaptureWindow -lvfw32
c2345207 1829
f8aa696f 1830# check for ioctl_meteor.h, ioctl_bt848.h and alternatives
1c915f83
RP
1831{ check_header dev/bktr/ioctl_meteor.h &&
1832 check_header dev/bktr/ioctl_bt848.h; } ||
1833{ check_header machine/ioctl_meteor.h &&
1834 check_header machine/ioctl_bt848.h; } ||
1835{ check_header dev/video/meteor/ioctl_meteor.h &&
1836 check_header dev/video/bktr/ioctl_bt848.h; } ||
1837check_header dev/ic/bt8xx.h
f8aa696f 1838
c7682de0
RP
1839check_header sys/soundcard.h
1840check_header soundcard.h
deb29777 1841
7483e694 1842# deal with the X11 frame grabber
56a059ac 1843enabled x11grab &&
f58f4ce1
GP
1844check_header X11/Xlib.h &&
1845check_header X11/extensions/XShm.h &&
1846check_func XOpenDisplay -lX11 &&
06eab4ba 1847check_func XShmCreateImage -lX11 -lXext
f58f4ce1 1848
40bcf4c7 1849enabled debug && add_cflags -g"$debuglevel"
57bd82d4
MR
1850
1851# add some useful compiler flags if supported
1852check_cflags -Wdeclaration-after-statement
dcd479c0
MR
1853check_cflags -Wall
1854check_cflags -Wno-switch
c07bd6a9
MN
1855check_cflags -Wdisabled-optimization
1856check_cflags -Wpointer-arith
1857check_cflags -Wredundant-decls
cc1fb623 1858check_cflags -Wno-pointer-sign
f4929996 1859check_cflags -Wcast-qual
9aceb3cf 1860check_cflags -Wwrite-strings
652a5bf6 1861check_cflags -Wtype-limits
5af4e0cc 1862enabled extra_warnings && check_cflags -Winline
cf9d24ad 1863
57bd82d4 1864# add some linker flags
5c0e9479 1865check_ldflags -Wl,--warn-common
8351d2ba
DB
1866check_ldflags -Wl,--as-needed
1867check_ldflags '-Wl,-rpath-link,\$(BUILD_ROOT)/libpostproc -Wl,-rpath-link,\$(BUILD_ROOT)/libswscale -Wl,-rpath-link,\$(BUILD_ROOT)/libavfilter -Wl,-rpath-link,\$(BUILD_ROOT)/libavdevice -Wl,-rpath-link,\$(BUILD_ROOT)/libavformat -Wl,-rpath-link,\$(BUILD_ROOT)/libavcodec -Wl,-rpath-link,\$(BUILD_ROOT)/libavutil'
c2fd6530 1868check_ldflags -Wl,-Bsymbolic
94a3401e 1869
bd2216e4
MR
1870if enabled small; then
1871 check_cflags -Os # not all compilers support -Os
8400d6b8
DB
1872 optimizations="small"
1873elif enabled optimizations; then
3dddba4b 1874 if $cc -v 2>&1 | grep -q xlc; then
30a3e5d4
NP
1875 add_cflags "-O5"
1876 add_ldflags "-O5"
cf9d24ad 1877 else
30a3e5d4 1878 add_cflags "-O3"
cf9d24ad 1879 fi
cddf3f45 1880fi
11fdbc44 1881check_cflags -fno-math-errno
b2eb2ff0 1882check_cflags -fno-signed-zeros
cddf3f45 1883
504a64b9 1884# add some flags for Intel C Compiler
0c45cd07 1885if $cc --version 2> /dev/null | grep -q Intel; then
504a64b9
CEH
1886 # Just warnings, no remarks
1887 check_cflags -w1
1888 # -wd: Disable following warnings
1889 # 144, 167, 556: -Wno-pointer-sign
1890 # 10006: ignoring unknown option -fno-signed-zeros
1891 # 10156: ignoring option '-W'; no argument required
1892 check_cflags -wd144,167,556,10006,10156
1893 # 11030: Warning unknown option --as-needed
1894 # 10156: ignoring option '-export'; no argument required
1895 check_ldflags -wd10156,11030
907eb3b5
CEH
1896 # Allow to compile with optimizations
1897 check_ldflags -march=$cpu
504a64b9
CEH
1898fi
1899
80581e98 1900# PIC flags for shared library objects where they are needed
5af4e0cc 1901if enabled shared; then
569cb218
MR
1902 # LIBOBJFLAGS may have already been set in the OS configuration
1903 if test -z "$LIBOBJFLAGS" ; then
1904 case "$arch" in
b6bd7268 1905 x86_64|ia64|alpha|sparc*|power*|parisc*|mips*) LIBOBJFLAGS='$(PIC)' ;;
569cb218
MR
1906 esac
1907 fi
80581e98
MN
1908fi
1909
90be59ef 1910if enabled gprof; then
30a3e5d4
NP
1911 add_cflags "-p"
1912 add_ldflags "-p"
1db54e20
DB
1913fi
1914
3b26ee47 1915VHOOKCFLAGS="-fPIC"
18451f7d 1916
7f3c02fc 1917# Find out if the .align argument is a power of two or not.
4454dc1b 1918if test $asmalign_pot = "unknown"; then
497237c7
RP
1919 disable asmalign_pot
1920 echo 'asm (".align 3");' | check_cc && enable asmalign_pot
4454dc1b
JD
1921fi
1922
7483e694
DB
1923enabled_any $DECODER_LIST && enable decoders
1924enabled_any $ENCODER_LIST && enable encoders
1925enabled_any $BSF_LIST && enable bsfs
1926enabled_any $DEMUXER_LIST && enable demuxers
1927enabled_any $MUXER_LIST && enable muxers
f7679c54 1928enabled_any $FILTER_LIST && enable filters
7483e694
DB
1929enabled_any $INDEV_LIST && enable demuxers
1930enabled_any $OUTDEV_LIST && enable muxers
1931enabled_any $PROTOCOL_LIST && enable protocols
1932
1933enabled_any $THREADS_LIST && enable threads
1934
1935check_deps $CONFIG_LIST \
1936 $HAVE_LIST \
1937 $DECODER_LIST \
1938 $ENCODER_LIST \
1939 $PARSER_LIST \
1940 $BSF_LIST \
1941 $DEMUXER_LIST \
1942 $MUXER_LIST \
f7679c54 1943 $FILTER_LIST \
7483e694
DB
1944 $INDEV_LIST \
1945 $OUTDEV_LIST \
1946 $PROTOCOL_LIST \
f70f03f6 1947
f7b8bffe 1948enabled libdc1394 && append pkg_requires "libraw1394"
690bfceb 1949enabled libdirac && append pkg_requires "dirac"
fb2ce7d9 1950enabled libtheora && append pkg_requires "theora"
f9def9cc 1951enabled libvorbis && append pkg_requires "vorbisenc"
fb2ce7d9 1952
3e89171a 1953echo "install prefix $prefix"
f36958f8
DB
1954echo "source path $source_path"
1955echo "C compiler $cc"
bfd5afd8 1956echo ".align is power-of-two $asmalign_pot"
f36958f8 1957echo "ARCH $arch ($cpu)"
ce8871c2
MR
1958if test "$build_suffix" != ""; then
1959 echo "build suffix $build_suffix"
eb94aca9 1960fi
ac63af34
DB
1961if test "$extra_version" != ""; then
1962 echo "version string suffix $extra_version"
1963fi
0db2ce77 1964echo "big-endian ${bigendian-no}"
419b8784 1965if test $arch = "x86_32" -o $arch = "x86_64"; then
af44e8e4 1966 echo "yasm ${yasm-no}"
0db2ce77
MR
1967 echo "MMX enabled ${mmx-no}"
1968 echo "CMOV enabled ${cmov-no}"
1969 echo "CMOV is fast ${fast_cmov-no}"
971cc990
MN
1970 echo "EBX available ${ebx_available-no}"
1971 echo "EBP available ${ebp_available-no}"
e41e8342 1972fi
cc6a90dd 1973if test $arch = "armv4l"; then
0db2ce77
MR
1974 echo "ARMv5TE enabled ${armv5te-no}"
1975 echo "ARMv6 enabled ${armv6-no}"
f55b299a 1976 echo "ARM VFP enabled ${armvfp-no}"
0db2ce77 1977 echo "IWMMXT enabled ${iwmmxt-no}"
6b18d278 1978 echo "NEON enabled ${neon-no}"
eba9ae3c 1979fi
e241ba14 1980if test $arch = "mips"; then
0db2ce77 1981 echo "MMI enabled ${mmi-no}"
e41e8342 1982fi
cc6a90dd 1983if test $arch = "powerpc"; then
0db2ce77
MR
1984 echo "AltiVec enabled ${altivec-no}"
1985 echo "dcbzl available ${dcbzl-no}"
e41e8342 1986fi
0db2ce77
MR
1987echo "gprof enabled ${gprof-no}"
1988echo "debug symbols ${debug-no}"
87a0fb62 1989echo "strip symbols ${stripping-no}"
8400d6b8 1990echo "optimizations ${optimizations-no}"
0db2ce77
MR
1991echo "static ${static-no}"
1992echo "shared ${shared-no}"
4a24ab64 1993echo "postprocessing support ${postproc-no}"
13ca50f3 1994echo "software scaler enabled ${swscale-no}"
f7679c54 1995echo "new filter support ${avfilter-no}"
81124ba0 1996echo "filters using lavformat ${avfilter_lavf-no}"
0db2ce77 1997echo "video hooking ${vhook-no}"
90be59ef 1998if enabled vhook; then
0db2ce77
MR
1999 echo "Imlib2 support ${imlib2-no}"
2000 echo "FreeType support ${freetype2-no}"
68892110 2001fi
0db2ce77 2002echo "network support ${network-no}"
90be59ef 2003if enabled network; then
0db2ce77 2004 echo "IPv6 support ${ipv6-no}"
bfd5afd8 2005fi
0db2ce77
MR
2006echo "threading support ${thread_type-no}"
2007echo "SDL support ${sdl-no}"
90be59ef 2008if enabled sdl_too_old; then
bfd5afd8
DB
2009 echo "-> Your SDL version is too old - please upgrade to have FFplay/SDL support."
2010fi
0db2ce77
MR
2011echo "Sun medialib support ${mlib-no}"
2012echo "AVISynth enabled ${avisynth-no}"
2013echo "liba52 support ${liba52-no}"
2014echo "liba52 dlopened ${liba52bin-no}"
2015echo "libamr-nb support ${libamr_nb-no}"
2016echo "libamr-wb support ${libamr_wb-no}"
f7b8bffe 2017echo "libdc1394 support ${libdc1394-no}"
690bfceb 2018echo "libdirac enabled ${libdirac-no}"
0db2ce77
MR
2019echo "libfaac enabled ${libfaac-no}"
2020echo "libfaad enabled ${libfaad-no}"
7e0871a7 2021echo "libfaad dlopened ${libfaadbin-no}"
0db2ce77
MR
2022echo "libgsm enabled ${libgsm-no}"
2023echo "libmp3lame enabled ${libmp3lame-no}"
2024echo "libnut enabled ${libnut-no}"
f7cd9eed 2025echo "libschroedinger enabled ${libschroedinger-no}"
0db2ce77
MR
2026echo "libtheora enabled ${libtheora-no}"
2027echo "libvorbis enabled ${libvorbis-no}"
d6bd62db
DB
2028echo "libx264 enabled ${libx264-no}"
2029echo "libxvid enabled ${libxvid-no}"
0db2ce77 2030echo "zlib enabled ${zlib-no}"
f402916e 2031echo "bzlib enabled ${bzlib-no}"
2c62e737 2032echo
de6d9b64 2033
f7679c54 2034for type in decoder encoder parser demuxer muxer protocol filter bsf indev outdev; do
8138b9db 2035 echo "Enabled ${type}s:"
f65c9da1 2036 eval list=\$$(toupper $type)_LIST
8138b9db 2037 for part in $list; do
f65c9da1
MR
2038 enabled $part && echo ${part%_*}
2039 done | sort | pr -3 -t
2040 echo
8138b9db
RP
2041done
2042
ba321adb
JK
2043license="LGPL"
2044if enabled nonfree; then
2045 license="unredistributable"
2046elif enabled gpl; then
2047 license="GPL"
2048fi
2049
2050echo "License: $license"
ca5323af 2051
cf1392e9
DB
2052echo "Creating config.mak and config.h..."
2053
29799f8b
DB
2054echo "# Automatically generated by configure - do not modify!" > config.mak
2055echo "/* Automatically generated by configure - do not modify! */" > $TMPH
9c05103f
DB
2056echo "#ifndef FFMPEG_CONFIG_H" >> $TMPH
2057echo "#define FFMPEG_CONFIG_H" >> $TMPH
0fd12426 2058echo "#define FFMPEG_CONFIGURATION \"$FFMPEG_CONFIGURATION\"" >> $TMPH
de6d9b64 2059
d921f03f 2060echo "FFMPEG_CONFIGURATION=$FFMPEG_CONFIGURATION" >> config.mak
c9d19248 2061echo "prefix=$prefix" >> config.mak
22a324da
DB
2062echo "LIBDIR=\$(DESTDIR)$libdir" >> config.mak
2063echo "SHLIBDIR=\$(DESTDIR)$shlibdir" >> config.mak
2064echo "INCDIR=\$(DESTDIR)$incdir" >> config.mak
2065echo "BINDIR=\$(DESTDIR)$bindir" >> config.mak
2066echo "MANDIR=\$(DESTDIR)$mandir" >> config.mak
980fc7b8 2067echo "CC=$cc" >> config.mak
304d586d 2068echo "YASM=$yasmexe" >> config.mak
980fc7b8 2069echo "AR=$ar" >> config.mak
be7109c1 2070echo "RANLIB=$ranlib" >> config.mak
20369773 2071echo "LN_S=$ln_s" >> config.mak
87a0fb62 2072enabled stripping &&
3ae3b721 2073 echo "STRIP=$strip" >> config.mak ||
f25fc9b1 2074 echo "STRIP=echo ignoring strip" >> config.mak
75388c74 2075
a9b3f630 2076echo "OPTFLAGS=$CFLAGS" >> config.mak
2270b4b2 2077echo "VHOOKCFLAGS=$VHOOKCFLAGS" >> config.mak
0f3cb305 2078echo "LDFLAGS=$LDFLAGS" >> config.mak
c536cb09 2079echo "FFSERVERLDFLAGS=$FFSERVERLDFLAGS" >> config.mak
e1707f52 2080echo "SHFLAGS=$SHFLAGS" >> config.mak
304d586d 2081echo "YASMFLAGS=$YASMFLAGS" >> config.mak
408382a4 2082echo "VHOOKSHFLAGS=$VHOOKSHFLAGS" >> config.mak
fbb9d104 2083echo "VHOOKLIBS=$VHOOKLIBS" >> config.mak
80581e98 2084echo "LIBOBJFLAGS=$LIBOBJFLAGS" >> config.mak
5af4e0cc 2085echo "BUILD_STATIC=$static" >> config.mak
ce8871c2 2086echo "BUILDSUF=$build_suffix" >> config.mak
c5f14466 2087echo "FULLNAME=$FULLNAME" >> config.mak
f3ec2d46 2088echo "LIBPREF=$LIBPREF" >> config.mak
c5f14466 2089echo "LIBSUF=$LIBSUF" >> config.mak
24743a76 2090echo "LIBNAME=$LIBNAME" >> config.mak
f3ec2d46 2091echo "SLIBPREF=$SLIBPREF" >> config.mak
c5f14466
RP
2092echo "SLIBSUF=$SLIBSUF" >> config.mak
2093echo "EXESUF=$EXESUF" >> config.mak
ac63af34 2094echo "EXTRA_VERSION=$extra_version" >> config.mak
315c741d 2095echo "DEPEND_CMD=$DEPEND_CMD" >> config.mak
4dc62701 2096
90be59ef 2097if enabled bigendian; then
7483e694
DB
2098 echo "WORDS_BIGENDIAN=yes" >> config.mak
2099 echo "#define WORDS_BIGENDIAN 1" >> $TMPH
91d1f1a4 2100fi
44161118 2101
90be59ef 2102if enabled sdl; then
7483e694
DB
2103 echo "SDL_LIBS=`"${SDL_CONFIG}" --libs`" >> config.mak
2104 echo "SDL_CFLAGS=`"${SDL_CONFIG}" --cflags`" >> config.mak
a86b921c 2105fi
90be59ef 2106if enabled texi2html; then
7483e694 2107 echo "BUILD_DOC=yes" >> config.mak
146ea952 2108fi
5a872801 2109
719c8e00
MR
2110get_version(){
2111 name=$1
2112 file=$source_path/$2
147e7692
MR
2113 eval $(grep "#define ${name}_VERSION_M" "$file" | awk '{ print $2"="$3 }')
2114 eval ${name}_VERSION=\$${name}_VERSION_MAJOR.\$${name}_VERSION_MINOR.\$${name}_VERSION_MICRO
0e32c8c6
MR
2115 lcname=$(tolower $name)
2116 eval echo "${lcname}_VERSION=\$${name}_VERSION" >> config.mak
2117 eval echo "${lcname}_VERSION_MAJOR=\$${name}_VERSION_MAJOR" >> config.mak
719c8e00
MR
2118}
2119
147e7692
MR
2120get_version LIBSWSCALE libswscale/swscale.h
2121get_version LIBPOSTPROC libpostproc/postprocess.h
2122get_version LIBAVCODEC libavcodec/avcodec.h
2123get_version LIBAVDEVICE libavdevice/avdevice.h
2124get_version LIBAVFORMAT libavformat/avformat.h
2125get_version LIBAVUTIL libavutil/avutil.h
a6601d69 2126get_version LIBAVFILTER libavfilter/avfilter.h
5a872801 2127
5af4e0cc 2128if enabled shared; then
7483e694
DB
2129 echo "BUILD_SHARED=yes" >> config.mak
2130 echo "PIC=-fPIC -DPIC" >> config.mak
dcc01c06 2131 echo "LIBTARGET=${LIBTARGET}" >> config.mak
7483e694
DB
2132 echo "SLIBNAME=${SLIBNAME}" >> config.mak
2133 echo "SLIBNAME_WITH_VERSION=${SLIBNAME_WITH_VERSION}" >> config.mak
2134 echo "SLIBNAME_WITH_MAJOR=${SLIBNAME_WITH_MAJOR}" >> config.mak
d22e8442 2135 echo "SLIB_CREATE_DEF_CMD=${SLIB_CREATE_DEF_CMD}" >> config.mak
7483e694
DB
2136 echo "SLIB_EXTRA_CMD=${SLIB_EXTRA_CMD}" >> config.mak
2137 echo "SLIB_INSTALL_EXTRA_CMD=${SLIB_INSTALL_EXTRA_CMD}" >> config.mak
2138 echo "SLIB_UNINSTALL_EXTRA_CMD=${SLIB_UNINSTALL_EXTRA_CMD}" >> config.mak
0319c531 2139fi
d7e27559 2140echo "LIB_INSTALL_EXTRA_CMD=${LIB_INSTALL_EXTRA_CMD}" >> config.mak
ef0bc4c9 2141echo "EXTRALIBS=$extralibs" >> config.mak
d2845d68 2142
3d907e22
MR
2143print_config ARCH_ $TMPH config.mak $ARCH_LIST
2144print_config HAVE_ $TMPH config.mak $HAVE_LIST
7483e694
DB
2145print_config CONFIG_ $TMPH config.mak $CONFIG_LIST \
2146 $DECODER_LIST \
2147 $ENCODER_LIST \
2148 $PARSER_LIST \
2149 $BSF_LIST \
2150 $DEMUXER_LIST \
2151 $MUXER_LIST \
f7679c54 2152 $FILTER_LIST \
7483e694
DB
2153 $PROTOCOL_LIST \
2154 $INDEV_LIST \
2155 $OUTDEV_LIST \
8ac17293 2156
c13e1abd
FH
2157echo "#define restrict $_restrict" >> $TMPH
2158
bd2216e4 2159if enabled small; then
7483e694 2160 echo "#define av_always_inline" >> $TMPH
bb801c97
MN
2161fi
2162
997baf01
MR
2163echo "SRC_PATH=\"$source_path\"" >> config.mak
2164echo "SRC_PATH_BARE=$source_path" >> config.mak
2165echo "BUILD_ROOT=\"$PWD\"" >> config.mak
0f3cb305 2166
8156056e 2167# Apparently it's not possible to portably echo a backslash.
3ae3b721 2168enabled asmalign_pot &&
7483e694 2169 printf '#define ASMALIGN(ZEROBITS) ".align " #ZEROBITS "\\n\\t"\n' >> $TMPH ||
295b8c70 2170 printf '#define ASMALIGN(ZEROBITS) ".align 1 << " #ZEROBITS "\\n\\t"\n' >> $TMPH
4454dc1b 2171
b4d96ba2 2172echo "#define EXTERN_PREFIX \"${extern_prefix}\"" >> $TMPH
bc634f6f 2173
9c05103f
DB
2174echo "#endif /* FFMPEG_CONFIG_H */" >> $TMPH
2175
b7860763 2176# Do not overwrite an unchanged config.h to avoid superfluous rebuilds.
3ae3b721
RP
2177cmp -s $TMPH config.h &&
2178 echo "config.h is unchanged" ||
2179 mv -f $TMPH config.h
3d204385 2180
cea0ac52 2181rm -f $TMPC $TMPE $TMPH $TMPO $TMPS $TMPSH
def4272a 2182
165af439 2183# build tree in object directory if source path is different from current one
90be59ef 2184if enabled source_path_used; then
165af439 2185 DIRS="\
7483e694
DB
2186 doc \
2187 libavcodec \
2188 libavcodec/alpha \
2189 libavcodec/armv4l \
2190 libavcodec/bfin \
2191 libavcodec/i386 \
2192 libavcodec/mlib \
2193 libavcodec/ppc \
2194 libavcodec/sh4 \
2195 libavcodec/sparc \
52a9cf34 2196 libavdevice \
f7679c54 2197 libavfilter \
7483e694
DB
2198 libavformat \
2199 libavutil \
2200 libpostproc \
2201 libswscale \
2202 tests \
2203 tools \
2204 vhook \
2205 "
165af439 2206 FILES="\
7483e694
DB
2207 Makefile \
2208 common.mak \
71c61f62 2209 subdir.mak \
7483e694
DB
2210 doc/texi2pod.pl \
2211 libavcodec/Makefile \
52a9cf34 2212 libavdevice/Makefile \
f7679c54 2213 libavfilter/Makefile \
7483e694
DB
2214 libavformat/Makefile \
2215 libavutil/Makefile \
2216 libpostproc/Makefile \
2217 libswscale/Makefile \
2218 "
165af439 2219 for dir in $DIRS ; do
7483e694 2220 mkdir -p $dir
165af439
MR
2221 done
2222 for f in $FILES ; do
20369773 2223 $ln_s "$source_path/$f" $f
165af439
MR
2224 done
2225fi
def4272a 2226
def4272a 2227
d0674868 2228# build pkg-config files
def4272a 2229
d0674868
DB
2230pkgconfig_generate(){
2231name=$1
e426941d 2232shortname=${name#lib}
d0674868
DB
2233comment=$2
2234version=$3
2235libs=$4
2236requires=$5
25cd5cb3 2237cat <<EOF > $name/$name.pc
3e89171a 2238prefix=$prefix
a94e666c 2239exec_prefix=\${prefix}
f2b7382c 2240libdir=$libdir
7622778e 2241includedir=$incdir
def4272a 2242
d0674868
DB
2243Name: $name
2244Description: $comment
2245Version: $version
5dcfe9f8
AH
2246Requires: $(disabled shared && echo $requires)
2247Requires.private: $(enabled shared && echo $requires)
def4272a 2248Conflicts:
12701f6e
AH
2249Libs: -L\${libdir} -l${shortname} $(disabled shared && echo $libs)
2250Libs.private: $(enabled shared && echo $libs)
76a448ed 2251Cflags: -I\${includedir}
def4272a 2252EOF
25cd5cb3 2253cat <<EOF > $name/$name-uninstalled.pc
def4272a
AJ
2254prefix=
2255exec_prefix=
46d1ff83 2256libdir=\${pcfiledir}
1d44d365 2257includedir=${source_path}
def4272a 2258
d0674868
DB
2259Name: $name
2260Description: $comment
2261Version: $version
2262Requires: $requires
def4272a 2263Conflicts:
12701f6e 2264Libs: \${libdir}/${LIBPREF}${shortname}${LIBSUF} $libs
def4272a
AJ
2265Cflags: -I\${includedir}
2266EOF
d0674868 2267}
def4272a 2268
e426941d 2269pkgconfig_generate libavutil "FFmpeg utility library" "$LIBAVUTIL_VERSION"
e426941d 2270pkgconfig_generate libavcodec "FFmpeg codec library" "$LIBAVCODEC_VERSION" "$extralibs" "$pkg_requires libavutil = $LIBAVUTIL_VERSION"
e426941d 2271pkgconfig_generate libavformat "FFmpeg container format library" "$LIBAVFORMAT_VERSION" "$extralibs" "$pkg_requires libavcodec = $LIBAVCODEC_VERSION"
e426941d 2272pkgconfig_generate libavdevice "FFmpeg device handling library" "$LIBAVDEVICE_VERSION" "$extralibs" "$pkg_requires libavformat = $LIBAVFORMAT_VERSION"
3ed1a2ee 2273enabled avfilter &&
35a71f1d 2274 pkgconfig_generate libavfilter "FFmpeg video filtering library" "$LIBAVFILTER_VERSION" "$extralibs" "$pkg_requires libavutil = $LIBAVUTIL_VERSION"
3ed1a2ee 2275enabled postproc &&
e426941d 2276 pkgconfig_generate libpostproc "FFmpeg post processing library" "$LIBPOSTPROC_VERSION"
13ca50f3 2277if enabled swscale; then
e426941d 2278 pkgconfig_generate libswscale "FFmpeg image rescaling library" "$LIBSWSCALE_VERSION" "" "libavutil = $LIBAVUTIL_VERSION"
6c0d0413 2279else
f436a23e 2280 pkgconfig_generate libswscale "FFmpeg image rescaling library" "$LIBSWSCALE_VERSION" "" "$pkg_requires libavcodec = $LIBAVCODEC_VERSION"
25cd5cb3 2281 apply libswscale/libswscale.pc sed s/^Libs:.*$/Libs:/
6c0d0413 2282fi