Skip to content
Snippets Groups Projects
configure 163 KiB
Newer Older
  • Learn to ignore specific revisions
  • #include <$header>
    #if !($condition)
    #error "unsatisfied condition: $condition"
    #endif
    EOF
    }
    
    
    check_cpp_condition(){
        log check_cpp_condition "$@"
        name=$1
        shift 1
        disable $name
        test_cpp_condition "$@" && enable $name
    }
    
    
    test_cflags_cpp(){
        log test_cflags_cpp "$@"
        flags=$1
        condition=$2
        shift 2
        set -- $($cflags_filter "$flags")
    
    #if !($condition)
    #error "unsatisfied condition: $condition"
    #endif
    EOF
    }
    
    
        name="$1"
        headers="$2"
        funcs="$3"
        shift 3
        disable $name
        check_func_headers "$headers" "$funcs" "$@" &&
    
            enable $name && eval ${name}_extralibs="\$@"
    
    test_pkg_config(){
        log test_pkg_config "$@"
    
        name="$1"
        pkg_version="$2"
        pkg="${2%% *}"
        headers="$3"
        funcs="$4"
        shift 4
        disable $name
    
        test_cmd $pkg_config --exists --print-errors $pkg_version || return
    
        pkg_cflags=$($pkg_config --cflags $pkg_config_flags $pkg)
        pkg_libs=$($pkg_config --libs $pkg_config_flags $pkg)
    
        check_func_headers "$headers" "$funcs" $pkg_cflags $pkg_libs "$@" &&
    
            set_sanitized "${name}_cflags"    $pkg_cflags &&
            set_sanitized "${name}_extralibs" $pkg_libs
    }
    
    check_pkg_config(){
        log check_pkg_config "$@"
        name="$1"
        test_pkg_config "$@" &&
            eval add_cflags \$${name}_cflags
    
    test_exec(){
        log test_exec "$@"
        test_ld "$@" && { 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.
    
    
        (test_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
    
        test_code cc "$headers" "$type v" "$@" && enable_sanitized "$type"
    
    check_struct(){
    
        headers=$1
        struct=$2
        member=$3
        shift 3
    
        disable_sanitized "${struct}_${member}"
    
        test_code cc "$headers" "const void *p = &(($struct *)0)->$member" "$@" &&
    
            enable_sanitized "${struct}_${member}"
    
    check_builtin(){
        log check_builtin "$@"
        name=$1
    
    check_compile_assert(){
        log check_compile_assert "$@"
        name=$1
        headers=$2
        condition=$3
        shift 3
        disable "$name"
    
        test_code cc "$headers" "char c[2 * !!($condition) - 1]" "$@" && enable "$name"
    
    check_cc(){
        log check_cc "$@"
        name=$1
        shift
        disable "$name"
        test_code cc "$@" && enable "$name"
    }
    
    
        shift
        check_lib $name "$@" || die "ERROR: $name_version not found"
    
    require_cc(){
        log require_cc "$@"
        name="$1"
        shift
        test_code cc "$@" || die "ERROR: $name failed"
    }
    
    
        check_header "$@" || die "ERROR: $headers not found"
    
        log require_cpp_condition "$@"
    
        test_cpp_condition "$@" || die "ERROR: $condition not satisfied"
    
    require_pkg_config(){
    
        check_pkg_config "$@" || die "ERROR: $pkg_version not found"
    
    hostcc_e(){
        eval printf '%s\\n' $HOSTCC_E
    }
    
    
    hostcc_o(){
        eval printf '%s\\n' $HOSTCC_O
    }
    
    
        cat > $TMPC
        log_file $TMPC
    
        test_cmd $host_cc $host_cflags "$@" $HOSTCC_C $(hostcc_o $TMPO) $TMPC
    
        cat > $TMPC
        log_file $TMPC
    
        test_cmd $host_cc $host_cppflags $host_cflags "$@" $(hostcc_e $TMPO) $TMPC
    
    check_host_cppflags(){
        log check_host_cppflags "$@"
    
        test_host_cpp "$@" <<EOF && append host_cppflags "$@"
    
    check_host_cflags(){
        log check_host_cflags "$@"
    
        set -- $($host_cflags_filter "$@")
    
        test_host_cc "$@" <<EOF && append host_cflags "$@"
    
    test_host_cpp_condition(){
        log test_host_cpp_condition "$@"
    
        header=$1
        condition=$2
        shift 2
    
    #include <$header>
    #if !($condition)
    #error "unsatisfied condition: $condition"
    #endif
    EOF
    }
    
    
    check_host_cpp_condition(){
        log check_host_cpp_condition "$@"
        name=$1
        shift 1
        disable $name
        test_host_cpp_condition "$@" && enable $name
    }
    
    
        cmp -s "$1" "$2" && { test "$quiet" != "yes" && echo "$2 is unchanged"; } && return
    
        mkdir -p "$(dirname $2)"
    
    Diego Biurrun's avatar
    Diego Biurrun committed
        cp -f "$1" "$2"
    
    # CONFIG_LIST contains configurable options, while HAVE_LIST is for
    # system-dependent things.
    
    
    "
    AVFILTER_COMPONENTS="
        filters
    "
    AVFORMAT_COMPONENTS="
        demuxers
        muxers
    
    COMPONENT_LIST="
        $AVCODEC_COMPONENTS
        $AVDEVICE_COMPONENTS
        $AVFILTER_COMPONENTS
        $AVFORMAT_COMPONENTS
    "
    
    
        filter_audio_example
    
        metadata_example
    
        qsvdec_example
    
        transcode_aac_example
    
    # catchall list of things that require external libs to link
    EXTRALIBS_LIST="
        cpu_init
        cws2fws
    "
    
    
    HWACCEL_LIBRARY_NONFREE_LIST="
    
        libnpp
    "
    HWACCEL_LIBRARY_LIST="
        $HWACCEL_LIBRARY_NONFREE_LIST
    
    EXTERNAL_LIBRARY_GPL_LIST="
        libcdio
        libx264
        libx265
        libxavs
        libxvid
    "
    
    EXTERNAL_LIBRARY_NONFREE_LIST="
        libfaac
        libfdk_aac
        openssl
    "
    
    EXTERNAL_LIBRARY_VERSION3_LIST="
        libopencore_amrnb
        libopencore_amrwb
        libvo_aacenc
        libvo_amrwbenc
    "
    
    
        $EXTERNAL_LIBRARY_GPL_LIST
        $EXTERNAL_LIBRARY_NONFREE_LIST
        $EXTERNAL_LIBRARY_VERSION3_LIST
    
        libdcadec
    
        libfontconfig
    
        libopenjpeg
        libopus
        libpulse
        librtmp
        libschroedinger
    
        libsnappy
    
        libtwolame
    
    Justin Ruggles's avatar
    Justin Ruggles committed
        libwebp
    
        libxcb
        libxcb_shm
        libxcb_xfixes
    
    FEATURE_LIST="
        gray
        hardcoded_tables
    
        runtime_cpudetect
        safe_bitstream_reader
        shared
        small
        sram
        static
        swscale_alpha
    "
    
    
    # COMPONENT_LIST needs to come last to ensure correct dependency checking
    
    CONFIG_LIST="
        $EXAMPLE_LIST
        $EXTERNAL_LIBRARY_LIST
    
        $FEATURE_LIST
        $LICENSE_LIST
        $LIBRARY_LIST
        $PROGRAM_LIST
        $SUBSYSTEM_LIST
    
    THREADS_LIST="
    
    ATOMICS_LIST="
    
        atomics_gcc
        atomics_suncc
    
    ARCH_LIST="
    
    Måns Rullgård's avatar
    Måns Rullgård committed
        tomi
    
    ARCH_EXT_LIST_ARM="
    
        armv8
    
    ARCH_EXT_LIST_X86_SIMD="
    
    ARCH_EXT_LIST_PPC="
        altivec
        dcbzl
        ldbrx
    
    ARCH_EXT_LIST_MIPS="
        loongson
        mips32r1
        mips64r1
        mips32r2
        mips64r2
        mips32r6
        mips64r6
    "
    
    
        $ARCH_EXT_LIST_MIPS
    
    ARCH_FEATURES="
        aligned_stack
        fast_64bit
        fast_clz
        fast_cmov
        local_aligned_8
        local_aligned_16
    
    James Almer's avatar
    James Almer committed
        local_aligned_32
    
    "
    
    BUILTIN_LIST="
        atomic_cas_ptr
        machine_rw_barrier
        MemoryBarrier
        mm_empty
        rdtsc
    
    Josh de Kock's avatar
    Josh de Kock committed
        sem_timedwait
    
    HAVE_LIST_CMDLINE="
    
    HAVE_LIST_PUB="
    
        fast_unaligned
    
        AVFoundation_AVFoundation_h
    
        arpa_inet_h
        cdio_paranoia_h
        cdio_paranoia_paranoia_h
    
    Josh de Kock's avatar
    Josh de Kock committed
        dispatch_dispatch_h
    
        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
        direct_h
    
        dxva_h
        io_h
        machine_ioctl_bt848_h
        machine_ioctl_meteor_h
        malloc_h
        poll_h
        sys_param_h
        sys_resource_h
        sys_select_h
        sys_soundcard_h
        sys_time_h
        sys_un_h
        sys_videoio_h
        unistd_h
    
    INTRINSICS_LIST="
        intrinsics_neon
    "
    
    
    SYSTEM_FEATURES="
        dos_paths
        libc_msvcrt
        MMAL_PARAMETER_VIDEO_MAX_NUM_CALLBACKS
        section_data_rel_ro
        threads
        uwp
    "
    
    
    Alex Beregszaszi's avatar
    Alex Beregszaszi committed
        closesocket
    
    Måns Rullgård's avatar
    Måns Rullgård committed
        fcntl
    
        GetProcessAffinityMask
    
    Ramiro Polla's avatar
    Ramiro Polla committed
        getrusage
    
        GetSystemTimeAsFileTime
    
        MapViewOfFile
    
        mprotect
    
        nanosleep
    
        posix_memalign
    
        strerror_r
    
        ebp_available
        ebx_available
        gnu_as
        ibm_asm
        inline_asm_labels
        pragma_deprecated
        symver_asm_label
        symver_gnu_asm
        vfp_args
        xform_asm
        xmm_clobbers
    "
    
    TYPES_LIST="
    
        CUVIDDECODECREATEINFO_bitDepthMinus8
    
        struct_group_source_req
        struct_ip_mreq_source
    
        struct_pollfd
    
        struct_v4l2_frmivalenum_discrete
    
    "
    
    HAVE_LIST="
        $ARCH_EXT_LIST
        $(add_suffix _external $ARCH_EXT_LIST)
        $(add_suffix _inline   $ARCH_EXT_LIST)
        $ARCH_FEATURES
        $BUILTIN_LIST
        $HAVE_LIST_CMDLINE
        $HAVE_LIST_PUB
        $HEADERS_LIST
    
        $INTRINSICS_LIST
    
        $THREADS_LIST
        $TOOLCHAIN_FEATURES
        $TYPES_LIST
    
    Diego Biurrun's avatar
    Diego Biurrun committed
    # options emitted with CONFIG_ prefix but not available on the command line
    
    Anton Khirnov's avatar
    Anton Khirnov committed
        qsvdec
    
        texturedsp
        texturedspenc
    
    PATHS_LIST="
    
    Luca Barbato's avatar
    Luca Barbato committed
        objcc
    
        pkg_config_flags
    
    Måns Rullgård's avatar
    Måns Rullgård committed
        samples
    
        toolchain
    
    CMDLINE_APPEND="
        extra_cflags
    
    Luca Barbato's avatar
    Luca Barbato committed
        extra_objcflags
    
    # code dependency declarations
    
    
    # architecture extensions
    
    armv5te_deps="arm"
    armv6_deps="arm"
    
    armv6t2_deps="arm"
    
    armv8_deps="aarch64"
    
    neon_deps_any="aarch64 arm"
    
    intrinsics_neon_deps="neon"
    
    vfp_deps_any="aarch64 arm"
    
    vfpv3_deps="vfp"
    
    map 'eval ${v}_inline_deps=inline_asm' $ARCH_EXT_LIST_ARM
    
    
    altivec_deps="ppc"
    
    dcbzl_deps="ppc"
    ldbrx_deps="ppc"
    
    vsx_deps="altivec"
    power8_deps="vsx"
    
    loongson_deps="mips"
    mips32r1_deps="mips32"
    mips32r2_deps="mips32"
    mips32r6_deps="mips32"
    mips64r1_deps="mips64"
    mips64r2_deps="mips64"
    mips64r6_deps="mips64"
    
    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"
    
    fma3_deps="avx"
    
    mmx_external_deps="x86asm"
    
    mmx_inline_deps="inline_asm x86"
    
    for ext in $(filter_out mmx $ARCH_EXT_LIST_X86_SIMD); 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"
    
    simd_align_16_if_any="altivec neon sse"
    
    simd_align_32_if_any="avx"
    
    symver_if_any="symver_asm_label symver_gnu_asm"
    
    valgrind_backtrace_conflict="optimizations"
    valgrind_backtrace_deps="valgrind_valgrind_h"
    
    # 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"
    
    w32threads_deps="atomics_native"
    
    cbs_h264_select="cbs golomb"
    
    cbs_h265_select="cbs golomb"
    
    dct_select="rdft"
    
    faandct_deps="faan"
    faandct_select="fdctdsp"
    faanidct_deps="faan"
    faanidct_select="idctdsp"