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