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