Skip to content
Snippets Groups Projects
configure 163 KiB
Newer Older
  • Learn to ignore specific revisions
  •     check_cpp "$@" <<EOF
    
    #include <$header>
    #if !($condition)
    #error "unsatisfied condition: $condition"
    #endif
    EOF
    }
    
    
    check_lib(){
        log check_lib "$@"
        header="$1"
        func="$2"
        shift 2
    
        check_header $header && check_func $func "$@" && add_extralibs "$@"
    
    check_lib2(){
        log check_lib2 "$@"
        headers="$1"
    
        check_func_headers "$headers" "$funcs" "$@" && add_extralibs "$@"
    
    Mohamed Naufal's avatar
    Mohamed Naufal committed
    check_lib_cpp(){
        log check_lib_cpp "$@"
        headers="$1"
        classes="$2"
        shift 2
        check_class_headers_cpp "$headers" "$classes" "$@" && add_extralibs "$@"
    }
    
    
    check_pkg_config(){
        log check_pkg_config "$@"
    
        headers="$2"
        funcs="$3"
        shift 3
    
        check_cmd $pkg_config --exists --print-errors $pkgandversion || return
    
        pkg_cflags=$($pkg_config --cflags $pkg)
        pkg_libs=$($pkg_config --libs $pkg)
        check_func_headers "$headers" "$funcs" $pkg_cflags $pkg_libs "$@" &&
            set_safe ${pkg}_cflags $pkg_cflags   &&
            set_safe ${pkg}_libs   $pkg_libs
    }
    
    
    Mohamed Naufal's avatar
    Mohamed Naufal committed
        check_ld "cc" "$@" && { enabled cross_compile || $TMPE >> $logfile 2>&1; }
    
    check_exec_crash(){
    
    
        # exit() is not async signal safe.  _Exit (C99) and _exit (POSIX)
        # are safe but may not be available everywhere.  Thus we use
        # raise(SIGTERM) instead.  The check is run in a subshell so we
        # can redirect the "Terminated" message from the shell.  SIGBUS
        # is not defined by standard C so it is used conditionally.
    
    
        (check_exec "$@") >> $logfile 2>&1 <<EOF
    
    #include <signal.h>
    static void sighandler(int sig){
        raise(SIGTERM);
    }
    
    int (*func_ptr)(void) = foo;
    
    Diego Biurrun's avatar
    Diego Biurrun committed
    int main(void){
    
        signal(SIGILL, sighandler);
        signal(SIGFPE, sighandler);
        signal(SIGSEGV, sighandler);
    #ifdef SIGBUS
        signal(SIGBUS, sighandler);
    #endif
    
        return func_ptr();
    
    check_type(){
        log check_type "$@"
        headers=$1
        type=$2
        shift 2
    
        check_code cc "$headers" "$type v" "$@" && enable_safe "$type"
    
    check_struct(){
    
        headers=$1
        struct=$2
        member=$3
        shift 3
        disable_safe "${struct}_${member}"
    
        check_code cc "$headers" "const void *p = &(($struct *)0)->$member" "$@" &&
            enable_safe "${struct}_${member}"
    
    check_builtin(){
        log check_builtin "$@"
        name=$1
        headers=$2
        builtin=$3
        shift 3
        disable "$name"
    
        check_code ld "$headers" "$builtin" "cc" "$@" && enable "$name"
    
    require(){
        name="$1"
        header="$2"
        func="$3"
        shift 3
        check_lib $header $func "$@" || die "ERROR: $name not found"
    
    require2(){
        name="$1"
        headers="$2"
        func="$3"
        shift 3
        check_lib2 "$headers" $func "$@" || die "ERROR: $name not found"
    }
    
    
    Mohamed Naufal's avatar
    Mohamed Naufal committed
    require_cpp(){
        name="$1"
        headers="$2"
        classes="$3"
        shift 3
        check_lib_cpp "$headers" "$classes" "$@" || die "ERROR: $name not found"
    }
    
    
    require_pkg_config(){
        pkg="$1"
        check_pkg_config "$@" || die "ERROR: $pkg not found"
        add_cflags    $(get_safe ${pkg}_cflags)
        add_extralibs $(get_safe ${pkg}_libs)
    }
    
    
    require_libfreetype(){
        log require_libfreetype "$@"
        pkg="freetype2"
        check_cmd $pkg_config --exists --print-errors $pkg \
          || die "ERROR: $pkg not found"
        pkg_cflags=$($pkg_config --cflags $pkg)
        pkg_libs=$($pkg_config --libs $pkg)
        {
            echo "#include <ft2build.h>"
            echo "#include FT_FREETYPE_H"
            echo "long check_func(void) { return (long) FT_Init_FreeType; }"
            echo "int main(void) { return 0; }"
        } | check_ld "cc" $pkg_cflags $pkg_libs \
          && set_safe ${pkg}_cflags $pkg_cflags \
          && set_safe ${pkg}_libs   $pkg_libs \
          || die "ERROR: $pkg not found"
        add_cflags    $(get_safe ${pkg}_cflags)
        add_extralibs $(get_safe ${pkg}_libs)
    }
    
    
    hostcc_e(){
        eval printf '%s\\n' $HOSTCC_E
    }
    
    
    hostcc_o(){
        eval printf '%s\\n' $HOSTCC_O
    }
    
    
    check_host_cc(){
        log check_host_cc "$@"
        cat > $TMPC
        log_file $TMPC
    
        check_cmd $host_cc $host_cflags "$@" $HOSTCC_C $(hostcc_o $TMPO) $TMPC
    
    check_host_cpp(){
        log check_host_cpp "$@"
        cat > $TMPC
        log_file $TMPC
        check_cmd $host_cc $HOSTCPPFLAGS $HOSTCFLAGS "$@" $(hostcc_e $TMPO) $TMPC
    }
    
    
    check_host_cppflags(){
        log check_host_cppflags "$@"
        check_host_cc "$@" <<EOF && append host_cppflags "$@"
    int x;
    EOF
    }
    
    
    check_host_cflags(){
        log check_host_cflags "$@"
    
        set -- $($host_cflags_filter "$@")
    
        check_host_cc "$@" <<EOF && append host_cflags "$@"
    int x;
    EOF
    }
    
    
    check_host_cpp_condition(){
        log check_host_cpp_condition "$@"
        header=$1
        condition=$2
        shift 2
        check_host_cpp "$@" <<EOF
    #include <$header>
    #if !($condition)
    #error "unsatisfied condition: $condition"
    #endif
    EOF
    }
    
    
    apply(){
        file=$1
        shift
        "$@" < "$file" > "$file.tmp" && mv "$file.tmp" "$file" || rm "$file.tmp"
    }
    
    
        cmp -s "$1" "$2" && echo "$2 is unchanged" && return
        mkdir -p "$(dirname $2)"
    
    Mans Rullgard's avatar
    Mans Rullgard committed
        $cp_f "$1" "$2"
    
    # CONFIG_LIST contains configurable options, while HAVE_LIST is for
    # system-dependent things.
    
    
    COMPONENT_LIST="
        bsfs
        decoders
        demuxers
        encoders
    
    Vitor Sessak's avatar
    Vitor Sessak committed
        filters
    
        avio_reading_example
    
        decoding_encoding_example
        demuxing_decoding_example
        filtering_audio_example
        filtering_video_example
        metadata_example
    
        remuxing_example
    
        resampling_audio_example
        scaling_video_example
    
        transcode_aac_example
    
    EXTERNAL_LIBRARY_LIST="
        avisynth
        bzlib
    
        decklink
    
    wm4's avatar
    wm4 committed
        libgme
    
        libopencore_amrnb
        libopencore_amrwb
        libopencv
        libopenjpeg
        libopus
        libpulse
    
        libquvi
    
        libvo_aacenc
        libvo_amrwbenc
        libvorbis
        libvpx
    
    Justin Ruggles's avatar
    Justin Ruggles committed
        libwebp
    
    Stefano Sabatini's avatar
    Stefano Sabatini committed
        libzmq
    
    Lukasz Marek's avatar
    Lukasz Marek committed
        opengl
    
    LIBRARY_LIST="
        avcodec
        avdevice
        avfilter
        avformat
        avresample
        avutil
    
        postproc
    
    Aurelien Jacobs's avatar
    Aurelien Jacobs committed
        hardcoded_tables
    
        memory_poisoning
    
        runtime_cpudetect
    
        os2threads
    
    ATOMICS_LIST='
        atomics_gcc
        atomics_suncc
    
    Måns Rullgård's avatar
    Måns Rullgård committed
        tomi
    
    ARCH_EXT_LIST_ARM='
        armv5te
        armv6
        armv6t2
        neon
    
        mipsfpu
        mips32r2
        mipsdspr1
        mipsdspr2
    
    HAVE_LIST_PUB='
        bigendian
    
        fast_unaligned
    
        $(add_suffix _external $ARCH_EXT_LIST)
        $(add_suffix _inline   $ARCH_EXT_LIST)
    
        $ATOMICS_LIST
    
        aligned_stack
    
        alsa_asoundlib_h
    
        atomics_native
    
        attribute_may_alias
    
        attribute_packed
    
        cdio_paranoia_h
        cdio_paranoia_paranoia_h
    
    Alex Beregszaszi's avatar
    Alex Beregszaszi committed
        closesocket
    
        dev_bktr_ioctl_bt848_h
        dev_bktr_ioctl_meteor_h
        dev_ic_bt8xx_h
        dev_video_bktr_ioctl_bt848_h
    
        dev_video_meteor_ioctl_meteor_h
    
    Lukasz Marek's avatar
    Lukasz Marek committed
        ES2_gl_h
    
    Måns Rullgård's avatar
    Måns Rullgård committed
        fcntl
    
    Måns Rullgård's avatar
    Måns Rullgård committed
        fork
    
        GetProcessAffinityMask
    
        GetSystemTimeAsFileTime
    
    Ramiro Polla's avatar
    Ramiro Polla committed
        getrusage
    
    Lukasz Marek's avatar
    Lukasz Marek committed
        glXGetProcAddress
    
        kbhit
    
    Måns Rullgård's avatar
    Måns Rullgård committed
        ldbrx
    
        machine_ioctl_bt848_h
        machine_ioctl_meteor_h
    
        machine_rw_barrier
    
        MapViewOfFile
    
        mkstemp
    
        mprotect
    
        nanosleep
    
    Lukasz Marek's avatar
    Lukasz Marek committed
        OpenGL_gl3_h
    
        posix_memalign
    
        pthread_cancel
    
        rsync_contimeout
    
        sndio_h
    
    Måns Rullgård's avatar
    Måns Rullgård committed
        soundcard_h
    
        strerror_r
    
        struct_group_source_req
        struct_ip_mreq_source
    
        struct_pollfd
    
        struct_sctp_event_subscribe
    
        struct_stat_st_mtim_tv_nsec
    
        struct_v4l2_frmivalenum_discrete
    
    Måns Rullgård's avatar
    Måns Rullgård committed
        sys_soundcard_h
    
        sys_time_h
    
    Luca Barbato's avatar
    Luca Barbato committed
        sys_un_h
    
        unistd_h
    
    Lukasz Marek's avatar
    Lukasz Marek committed
        wglGetProcAddress
    
        windows_h
    
    Diego Biurrun's avatar
    Diego Biurrun committed
    # options emitted with CONFIG_ prefix but not available on the command line
    
        dsputil
    
    Mohamed Naufal's avatar
    Mohamed Naufal committed
        cxx
    
        host_ldflags
        host_libs
    
    Måns Rullgård's avatar
    Måns Rullgård committed
        samples
    
        toolchain
    
    CMDLINE_APPEND="
        extra_cflags
    
    Mohamed Naufal's avatar
    Mohamed Naufal committed
        extra_cxxflags
    
    # code dependency declarations
    
    
    # architecture extensions
    
    armv5te_deps="arm"
    armv6_deps="arm"
    
    armv6t2_deps="arm"
    
    neon_deps_any="aarch64 arm"
    vfp_deps_any="aarch64 arm"
    
    vfpv3_deps="vfp"
    
    map 'eval ${v}_inline_deps=inline_asm' $ARCH_EXT_LIST_ARM
    
    
    mipsfpu_deps="mips"
    mips32r2_deps="mips"
    mipsdspr1_deps="mips"
    mipsdspr2_deps="mips"
    
    
    altivec_deps="ppc"
    ppc4xx_deps="ppc"
    
    vis_deps="sparc"
    
    
    cpunop_deps="i686"
    x86_64_select="i686"
    x86_64_suggest="fast_cmov"
    
    amd3dnow_deps="mmx"
    amd3dnowext_deps="amd3dnow"
    
    mmx_deps="x86"
    
    mmxext_deps="mmx"
    
    sse_deps="mmxext"
    sse2_deps="sse"
    sse3_deps="sse2"
    ssse3_deps="sse3"
    sse4_deps="ssse3"
    sse42_deps="sse4"
    avx_deps="sse42"
    
    xop_deps="avx"
    
    mmx_external_deps="yasm"
    mmx_inline_deps="inline_asm"
    mmx_suggest="mmx_external mmx_inline"
    
    for ext in $(filter_out mmx $ARCH_EXT_LIST_X86); do
        eval dep=\$${ext}_deps
        eval ${ext}_external_deps='"${dep}_external"'
        eval ${ext}_inline_deps='"${dep}_inline"'
        eval ${ext}_suggest='"${ext}_external ${ext}_inline"'
    done
    
    
    aligned_stack_if_any="aarch64 ppc x86"
    fast_64bit_if_any="aarch64 alpha ia64 mips64 parisc64 ppc64 sparc64 x86_64"
    fast_clz_if_any="aarch64 alpha avr32 mips ppc x86"
    fast_unaligned_if_any="aarch64 ppc x86"
    
    need_memalign="altivec neon sse"
    
    # system capabilities
    log2_deps="!libc_msvcrt"
    
    
    symver_if_any="symver_asm_label symver_gnu_asm"
    
    
    # threading support
    atomics_gcc_if="sync_val_compare_and_swap"
    atomics_suncc_if="atomic_cas_ptr machine_rw_barrier"
    atomics_win32_if="MemoryBarrier"
    atomics_native_if_any="$ATOMICS_LIST"
    threads_if_any="$THREADS_LIST"
    
    
    dct_select="rdft"
    
    error_resilience_select="dsputil"
    
    frame_thread_encoder_deps="encoders threads"
    
    lpc_select="dsputil"
    
    mdct_select="fft"
    rdft_select="fft"
    
    mpegaudio_select="mpegaudiodsp"
    
    mpegvideo_select="dsputil h264chroma hpeldsp videodsp"
    
    aac_decoder_select="mdct sinewin"
    
    aac_encoder_select="audio_frame_queue mdct sinewin"
    
    aac_latm_decoder_select="aac_decoder aac_latm_parser"
    
    ac3_decoder_select="mdct ac3dsp ac3_parser dsputil"
    ac3_encoder_select="mdct ac3dsp dsputil"
    ac3_fixed_encoder_select="mdct ac3dsp dsputil"
    
    aic_decoder_select="dsputil golomb"
    
    als_decoder_select="dsputil"
    
    amv_decoder_select="dsputil hpeldsp exif"
    
    amv_encoder_select="aandcttables"
    
    ape_decoder_select="dsputil"
    
    asv1_decoder_select="dsputil"
    asv1_encoder_select="dsputil"
    asv2_decoder_select="dsputil"
    asv2_encoder_select="dsputil"
    
    atrac1_decoder_select="mdct sinewin"
    
    Maxim Poliakovski's avatar
    Maxim Poliakovski committed
    atrac3p_decoder_select="mdct sinewin"
    
    avrn_decoder_select="exif"
    
    bink_decoder_select="dsputil hpeldsp"
    
    binkaudio_dct_decoder_select="mdct rdft dct sinewin"
    binkaudio_rdft_decoder_select="mdct rdft sinewin"
    
    cavs_decoder_select="dsputil golomb h264chroma videodsp"
    
    cllc_decoder_select="dsputil"
    
    comfortnoise_encoder_select="lpc"
    
    cook_decoder_select="dsputil mdct sinewin"
    
    cscd_decoder_select="lzo"
    
    cscd_decoder_suggest="zlib"
    
    dirac_decoder_select="dsputil dwt golomb videodsp"
    dnxhd_decoder_select="dsputil"
    dnxhd_encoder_select="aandcttables dsputil mpegvideoenc"
    
    dvvideo_decoder_select="dsputil"
    
    dvvideo_encoder_select="dsputil"
    
    eac3_decoder_select="ac3_decoder"
    
    eac3_encoder_select="ac3_encoder"
    
    eamad_decoder_select="aandcttables dsputil mpegvideo"
    
    eatgq_decoder_select="aandcttables"
    
    eatqi_decoder_select="aandcttables error_resilience mpegvideo"
    
    ffv1_decoder_select="dsputil golomb rangecoder"
    
    ffv1_encoder_select="dsputil rangecoder"
    
    ffvhuff_decoder_select="dsputil llviddsp"
    ffvhuff_encoder_select="dsputil huffman llviddsp"
    
    fic_decoder_select="dsputil golomb"
    
    flac_decoder_select="golomb"
    
    flac_encoder_select="dsputil golomb lpc"
    
    flashsv_decoder_select="zlib"
    flashsv_encoder_select="zlib"
    flashsv2_encoder_select="zlib"
    flashsv2_decoder_select="zlib"
    
    flv_decoder_select="h263_decoder"
    
    flv_encoder_select="h263_encoder"
    
    fourxm_decoder_select="dsputil"
    fraps_decoder_select="dsputil huffman"
    
    g729_decoder_select="dsputil"
    
    h261_decoder_select="error_resilience mpegvideo"
    
    h261_encoder_select="aandcttables mpegvideoenc"
    
    h263_decoder_select="error_resilience h263_parser h263dsp mpegvideo"
    h263_encoder_select="aandcttables h263dsp mpegvideoenc"
    
    h263i_decoder_select="h263_decoder"
    
    h263p_encoder_select="h263_encoder"
    
    h264_decoder_select="golomb h264chroma h264dsp h264pred h264qpel videodsp"
    
    h264_decoder_suggest="error_resilience"
    
    hevc_decoder_select="dsputil golomb videodsp"
    
    huffyuv_decoder_select="dsputil llviddsp"
    huffyuv_encoder_select="dsputil huffman llviddsp"
    
    iac_decoder_select="dsputil fft mdct sinewin"
    
    imc_decoder_select="dsputil fft mdct sinewin"
    
    indeo3_decoder_select="hpeldsp"
    
    interplay_video_decoder_select="hpeldsp"
    
    jpegls_decoder_select="dsputil golomb hpeldsp exif"
    
    jpegls_encoder_select="golomb"
    
    jv_decoder_select="dsputil"
    lagarith_decoder_select="dsputil"
    
    ljpeg_encoder_select="aandcttables mpegvideoenc"
    
    loco_decoder_select="golomb"
    
    mdec_decoder_select="dsputil error_resilience mpegvideo"
    
    metasound_decoder_select="lsp mdct sinewin"
    
    mimic_decoder_select="dsputil hpeldsp"
    
    mjpeg_decoder_select="dsputil hpeldsp exif"
    mjpegb_decoder_select="dsputil hpeldsp exif"
    
    mjpeg_encoder_select="aandcttables dsputil mpegvideoenc"
    mlp_decoder_select="dsputil mlp_parser"
    motionpixels_decoder_select="dsputil"
    
    mp1_decoder_select="mpegaudio"
    mp1float_decoder_select="mpegaudio"
    mp2_decoder_select="mpegaudio"
    mp2float_decoder_select="mpegaudio"
    mp3_decoder_select="mpegaudio"
    mp3adu_decoder_select="mpegaudio"
    mp3adufloat_decoder_select="mpegaudio"
    mp3float_decoder_select="mpegaudio"
    mp3on4_decoder_select="mpegaudio"
    mp3on4float_decoder_select="mpegaudio"
    
    mpc7_decoder_select="dsputil mpegaudiodsp"
    mpc8_decoder_select="dsputil mpegaudiodsp"
    
    mpeg_xvmc_decoder_deps="X11_extensions_XvMClib_h"
    
    mpeg_xvmc_decoder_select="mpeg2video_decoder"
    
    mpeg1video_decoder_select="error_resilience mpegvideo"
    
    mpeg1video_encoder_select="aandcttables mpegvideoenc h263dsp"
    
    mpeg2video_decoder_select="error_resilience mpegvideo"
    
    mpeg2video_encoder_select="aandcttables mpegvideoenc h263dsp"
    
    mpeg4_decoder_select="h263_decoder mpeg4video_parser"
    mpeg4_encoder_select="h263_encoder"
    
    msmpeg4v1_decoder_select="h263_decoder"
    msmpeg4v2_decoder_select="h263_decoder"
    
    msmpeg4v2_encoder_select="h263_encoder"
    
    msmpeg4v3_decoder_select="h263_decoder"
    
    msmpeg4v3_encoder_select="h263_encoder"
    
    mss2_decoder_select="error_resilience vc1_decoder"
    
    mxpeg_decoder_select="dsputil hpeldsp exif"
    
    nellymoser_decoder_select="mdct sinewin"
    
    nellymoser_encoder_select="audio_frame_queue mdct sinewin"
    
    nuv_decoder_select="dsputil lzo"
    
    png_decoder_select="zlib"
    png_encoder_select="dsputil zlib"
    
    prores_decoder_select="dsputil"
    
    prores_encoder_select="dsputil"
    
    qdm2_decoder_select="mdct rdft mpegaudiodsp"