Skip to content
Snippets Groups Projects
configure 223 KiB
Newer Older
  • Learn to ignore specific revisions
  • jack_indev_deps="jack_jack_h"
    jack_indev_deps_any="sem_timedwait dispatch_dispatch_h"
    
    lavfi_indev_deps="avfilter"
    
    libcdio_indev_deps="libcdio"
    
    libdc1394_indev_deps="libdc1394"
    
    libv4l2_indev_deps="libv4l2"
    
    openal_indev_deps="openal"
    
    Lukasz Marek's avatar
    Lukasz Marek committed
    opengl_outdev_deps="opengl"
    
    oss_indev_deps_any="soundcard_h sys_soundcard_h"
    oss_outdev_deps_any="soundcard_h sys_soundcard_h"
    
    pulse_indev_deps="libpulse"
    
    Lukasz Marek's avatar
    Lukasz Marek committed
    pulse_outdev_deps="libpulse"
    
    qtkit_indev_extralibs="-framework QTKit -framework Foundation -framework QuartzCore"
    qtkit_indev_select="qtkit"
    
    sdl2_outdev_deps="sdl2"
    
    sndio_indev_deps="sndio_h"
    sndio_outdev_deps="sndio_h"
    
    v4l_indev_deps="linux_videodev_h"
    v4l2_indev_deps_any="linux_videodev2_h sys_videoio_h"
    
    Clément Bœsch's avatar
    Clément Bœsch committed
    v4l2_outdev_deps_any="linux_videodev2_h sys_videoio_h"
    
    vfwcap_indev_deps="capCreateCaptureWindow vfwcap_defines"
    
    vfwcap_indev_extralibs="-lavicap32"
    
    xcbgrab_indev_deps="libxcb"
    
    xv_outdev_deps="X11_extensions_Xvlib_h XvGetPortAttribute"
    xv_outdev_extralibs="-lXv -lX11 -lXext"
    
    # protocols
    
    async_protocol_deps="threads"
    
    Petri Hintukainen's avatar
    Petri Hintukainen committed
    bluray_protocol_deps="libbluray"
    
    Samuel Pitoiset's avatar
    Samuel Pitoiset committed
    ffrtmpcrypt_protocol_deps="!librtmp_protocol"
    
    ffrtmpcrypt_protocol_deps_any="gcrypt gmp openssl"
    
    Samuel Pitoiset's avatar
    Samuel Pitoiset committed
    ffrtmpcrypt_protocol_select="tcp_protocol"
    
    ffrtmphttp_protocol_deps="!librtmp_protocol"
    ffrtmphttp_protocol_select="http_protocol"
    
    Lukasz Marek's avatar
    Lukasz Marek committed
    ftp_protocol_select="tcp_protocol"
    
    http_protocol_select="tcp_protocol"
    
    httpproxy_protocol_select="tcp_protocol"
    
    https_protocol_select="tls_protocol"
    
    Marvin Scholz's avatar
    Marvin Scholz committed
    icecast_protocol_select="http_protocol"
    
    librtmp_protocol_deps="librtmp"
    librtmpe_protocol_deps="librtmp"
    librtmps_protocol_deps="librtmp"
    librtmpt_protocol_deps="librtmp"
    librtmpte_protocol_deps="librtmp"
    
    libsmbclient_protocol_deps="libsmbclient gplv3"
    
    libssh_protocol_deps="libssh"
    
    Måns Rullgård's avatar
    Måns Rullgård committed
    mmsh_protocol_select="http_protocol"
    
    rtmp_protocol_deps="!librtmp_protocol"
    
    rtmp_protocol_select="tcp_protocol"
    
    Samuel Pitoiset's avatar
    Samuel Pitoiset committed
    rtmpe_protocol_select="ffrtmpcrypt_protocol"
    
    Samuel Pitoiset's avatar
    Samuel Pitoiset committed
    rtmps_protocol_deps="!librtmp_protocol"
    rtmps_protocol_select="tls_protocol"
    
    rtmpt_protocol_select="ffrtmphttp_protocol"
    
    Samuel Pitoiset's avatar
    Samuel Pitoiset committed
    rtmpte_protocol_select="ffrtmpcrypt_protocol ffrtmphttp_protocol"
    
    rtmpts_protocol_select="ffrtmphttp_protocol https_protocol"
    
    rtp_protocol_select="udp_protocol"
    
    sctp_protocol_deps="struct_sctp_event_subscribe struct_msghdr_msg_flags"
    
    srtp_protocol_select="rtp_protocol srtp"
    
    tls_gnutls_protocol_deps="gnutls !tls_schannel_protocol !tls_securetransport_protocol"
    
    tls_gnutls_protocol_select="tcp_protocol"
    
    tls_openssl_protocol_deps="openssl !tls_schannel_protocol !tls_securetransport_protocol !tls_gnutls_protocol"
    
    tls_openssl_protocol_select="tcp_protocol"
    
    tls_schannel_protocol_deps="schannel"
    tls_schannel_protocol_select="tcp_protocol"
    
    tls_securetransport_protocol_deps="securetransport"
    
    tls_securetransport_protocol_select="tcp_protocol"
    
    tls_protocol_deps_any="tls_schannel_protocol tls_securetransport_protocol tls_gnutls_protocol tls_openssl_protocol"
    
    udplite_protocol_select="network"
    
    Luca Barbato's avatar
    Luca Barbato committed
    unix_protocol_deps="sys_un_h"
    unix_protocol_select="network"
    
    Paul B Mahol's avatar
    Paul B Mahol committed
    afftfilt_filter_deps="avcodec"
    afftfilt_filter_select="fft"
    
    amovie_filter_deps="avcodec avformat"
    
    aresample_filter_deps="swresample"
    
    ass_filter_deps="libass"
    
    atempo_filter_deps="avcodec"
    atempo_filter_select="rdft"
    
    Stefano Sabatini's avatar
    Stefano Sabatini committed
    azmq_filter_deps="libzmq"
    
    blackframe_filter_deps="gpl"
    
    boxblur_filter_deps="gpl"
    
    bs2b_filter_deps="libbs2b"
    
    colormatrix_filter_deps="gpl"
    
    cover_rect_filter_deps="avcodec avformat gpl"
    
    cropdetect_filter_deps="gpl"
    
    deinterlace_qsv_filter_deps="libmfx"
    
    deinterlace_vaapi_filter_deps="vaapi"
    
    delogo_filter_deps="gpl"
    
    deshake_filter_select="pixelutils"
    
    drawtext_filter_deps="libfreetype"
    
    eq_filter_deps="gpl"
    
    fftfilt_filter_deps="avcodec"
    fftfilt_filter_select="rdft"
    
    find_rect_filter_deps="avcodec avformat gpl"
    
    firequalizer_filter_deps="avcodec"
    firequalizer_filter_select="rdft"
    
    flite_filter_deps="libflite"
    
    framerate_filter_select="pixelutils"
    
    Stefano Sabatini's avatar
    Stefano Sabatini committed
    frei0r_filter_deps="frei0r dlopen"
    frei0r_src_filter_deps="frei0r dlopen"
    
    fspp_filter_deps="gpl"
    
    Clément Bœsch's avatar
    Clément Bœsch committed
    geq_filter_deps="gpl"
    
    histeq_filter_deps="gpl"
    
    hqdn3d_filter_deps="gpl"
    
    interlace_filter_deps="gpl"
    
    kerndeint_filter_deps="gpl"
    
    ladspa_filter_deps="ladspa dlopen"
    
    mcdeint_filter_deps="avcodec gpl"
    
    movie_filter_deps="avcodec avformat"
    
    mpdecimate_filter_deps="gpl"
    mpdecimate_filter_select="pixelutils"
    
    mptestsrc_filter_deps="gpl"
    
    negate_filter_deps="lut_filter"
    
    nnedi_filter_deps="gpl"
    
    Paul B Mahol's avatar
    Paul B Mahol committed
    ocr_filter_deps="libtesseract"
    
    owdenoise_filter_deps="gpl"
    
    pan_filter_deps="swresample"
    
    perspective_filter_deps="gpl"
    
    phase_filter_deps="gpl"
    
    pp7_filter_deps="gpl"
    
    Clément Bœsch's avatar
    Clément Bœsch committed
    pp_filter_deps="gpl postproc"
    
    pullup_filter_deps="gpl"
    
    removelogo_filter_deps="avcodec avformat swscale"
    
    repeatfields_filter_deps="gpl"
    
    resample_filter_deps="avresample"
    
    rubberband_filter_deps="librubberband"
    
    sab_filter_deps="gpl swscale"
    
    scale2ref_filter_deps="swscale"
    
    scale_filter_deps="swscale"
    
    scale_qsv_filter_deps="libmfx"
    
    select_filter_select="pixelutils"
    
    showcqt_filter_deps="avcodec avformat swscale"
    
    showcqt_filter_select="fft"
    
    showfreqs_filter_deps="avcodec"
    showfreqs_filter_select="fft"
    
    showspectrum_filter_select="fft"
    showspectrumpic_filter_deps="avcodec"
    showspectrumpic_filter_select="fft"
    
    signature_filter_deps="gpl avcodec avformat"
    
    smartblur_filter_deps="gpl swscale"
    
    sofalizer_filter_deps="netcdf avcodec"
    sofalizer_filter_select="fft"
    
    spectrumsynth_filter_deps="avcodec"
    spectrumsynth_filter_select="fft"
    
    spp_filter_select="fft idctdsp fdctdsp me_cmp pixblockdsp"
    
    stereo3d_filter_deps="gpl"
    
    subtitles_filter_deps="avformat avcodec libass"
    
    super2xsai_filter_deps="gpl"
    
    pixfmts_super2xsai_test_deps="super2xsai_filter"
    
    tinterlace_filter_deps="gpl"
    
    tinterlace_merge_test_deps="tinterlace_filter"
    tinterlace_pad_test_deps="tinterlace_filter"
    
    Arwa Arif's avatar
    Arwa Arif committed
    uspp_filter_deps="gpl avcodec"
    
    vaguedenoiser_filter_deps="gpl"
    
    vidstabdetect_filter_deps="libvidstab"
    vidstabtransform_filter_deps="libvidstab"
    
    Stefano Sabatini's avatar
    Stefano Sabatini committed
    zmq_filter_deps="libzmq"
    
    Paul B Mahol's avatar
    Paul B Mahol committed
    zoompan_filter_deps="swscale"
    
    zscale_filter_deps="libzimg"
    
    Mark Thompson's avatar
    Mark Thompson committed
    scale_vaapi_filter_deps="vaapi VAProcPipelineParameterBuffer"
    
    avio_dir_cmd_deps="avformat avutil"
    avio_reading_deps="avformat avcodec avutil"
    
    decode_audio_example_deps="avcodec avutil"
    
    decode_video_example_deps="avcodec avutil"
    
    demuxing_decoding_example_deps="avcodec avformat avutil"
    
    encode_audio_example_deps="avcodec avutil"
    
    encode_video_example_deps="avcodec avutil"
    
    extract_mvs_example_deps="avcodec avformat avutil"
    
    filter_audio_example_deps="avfilter avutil"
    
    filtering_audio_example_deps="avfilter avcodec avformat avutil"
    filtering_video_example_deps="avfilter avcodec avformat avutil"
    
    http_multiclient_example_deps="avformat avutil fork"
    
    metadata_example_deps="avformat avutil"
    
    muxing_example_deps="avcodec avformat avutil swscale"
    
    qsvdec_example_deps="avcodec avutil libmfx h264_qsv_decoder vaapi_x11"
    
    remuxing_example_deps="avcodec avformat avutil"
    
    resampling_audio_example_deps="avutil swresample"
    scaling_video_example_deps="avutil swscale"
    
    transcode_aac_example_deps="avcodec avformat swresample"
    
    transcoding_example_deps="avfilter avcodec avformat avutil"
    
    # libraries, in linking order
    
    avdevice_deps="avformat avcodec avutil"
    
    avformat_deps="avcodec avutil"
    
    postproc_deps="avutil gpl"
    
    swresample_deps="avutil"
    
    # programs
    
    ffmpeg_deps="avcodec avfilter avformat swresample"
    
    ffmpeg_select="aformat_filter anull_filter atrim_filter format_filter
                   null_filter
    
    Marton Balint's avatar
    Marton Balint committed
    ffplay_deps="avcodec avformat swscale swresample sdl2"
    ffplay_libs='$sdl2_libs'
    
    ffplay_select="rdft crop_filter transpose_filter hflip_filter vflip_filter rotate_filter"
    
    ffserver_deps="avformat fork sarestart"
    ffserver_select="ffm_muxer rtp_protocol rtsp_demuxer"
    
    # documentation
    podpages_deps="perl"
    manpages_deps="perl pod2man"
    
    htmlpages_deps="perl"
    htmlpages_deps_any="makeinfo_html texi2html"
    
    txtpages_deps="perl makeinfo"
    
    doc_deps_any="manpages htmlpages podpages txtpages"
    
    Fabrice Bellard's avatar
    Fabrice Bellard committed
    # default parameters
    
    
    # installation paths
    
    prefix_default="/usr/local"
    bindir_default='${prefix}/bin'
    
    datadir_default='${prefix}/share/ffmpeg'
    
    docdir_default='${prefix}/share/doc/ffmpeg'
    
    incdir_default='${prefix}/include'
    libdir_default='${prefix}/lib'
    mandir_default='${prefix}/share/man'
    
    ar_default="ar"
    
    Mohamed Naufal's avatar
    Mohamed Naufal committed
    cxx_default="g++"
    
    host_cc_default="gcc"
    
    Mans Rullgard's avatar
    Mans Rullgard committed
    cp_f="cp -f"
    
    doxygen_default="doxygen"
    
    ln_s_default="ln -s -f"
    
    nm_default="nm -g"
    
    objformat="elf"
    
    pkg_config_default=pkg-config
    
    version_script='--version-script'
    
    windres_default="windres"
    
    target_os_default=$(tolower $(uname -s))
    host_os=$target_os_default
    
    # machine
    if test "$target_os_default" = aix; then
        arch_default=$(uname -p)
    
        strip_default="strip -X32_64"
    
    else
        arch_default=$(uname -m)
    fi
    cpu="generic"
    
    # configurable options
    
    enable $DOCUMENT_LIST
    
    enable $EXAMPLE_LIST
    enable $(filter_out avresample $LIBRARY_LIST)
    
    enable faan faandct faanidct
    
    enable runtime_cpudetect
    
    enable safe_bitstream_reader
    
    enable static
    
    sws_max_filter_size_default=256
    set_default sws_max_filter_size
    
    
    # build settings
    
    SHFLAGS='-shared -Wl,-soname,$$(@F)'
    
    FULLNAME='$(NAME)$(BUILDSUF)'
    LIBNAME='$(LIBPREF)$(FULLNAME)$(LIBSUF)'
    
    SLIBNAME='$(SLIBPREF)$(FULLNAME)$(SLIBSUF)'
    
    SLIBNAME_WITH_VERSION='$(SLIBNAME).$(LIBVERSION)'
    SLIBNAME_WITH_MAJOR='$(SLIBNAME).$(LIBMAJOR)'
    
    Måns Rullgård's avatar
    Måns Rullgård committed
    LIB_INSTALL_EXTRA_CMD='$$(RANLIB) "$(LIBDIR)/$(LIBNAME)"'
    
    SLIB_INSTALL_NAME='$(SLIBNAME_WITH_VERSION)'
    SLIB_INSTALL_LINKS='$(SLIBNAME_WITH_MAJOR) $(SLIBNAME)'
    
    VERSION_SCRIPT_POSTPROCESS_CMD="cat"
    
    asflags_filter=echo
    cflags_filter=echo
    
    ldflags_filter=echo
    
    
    Mohamed Naufal's avatar
    Mohamed Naufal committed
    CXX_O='-o $@'
    
    Luca Barbato's avatar
    Luca Barbato committed
    OBJCC_C='-c'
    OBJCC_E='-E -o $@'
    OBJCC_O='-o $@'
    
    HOSTCC_E='-E -o $@'
    
    HOSTLD_O='-o $@'
    
    host_libs='-lm'
    
    host_cflags_filter=echo
    host_ldflags_filter=echo
    
    target_path='$(CURDIR)'
    
    # since the object filename is not given with the -MM flag, the compiler
    # is only able to print the basename, and we must add the path ourselves
    
    DEPCMD='$(DEP$(1)) $(DEP$(1)FLAGS) $($(1)DEP_FLAGS) $< 2>/dev/null | sed -e "/^\#.*/d" -e "s,^[[:space:]]*$(@F),$(@D)/$(@F)," > $(@:.o=.d)'
    
    if test -f configure; then
    
        source_path=.
    
        source_path=$(cd $(dirname "$0"); pwd)
    
        case "$source_path" in
            *[[:blank:]]*) die "Out of tree builds are impossible with whitespace in source path." ;;
        esac
    
        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)
    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)
    
    FILTER_LIST=$(find_things   filter   FILTER   libavfilter/allfilters.c)
    
    find_things_extern(){
        thing=$1
        pattern=$2
        file=$source_path/$3
        sed -n "s/^[^#]*extern.*$pattern *ff_\([^ ]*\)_$thing;/\1_$thing/p" "$file"
    }
    
    
    BSF_LIST=$(find_things_extern bsf AVBitStreamFilter libavcodec/bitstream_filters.c)
    
    PROTOCOL_LIST=$(find_things_extern protocol URLProtocol libavformat/protocols.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
    "
    
    
    for n in $COMPONENT_LIST; do
        v=$(toupper ${n%s})_LIST
        eval enable \$$v
        eval ${n}_if_any="\$$v"
    done
    
    
    enable $ARCH_EXT_LIST
    
    
    die_unknown(){
        echo "Unknown option \"$1\"."
        echo "See $0 --help for available options."
        exit 1
    }
    
    
    print_in_columns() {
        cols=$(expr $ncols / 24)
        cat | tr ' ' '\n' | sort | pr -r "-$cols" -w $ncols -t
    
    Ramiro Polla's avatar
    Ramiro Polla committed
        suffix=_$1
        shift
    
        echo $* | sed s/$suffix//g | print_in_columns
    
    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-ldexeflags=*)
                add_ldexeflags $optval
            ;;
    
            --extra-ldlibflags=*)
                add_ldlibflags $optval
            ;;
    
            --extra-libs=*)
                add_extralibs $optval
    
            --disable-devices)
                disable $INDEV_LIST $OUTDEV_LIST
    
            --enable-debug=*)
                debuglevel="$optval"
    
            ;;
            --disable-programs)
                disable $PROGRAM_LIST
            ;;
            --disable-everything)
    
                map 'eval unset \${$(toupper ${v%s})_LIST}' $COMPONENT_LIST
    
                map 'eval unset \${$(toupper ${v%s})_LIST}' $COMPONENT_LIST
    
                disable $LIBRARY_LIST $PROGRAM_LIST doc
    
            --enable-random|--disable-random)
                action=${opt%%-random}
                do_random ${action#--} $COMPONENT_LIST
            ;;
            --enable-random=*|--disable-random=*)
                action=${opt%%-random=*}
                do_random ${action#--} $optval
            ;;
            --enable-*=*|--disable-*=*)
                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}
    
                list=$(filter "$name" $list)
                [ "$list" = "" ] && warn "Option $opt did not match anything"
                $action $list
    
            ;;
            --enable-?*|--disable-?*)
                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
            ;;
    
            --fatal-warnings) enable fatal_warnings
            ;;
    
            *)
                optname="${opt%%=*}"
                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
            ;;
    
    # Mark specifically enabled, but normally autodetected libraries as requested.
    for lib in $AUTODETECT_LIBS; do
        enabled $lib && request $lib
    done
    
    
    # Enable platform codecs by default.
    enable_weak audiotoolbox
    
    # Enable hwaccels by default.
    enable_weak d3d11va dxva2 vaapi vda vdpau videotoolbox_hwaccel xvmc
    enable_weak xlib
    
    enable_weak cuda cuvid nvenc vda_framework videotoolbox videotoolbox_encoder
    
    
    Måns Rullgård's avatar
    Måns Rullgård committed
    disabled logging && logfile=/dev/null
    
    
    # Disable all the library-specific components if the library itself
    # is disabled, see AVCODEC_LIST and following _LIST variables.
    
    disable_components(){
    
            eval components="\$$(toupper ${1})_COMPONENTS"
            map 'eval echo \${$(toupper ${v%s})_LIST}' $components
        )
    }
    
    map 'disable_components $v' $LIBRARY_LIST
    
    
    echo "# $0 $FFMPEG_CONFIGURATION" > $logfile
    
    Måns Rullgård's avatar
    Måns Rullgård committed
    set >> $logfile
    
    
    test -n "$valgrind" && toolchain="valgrind-memcheck"
    
    
    case "$toolchain" in
    
        *-asan)
            cc_default="${toolchain%-asan}"
    
            add_cflags  -fsanitize=address
            add_ldflags -fsanitize=address
    
        *-msan)
            cc_default="${toolchain%-msan}"
            add_cflags  -fsanitize=memory -fsanitize-memory-track-origins
            add_ldflags -fsanitize=memory
        ;;
    
        *-tsan)
            cc_default="${toolchain%-tsan}"
    
            add_cflags  -fsanitize=thread -fPIE
    
            add_ldflags -fsanitize=thread -pie
    
            case "$toolchain" in
                gcc-tsan)
                    add_cflags  -fPIC
                    add_ldflags -fPIC
                    ;;
            esac
    
        *-usan)
            cc_default="${toolchain%-usan}"
    
            add_cflags  -fsanitize=undefined
            add_ldflags -fsanitize=undefined
        ;;
    
            target_exec_default="valgrind"
    
            case "$toolchain" in
                valgrind-massif)
    
                    target_exec_args="--tool=massif --alloc-fn=av_malloc --alloc-fn=av_mallocz --alloc-fn=av_calloc --alloc-fn=av_fast_padded_malloc --alloc-fn=av_fast_malloc --alloc-fn=av_realloc_f --alloc-fn=av_fast_realloc --alloc-fn=av_realloc"
    
                    ;;
                valgrind-memcheck)
    
                    target_exec_args="--error-exitcode=1 --malloc-fill=0x2a --track-origins=yes --leak-check=full --gen-suppressions=all --suppressions=$source_path/tests/fate-valgrind.supp"
    
            # Check whether the current MSVC version needs the C99 converter.
            # From MSVC 2013 (compiler major version 18) onwards, it does actually
    
            # support enough of C99 to build ffmpeg. Default to the new
    
            # behaviour if the regexp was unable to match anything, since this
            # successfully parses the version number of existing supported
            # versions that require the converter (MSVC 2010 and 2012).
            cl_major_ver=$(cl 2>&1 | sed -n 's/.*Version \([[:digit:]]\{1,\}\)\..*/\1/p')
            if [ -z "$cl_major_ver" ] || [ $cl_major_ver -ge 18 ]; then
    
            ld_default="$source_path/compat/windows/mslink"
    
            nm_default="dumpbin -symbols"
    
            target_os_default="win32"
    
            # Use a relative path for TMPDIR. This makes sure all the
            # ffconf temp files are written with a relative path, avoiding
            # issues with msys/win32 path conversion for MSVC parameters
            # such as -Fo<file> or -out:<file>.
            TMPDIR=.
    
            nm_default="dumpbin -symbols"
            ar_default="xilib"
            target_os_default="win32"
    
        gcov)
            add_cflags  -fprofile-arcs -ftest-coverage
            add_ldflags -fprofile-arcs -ftest-coverage
        ;;
    
        llvm-cov)
            add_cflags -fprofile-arcs -ftest-coverage
            add_ldflags --coverage
        ;;
    
            add_cppflags -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2
            add_cflags   -fno-strict-overflow -fstack-protector-all
            add_ldflags  -Wl,-z,relro -Wl,-z,now
    
            add_cflags   -fPIE
            add_ldexeflags -fPIE -pie
    
        ?*)
            die "Unknown toolchain $toolchain"
        ;;
    esac
    
    
    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
    
    
    ar_default="${cross_prefix}${ar_default}"
    cc_default="${cross_prefix}${cc_default}"
    
    cxx_default="${cross_prefix}${cxx_default}"
    
    nm_default="${cross_prefix}${nm_default}"
    pkg_config_default="${cross_prefix}${pkg_config_default}"
    
    if ${cross_prefix}${ranlib_default} 2>&1 | grep -q "\-D "; then
        ranlib_default="${cross_prefix}${ranlib_default} -D"
    else
        ranlib_default="${cross_prefix}${ranlib_default}"
    fi
    
    strip_default="${cross_prefix}${strip_default}"
    windres_default="${cross_prefix}${windres_default}"
    
    
    sysinclude_default="${sysroot}/usr/include"
    
    
    set_default arch cc cxx doxygen pkg_config ranlib strip sysinclude \
        target_exec target_os yasmexe
    
    enabled cross_compile || host_cc_default=$cc
    set_default host_cc
    
    pkg_config_fail_message=""
    
    if ! $pkg_config --version >/dev/null 2>&1; then
        warn "$pkg_config not found, library detection may fail."
        pkg_config=false
    
    elif is_in -static $cc $LDFLAGS && ! is_in --static $pkg_config $pkg_config_flags; then
        pkg_config_fail_message="
    Note: When building a static binary, add --pkg-config-flags=\"--static\"."
    
    if test $doxygen != $doxygen_default && \
      ! $doxygen --version >/dev/null 2>&1; then
        warn "Specified doxygen \"$doxygen\" not found, API documentation will fail to build."
    fi
    
    
            mingw32*|mingw64*|win32|win64|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 [ -n "$tempprefix" ] ; then
        mktemp(){
            echo $tempprefix.${HOSTNAME}.${UID}
        }
    elif ! 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
    
    
    armasm_flags(){
        for flag; do
            case $flag in
                # Filter out MSVC cl.exe options from cflags that shouldn't
                # be passed to gas-preprocessor
                -M[TD]*)                                            ;;
                *)                  echo $flag                      ;;
            esac
       done
    }
    
    
    ccc_flags(){
        for flag; do
            case $flag in
                -std=c99)           echo -c99                       ;;
                -mcpu=*)            echo -arch ${flag#*=}           ;;
                -mieee)             echo -ieee                      ;;
                -O*|-fast)          echo $flag                      ;;
                -fno-math-errno)    echo -assume nomath_errno       ;;
                -g)                 echo -g3                        ;;
                -Wall)              echo -msg_enable level2         ;;
                -Wno-pointer-sign)  echo -msg_disable ptrmismatch1  ;;
                -Wl,*)              echo $flag                      ;;
                -f*|-W*)                                            ;;
                *)                  echo $flag                      ;;
            esac
       done
    }
    
    
    Luca Barbato's avatar
    Luca Barbato committed
    cparser_flags(){
        for flag; do
            case $flag in
                -Wno-switch)             echo -Wno-switch-enum ;;
                -Wno-format-zero-length) ;;
                -Wdisabled-optimization) ;;
                -Wno-pointer-sign)       echo -Wno-other ;;
                *)                       echo $flag ;;
            esac
        done
    }
    
    
        for flag; do
            case $flag in
    
                # In addition to specifying certain flags under the compiler
                # specific filters, they must be specified here as well or else the
                # generic catch all at the bottom will print the original flag.
                -Wall)                ;;
                -std=c99)             ;;
                # Common flags
    
                -fomit-frame-pointer) ;;
    
                -g)                   echo -Z7 ;;
                -fno-math-errno)      ;;
                -fno-common)          ;;
                -fno-signed-zeros)    ;;
    
                -lz)                  echo zlib.lib ;;
    
                -lavifil32)           echo vfw32.lib ;;
                -lavicap32)           echo vfw32.lib user32.lib ;;
    
                -lx264)               echo libx264.lib ;;
    
                -l*)                  echo ${flag#-l}.lib ;;
    
                -LARGEADDRESSAWARE)   echo $flag ;;
    
                -L*)                  echo -libpath:${flag#-L} ;;
    
    msvc_flags(){
        msvc_common_flags "$@"
        for flag; do
            case $flag in
    
                -Wall)                echo -W4 -wd4244 -wd4127 -wd4018 -wd4389     \
    
                                           -wd4146 -wd4057 -wd4204 -wd4706 -wd4305 \
                                           -wd4152 -wd4324 -we4013 -wd4100 -wd4214 \
    
            esac
        done
    }
    
    icl_flags(){
        msvc_common_flags "$@"
        for flag; do
            case $flag in
                # Despite what Intel's documentation says -Wall, which is supported
                # on Windows, does enable remarks so disable them here.
                -Wall)                echo $flag -Qdiag-disable:remark ;;
                -std=c99)             echo -Qstd=c99 ;;
    
                -flto)                echo -ipo ;;
    
    icc_flags(){
        for flag; do
            case $flag in
                -flto)                echo -ipo ;;
                *)                    echo $flag ;;
            esac
        done
    }
    
    
    pgi_flags(){
        for flag; do
            case $flag in
    
                -flto)                echo -Mipa=fast,libopt,libinline,vestigial ;;
    
                -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   ;;
    
                        bonnell)                   echo -xarch=ssse3         ;;
                        corei7|nehalem)            echo -xtarget=nehalem     ;;
                        westmere)                  echo -xtarget=westmere    ;;
                        silvermont)                echo -xarch=sse4_2        ;;
                        corei7-avx|sandybridge)    echo -xtarget=sandybridge ;;
    
                        core-avx*|ivybridge|haswell|broadwell|skylake*|knl)
    
                                                   echo -xarch=avx           ;;
    
                        amdfam10|barcelona)        echo -xtarget=barcelona   ;;
    
                        btver1)                    echo -xarch=amdsse4a      ;;
    
                        btver2|bdver*|znver*)      echo -xarch=avx           ;;
    
                        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*|-mimpure-text)                      ;;
                -shared)              echo -G                 ;;
    
                *)                    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        ;;
    
                -mfpu=vfpv3-d16) echo --float_support=vfpv3d16    ;;
    
                -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
        unset _ld_o _ldflags _ld_lib _ld_path
    
        unset _depflags _DEPCMD _DEPFLAGS
    
        if $_cc --version 2>&1 | grep -q '^GNU assembler'; then
            true # no-op to avoid reading stdin in following checks
        elif $_cc -v 2>&1 | grep -q '^gcc.*LLVM'; then
    
            gcc_extra_ver=$(expr "$($_cc --version 2>/dev/null | head -n1)" : '.*\((.*)\)')
            _ident="llvm-gcc $($_cc -dumpversion 2>/dev/null) $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")
    
                *) _depflags='-MMD -MF $(@:.o=.d) -MT $@' ;;
    
            if [ "$first" = true ]; then
                case $gcc_basever in
                    4.2*)
                    warn "gcc 4.2 is outdated and may miscompile FFmpeg. Please use a newer compiler." ;;
                esac
            fi
    
            _cflags_speed='-O3'
            _cflags_size='-Os'
    
        elif $_cc --version 2>/dev/null | grep -q ^icc; then
    
            _type=icc
            _ident=$($_cc --version | head -n1)
            _depflags='-MMD'
            _cflags_speed='-O3'