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