]> git.sesse.net Git - ffmpeg/blobdiff - configure
3 lines while -> 1 line for loop
[ffmpeg] / configure
index f772ed13d525adc14c68710f35dd28aa448c6aab..db94c14dd4684141ae97ca9232d3410a3a866eef 100755 (executable)
--- a/configure
+++ b/configure
@@ -9,7 +9,7 @@ show_help(){
   echo
   echo "Standard options:"
   echo "  --help                   print this message"
-  echo "  --log                    log tests and output to config.err"
+  echo "  --log[=FILE|yes|no]      log tests and output to FILE [config.err]"
   echo "  --prefix=PREFIX          install in PREFIX [$prefix]"
   echo "  --libdir=DIR             install libs in DIR [PREFIX/lib]"
   echo "  --incdir=DIR             install includes in DIR [PREFIX/include/ffmpeg]"
@@ -48,6 +48,7 @@ show_help(){
   echo "Advanced options (experts only):"
   echo "  --source-path=PATH       path to source code [$source_path]"
   echo "  --cross-prefix=PREFIX    use PREFIX for compilation tools [$cross_prefix]"
+  echo "  --cross-compile          assume a cross-compiler is used"
   echo "  --cc=CC                  use C compiler CC [$cc]"
   echo "  --make=MAKE              use specified make [$make]"
   echo "  --extra-cflags=ECFLAGS   add ECFLAGS to CFLAGS [$CFLAGS]"
@@ -107,9 +108,29 @@ logfile(){
     log END $1
 }
 
-die(){
+echolog(){
     log "$@"
     echo "$@"
+}
+
+die(){
+    echolog "$@"
+    cat <<EOF
+If you think configure made a mistake, make sure you are using the latest
+version from SVN.  If the latest version fails, report the problem to the
+ffmpeg-devel@mplayerhq.hu mailing list or IRC #ffmpeg on irc.freenode.net.
+EOF
+    if enabled log; then
+        cat <<EOF
+Include the log file "$logfile" produced by configure as this will help
+solving the problem.
+EOF
+    else
+cat <<EOF
+Rerun configure with logging enabled (do not use --log=no), and include the
+log this produces with your report.
+EOF
+    fi
     rm -f $TMPC $TMPO $TMPE $TMPS $TMPH
     exit 1
 }
@@ -247,7 +268,7 @@ check_lib(){
 }
 
 check_exec(){
-    check_ld "$@" && { test -n "$cross_prefix" || $TMPE; }
+    check_ld "$@" && { test "$cross_compile" = yes || $TMPE 2>&1 >>$logfile; }
 }
 
 require(){
@@ -278,14 +299,15 @@ TMPS="${TMPDIR1}/ffmpeg-conf-${RANDOM}-$$-${RANDOM}.S"
 TMPH="${TMPDIR1}/ffmpeg-conf-${RANDOM}-$$-${RANDOM}.h"
 
 # default parameters
-log="no"
-logfile="/dev/null"
+log="yes"
+logfile="config.err"
 prefix="/usr/local"
 libdir=""
 incdir=""
 mandir=""
 bindir=""
 cross_prefix=""
+cross_compile="no"
 cc="gcc"
 ar="ar"
 ranlib="ranlib"
@@ -321,7 +343,7 @@ case "$cpu" in
   "Power Macintosh"|ppc|powerpc)
     cpu="powerpc"
   ;;
-  mips|mipsel)
+  mips|mipsel|IP*)
     cpu="mips"
   ;;
   sun4u|sparc64)
@@ -476,7 +498,6 @@ bktr="yes"
 audio_oss="yes"
 dv1394="no"
 make="gmake"
-FFLDFLAGS="$FFLDFLAGS -export-dynamic"
 extralibs="$extralibs -lossaudio"
 ;;
 OpenBSD)
@@ -487,7 +508,6 @@ audio_oss="yes"
 dv1394="no"
 make="gmake"
 LIBOBJFLAGS="\$(PIC)"
-FFLDFLAGS="$FFLDFLAGS -export-dynamic -pthread"
 LDCONFIG="ldconfig -m \$(libdir)"
 extralibs="$extralibs -lossaudio"
 ;;
@@ -499,7 +519,6 @@ audio_oss="yes"
 dv1394="no"
 make="gmake"
 CFLAGS="$CFLAGS -pthread"
-FFLDFLAGS="$FFLDFLAGS -export-dynamic -pthread"
 ;;
 GNU/kFreeBSD)
 v4l="no"
@@ -508,7 +527,6 @@ bktr="yes"
 audio_oss="yes"
 dv1394="no"
 CFLAGS="$CFLAGS -pthread"
-LDFLAGS="$LDFLAGS -rdynamic"
 ;;
 BSD/OS)
 v4l="no"
@@ -554,7 +572,6 @@ cygwin="yes"
 EXESUF=".exe"
 ;;
 Linux)
-FFLDFLAGS="$FFLDFLAGS -rdynamic"
 ;;
 IRIX*)
 ranlib="echo ignoring ranlib"
