Skip to content
Snippets Groups Projects
configure 229 KiB
Newer Older
  • Learn to ignore specific revisions
  • Loren Merritt's avatar
    Loren Merritt committed
        echo "$1" > $TMPS
        log_file $TMPS
        shift 1
    
        check_cmd $x86asmexe $X86ASMFLAGS -Werror "$@" -o $TMPO $TMPS
    
    ld_o(){
        eval printf '%s\\n' $LD_O
    }
    
    
    Mohamed Naufal's avatar
    Mohamed Naufal committed
        type=$1
        shift 1
    
    Jonas Bechtel's avatar
    Jonas Bechtel committed
        flags=$(filter_out '-l*|*.so' $@)
        libs=$(filter '-l*|*.so' $@)
    
        check_$type $($cflags_filter $flags) || return
    
        flags=$($ldflags_filter $flags)
        libs=$($ldflags_filter $libs)
    
        check_cmd $ld $LDFLAGS $LDEXEFLAGS $flags $(ld_o $TMPE) $TMPO $libs $extralibs
    
    print_include(){
        hdr=$1
        test "${hdr%.h}" = "${hdr}" &&
            echo "#include $hdr"    ||
            echo "#include <$hdr>"
    }
    
    
    check_code(){
        log check_code "$@"
        check=$1
        headers=$2
        code=$3
        shift 3
        {
            for hdr in $headers; do
    
            done
            echo "int main(void) { $code; return 0; }"
        } | check_$check "$@"
    }
    
    
    check_cppflags(){
        log check_cppflags "$@"
    
        check_cpp "$@" <<EOF && append CPPFLAGS "$@"
    
    test_cflags(){
        log test_cflags "$@"
    
        set -- $($cflags_filter "$@")
    
    check_cflags(){
        log check_cflags "$@"
        test_cflags "$@" && add_cflags "$@"
    }
    
    
    Mohamed Naufal's avatar
    Mohamed Naufal committed
    check_cxxflags(){
        log check_cxxflags "$@"
    
        set -- $($cflags_filter "$@")
    
    Mohamed Naufal's avatar
    Mohamed Naufal committed
        check_cxx "$@" <<EOF && append CXXFLAGS "$@"
    int x;
    EOF
    }
    
    
    Luca Barbato's avatar
    Luca Barbato committed
    test_objcflags(){
    
        log test_objcflags "$@"
        set -- $($objcflags_filter "$@")
    
    Luca Barbato's avatar
    Luca Barbato committed
        check_objcc "$@" <<EOF
    int x;
    EOF
    }
    
    check_objcflags(){
    
    Luca Barbato's avatar
    Luca Barbato committed
        test_objcflags "$@" && add_objcflags "$@"
    }
    
    
    test_ldflags(){
        log test_ldflags "$@"
    
        set -- $($ldflags_filter "$@")
    
    Mohamed Naufal's avatar
    Mohamed Naufal committed
        check_ld "cc" "$@" <<EOF
    
    check_ldflags(){
        log check_ldflags "$@"
        test_ldflags "$@" && add_ldflags "$@"
    }
    
    
    test_stripflags(){
        log test_stripflags "$@"
        # call check_cc to get a fresh TMPO
        check_cc <<EOF
    int main(void) { return 0; }
    EOF
    
        check_cmd $strip $ASMSTRIPFLAGS "$@" $TMPO
    
    }
    
    check_stripflags(){
        log check_stripflags "$@"
        test_stripflags "$@" && add_stripflags "$@"
    }
    
    
    check_header(){
    
        disable_sanitized $headers
        {
            for hdr in $headers; do
                print_include $hdr
            done
            echo "int x;"
        } | check_cpp "$@" && enable_sanitized $headers
    
    check_header_objcc(){
        log check_header_objcc "$@"
    
        disable_sanitized $header
    
        {
           echo "#include <$header>"
           echo "int main(void) { return 0; }"
    
        } | check_objcc && check_stat "$TMPO" && enable_sanitized $header
    
    check_apple_framework(){
        log check_apple_framework "$@"
        framework="$1"
        name="$(tolower $framework)"
        header="${framework}/${framework}.h"
        disable $name
    
        check_header_objcc $header &&
            enable $name && eval ${name}_extralibs='"-framework $framework"'
    
    Måns Rullgård's avatar
    Måns Rullgård committed
        disable $func
    
    Mohamed Naufal's avatar
    Mohamed Naufal committed
        check_ld "cc" "$@" <<EOF && enable $func
    
    extern int $func();
    
    check_complexfunc(){
        log check_complexfunc "$@"
        func=$1
        narg=$2
        shift 2
        test $narg = 2 && args="f, g" || args="f * I"
        disable $func
        check_ld "cc" "$@" <<EOF && enable $func
    #include <complex.h>
    #include <math.h>
    float foo(complex float f, complex float g) { return $func($args); }
    int main(void){ return (int) foo; }
    EOF
    }
    
    
    check_mathfunc(){
    
        log check_mathfunc "$@"
    
        narg=$2
        shift 2
        test $narg = 2 && args="f, g" || args="f"
    
        disable $func
        check_ld "cc" "$@" <<EOF && enable $func
    #include <math.h>
    
    float foo(float f, float g) { return $func($args); }
    
    check_func_headers(){
        log check_func_headers "$@"
    
            for func in $funcs; do
                echo "long check_$func(void) { return (long) $func; }"
            done
    
            echo "int main(void) { int ret = 0;"
            # LTO could optimize out the test functions without this
            for func in $funcs; do
                echo " ret |= ((intptr_t)check_$func) & 0xFFFF;"
            done
            echo "return ret; }"
    
        } | check_ld "cc" "$@" && enable $funcs && enable_sanitized $headers
    
    Mohamed Naufal's avatar
    Mohamed Naufal committed
    }
    
    check_class_headers_cpp(){
        log check_class_headers_cpp "$@"
        headers=$1
        classes=$2
        shift 2
        {
            for hdr in $headers; do
                echo "#include <$hdr>"
            done
            echo "int main(void) { "
            i=1
            for class in $classes; do
                echo "$class obj$i;"
                i=$(expr $i + 1)
            done
            echo "return 0; }"
    
        } | check_ld "cxx" "$@" && enable $funcs && enable_sanitized $headers
    
    check_cpp_condition(){
        log check_cpp_condition "$@"
        header=$1
        condition=$2
    
        check_cpp "$@" <<EOF
    
    #include <$header>
    #if !($condition)
    #error "unsatisfied condition: $condition"
    #endif
    EOF
    }
    
    
        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="\$@"
    
    Mohamed Naufal's avatar
    Mohamed Naufal committed
    check_lib_cpp(){
        log check_lib_cpp "$@"
    
        name="$1"
        headers="$2"
        classes="$3"
        shift 3
        disable $name
        check_class_headers_cpp "$headers" "$classes" "$@" &&
            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
    
        check_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
    
    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
    
        disable_sanitized "$type"
        check_code cc "$headers" "$type v" "$@" && enable_sanitized "$type"
    
    check_struct(){
    
        headers=$1
        struct=$2
        member=$3
        shift 3
    
        disable_sanitized "${struct}_${member}"
    
        check_code cc "$headers" "const void *p = &(($struct *)0)->$member" "$@" &&
    
            enable_sanitized "${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"
    
    check_compile_assert(){
        log check_compile_assert "$@"
        name=$1
        headers=$2
        condition=$3
        shift 3
        disable "$name"
        check_code cc "$headers" "char c[2 * !!($condition) - 1]" "$@" && enable "$name"
    }
    
    
        check_lib $name "$headers" $func "$@" || die "ERROR: $name_version 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"
    }
    
    
        check_header "$headers" "$@" || die "ERROR: $headers not found"
    
        log require_cpp_condition "$@"
    
        header="$1"
        condition="$2"
        shift 2
        check_cpp_condition "$header" "$condition" "$@" || die "ERROR: $condition not satisfied"
    }
    
    
        check_pkg_config "$@" || die "ERROR: $pkg_version not found using pkg-config$pkg_config_fail_message"
    
    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 $host_cppflags $host_cflags "$@" $(hostcc_e $TMPO) $TMPC
    
    check_host_cppflags(){
        log check_host_cppflags "$@"
    
        check_host_cpp "$@" <<EOF && append host_cppflags "$@"
    
    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
    }
    
    
        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.
    
    
    COMPONENT_LIST="
        $AVCODEC_COMPONENTS
        $AVDEVICE_COMPONENTS
        $AVFILTER_COMPONENTS
        $AVFORMAT_COMPONENTS
    "
    
    
        avio_reading_example
    
        demuxing_decoding_example
    
        filter_audio_example
    
        filtering_audio_example
        filtering_video_example
    
        http_multiclient_example
    
        metadata_example
    
        qsvdec_example
    
        remuxing_example
    
        resampling_audio_example
        scaling_video_example
    
        transcode_aac_example
    
        transcoding_example
    
        vaapi_encode_example
    
        iconv
        libxcb
        libxcb_shm
        libxcb_shape
        libxcb_xfixes
        lzma
        schannel
        sdl2
        securetransport
    
    EXTERNAL_LIBRARY_GPL_LIST="
    
        libx264
        libx265
        libxavs
        libxvid
    "
    
    EXTERNAL_LIBRARY_NONFREE_LIST="
    
    "
    
    EXTERNAL_LIBRARY_VERSION3_LIST="
    
        libopencore_amrnb
        libopencore_amrwb
    
    EXTERNAL_LIBRARY_GPLV3_LIST="
        libsmbclient
    "
    
    
        $EXTERNAL_LIBRARY_GPL_LIST
        $EXTERNAL_LIBRARY_NONFREE_LIST
        $EXTERNAL_LIBRARY_VERSION3_LIST
    
        $EXTERNAL_LIBRARY_GPLV3_LIST
    
        chromaprint
    
    Mark Thompson's avatar
    Mark Thompson committed
        libdrm
    
        libfontconfig
    
    wm4's avatar
    wm4 committed
        libgme
    
        libopenmpt
    
        libsnappy
    
    Paul B Mahol's avatar
    Paul B Mahol committed
        libtesseract
    
    Justin Ruggles's avatar
    Justin Ruggles committed
        libwebp
    
        libzimg
    
    Stefano Sabatini's avatar
    Stefano Sabatini committed
        libzmq
    
    Lukasz Marek's avatar
    Lukasz Marek committed
        opengl
    
        videotoolbox
    
    # catchall list of things that require external libs to link
    EXTRALIBS_LIST="
        cpu_init
        cws2fws
    "
    
    
    HWACCEL_LIBRARY_NONFREE_LIST="
    
        $HWACCEL_LIBRARY_NONFREE_LIST
    
        runtime_cpudetect
        safe_bitstream_reader
        shared
        small
        static
        swscale_alpha
    "
    
    
    LIBRARY_LIST="
        avcodec
        avdevice
        avfilter
        avformat
        avresample
        avutil
    
        postproc
    
        pixelutils
    
    # COMPONENT_LIST needs to come last to ensure correct dependency checking
    
        $EXTERNAL_AUTODETECT_LIBRARY_LIST
    
        $HWACCEL_AUTODETECT_LIBRARY_LIST
    
        memory_poisoning
    
    THREADS_LIST="
    
        os2threads
    
    ATOMICS_LIST="
    
        atomics_gcc
        atomics_suncc
    
    AUTODETECT_LIBS="
        $EXTERNAL_AUTODETECT_LIBRARY_LIST
        $HWACCEL_AUTODETECT_LIBRARY_LIST
        $THREADS_LIST
    "
    
    
    ARCH_LIST="
    
    Måns Rullgård's avatar
    Måns Rullgård committed
        tomi
    
    ARCH_EXT_LIST_ARM="
    
        armv8
    
    ARCH_EXT_LIST_MIPS="
        mipsfpu
        mips32r2
    
        loongson2
        loongson3
    
    ARCH_EXT_LIST_X86_SIMD="
    
    Rodger Combs's avatar
    Rodger Combs committed
        aesni
    
    ARCH_EXT_LIST_PPC="
        altivec
        dcbzl
        ldbrx
    
    ARCH_FEATURES="
        aligned_stack
        fast_64bit
        fast_clz
        fast_cmov
    
    BUILTIN_LIST="
        atomic_cas_ptr
        machine_rw_barrier
        MemoryBarrier
        mm_empty
        rdtsc
    
    HAVE_LIST_CMDLINE="
    
    HAVE_LIST_PUB="
    
        fast_unaligned
    
        cdio_paranoia_h
        cdio_paranoia_paranoia_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
    
        io_h
        machine_ioctl_bt848_h
        machine_ioctl_meteor_h
        malloc_h
    
        opencv2_core_core_c_h
    
        poll_h
        sys_param_h
        sys_resource_h
        sys_select_h
        sys_soundcard_h
        sys_time_h
        sys_un_h
        sys_videoio_h
    
    INTRINSICS_LIST="
        intrinsics_neon
    "
    
    
    SYSTEM_FEATURES="
        dos_paths
        libc_msvcrt
        MMAL_PARAMETER_VIDEO_MAX_NUM_CALLBACKS