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