Skip to content
Snippets Groups Projects
configure 124 KiB
Newer Older
  • Learn to ignore specific revisions
  • if test -f configure; then
    
        source_path=.
    
        source_path=$(cd $(dirname "$0"); pwd)
    
        echo "$source_path" | grep -q '[[:blank:]]' &&
    
            die "Out of tree builds are impossible with whitespace in source path."
    
        test -e "$source_path/config.h" &&
            die "Out of tree builds are impossible with config.h in source dir."
    
        r=${v#*=}
        l=${v%"$r"}
        r=$(sh_quote "$r")
    
        FFMPEG_CONFIGURATION="${FFMPEG_CONFIGURATION# } ${l}${r}"
    
    find_things(){
        thing=$1
        pattern=$2
        file=$source_path/$3
    
        sed -n "s/^[^#]*$pattern.*([^,]*, *\([^,]*\)\(,.*\)*).*/\1_$thing/p" "$file"
    
    }
    
    ENCODER_LIST=$(find_things  encoder  ENC      libavcodec/allcodecs.c)
    DECODER_LIST=$(find_things  decoder  DEC      libavcodec/allcodecs.c)
    
    HWACCEL_LIST=$(find_things  hwaccel  HWACCEL  libavcodec/allcodecs.c)
    
    PARSER_LIST=$(find_things   parser   PARSER   libavcodec/allcodecs.c)
    BSF_LIST=$(find_things      bsf      BSF      libavcodec/allcodecs.c)
    MUXER_LIST=$(find_things    muxer    _MUX     libavformat/allformats.c)
    DEMUXER_LIST=$(find_things  demuxer  DEMUX    libavformat/allformats.c)
    
    OUTDEV_LIST=$(find_things   outdev   OUTDEV   libavdevice/alldevices.c)
    INDEV_LIST=$(find_things    indev    _IN      libavdevice/alldevices.c)
    
    PROTOCOL_LIST=$(find_things protocol PROTOCOL libavformat/allformats.c)
    
    FILTER_LIST=$(find_things   filter   FILTER   libavfilter/allfilters.c)
    
    ALL_COMPONENTS="
        $BSF_LIST
        $DECODER_LIST
        $DEMUXER_LIST
        $ENCODER_LIST
        $FILTER_LIST
        $HWACCEL_LIST
        $INDEV_LIST
        $MUXER_LIST
        $OUTDEV_LIST
        $PARSER_LIST
        $PROTOCOL_LIST
    "
    
    
        map "echo ${2}\${v}_test" $(ls "$source_path"/tests/ref/$1 | grep -v '[^-a-z0-9_]')
    
    LAVF_FATE_TESTS=$(find_tests lavf-fate)
    
    LAVF_TESTS=$(find_tests lavf)
    
    LAVFI_TESTS=$(find_tests lavfi)
    
    SEEK_TESTS=$(find_tests seek seek_)
    
    ALL_TESTS="$LAVF_FATE_TESTS $LAVF_TESTS $LAVFI_TESTS $SEEK_TESTS"
    
    for n in $COMPONENT_LIST; do
        v=$(toupper ${n%s})_LIST
        eval enable \$$v
        eval ${n}_if_any="\$$v"
    done
    
    
    enable $ARCH_EXT_LIST $ALL_TESTS
    
    
    die_unknown(){
        echo "Unknown option \"$1\"."
        echo "See $0 --help for available options."
        exit 1
    }
    
    
    Ramiro Polla's avatar
    Ramiro Polla committed
        suffix=_$1
        shift
    
        echo $* | sed s/$suffix//g | tr ' ' '\n' | sort | pr -3 -t
    
    rand_list(){
        IFS=', '
        set -- $*
        unset IFS
        for thing; do
            comp=${thing%:*}
            prob=${thing#$comp}
            prob=${prob#:}
            is_in ${comp} $COMPONENT_LIST && eval comp=\$$(toupper ${comp%s})_LIST
            echo "prob ${prob:-0.5}"
            printf '%s\n' $comp
        done
    }
    
    do_random(){
        action=$1
        shift
        random_seed=$(awk "BEGIN { srand($random_seed); print srand() }")
        $action $(rand_list "$@" | awk "BEGIN { srand($random_seed) } \$1 == \"prob\" { prob = \$2; next } rand() < prob { print }")
    }
    
    
        --extra-ldflags=*) add_ldflags $optval
    
        --extra-libs=*) add_extralibs $optval
    
        --disable-devices) disable $INDEV_LIST $OUTDEV_LIST
    
        --enable-debug=*) debuglevel="$optval"
        ;;
    
        --disable-everything)
    
        map 'eval unset \${$(toupper ${v%s})_LIST}' $COMPONENT_LIST
    
        --enable-random|--disable-random)
        action=${opt%%-random}
        do_random ${action#--} $COMPONENT_LIST
        ;;
        --enable-random=*|--disable-random=*)
        action=${opt%%-random=*}
        do_random ${action#--} $optval
        ;;
    
        eval $(echo "${opt%%=*}" | sed 's/--/action=/;s/-/ thing=/')
    
        is_in "${thing}s" $COMPONENT_LIST || die_unknown "$opt"
        eval list=\$$(toupper $thing)_LIST
    
        name=$(echo "${optval}" | sed "s/,/_${thing}|/g")_${thing}
        $action $(filter "$name" $list)
    
        eval $(echo "$opt" | sed 's/--/action=/;s/-/ option=/;s/-/_/g')
    
        if is_in $option $COMPONENT_LIST; then
    
            test $action = disable && action=unset
    
            eval $action \$$(toupper ${option%s})_LIST
        elif is_in $option $CMDLINE_SELECT; then
            $action $option
        else
            die_unknown $opt
        fi
    
        ;;
        --list-*)
            NAME="${opt#--list-}"
            is_in $NAME $COMPONENT_LIST || die_unknown $opt
            NAME=${NAME%s}
            eval show_list $NAME \$$(toupper $NAME)_LIST
        ;;
        --help|-h) show_help
        ;;
        *)
    
        optname="${optname#--}"
        optname=$(echo "$optname" | sed 's/-/_/g')
    
        if is_in $optname $CMDLINE_SET; then
            eval $optname='$optval'
        elif is_in $optname $CMDLINE_APPEND; then
            append $optname "$optval"
        else
             die_unknown $opt
        fi
    
    Måns Rullgård's avatar
    Måns Rullgård committed
    disabled logging && logfile=/dev/null
    
    
    echo "# $0 $FFMPEG_CONFIGURATION" > $logfile
    
    Måns Rullgård's avatar
    Måns Rullgård committed
    set >> $logfile
    
    
    test -n "$cross_prefix" && enable cross_compile
    
    
    if enabled cross_compile; then
        test -n "$arch" && test -n "$target_os" ||
            die "Must specify target arch and OS when cross-compiling"
    fi
    
    
    set_default arch target_os postproc_version
    
    # Check if we should build alternative libpostproc version instead of current
    if   test "$postproc_version" = $ALT_PP_VER; then
      LIBPOSTPROC_VERSION=$ALT_PP_VER
      LIBPOSTPROC_VERSION_MAJOR=$ALT_PP_VER_MAJOR
      LIBPOSTPROC_VERSION_MINOR=$ALT_PP_VER_MINOR
      LIBPOSTPROC_VERSION_MICRO=$ALT_PP_VER_MICRO
    elif test "$postproc_version" != current; then
      die "Invalid argument to --postproc-version. See --help output."
    fi
    
    ar_default="${cross_prefix}${ar_default}"
    
    cc_default="${cross_prefix}${cc_default}"
    
    Mohamed Naufal's avatar
    Mohamed Naufal committed
    cxx_default="${cross_prefix}${cxx_default}"
    
    Måns Rullgård's avatar
    Måns Rullgård committed
    nm_default="${cross_prefix}${nm_default}"
    
    pkg_config_default="${cross_prefix}${pkg_config_default}"
    
    ranlib="${cross_prefix}${ranlib}"
    
    strip_default="${cross_prefix}${strip_default}"
    
    sysinclude_default="${sysroot}/usr/include"
    
    
    set_default cc cxx nm pkg_config strip sysinclude yasmexe
    
    enabled cross_compile || host_cc_default=$cc
    set_default host_cc
    
    if ! $pkg_config --version >/dev/null 2>&1; then
        warn "$pkg_config not found, library detection may fail."
        pkg_config=false
    fi
    
    
            mingw32*|cygwin*|*-dos|freedos|opendos|os/2*|symbian) echo .exe ;;
    
        esac
    }
    
    EXESUF=$(exesuf $target_os)
    HOSTEXESUF=$(exesuf $host_os)
    
    # set temporary file name
    
    : ${TMPDIR:=$TEMPDIR}
    
    : ${TMPDIR:=/tmp}
    
    if ! check_cmd mktemp -u XXXXXX; then
    
        # simple replacement for missing mktemp
        # NOT SAFE FOR GENERAL USE
        mktemp(){
    
            echo "${2%%XXX*}.${HOSTNAME}.${UID}.$$"
    
        }
    fi
    
    tmpfile(){
        tmp=$(mktemp -u "${TMPDIR}/ffconf.XXXXXXXX")$2 &&
            (set -C; exec > $tmp) 2>/dev/null ||
    
            die "Unable to create temporary file in $TMPDIR."
    
        append TMPFILES $tmp
        eval $1=$tmp
    }
    
    trap 'rm -f -- $TMPFILES' EXIT
    
    
    tmpfile TMPASM .asm
    
    tmpfile TMPE   $EXESUF
    tmpfile TMPH   .h
    tmpfile TMPO   .o
    tmpfile TMPS   .S
    tmpfile TMPSH  .sh
    tmpfile TMPV   .ver
    
    chmod +x $TMPE
    
    
    # make sure we can execute files in $TMPDIR
    cat > $TMPSH 2>> $logfile <<EOF
    #! /bin/sh
    EOF
    chmod +x $TMPSH >> $logfile 2>&1
    if ! $TMPSH >> $logfile 2>&1; then
        cat <<EOF
    Unable to create and execute files in $TMPDIR.  Set the TMPDIR environment
    variable to another directory and make sure that it is not mounted noexec.
    EOF
        die "Sanity test failed."
    fi
    
    
    pgi_flags(){
        for flag; do
            case $flag in
                -fomit-frame-pointer) echo -Mnoframe ;;
                -g)                   echo -gopt ;;
                *)                    echo $flag ;;
            esac
        done
    }
    
    suncc_flags(){
        for flag; do
            case $flag in
                -march=*|-mcpu=*)
                    case "${flag#*=}" in
                        native)                   echo -xtarget=native       ;;
                        v9|niagara)               echo -xarch=sparc          ;;
                        ultrasparc)               echo -xarch=sparcvis       ;;
                        ultrasparc3|niagara2)     echo -xarch=sparcvis2      ;;
                        i586|pentium)             echo -xchip=pentium        ;;
                        i686|pentiumpro|pentium2) echo -xtarget=pentium_pro  ;;
                        pentium3*|c3-2)           echo -xtarget=pentium3     ;;
                        pentium-m)          echo -xarch=sse2 -xchip=pentium3 ;;
                        pentium4*)          echo -xtarget=pentium4           ;;
                        prescott|nocona)    echo -xarch=sse3 -xchip=pentium4 ;;
                        *-sse3)             echo -xarch=sse3                 ;;
                        core2)              echo -xarch=ssse3 -xchip=core2   ;;
                        amdfam10|barcelona)       echo -xarch=sse4_1         ;;
                        athlon-4|athlon-[mx]p)    echo -xarch=ssea           ;;
                        k8|opteron|athlon64|athlon-fx)
                                                  echo -xarch=sse2a          ;;
                        athlon*)                  echo -xarch=pentium_proa   ;;
                    esac
                    ;;
                -std=c99)             echo -xc99              ;;
                -fomit-frame-pointer) echo -xregs=frameptr    ;;
                -fPIC)                echo -KPIC -xcode=pic32 ;;
                -W*,*)                echo $flag              ;;
                -f*-*|-W*)                                    ;;
                *)                    echo $flag              ;;
            esac
        done
    }
    
    tms470_flags(){
        for flag; do
            case $flag in
                -march=*|-mcpu=*)
                    case "${flag#*=}" in
                        armv7-a|cortex-a*)      echo -mv=7a8 ;;
                        armv7-r|cortex-r*)      echo -mv=7r4 ;;
                        armv7-m|cortex-m*)      echo -mv=7m3 ;;
                        armv6*|arm11*)          echo -mv=6   ;;
                        armv5*e|arm[79]*e*|arm9[24]6*|arm96*|arm102[26])
                                                echo -mv=5e  ;;
                        armv4*|arm7*|arm9[24]*) echo -mv=4   ;;
                    esac
                    ;;
                -mfpu=neon)     echo --float_support=vfpv3 --neon ;;
                -mfpu=vfp)      echo --float_support=vfpv2        ;;
                -mfpu=vfpv3)    echo --float_support=vfpv3        ;;
                -msoft-float)   echo --float_support=vfplib       ;;
                -O[0-3]|-mf=*)  echo $flag                        ;;
                -g)             echo -g -mn                       ;;
                -pds=*)         echo $flag                        ;;
    
                -D*|-I*)        echo $flag                        ;;
                --gcc|--abi=*)  echo $flag                        ;;
                -me)            echo $flag                        ;;
    
        unset _type _ident _cc_c _cc_e _cc_o _flags _cflags _ldflags
    
        unset _depflags _DEPCMD _DEPFLAGS
    
        _flags_filter=echo
    
        if $_cc -v 2>&1 | grep -q '^gcc.*LLVM'; then
            _type=llvm_gcc
            gcc_extra_ver=$(expr "$($_cc --version | head -n1)" : '.*\((.*)\)')
            _ident="llvm-gcc $($_cc -dumpversion) $gcc_extra_ver"
            _depflags='-MMD -MF $(@:.o=.d) -MT $@'
            _cflags_speed='-O3'
            _cflags_size='-Os'
        elif $_cc -v 2>&1 | grep -qi ^gcc; then
            _type=gcc
            gcc_version=$($_cc --version | head -n1)
            gcc_basever=$($_cc -dumpversion)
            gcc_pkg_ver=$(expr "$gcc_version" : '[^ ]* \(([^)]*)\)')
            gcc_ext_ver=$(expr "$gcc_version" : ".*$gcc_pkg_ver $gcc_basever \\(.*\\)")
            _ident=$(cleanws "gcc $gcc_basever $gcc_pkg_ver $gcc_ext_ver")
            if ! $_cc -dumpversion | grep -q '^2\.'; then
                _depflags='-MMD -MF $(@:.o=.d) -MT $@'
            fi
            _cflags_speed='-O3'
            _cflags_size='-Os'
        elif $_cc --version 2>/dev/null | grep -q Intel; then
            _type=icc
            _ident=$($_cc --version | head -n1)
            _depflags='-MMD'
            _cflags_speed='-O3'
            _cflags_size='-Os'
            _cflags_noopt='-O1'
        elif $_cc -v 2>&1 | grep -q xlc; then
            _type=xlc
            _ident=$($_cc -qversion 2>/dev/null | head -n1)
            _cflags_speed='-O5'
            _cflags_size='-O5 -qcompact'
        elif $_cc -V 2>/dev/null | grep -q Compaq; then
            _type=ccc
            _ident=$($_cc -V | head -n1 | cut -d' ' -f1-3)
            _DEPFLAGS='-M'
            debuglevel=3
            _ldflags='-Wl,-z,now' # calls to libots crash without this
            _cflags_speed='-fast'
            _cflags_size='-O1'
        elif $_cc --vsn 2>/dev/null | grep -q "ARM C/C++ Compiler"; then
            test -d "$sysroot" || die "No valid sysroot specified."
            _type=armcc
            _ident=$($_cc --vsn | head -n1)
            armcc_conf="$PWD/armcc.conf"
            $_cc --arm_linux_configure                 \
                 --arm_linux_config_file="$armcc_conf" \
                 --configure_sysroot="$sysroot"        \
                 --configure_cpp_headers="$sysinclude" >>$logfile 2>&1 ||
                 die "Error creating armcc configuration file."
            $_cc --vsn | grep -q RVCT && armcc_opt=rvct || armcc_opt=armcc
            _flags="--arm_linux_config_file=$armcc_conf --translate_gcc"
            as_default="${cross_prefix}gcc"
            _depflags='-MMD'
            _cflags_speed='-O3'
            _cflags_size='-Os'
        elif $_cc -version 2>/dev/null | grep -q TMS470; then
            _type=tms470
            _ident=$($_cc -version | head -n1 | tr -s ' ')
            _flags='--gcc --abi=eabi -me'
            _cflags='-D__gnuc_va_list=va_list -D__USER_LABEL_PREFIX__='
    
            _cc_o='-fe=$@'
            as_default="${cross_prefix}gcc"
            ld_default="${cross_prefix}gcc"
            _depflags='-ppa -ppd=$(@:.o=.d)'
            _cflags_speed='-O3 -mf=5'
            _cflags_size='-O3 -mf=2'
            _flags_filter=tms470_flags
        elif $_cc -v 2>&1 | grep -q clang; then
            _type=clang
            _ident=$($_cc --version | head -n1)
            _depflags='-MMD'
            _cflags_speed='-O3'
            _cflags_size='-Os'
        elif $_cc -V 2>&1 | grep -q Sun; then
            _type=suncc
            _ident=$($_cc -V 2>&1 | head -n1 | cut -d' ' -f 2-)
            _DEPCMD='$(DEP$(1)) $(DEP$(1)FLAGS) $($(1)DEP_FLAGS) $< | sed -e "1s,^.*: ,$@: ," -e "\$$!s,\$$, \\\," -e "1!s,^.*: , ," > $(@:.o=.d)'
            _DEPFLAGS='-xM1'
            _ldflags='-std=c99'
            _cflags_speed='-O5'
            _cflags_size='-O5 -xspace'
            _flags_filter=suncc_flags
        elif $_cc -v 2>&1 | grep -q 'PathScale\|Path64'; then
            _type=pathscale
            _ident=$($_cc -v 2>&1 | head -n1 | tr -d :)
            _depflags='-MMD -MF $(@:.o=.d) -MT $@'
            _cflags_speed='-O2'
            _cflags_size='-Os'
            _flags_filter='filter_out -Wdisabled-optimization'
        elif $_cc -v 2>&1 | grep -q Open64; then
            _type=open64
            _ident=$($_cc -v 2>&1 | head -n1 | tr -d :)
            _depflags='-MMD -MF $(@:.o=.d) -MT $@'
            _cflags_speed='-O2'
            _cflags_size='-Os'
            _flags_filter='filter_out -Wdisabled-optimization|-Wtype-limits|-fno-signed-zeros'
        elif $_cc -V 2>&1 | grep -q Portland; then
            _type=pgi
            _ident="PGI $($_cc -V 2>&1 | awk '/^pgcc/ { print $2; exit }')"
            opt_common='-alias=ansi -Mlre -Mpre'
            _cflags_speed="-O3 -Mautoinline -Munroll=c:4 $opt_common"
            _cflags_size="-O2 -Munroll=c:1 $opt_common"
            _cflags_noopt="-O1"
            _flags_filter=pgi_flags
    
    
        eval ${pfx}_type=\$_type
        eval ${pfx}_ident=\$_ident
    }
    
    set_ccvars(){
    
        eval ${1}_C=\${_cc_c-\${${1}_C}}
    
        eval ${1}_E=\${_cc_e-\${${1}_E}}
    
        eval ${1}_O=\${_cc_o-\${${1}_O}}
    
        if [ -n "$_depflags" ]; then
            eval ${1}_DEPFLAGS=\$_depflags
        else
            eval ${1}DEP=\${_DEPCMD:-\$DEPCMD}
            eval ${1}DEP_FLAGS=\${_DEPFLAGS:-\$DEPFLAGS}
            eval DEP${1}FLAGS=\$_flags
        fi
    }
    
    probe_cc cc "$cc"
    cflags_filter=$_flags_filter
    cflags_speed=$_cflags_speed
    cflags_size=$_cflags_size
    cflags_noopt=$_cflags_noopt
    add_cflags $_flags $_cflags
    cc_ldflags=$_ldflags
    set_ccvars CC
    
    probe_cc hostcc "$host_cc"
    host_cflags_filter=$_flags_filter
    host_ldflags_filter=$_flags_filter
    add_host_cflags  $_flags $_cflags
    add_host_ldflags $_flags $_ldflags
    set_ccvars HOSTCC
    
    test -n "$cc_type" && enable $cc_type ||
        warn "Unknown C compiler $cc, unable to select optimal CFLAGS"
    
    : ${dep_cc_default:=$cc}
    
    : ${ld_default:=$cc}
    
    set_default ar as dep_cc ld
    
    probe_cc as "$as"
    asflags_filter=$_flags_filter
    add_asflags $_flags $_cflags
    set_ccvars AS
    
    probe_cc ld "$ld"
    ldflags_filter=$_flags_filter
    add_ldflags $_flags $_ldflags
    test "$cc_type" != "$ld_type" && add_ldflags $cc_ldflags
    LD_O=${_cc_o-$LD_O}
    
    if [ -z "$CC_DEPFLAGS" ] && [ "$dep_cc" != "$cc" ]; then
        probe_cc depcc "$dep_cc"
        CCDEP=${_DEPCMD:-$DEPCMD}
        CCDEP_FLAGS=${_DEPFLAGS:=$DEPFLAGS}
        DEPCCFLAGS=$_flags
    fi
    
    Mohamed Naufal's avatar
    Mohamed Naufal committed
    add_cxxflags $extra_cxxflags
    
    add_asflags $extra_cflags
    
    if test -n "$sysroot"; then
        case "$cc_type" in
    
            gcc|llvm_gcc|clang)
    
                add_cppflags --sysroot="$sysroot"
    
                add_ldflags --sysroot="$sysroot"
            ;;
    
            tms470)
                add_cppflags -I"$sysinclude"
                add_ldflags  --sysroot="$sysroot"
            ;;
    
    if test "$cpu" = host; then
        enabled cross_compile && die "--cpu=host makes no sense when cross-compiling."
    
        case "$cc_type" in
    
                check_native(){
                    $cc $1=native -v -c -o $TMPO $TMPC >$TMPE 2>&1 || return
    
                    sed -n "/cc1.*$1=/{
    
                                s/.*$1=\\([^ ]*\\).*/\\1/
                                p
                                q
                            }" $TMPE
    
                }
                cpu=$(check_native -march || check_native -mcpu)
            ;;
        esac
    
        test "${cpu:-host}" = host && die "--cpu=host not supported with compiler $cc"
    fi
    
    
    # Deal with common $arch aliases
    case "$arch" in
    
            arch="arm"
        ;;
        mips|mipsel|IP*)
            arch="mips"
        ;;
    
            arch="mips"
            subarch="mips64"
        ;;
        parisc|hppa)
            arch="parisc"
        ;;
        parisc64|hppa64)
            arch="parisc"
            subarch="parisc64"
        ;;
    
        "Power Macintosh"|ppc|powerpc|ppc64|powerpc64)
    
            arch="ppc"
        ;;
        s390|s390x)
            arch="s390"
        ;;
        sh4|sh)
            arch="sh4"
        ;;
        sun4u|sparc64)
            arch="sparc"
            subarch="sparc64"
        ;;
    
        i[3-6]86|i86pc|BePC|x86pc|x86_64|x86_32|amd64)
    
    is_in $arch $ARCH_LIST || warn "unknown architecture $arch"
    
    # Add processor-specific flags
    
    if test "$cpu" = generic; then
        : do nothing
    elif enabled ppc; then
    
        case $(tolower $cpu) in
            601|ppc601|powerpc601)
    
    Måns Rullgård's avatar
    Måns Rullgård committed
                cpuflags="-mcpu=601"
    
    Måns Rullgård's avatar
    Måns Rullgård committed
            ;;
    
            603*|ppc603*|powerpc603*)
    
    Måns Rullgård's avatar
    Måns Rullgård committed
                cpuflags="-mcpu=603"
    
    Måns Rullgård's avatar
    Måns Rullgård committed
            ;;
    
            604*|ppc604*|powerpc604*)
    
    Måns Rullgård's avatar
    Måns Rullgård committed
                cpuflags="-mcpu=604"
    
    Måns Rullgård's avatar
    Måns Rullgård committed
            ;;
    
            g3|75*|ppc75*|powerpc75*)
    
    Måns Rullgård's avatar
    Måns Rullgård committed
                cpuflags="-mcpu=750 -mpowerpc-gfxopt"
    
    Måns Rullgård's avatar
    Måns Rullgård committed
            ;;
    
            g4|745*|ppc745*|powerpc745*)
    
    Måns Rullgård's avatar
    Måns Rullgård committed
                cpuflags="-mcpu=7450 -mpowerpc-gfxopt"
            ;;
    
            74*|ppc74*|powerpc74*)
    
    Måns Rullgård's avatar
    Måns Rullgård committed
                cpuflags="-mcpu=7400 -mpowerpc-gfxopt"
            ;;
    
            g5|970|ppc970|powerpc970)
    
    Måns Rullgård's avatar
    Måns Rullgård committed
                cpuflags="-mcpu=970 -mpowerpc-gfxopt -mpowerpc64"
            ;;
    
            power[3-7]*)
                cpuflags="-mcpu=$cpu -mpowerpc-gfxopt -mpowerpc64"
            ;;
    
    Måns Rullgård's avatar
    Måns Rullgård committed
                cpuflags="-mcpu=cell"
                enable ldbrx
            ;;
    
            e500v2)
                cpuflags="-mcpu=8548 -mhard-float -mfloat-gprs=double"
                disable altivec
            ;;
            e500)
                cpuflags="-mcpu=8540 -mhard-float"
                disable altivec
            ;;
    
    Måns Rullgård's avatar
    Måns Rullgård committed
        esac
    
    Måns Rullgård's avatar
    Måns Rullgård committed
        case $cpu in
            i[345]86|pentium)
                cpuflags="-march=$cpu"
                disable mmx
            ;;
            # targets that do NOT support conditional mov (cmov)
            pentium-mmx|k6|k6-[23]|winchip-c6|winchip2|c3)
                cpuflags="-march=$cpu"
                disable cmov
            ;;
            # targets that do support conditional mov (cmov)
    
            i686|pentiumpro|pentium[23]|pentium-m|athlon|athlon-tbird|athlon-4|athlon-[mx]p|athlon64*|k8*|opteron*|athlon-fx|core2|amdfam10|barcelona|atom)
    
    Måns Rullgård's avatar
    Måns Rullgård committed
                cpuflags="-march=$cpu"
                enable cmov
                enable fast_cmov
            ;;
            # targets that do support conditional mov but on which it's slow
            pentium4|pentium4m|prescott|nocona)
                cpuflags="-march=$cpu"
                enable cmov
                disable fast_cmov
            ;;
        esac
    
    
    elif enabled sparc; then
    
    
    Måns Rullgård's avatar
    Måns Rullgård committed
        case $cpu in
    
            niagara)
                cpuflags="-mcpu=$cpu"
                disable vis
            ;;
    
    Måns Rullgård's avatar
    Måns Rullgård committed
            sparc64)
                cpuflags="-mcpu=v9"
            ;;
        esac
    
        case $cpu in
            armv*)
                cpuflags="-march=$cpu"
    
                subarch=$(echo $cpu | sed 's/[^a-z0-9]//g')
    
                case $cpu in
                    cortex-a*)                               subarch=armv7a  ;;
                    cortex-r*)                               subarch=armv7r  ;;
    
                    cortex-m*)                 enable thumb; subarch=armv7m  ;;
    
                    arm11*)                                  subarch=armv6   ;;
                    arm[79]*e*|arm9[24]6*|arm96*|arm102[26]) subarch=armv5te ;;
                    armv4*|arm7*|arm9[24]*)                  subarch=armv4   ;;
                esac
    
    
    elif enabled alpha; then
    
    
        enabled ccc && cpuflags="-arch $cpu" || cpuflags="-mcpu=$cpu"
    
        case $cpu in
            24kc)
                disable mipsfpu
                disable mipsdspr1
                disable mipsdspr2
            ;;
            24kf*)
                disable mipsdspr1
                disable mipsdspr2
            ;;
            24kec|34kc|1004kc)
                disable mipsfpu
                disable mipsdspr2
            ;;
            24kef*|34kf*|1004kf*)
                disable mipsdspr2
            ;;
            74kc)
                disable mipsfpu
            ;;
        esac
    
    
    elif enabled avr32; then
    
    
    Måns Rullgård's avatar
    Måns Rullgård committed
        case $cpu in
            ap7[02]0[0-2])
                subarch="avr32_ap"
                cpuflags="-mpart=$cpu"
            ;;
            ap)
                subarch="avr32_ap"
                cpuflags="-march=$cpu"
            ;;
            uc3[ab]*)
                subarch="avr32_uc"
                cpuflags="-mcpu=$cpu"
            ;;
            uc)
                subarch="avr32_uc"
                cpuflags="-march=$cpu"
            ;;
        esac
    
    add_cflags $cpuflags
    add_asflags $cpuflags
    
    
    # compiler sanity check
    check_exec <<EOF
    int main(void){ return 0; }
    EOF
    if test "$?" != 0; then
        echo "$cc is unable to create an executable file."
        if test -z "$cross_prefix" && ! enabled cross_compile ; then
            echo "If $cc is a cross-compiler, use the --enable-cross-compile option."
            echo "Only do this if you know what cross compiling means."
        fi
        die "C compiler test failed."
    fi
    
    
    Mohamed Naufal's avatar
    Mohamed Naufal committed
    add_cxxflags -D__STDC_CONSTANT_MACROS
    
    check_cflags -std=c99
    
    check_cc -D_FILE_OFFSET_BITS=64 <<EOF && add_cppflags -D_FILE_OFFSET_BITS=64
    
    check_cc -D_LARGEFILE_SOURCE <<EOF && add_cppflags -D_LARGEFILE_SOURCE
    
    check_host_cflags -std=c99
    
    case "$arch" in
    
        alpha|ia64|mips|parisc|sparc)
    
            spic=$shared
    
            subarch="x86_32"
    
            check_code cc "" "int test[(int)sizeof(char*) - 7]" && subarch="x86_64"
    
            if test "$subarch" = "x86_64"; then
    
                spic=$shared
    
        ppc)
            check_cc <<EOF && subarch="ppc64"
            int test[(int)sizeof(char*) - 7];
    EOF
        ;;
    
    enable $subarch
    
    enabled spic && enable pic
    
    François Revol's avatar
    François Revol committed
            host_libs=
    
            SHFLAGS='-shared -Wl,-h,$$(@F)'
    
            enabled x86 && SHFLAGS="-mimpure-text $SHFLAGS"
    
            add_cppflags -D__EXTENSIONS__ -D_XOPEN_SOURCE=600
    
            # When using suncc to build, the Solaris linker will mark
            # an executable with each instruction set encountered by
            # the Solaris assembler.  As our libraries contain their own
            # guards for processor-specific code, instead suppress
            # generation of the HWCAPS ELF section on Solaris x86 only.
            enabled_all suncc x86 && echo "hwcap_1 = OVERRIDE;" > mapfile && add_ldflags -Wl,-M,mapfile
    
            nm_opts='-P -g'
    
            disable symver
    
            oss_indev_extralibs="-lossaudio"
            oss_outdev_extralibs="-lossaudio"
    
    David Hill's avatar
    David Hill committed
        openbsd|bitrig)
    
            # On OpenBSD 4.5. the compiler does not use PIC unless
    
            # explicitly using -fPIC. FFmpeg builds fine without PIC,
    
            # however the generated executable will not do anything
            # (simply quits with exit-code 1, no crash, no output).
    
            # Thus explicitly enable PIC here.
    
            disable symver
    
            SLIBNAME_WITH_MAJOR='$(SLIBNAME).$(LIBVERSION)'
    
            oss_indev_extralibs="-lossaudio"
            oss_outdev_extralibs="-lossaudio"
    
        dragonfly)
            disable symver
            ;;
        freebsd)
    
            add_extralibs -lpoll -lgnugetopt
    
            gas="gas-preprocessor.pl $cc"
    
            enabled ppc && add_asflags -force_cpusubtype_ALL
    
            SHFLAGS='-dynamiclib -Wl,-single_module -Wl,-install_name,$(SHLIBDIR)/$(SLIBNAME_WITH_MAJOR),-current_version,$(LIBVERSION),-compatibility_version,$(LIBMAJOR)'
    
            enabled x86_32 && append SHFLAGS -Wl,-read_only_relocs,suppress
    
            add_ldflags -Wl,-dynamic,-search_paths_first
    
            SLIBSUF=".dylib"
            SLIBNAME_WITH_VERSION='$(SLIBPREF)$(FULLNAME).$(LIBVERSION)$(SLIBSUF)'
            SLIBNAME_WITH_MAJOR='$(SLIBPREF)$(FULLNAME).$(LIBMAJOR)$(SLIBSUF)'
            FFSERVERLDFLAGS=-Wl,-bind_at_load
    
    Loren Merritt's avatar
    Loren Merritt committed
            objformat="macho"
    
            enabled x86_64 && objformat="macho64"
    
            enabled_any pic shared ||
    
                { check_cflags -mdynamic-no-pic && add_asflags -mdynamic-no-pic; }
    
            if test $target_os = "mingw32ce"; then
    
            LIBTARGET=i386
    
            SLIBPREF=""
            SLIBSUF=".dll"
            SLIBNAME_WITH_VERSION='$(SLIBPREF)$(FULLNAME)-$(LIBVERSION)$(SLIBSUF)'
            SLIBNAME_WITH_MAJOR='$(SLIBPREF)$(FULLNAME)-$(LIBMAJOR)$(SLIBSUF)'
    
            if check_cmd lib.exe -list; then
    
                SLIB_EXTRA_CMD='-lib.exe /machine:$(LIBTARGET) /def:$$(@:$(SLIBSUF)=.def) /out:$(SUBDIR)$(SLIBNAME:$(SLIBSUF)=.lib)'
                if enabled x86_64; then
                    LIBTARGET=x64
                fi
            elif check_cmd $dlltool --version; then
    
                SLIB_EXTRA_CMD=-'$(DLLTOOL) -m $(LIBTARGET) -d $$(@:$(SLIBSUF)=.def) -l $(SUBDIR)$(SLIBNAME:$(SLIBSUF)=.lib) -D $(SLIBNAME_WITH_MAJOR)'
    
            SLIB_INSTALL_NAME='$(SLIBNAME_WITH_MAJOR)'
            SLIB_INSTALL_LINKS=
            SLIB_INSTALL_EXTRA_SHLIB='$(SLIBNAME:$(SLIBSUF)=.lib)'
            SLIB_INSTALL_EXTRA_LIB='lib$(SLIBNAME:$(SLIBSUF)=.dll.a) $(SLIBNAME_WITH_MAJOR:$(SLIBSUF)=.def)'
    
            SHFLAGS='-shared -Wl,--output-def,$$(@:$(SLIBSUF)=.def) -Wl,--out-implib,$(SUBDIR)lib$(SLIBNAME:$(SLIBSUF)=.dll.a) -Wl,--enable-runtime-pseudo-reloc -Wl,--enable-auto-image-base'
    
    Loren Merritt's avatar
    Loren Merritt committed
            objformat="win32"
    
            check_cflags -fno-common
    
            check_cpp_condition _mingw.h "defined (__MINGW64_VERSION_MAJOR) || (__MINGW32_MAJOR_VERSION > 3) \
                                          || (__MINGW32_MAJOR_VERSION == 3 && __MINGW32_MINOR_VERSION >= 15)" ||
    
    Ramiro Polla's avatar
    Ramiro Polla committed
                    die "ERROR: MinGW runtime version must be >= 3.15."
    
            add_cppflags -U__STRICT_ANSI__
    
            SLIBPREF="cyg"
            SLIBSUF=".dll"
            SLIBNAME_WITH_VERSION='$(SLIBPREF)$(FULLNAME)-$(LIBVERSION)$(SLIBSUF)'
            SLIBNAME_WITH_MAJOR='$(SLIBPREF)$(FULLNAME)-$(LIBMAJOR)$(SLIBSUF)'
            SHFLAGS='-shared -Wl,--enable-auto-image-base'
    
    Loren Merritt's avatar
    Loren Merritt committed
            objformat="win32"
    
            check_cflags -fno-common
    
            add_cppflags -U__STRICT_ANSI__
    
    Michael Kostylev's avatar
    Michael Kostylev committed
        *-dos|freedos|opendos)
            network_extralibs="-lsocket"
    
            objformat="coff"
    
            add_cppflags -U__STRICT_ANSI__
    
            add_cppflags -D_POSIX_C_SOURCE=200112 -D_XOPEN_SOURCE=600
    
            ln_s="cp -f"
    
            objformat="aout"
    
            add_cppflags -D_GNU_SOURCE
    
            add_ldflags -Zomf -Zbin-files -Zargs-wild -Zmap
    
    Måns Rullgård's avatar
    Måns Rullgård committed
            SHFLAGS='$(SUBDIR)$(NAME).def -Zdll -Zomf'
    
            FFSERVERLDFLAGS=""
    
            SLIBPREF=""
            SLIBSUF=".dll"
            SLIBNAME_WITH_VERSION='$(SLIBPREF)$(NAME)-$(LIBVERSION)$(SLIBSUF)'
            SLIBNAME_WITH_MAJOR='$(SLIBPREF)$(shell echo $(NAME) | cut -c1-6)$(LIBMAJOR)$(SLIBSUF)'
    
    Måns Rullgård's avatar
    Måns Rullgård committed
            SLIB_CREATE_DEF_CMD='echo LIBRARY $(SLIBNAME_WITH_MAJOR) INITINSTANCE TERMINSTANCE > $(SUBDIR)$(NAME).def; \
              echo PROTMODE >> $(SUBDIR)$(NAME).def; \
              echo CODE PRELOAD MOVEABLE DISCARDABLE >> $(SUBDIR)$(NAME).def; \
              echo DATA PRELOAD MOVEABLE MULTIPLE NONSHARED >> $(SUBDIR)$(NAME).def; \
              echo EXPORTS >> $(SUBDIR)$(NAME).def; \
              emxexp -o $(OBJS) >> $(SUBDIR)$(NAME).def'
            SLIB_EXTRA_CMD='emximp -o $(SUBDIR)$(LIBPREF)$(NAME)_dll.a $(SUBDIR)$(NAME).def; \
              emximp -o $(SUBDIR)$(LIBPREF)$(NAME)_dll.lib $(SUBDIR)$(NAME).def;'
    
            SLIB_INSTALL_EXTRA_LIB='$(LIBPREF)$(NAME)_dll.a $(LIBPREF)$(NAME)_dll.lib'
    
            enable_weak os2threads
    
            add_cppflags -D_POSIX_C_SOURCE=200112 -D_XOPEN_SOURCE=600 -D_BSD_SOURCE
    
            add_cppflags -D_POSIX_C_SOURCE=200112 -D_XOPEN_SOURCE=600
    
        qnx)
            add_cppflags -D_QNX_SOURCE
            network_extralibs="-lsocket"
            ;;
    
        symbian)
            SLIBSUF=".dll"
            enable dos_paths
    
            add_cflags --include=$sysinclude/gcce/gcce.h -fvisibility=default
            add_cppflags -D__GCCE__ -D__SYMBIAN32__ -DSYMBIAN_OE_POSIX_SIGNALS
            add_ldflags -Wl,--target1-abs,--no-undefined \
                        -Wl,-Ttext,0x80000,-Tdata,0x1000000 -shared \
                        -Wl,--entry=_E32Startup -Wl,-u,_E32Startup
            add_extralibs -l:eexe.lib -l:usrt2_2.lib -l:dfpaeabi.dso \
                          -l:drtaeabi.dso -l:scppnwdl.dso -lsupc++ -lgcc \
                          -l:libc.dso -l:libm.dso -l:euser.dso -l:libcrt0.lib
    
            die "Unknown OS '$target_os'."
    
    esc(){
        echo "$*" | sed 's/%/%25/g;s/:/%3a/g'
    }
    
    
    echo "config:$arch:$subarch:$cpu:$target_os:$(esc $cc_ident):$(esc $FFMPEG_CONFIGURATION)" >config.fate
    
    check_cpp_condition stdlib.h "defined(__PIC__) || defined(__pic__) || defined(PIC)" && enable pic