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