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