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