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