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