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