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