@@ -631,7 +648,9 @@ CODEC_LIST=`grep 'register_avcodec(&[a-z]' $source_path/libavcodec/allcodecs.c
 
 for opt do
   case "$opt" in
-  --log) log=yes
+  --log)
+  ;;
+  --log=*) log="${opt#*=}"
   ;;
   --prefix=*) prefix=`echo $opt | cut -d '=' -f 2`; force_prefix=yes
   ;;
@@ -645,6 +664,8 @@ for opt do
   ;;
   --cross-prefix=*) cross_prefix=`echo $opt | cut -d '=' -f 2`
   ;;
+  --cross-compile) cross_compile=yes
+  ;;
   --cc=*) cc=`echo $opt | cut -d '=' -f 2-`
   ;;
   --make=*) make=`echo $opt | cut -d '=' -f 2`
@@ -797,15 +818,18 @@ for opt do
   esac
 done
 
-if enabled log; then
-    logfile=config.err
+if test "$log" != no; then
+    test "$log" = yes || logfile="$log"
     echo "# $0 $@" >$logfile
     set >>$logfile
+else
+    logfile=/dev/null
 fi
 
 # Combine FFLDFLAGS and the LDFLAGS environment variable
 LDFLAGS="$FFLDFLAGS $LDFLAGS"
 
+test -n "$cross_prefix" && cross_compile=yes
 cc="${cross_prefix}${cc}"
 ar="${cross_prefix}${ar}"
 ranlib="${cross_prefix}${ranlib}"
@@ -1009,6 +1033,20 @@ if test $tune != "generic"; then
     esac
 fi
 
+# compiler sanity check
+check_exec <<EOF
+int main(){
+    return 0;
+}
+EOF
+if test "$?" != 0; then
+    echo "$cc is unable to create an executable file."
+    if test -z "$cross_prefix" -a "$cross_compile" = no; then
+        echo "If $cc is a cross-compiler, use the --cross-compile option."
+    fi
+    die "C compiler test failed."
+fi
+
 # check for SIMD availability
 
 # AltiVec flags: The FSF version of GCC differs from the Apple version
@@ -1107,13 +1145,13 @@ EOF
     SLIBPREF=""
     SLIBSUF=".dll"
     EXESUF=".exe"
-    if test "$force_prefix" != yes; then prefix="/c/Program Files/FFmpeg"; fi
+    if test "$force_prefix" != yes; then prefix="$PROGRAMFILES/FFmpeg"; fi
     if test "$force_libdir" != yes; then bindir="$prefix"; fi
 fi
 
 # ---
 # big/little-endian test
-if test -z "$cross_prefix" ; then
+if test "$cross_compile" = "no"; then
     check_ld <<EOF || die "endian test failed" && $TMPE && bigendian="yes"
 #include <inttypes.h>
 int main(int argc, char ** argv){
@@ -1175,10 +1213,9 @@ fi
 enabled dts     && require libdts dts.h dts_init -ldts
 enabled libgsm  && require libgsm gsm.h gsm_create -lgsm
 enabled mp3lame && require LAME lame/lame.h lame_init -lmp3lame
-enabled libogg  && require libogg ogg/ogg.h ogg_sync_init -logg
 enabled vorbis  && require libvorbis vorbis/vorbisenc.h vorbis_info_init -lvorbis -lvorbisenc
+enabled libogg  && require libogg ogg/ogg.h ogg_sync_init -logg
 enabled theora  && require libtheora theora/theora.h theora_info_init -ltheora
-enabled faad    && require libfaad faad.h faacDecOpen -lfaad
 enabled xvid    && require XviD xvid.h xvid_global -lxvidcore
 enabled x264    && require x264 x264.h x264_encoder_open -lx264
 enabled dc1394  && require libdc1394 libdc1394/dc1394_control.h dc1394_create_handle -ldc1394_control -lraw1394
@@ -1201,6 +1238,21 @@ EOF
     restore_flags
 fi
 
+# Ugh, recent faad2 versions have renamed all functions and #define the
+# old names in faad.h.  Generic tests won't work.
+if enabled faad; then
+    save_flags
+    temp_extralibs -lfaad
+    check_ld <<EOF && add_extralibs -lfaad || die "ERROR: libfaad not found"
+#include <faad.h>
+int main(){
+    faacDecOpen();
+    return 0;
+}
+EOF
+    restore_flags
+fi
+
 # test for lrintf in math.h
 check_exec <<EOF && have_lrintf=yes || have_lrintf=no
 #define _ISOC9X_SOURCE  1
@@ -1239,6 +1291,10 @@ if test "$vhook" = "yes" -o "$a52bin" = "yes" -o "$faadbin" = "yes"; then
     add_extralibs $ldl
 fi
 
+if enabled vhook; then
+    check_ldflags -rdynamic
+    check_ldflags -export-dynamic
+fi
 
 ##########################################
 # imlib check