Skip to content
Snippets Groups Projects
configure 191 KiB
Newer Older
check_header_oc(){
    log check_header_oc "$@"
    {
       echo "#include <$header>"
       echo "int main(void) { return 0; }"
    } | check_oc && check_stat "$TMPO" && enable_safe $headers
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_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 "$@"
        done
        for func in $funcs; do
            echo "long check_$func(void) { return (long) $func; }"
        done
        echo "int main(void) { return 0; }"
Mohamed Naufal's avatar
Mohamed Naufal committed
    } | check_ld "cc" "$@" && enable $funcs && enable_safe $headers
}

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_safe $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
}

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_config_flags $pkg)
    pkg_libs=$($pkg_config --libs $pkg_config_flags $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"
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"
}

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"
}

    check_pkg_config "$@" || return 1
    add_cflags    $(get_safe "${pkg}_cflags")
    add_extralibs $(get_safe "${pkg}_libs")
    use_pkg_config "$@" || die "ERROR: $pkg not found using pkg-config$pkg_config_fail_message"
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_config_flags $pkg)
    pkg_libs=$($pkg_config --libs $pkg_config_flags $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 $host_cppflags $host_cflags "$@" $(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
    avio_list_dir_example
    decoding_encoding_example
    demuxing_decoding_example
    filter_audio_example
    filtering_audio_example
    filtering_video_example
    metadata_example
    qsvdec_example
    remuxing_example
    resampling_audio_example
    scaling_video_example
    transcode_aac_example
    transcoding_example
EXTERNAL_LIBRARY_LIST="
    avisynth
    bzlib
    decklink
    libdcadec
    libfontconfig
wm4's avatar
wm4 committed
    libgme
    libopencore_amrnb
    libopencore_amrwb
    libopencv
    libquvi
    libvo_aacenc
    libvo_amrwbenc
    libvorbis
    libvpx
Justin Ruggles's avatar
Justin Ruggles committed
    libwebp
Derek Buitenhuis's avatar
Derek Buitenhuis committed
    libx265
    libxcb
    libxcb_shm
    libxcb_xfixes
Stefano Sabatini's avatar
Stefano Sabatini committed
    libzmq
Lukasz Marek's avatar
Lukasz Marek committed
    opengl
    securetransport
    gray
    hardcoded_tables
    runtime_cpudetect
    safe_bitstream_reader
    shared
    small
    static
    swscale_alpha
"

LIBRARY_LIST="
    avcodec
    avdevice
    avfilter
    avformat
    avresample
    avutil
    postproc
    pixelutils
    memory_poisoning
THREADS_LIST="
    os2threads
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_MIPS="
    mipsfpu
    mips32r2
ARCH_EXT_LIST_X86_SIMD="
ARCH_EXT_LIST_PPC="
    altivec
    dcbzl
    ldbrx
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
HAVE_LIST_CMDLINE="
HAVE_LIST_PUB="
    fast_unaligned
HEADERS_LIST="
    alsa_asoundlib_h
    altivec_h
    arpa_inet_h
    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
    dlfcn_h
    gsm_h
    io_h
    mach_mach_time_h
    machine_ioctl_bt848_h
    machine_ioctl_meteor_h
    malloc_h
    openjpeg_1_5_openjpeg_h
    OpenGL_gl3_h
    poll_h
    sndio_h
    soundcard_h
    sys_mman_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
"

Alex Beregszaszi's avatar
Alex Beregszaszi committed
    closesocket
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
Ramiro Polla's avatar
Ramiro Polla committed
    getrusage
    GetSystemTimeAsFileTime
Lukasz Marek's avatar
Lukasz Marek committed
    glXGetProcAddress
    kbhit
    LoadLibrary
    MapViewOfFile
    mkstemp
    mprotect
    nanosleep
    posix_memalign
    pthread_cancel
    strerror_r
    as_dn_directive
    asm_mod_q
    attribute_may_alias
    attribute_packed
    ebp_available
    ebx_available
    gnu_as
    symver_asm_label
    symver_gnu_asm
    vfp_args
    xform_asm
    xmm_clobbers
"

TYPES_LIST="
    struct_group_source_req
    struct_ip_mreq_source
    struct_pollfd
    struct_sctp_event_subscribe
    struct_stat_st_mtim_tv_nsec
    struct_v4l2_frmivalenum_discrete
"

HAVE_LIST="
    $ARCH_EXT_LIST
    $(add_suffix _external $ARCH_EXT_LIST)
    $(add_suffix _inline   $ARCH_EXT_LIST)
    $ARCH_FEATURES
    $ATOMICS_LIST
    $BUILTIN_LIST
    $HAVE_LIST_CMDLINE
    $HAVE_LIST_PUB
    $HEADERS_LIST
    $INTRINSICS_LIST
    $MATH_FUNCS
    $SYSTEM_FUNCS
    $THREADS_LIST
    $TOOLCHAIN_FEATURES
    $TYPES_LIST
    atomics_native
    dos_paths
    libc_msvcrt
    libdc1394_1
    libdc1394_2
    vaapi_x11
Diego Biurrun's avatar
Diego Biurrun committed
# options emitted with CONFIG_ prefix but not available on the command line
    llauddsp
Anton Khirnov's avatar
Anton Khirnov committed
    qsvdec
PATHS_LIST="
Mohamed Naufal's avatar
Mohamed Naufal committed
    cxx
    host_ldflags
    host_libs
    pkg_config_flags
Måns Rullgård's avatar
Måns Rullgård committed
    samples