Skip to content
Snippets Groups Projects
configure 130 KiB
Newer Older
  • Learn to ignore specific revisions
  • Måns Rullgård's avatar
    Måns Rullgård committed
            ;;
    
            power[3-7]*)
    
                cpuflags="-mcpu=$cpu"
    
    Måns Rullgård's avatar
    Måns Rullgård committed
                cpuflags="-mcpu=cell"
                enable ldbrx
            ;;
    
            e500mc)
                cpuflags="-mcpu=e500mc"
                disable altivec
            ;;
    
            e500v2)
                cpuflags="-mcpu=8548 -mhard-float -mfloat-gprs=double"
                disable altivec
            ;;
            e500)
                cpuflags="-mcpu=8540 -mhard-float"
                disable altivec
            ;;
    
    Måns Rullgård's avatar
    Måns Rullgård committed
        esac
    
    elif enabled sparc; then
    
        case $cpu in
            cypress|f93[04]|tsc701|sparcl*|supersparc|hypersparc|niagara|v[789])
                cpuflags="-mcpu=$cpu"
                disable vis
            ;;
            ultrasparc*|niagara[234])
                cpuflags="-mcpu=$cpu"
            ;;
        esac
    
    
    elif enabled x86; then
    
    
    Måns Rullgård's avatar
    Måns Rullgård committed
        case $cpu in
            i[345]86|pentium)
                cpuflags="-march=$cpu"
                disable mmx
            ;;
    
            # targets that do NOT support nopl and conditional mov (cmov)
    
    Måns Rullgård's avatar
    Måns Rullgård committed
            pentium-mmx|k6|k6-[23]|winchip-c6|winchip2|c3)
                cpuflags="-march=$cpu"
    
    Måns Rullgård's avatar
    Måns Rullgård committed
            ;;
    
            # targets that do support nopl and conditional mov (cmov)
    
            i686|pentiumpro|pentium[23]|pentium-m|athlon|athlon-tbird|athlon-4|athlon-[mx]p|athlon64*|k8*|opteron*|athlon-fx|core2|corei7*|amdfam10|barcelona|atom|bdver*)
    
    Måns Rullgård's avatar
    Måns Rullgård committed
                cpuflags="-march=$cpu"
    
    Måns Rullgård's avatar
    Måns Rullgård committed
                enable fast_cmov
            ;;
            # targets that do support conditional mov but on which it's slow
            pentium4|pentium4m|prescott|nocona)
                cpuflags="-march=$cpu"
    
    Måns Rullgård's avatar
    Måns Rullgård committed
                disable fast_cmov
            ;;
        esac
    
    if [ "$cpu" != generic ]; then
        add_cflags  $cpuflags
        add_asflags $cpuflags
    fi
    
    # compiler sanity check
    check_exec <<EOF
    int main(void){ return 0; }
    EOF
    if test "$?" != 0; then
        echo "$cc is unable to create an executable file."
        if test -z "$cross_prefix" && ! enabled cross_compile ; then
            echo "If $cc is a cross-compiler, use the --enable-cross-compile option."
            echo "Only do this if you know what cross compiling means."
        fi
        die "C compiler test failed."
    fi
    
    
    check_cflags -std=c99
    
    check_cc -D_FILE_OFFSET_BITS=64 <<EOF && add_cppflags -D_FILE_OFFSET_BITS=64
    
    check_cc -D_LARGEFILE_SOURCE <<EOF && add_cppflags -D_LARGEFILE_SOURCE
    
    check_host_cflags -std=c99
    
    check_64bit(){
        arch32=$1
        arch64=$2
        expr=$3
        check_code cc "" "int test[2*($expr) - 1]" &&
            subarch=$arch64 || subarch=$arch32
    }
    
    
    case "$arch" in
    
            spic=$shared
        ;;
        mips)
            check_64bit mips mips64 '_MIPS_SIM > 1'
    
            spic=$shared
    
        parisc)
            check_64bit parisc parisc64 'sizeof(void *) > 4'
            spic=$shared
        ;;
    
        ppc)
            check_64bit ppc ppc64 'sizeof(void *) > 4'
    
        sparc)
            check_64bit sparc sparc64 'sizeof(void *) > 4'
            spic=$shared
        ;;
    
            check_64bit x86_32 x86_64 'sizeof(void *) > 4'
    
            if test "$subarch" = "x86_64"; then
    
                spic=$shared
    
    enable $subarch
    
    enabled spic && enable_weak pic
    
            SHFLAGS=-shared
    
            add_cppflags '-I\$(SRC_PATH)/compat/aix'
    
            enabled shared && add_ldflags -Wl,-brtl
    
    François Revol's avatar
    François Revol committed
            host_libs=
    
            SHFLAGS='-shared -Wl,-h,$$(@F)'
    
            enabled x86 && SHFLAGS="-mimpure-text $SHFLAGS"
    
            add_cppflags -D__EXTENSIONS__ -D_XOPEN_SOURCE=600
    
            # When using suncc to build, the Solaris linker will mark
            # an executable with each instruction set encountered by
            # the Solaris assembler.  As our libraries contain their own
            # guards for processor-specific code, instead suppress
            # generation of the HWCAPS ELF section on Solaris x86 only.
    
            enabled_all suncc x86 &&
                echo "hwcap_1 = OVERRIDE;" > mapfile &&
                add_ldflags -Wl,-M,mapfile
    
            nm_default='nm -P -g'
    
            disable symver
    
            oss_indev_extralibs="-lossaudio"
            oss_outdev_extralibs="-lossaudio"
    
    Brad Smith's avatar
    Brad Smith committed
        openbsd|bitrig)
    
            disable symver
    
            SLIB_INSTALL_NAME='$(SLIBNAME).$(LIBMAJOR).$(LIBMINOR)'
    
            SLIB_INSTALL_LINKS=
    
            oss_indev_extralibs="-lossaudio"
            oss_outdev_extralibs="-lossaudio"
    
        dragonfly)
            disable symver
            ;;
        freebsd)
    
            add_extralibs -lpoll -lgnugetopt
    
            gas="gas-preprocessor.pl $cc"
    
            enabled ppc && add_asflags -force_cpusubtype_ALL
    
            SHFLAGS='-dynamiclib -Wl,-single_module -Wl,-install_name,$(SHLIBDIR)/$(SLIBNAME_WITH_MAJOR),-current_version,$(LIBVERSION),-compatibility_version,$(LIBMAJOR)'
    
            enabled x86_32 && append SHFLAGS -Wl,-read_only_relocs,suppress
    
            add_ldflags -Wl,-dynamic,-search_paths_first
    
            SLIBSUF=".dylib"
            SLIBNAME_WITH_VERSION='$(SLIBPREF)$(FULLNAME).$(LIBVERSION)$(SLIBSUF)'
            SLIBNAME_WITH_MAJOR='$(SLIBPREF)$(FULLNAME).$(LIBMAJOR)$(SLIBSUF)'
    
    Loren Merritt's avatar
    Loren Merritt committed
            objformat="macho"
    
            enabled x86_64 && objformat="macho64"
    
            enabled_any pic shared ||
    
                { check_cflags -mdynamic-no-pic && add_asflags -mdynamic-no-pic; }
    
            if test $target_os = "mingw32ce"; then
    
            LIBTARGET=i386
    
                LIBTARGET="i386:x86-64"
    
            check_ldflags -Wl,--nxcompat
            check_ldflags -Wl,--dynamicbase
    
            SLIBPREF=""
            SLIBSUF=".dll"
            SLIBNAME_WITH_VERSION='$(SLIBPREF)$(FULLNAME)-$(LIBVERSION)$(SLIBSUF)'
            SLIBNAME_WITH_MAJOR='$(SLIBPREF)$(FULLNAME)-$(LIBMAJOR)$(SLIBSUF)'
    
            SLIB_EXTRA_CMD=-'sed -e "s/ @[^ ]*//" $$(@:$(SLIBSUF)=.orig.def) > $$(@:$(SLIBSUF)=.def); $(DLLTOOL) -m $(LIBTARGET) -d $$(@:$(SLIBSUF)=.def) -l $(SUBDIR)$(SLIBNAME:$(SLIBSUF)=.lib) -D $(SLIBNAME_WITH_MAJOR)'
    
            SLIB_INSTALL_NAME='$(SLIBNAME_WITH_MAJOR)'
            SLIB_INSTALL_LINKS=
            SLIB_INSTALL_EXTRA_SHLIB='$(SLIBNAME:$(SLIBSUF)=.lib)'
            SLIB_INSTALL_EXTRA_LIB='lib$(SLIBNAME:$(SLIBSUF)=.dll.a) $(SLIBNAME_WITH_MAJOR:$(SLIBSUF)=.def)'
    
            SHFLAGS='-shared -Wl,--output-def,$$(@:$(SLIBSUF)=.orig.def) -Wl,--out-implib,$(SUBDIR)lib$(SLIBNAME:$(SLIBSUF)=.dll.a) -Wl,--enable-runtime-pseudo-reloc -Wl,--enable-auto-image-base'
    
    Loren Merritt's avatar
    Loren Merritt committed
            objformat="win32"
    
            dlltool="${cross_prefix}dlltool"
    
            ranlib=:
    
            if enabled shared; then
                # Link to the import library instead of the normal static library
                # for shared libs.
                LD_LIB='%.lib'
    
                # Cannot build both shared and static libs with MSVC or icl.
    
                disable static
            fi
            shlibdir_default="$bindir_default"
            SLIBPREF=""
            SLIBSUF=".dll"
            SLIBNAME_WITH_VERSION='$(SLIBPREF)$(FULLNAME)-$(LIBVERSION)$(SLIBSUF)'
            SLIBNAME_WITH_MAJOR='$(SLIBPREF)$(FULLNAME)-$(LIBMAJOR)$(SLIBSUF)'
            SLIB_CREATE_DEF_CMD='makedef $(SUBDIR)lib$(NAME).ver $(OBJS) > $$(@:$(SLIBSUF)=.def)'
            SLIB_INSTALL_NAME='$(SLIBNAME_WITH_MAJOR)'
            SLIB_INSTALL_LINKS=
            SLIB_INSTALL_EXTRA_SHLIB='$(SLIBNAME:$(SLIBSUF)=.lib)'
            SLIB_INSTALL_EXTRA_LIB='$(SLIBNAME_WITH_MAJOR:$(SLIBSUF)=.def)'
            SHFLAGS='-dll -def:$$(@:$(SLIBSUF)=.def) -implib:$(SUBDIR)$(SLIBNAME:$(SLIBSUF)=.lib)'
    
            objformat="win32"
            ranlib=:
            enable dos_paths
            ;;
    
            SLIBPREF="cyg"
            SLIBSUF=".dll"
            SLIBNAME_WITH_VERSION='$(SLIBPREF)$(FULLNAME)-$(LIBVERSION)$(SLIBSUF)'
            SLIBNAME_WITH_MAJOR='$(SLIBPREF)$(FULLNAME)-$(LIBMAJOR)$(SLIBSUF)'
    
            SLIB_INSTALL_NAME='$(SLIBNAME_WITH_MAJOR)'
            SLIB_INSTALL_LINKS=
            SLIB_INSTALL_EXTRA_LIB='lib$(FULLNAME).dll.a'
            SHFLAGS='-shared -Wl,--out-implib,$(SUBDIR)lib$(FULLNAME).dll.a'
    
    Loren Merritt's avatar
    Loren Merritt committed
            objformat="win32"
    
    Michael Kostylev's avatar
    Michael Kostylev committed
        *-dos|freedos|opendos)
            network_extralibs="-lsocket"
    
            objformat="coff"
    
            add_cppflags -U__STRICT_ANSI__
    
        os/2*)
            ln_s="cp -f"
    
            objformat="aout"
    
            add_cppflags -D_GNU_SOURCE
    
            add_ldflags -Zomf -Zbin-files -Zargs-wild -Zmap
    
    Måns Rullgård's avatar
    Måns Rullgård committed
            SHFLAGS='$(SUBDIR)$(NAME).def -Zdll -Zomf'
    
            SLIBPREF=""
            SLIBSUF=".dll"
            SLIBNAME_WITH_VERSION='$(SLIBPREF)$(NAME)-$(LIBVERSION)$(SLIBSUF)'
            SLIBNAME_WITH_MAJOR='$(SLIBPREF)$(shell echo $(NAME) | cut -c1-6)$(LIBMAJOR)$(SLIBSUF)'
    
    Måns Rullgård's avatar
    Måns Rullgård committed
            SLIB_CREATE_DEF_CMD='echo LIBRARY $(SLIBNAME_WITH_MAJOR) INITINSTANCE TERMINSTANCE > $(SUBDIR)$(NAME).def; \
    
                echo PROTMODE >> $(SUBDIR)$(NAME).def; \
                echo CODE PRELOAD MOVEABLE DISCARDABLE >> $(SUBDIR)$(NAME).def; \
                echo DATA PRELOAD MOVEABLE MULTIPLE NONSHARED >> $(SUBDIR)$(NAME).def; \
                echo EXPORTS >> $(SUBDIR)$(NAME).def; \
                emxexp -o $(OBJS) >> $(SUBDIR)$(NAME).def'
    
    Måns Rullgård's avatar
    Måns Rullgård committed
            SLIB_EXTRA_CMD='emximp -o $(SUBDIR)$(LIBPREF)$(NAME)_dll.a $(SUBDIR)$(NAME).def; \
    
                emximp -o $(SUBDIR)$(LIBPREF)$(NAME)_dll.lib $(SUBDIR)$(NAME).def;'
    
            SLIB_INSTALL_EXTRA_LIB='$(LIBPREF)$(NAME)_dll.a $(LIBPREF)$(NAME)_dll.lib'
    
            add_cppflags -D_BSD_SOURCE
    
        qnx)
            add_cppflags -D_QNX_SOURCE
            network_extralibs="-lsocket"
            ;;
    
        symbian)
            SLIBSUF=".dll"
            enable dos_paths
    
            add_cflags --include=$sysinclude/gcce/gcce.h -fvisibility=default
            add_cppflags -D__GCCE__ -D__SYMBIAN32__ -DSYMBIAN_OE_POSIX_SIGNALS
            add_ldflags -Wl,--target1-abs,--no-undefined \
                        -Wl,-Ttext,0x80000,-Tdata,0x1000000 -shared \
                        -Wl,--entry=_E32Startup -Wl,-u,_E32Startup
            add_extralibs -l:eexe.lib -l:usrt2_2.lib -l:dfpaeabi.dso \
                          -l:drtaeabi.dso -l:scppnwdl.dso -lsupc++ -lgcc \
                          -l:libc.dso -l:libm.dso -l:euser.dso -l:libcrt0.lib
    
        osf1)
            add_cppflags -D_OSF_SOURCE -D_POSIX_PII -D_REENTRANT
            ;;
    
    Mans Rullgard's avatar
    Mans Rullgard committed
        plan9)
            add_cppflags -D_C99_SNPRINTF_EXTENSION  \
                         -D_REENTRANT_SOURCE        \
                         -D_RESEARCH_SOURCE         \
                         -DFD_SETSIZE=96            \
                         -DHAVE_SOCK_OPTS
            add_compat strtod.o strtod=avpriv_strtod
            network_extralibs='-lbsd'
            exeobjs=compat/plan9/main.o
            disable avserver
            cp_f='cp'
            ;;
    
            die "Unknown OS '$target_os'."
    
    # determine libc flavour
    
    
    # uclibc defines __GLIBC__, so it needs to be checked before glibc.
    
    if check_cpp_condition features.h "defined __UCLIBC__"; then
        libc_type=uclibc
    
        add_cppflags -D_POSIX_C_SOURCE=200112 -D_XOPEN_SOURCE=600
    
    elif check_cpp_condition features.h "defined __GLIBC__"; then
        libc_type=glibc
    
        add_cppflags -D_POSIX_C_SOURCE=200112 -D_XOPEN_SOURCE=600
    
    # MinGW headers can be installed on Cygwin, so check for newlib first.
    elif check_cpp_condition newlib.h "defined _NEWLIB_VERSION"; then
        libc_type=newlib
        add_cppflags -U__STRICT_ANSI__
    
    elif check_header _mingw.h; then
        libc_type=mingw
        check_cpp_condition _mingw.h \
            "defined (__MINGW64_VERSION_MAJOR) || (__MINGW32_MAJOR_VERSION > 3) || \
                (__MINGW32_MAJOR_VERSION == 3 && __MINGW32_MINOR_VERSION >= 15)" ||
            die "ERROR: MinGW runtime version must be >= 3.15."
    
    elif check_func_headers stdlib.h _get_doserrno; then
        libc_type=msvcrt
    
        add_compat strtod.o strtod=avpriv_strtod
        add_compat msvcrt/snprintf.o snprintf=avpriv_snprintf   \
                                     _snprintf=avpriv_snprintf  \
                                     vsnprintf=avpriv_vsnprintf
    
        # The MSVC 2010 headers (Win 7.0 SDK) set _WIN32_WINNT to
        # 0x601 by default unless something else is set by the user.
        # This can easily lead to us detecting functions only present
        # in such new versions and producing binaries requiring windows 7.0.
        # Therefore explicitly set the default to XP unless the user has
        # set something else on the command line.
        check_cpp_condition stdlib.h "defined(_WIN32_WINNT)" || add_cppflags -D_WIN32_WINNT=0x0502
    
    elif check_cpp_condition stddef.h "defined __KLIBC__"; then
        libc_type=klibc
    
    elif check_cpp_condition sys/cdefs.h "defined __BIONIC__"; then
        libc_type=bionic
        add_compat strtod.o strtod=avpriv_strtod
    
    fi
    
    test -n "$libc_type" && enable $libc_type
    
    
    # hacks for compiler/libc/os combinations
    
    if enabled_all tms470 glibc; then
    
        CPPFLAGS="-I${source_path}/compat/tms470 ${CPPFLAGS}"
    
        add_cppflags -D__USER_LABEL_PREFIX__=
        add_cppflags -D__builtin_memset=memset
        add_cppflags -D__gnuc_va_list=va_list -D_VA_LIST_DEFINED
        add_cflags   -pds=48    # incompatible redefinition of macro
    fi
    
    
    if enabled_all ccc glibc; then
        add_ldflags -Wl,-z,now  # calls to libots crash without this
    fi
    
    
    esc(){
        echo "$*" | sed 's/%/%25/g;s/:/%3a/g'
    }
    
    echo "config:$arch:$subarch:$cpu:$target_os:$(esc $cc_ident):$(esc $LIBAV_CONFIGURATION)" >config.fate
    
    check_cpp_condition stdlib.h "defined(__PIC__) || defined(__pic__) || defined(PIC)" && enable_weak pic
    
    set_default $PATHS_LIST
    
    set_default nm
    
    # we need to build at least one lib type
    
    if ! enabled_any static shared; then
    
        cat <<EOF
    At least one library type must be built.
    Specify --enable-static to build the static libraries or --enable-shared to
    build the shared libraries as well. To only build the shared libraries specify
    --disable-static in addition to --enable-shared.
    EOF
        exit 1;
    fi
    
    
        enabled $1 || { enabled $2 && die "$2 is $1 and --enable-$1 is not specified."; }
    
    die_license_disabled gpl libcdio
    
    die_license_disabled gpl libx264
    
    die_license_disabled gpl libxavs
    
    die_license_disabled gpl libxvid
    die_license_disabled gpl x11grab
    
    
    die_license_disabled nonfree libfaac
    
    die_license_disabled nonfree libfdk_aac
    
    die_license_disabled nonfree openssl
    
    die_license_disabled version3 libopencore_amrnb
    die_license_disabled version3 libopencore_amrwb
    
    die_license_disabled version3 libvo_aacenc
    
    die_license_disabled version3 libvo_amrwbenc
    
    enabled version3 && { enabled gpl && enable gplv3 || enable lgplv3; }
    
    disabled optimizations || check_cflags -fomit-frame-pointer
    
    enable_weak_pic() {
        disabled pic && return
    
        case "$target_os" in
        mingw*|cygwin*)
            ;;
        *)
            add_cflags -fPIC
            ;;
        esac
    
    enabled pic && enable_weak_pic
    
    check_cc <<EOF || die "Symbol mangling check failed."
    int ff_extern;
    EOF
    
    sym=$($nm $TMPO | awk '/ff_extern/{ print substr($0, match($0, /[^ \t]*ff_extern/)) }')
    
    extern_prefix=${sym%%ff_extern*}
    
    
    check_cc <<EOF && enable_weak inline_asm
    
    void foo(void) { __asm__ volatile ("" ::); }
    EOF
    
    _restrict=
    for restrict_keyword in restrict __restrict__ __restrict; do
        check_cc <<EOF && _restrict=$restrict_keyword && break
    void foo(char * $restrict_keyword p);
    EOF
    done
    
    
    check_cc <<EOF && enable pragma_deprecated
    
    void foo(void) { _Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"") }
    
    check_cc <<EOF && enable attribute_packed
    struct { int x; } __attribute__((packed)) x;
    EOF
    
    
    check_cc <<EOF && enable attribute_may_alias
    union { int x; } __attribute__((may_alias)) x;
    EOF
    
    
    check_cc <<EOF || die "endian test failed"
    unsigned int endian = 'B' << 24 | 'I' << 16 | 'G' << 8 | 'E';
    EOF
    
    od -t x1 $TMPO | grep -q '42 *49 *47 *45' && enable bigendian
    
    check_inline_asm inline_asm_labels '"1:\n"'
    
    
    if enabled alpha; then
    
        check_cflags -mieee
    
    elif enabled arm; then
    
        check_cpp_condition stddef.h "defined __thumb__" && enable_weak thumb
    
        enabled thumb && check_cflags -mthumb || check_cflags -marm
    
        if     check_cpp_condition stddef.h "defined __ARM_PCS_VFP"; then
            enable vfp_args
        elif ! check_cpp_condition stddef.h "defined __ARM_PCS || defined __SOFTFP__"; then
            case "${cross_prefix:-$cc}" in
                *hardfloat*)         enable vfp_args;   fpabi=vfp ;;
                *) check_ld <<EOF && enable vfp_args && fpabi=vfp || fpabi=soft ;;
    
    __asm__ (".eabi_attribute 28, 1");
    int main(void) { return 0; }
    EOF
    
            esac
            warn "Compiler does not indicate floating-point ABI, guessing $fpabi."
        fi
    
        enabled armv5te && check_insn armv5te 'qadd r0, r0, r0'
        enabled armv6   && check_insn armv6   'sadd16 r0, r0, r0'
        enabled armv6t2 && check_insn armv6t2 'movt r0, #0'
        enabled neon    && check_insn neon    'vadd.i16 q0, q0, q0'
    
        enabled vfp     && check_insn vfp     'fadds s0, s0, s0'
    
        enabled vfpv3   && check_insn vfpv3   'vmov.f32 s0, #1.0'
    
    
        [ $target_os = linux ] ||
            map 'enabled_any ${v}_external ${v}_inline || disable $v' \
                $ARCH_EXT_LIST_ARM
    
        check_inline_asm asm_mod_q '"add r0, %Q0, %R0" :: "r"((long long)0)'
        check_inline_asm asm_mod_y '"vmul.i32 d0, d0, %y0" :: "x"(0)'
    
        [ $target_os != win32 ] && enabled_all armv6t2 shared !pic && enable_weak_pic
    
    elif enabled mips; then
    
        check_inline_asm loongson '"dmult.g $1, $2, $3"'
    
    elif enabled parisc; then
    
        if enabled gcc; then
            case $($cc -dumpversion) in
                4.[3-8].*) check_cflags -fno-optimize-sibling-calls ;;
            esac
        fi
    
    
    elif enabled ppc; then
    
        enable local_aligned_8 local_aligned_16
    
    
        check_inline_asm dcbzl     '"dcbzl 0, %0" :: "r"(0)'
        check_inline_asm ibm_asm   '"add 0, 0, 0"'
        check_inline_asm ppc4xx    '"maclhw r10, r11, r12"'
        check_inline_asm xform_asm '"lwzx %1, %y0" :: "Z"(*(int*)0), "r"(0)'
    
    
        # AltiVec flags: The FSF version of GCC differs from the Apple version
        if enabled altivec; then
    
            check_cflags -maltivec -mabi=altivec &&
            { check_header altivec.h && inc_altivec_h="#include <altivec.h>" ; } ||
            check_cflags -faltivec
    
            # check if our compiler supports Motorola AltiVec C API
            check_cc <<EOF || disable altivec
    $inc_altivec_h
    int main(void) {
    
        vector signed int v1 = (vector signed int) { 0 };
        vector signed int v2 = (vector signed int) { 1 };
        v1 = vec_add(v1, v2);
    
            enabled altivec || warn "Altivec disabled, possibly missing --cpu flag"
    
    elif enabled sparc; then
    
        enabled vis && check_inline_asm vis '"pdist %f0, %f0, %f0"'
    
    elif enabled x86; then
    
        check_builtin rdtsc    intrin.h   "__rdtsc()"
        check_builtin mm_empty mmintrin.h "_mm_empty()"
    
        enable local_aligned_8 local_aligned_16
    
    
        # check whether EBP is available on x86
        # As 'i' is stored on the stack, this program will crash
        # if the base pointer is used to access it because the
        # base pointer is cleared in the inline assembly code.
    
        check_exec_crash <<EOF && enable ebp_available
    
    volatile int i=0;
    __asm__ volatile ("xorl %%ebp, %%ebp" ::: "%ebp");
    return i;
    
    Reimar Döffinger's avatar
    Reimar Döffinger committed
        # check whether EBX is available on x86
    
        check_inline_asm ebx_available '""::"b"(0)' &&
            check_inline_asm ebx_available '"":::"%ebx"'
    
        # check whether xmm clobbers are supported
    
        check_inline_asm xmm_clobbers '"":::"%xmm0"'
    
        # check whether binutils is new enough to compile SSSE3/MMXEXT
    
        enabled ssse3  && check_inline_asm ssse3_inline  '"pabsw %xmm0, %xmm0"'
        enabled mmxext && check_inline_asm mmxext_inline '"pmaxub %mm0, %mm1"'
    
            if check_cmd $yasmexe --version; then
                enabled x86_64 && yasm_extra="-m amd64"
                yasm_debug="-g dwarf2"
            elif check_cmd nasm -v; then
                yasmexe=nasm
                yasm_debug="-g -F dwarf"
                enabled x86_64 && test "$objformat" = elf && objformat=elf64
            fi
    
            YASMFLAGS="-f $objformat $yasm_extra"
            enabled pic               && append YASMFLAGS "-DPIC"
            test -n "$extern_prefix"  && append YASMFLAGS "-DPREFIX"
            case "$objformat" in
                elf*) enabled debug && append YASMFLAGS $yasm_debug ;;
            esac
    
    
            check_yasm "movbe ecx, [5]" && enable yasm ||
                die "yasm/nasm not found or too old. Use --disable-yasm for a crippled build."
    
            check_yasm "vfmaddps ymm0, ymm1, ymm2, ymm3" || disable fma4_external
    
            check_yasm "CPU amdnop" && enable cpunop
    
        case "$cpu" in
            athlon*|opteron*|k8*|pentium|pentium-mmx|prescott|nocona|atom|geode)
                disable fast_clz
            ;;
        esac
    
    
    if enabled asm; then
        as=${gas:=$as}
    
        check_as <<EOF && enable gnu_as || \
    
            $nogas "GNU assembler not found, install gas-preprocessor"
    
    check_ldflags -Wl,--as-needed
    
    
    if check_func dlopen; then
        ldl=
    elif check_func dlopen -ldl; then
        ldl=-ldl
    
        check_type "sys/types.h sys/socket.h" socklen_t
        check_type netdb.h "struct addrinfo"
    
        check_type netinet/in.h "struct group_source_req" -D_BSD_SOURCE
        check_type netinet/in.h "struct ip_mreq_source" -D_BSD_SOURCE
    
        check_type netinet/in.h "struct ipv6_mreq" -D_DARWIN_C_SOURCE
        check_type netinet/in.h "struct sockaddr_in6"
    
        check_type poll.h "struct pollfd"
    
        check_type "sys/types.h sys/socket.h" "struct sockaddr_storage"
        check_struct "sys/types.h sys/socket.h" "struct sockaddr" sa_len
    
        check_type netinet/sctp.h "struct sctp_event_subscribe"
    
        check_func getaddrinfo $network_extralibs
    
        check_func getservbyport $network_extralibs
    
        # Prefer arpa/inet.h over winsock2
        if check_header arpa/inet.h ; then
            check_func closesocket
        elif check_header winsock2.h ; then
    
            check_func_headers winsock2.h closesocket -lws2 &&
                network_extralibs="-lws2" ||
            { check_func_headers winsock2.h closesocket -lws2_32 &&
    
                network_extralibs="-lws2_32"; }
    
            check_func_headers ws2tcpip.h getaddrinfo $network_extralibs
    
            check_type ws2tcpip.h socklen_t
            check_type ws2tcpip.h "struct addrinfo"
    
            check_type ws2tcpip.h "struct group_source_req"
            check_type ws2tcpip.h "struct ip_mreq_source"
    
            check_type ws2tcpip.h "struct ipv6_mreq"
    
            check_type winsock2.h "struct pollfd"
    
            check_type ws2tcpip.h "struct sockaddr_in6"
            check_type ws2tcpip.h "struct sockaddr_storage"
            check_struct winsock2.h "struct sockaddr" sa_len
        else
            disable network
        fi
    fi
    
    
    # Solaris has nanosleep in -lrt, OpenSolaris no longer needs that
    check_func nanosleep || { check_func nanosleep -lrt && add_extralibs -lrt; }
    
    
    Måns Rullgård's avatar
    Måns Rullgård committed
    check_func  fcntl
    
    check_func_headers stdlib.h getenv
    
    check_struct "sys/time.h sys/resource.h" "struct rusage" ru_maxrss
    
    check_func  gettimeofday
    
    check_func  inet_aton $network_extralibs
    
    check_func  isatty
    
    check_func  ${malloc_prefix}memalign            && enable memalign
    
    check_func  mprotect
    
    check_func  ${malloc_prefix}posix_memalign      && enable posix_memalign
    
    check_func_headers malloc.h _aligned_malloc     && enable aligned_malloc
    
    Måns Rullgård's avatar
    Måns Rullgård committed
    check_func  setrlimit
    
    check_func  strerror_r
    
    check_func  strptime
    
    Stefano Sabatini's avatar
    Stefano Sabatini committed
    check_func  strtok_r
    
    check_func  sched_getaffinity
    
    check_builtin sync_val_compare_and_swap "" "int *ptr; int oldval, newval; __sync_val_compare_and_swap(ptr, oldval, newval)"
    
    check_builtin machine_rw_barrier mbarrier.h "__machine_rw_barrier()"
    
    check_builtin atomic_cas_ptr atomic.h "void **ptr; void *oldval, *newval; atomic_cas_ptr(ptr, oldval, newval)"
    
    check_builtin MemoryBarrier windows.h "MemoryBarrier()"
    
    check_func  usleep
    
    check_func_headers io.h setmode
    
    check_lib2 "windows.h shellapi.h" CommandLineToArgvW -lshell32
    
    check_lib2 "windows.h wincrypt.h" CryptGenRandom -ladvapi32
    
    check_lib2 "windows.h psapi.h" GetProcessMemoryInfo -lpsapi
    
    check_func_headers windows.h GetProcessAffinityMask
    
    check_func_headers windows.h GetProcessTimes
    
    check_func_headers windows.h GetSystemTimeAsFileTime
    
    check_func_headers windows.h MapViewOfFile
    
    check_func_headers windows.h SetConsoleTextAttribute
    
    check_func_headers windows.h Sleep
    
    check_func_headers windows.h VirtualAlloc
    
    check_header dlfcn.h
    
    check_header dxva.h
    
    Laurent Aimar's avatar
    Laurent Aimar committed
    check_header dxva2api.h
    
    check_header io.h
    
    check_header malloc.h
    
    check_header sys/resource.h
    
    check_header sys/time.h
    
    Luca Barbato's avatar
    Luca Barbato committed
    check_header sys/un.h
    
    check_header unistd.h
    
    check_header vdpau/vdpau.h
    check_header vdpau/vdpau_x11.h
    
    check_header VideoDecodeAcceleration/VDADecoder.h
    
    check_header windows.h
    
    check_header X11/extensions/XvMClib.h
    
    disabled  zlib || check_lib   zlib.h      zlibVersion -lz   || disable  zlib
    
    disabled bzlib || check_lib2 bzlib.h BZ2_bzlibVersion -lbz2 || disable bzlib
    
    if ! disabled w32threads && ! enabled pthreads; then
    
        check_func_headers "windows.h process.h" _beginthreadex && enable w32threads
    
    # check for some common methods of building with pthread support
    # do this before the optional library checks as some of them require pthreads
    
    if ! disabled pthreads && ! enabled w32threads; then
        enable pthreads
    
    Måns Rullgård's avatar
    Måns Rullgård committed
        if check_func pthread_create; then
            :
        elif check_func pthread_create -pthread; then
            add_cflags -pthread
    
    Måns Rullgård's avatar
    Måns Rullgård committed
        elif check_func pthread_create -pthreads; then
            add_cflags -pthreads
    
        elif check_func pthread_create -lpthreadGC2; then
            add_extralibs -lpthreadGC2
    
    Måns Rullgård's avatar
    Måns Rullgård committed
        elif ! check_lib pthread.h pthread_create -lpthread; then
    
            test -n "$thread_type" &&
                die "ERROR: Only one thread type must be selected." ||
    
    enabled sync_val_compare_and_swap && enable atomics_gcc
    
    enabled_all atomic_cas_ptr machine_rw_barrier && enable atomics_suncc
    
    enabled MemoryBarrier && enable atomics_win32
    
    
    check_lib math.h sin -lm && LIBM="-lm"
    
    enabled vaapi && require vaapi va/va.h vaInitialize -lva
    
    Måns Rullgård's avatar
    Måns Rullgård committed
    
    
    atan2f_args=2
    ldexpf_args=2
    powf_args=2
    
    
    for func in $MATH_FUNCS; do
    
        eval check_mathfunc $func \${${func}_args:-1}
    
    # these are off by default, so fail if requested and not available
    
    enabled avisynth          && require2 vfw32 "windows.h vfw.h" AVIFileInit -lavifil32
    enabled frei0r            && { check_header frei0r.h || die "ERROR: frei0r.h header not found"; }
    enabled gnutls            && require_pkg_config gnutls gnutls/gnutls.h gnutls_global_init
    enabled libfaac           && require2 libfaac "stdint.h faac.h" faacEncGetVersion -lfaac
    enabled libfdk_aac        && require libfdk_aac fdk-aac/aacenc_lib.h aacEncOpen -lfdk-aac
    enabled libfreetype       && require_pkg_config freetype2 "ft2build.h freetype/freetype.h" FT_Init_FreeType
    enabled libgsm            && { for gsm_hdr in "gsm.h" "gsm/gsm.h"; do
                                       check_lib "${gsm_hdr}" gsm_create -lgsm && break;
                                   done || die "ERROR: libgsm not found"; }
    enabled libilbc           && require libilbc ilbc.h WebRtcIlbcfix_InitDecode -lilbc
    enabled libmp3lame        && require "libmp3lame >= 3.98.3" lame/lame.h lame_set_VBR_quality -lmp3lame
    enabled libopencore_amrnb && require libopencore_amrnb opencore-amrnb/interf_dec.h Decoder_Interface_init -lopencore-amrnb
    enabled libopencore_amrwb && require libopencore_amrwb opencore-amrwb/dec_if.h D_IF_init -lopencore-amrwb
    enabled libopencv         && require_pkg_config opencv opencv/cv.h cvCreateImageHeader
    enabled libopenjpeg       && require libopenjpeg openjpeg.h opj_version -lopenjpeg
    enabled libopus           && require_pkg_config opus opus_multistream.h opus_multistream_decoder_create
    enabled libpulse          && require_pkg_config libpulse-simple pulse/simple.h pa_simple_new
    enabled librtmp           && require_pkg_config librtmp librtmp/rtmp.h RTMP_Socket
    enabled libschroedinger   && require_pkg_config schroedinger-1.0 schroedinger/schro.h schro_init
    enabled libspeex          && require libspeex speex/speex.h speex_decoder_init -lspeex
    enabled libtheora         && require libtheora theora/theoraenc.h th_info_init -ltheoraenc -ltheoradec -logg
    enabled libvo_aacenc      && require libvo_aacenc vo-aacenc/voAAC.h voGetAACEncAPI -lvo-aacenc
    enabled libvo_amrwbenc    && require libvo_amrwbenc vo-amrwbenc/enc_if.h E_IF_init -lvo-amrwbenc
    enabled libvorbis         && require libvorbis vorbis/vorbisenc.h vorbis_info_init -lvorbisenc -lvorbis -logg
    enabled libvpx            && {
    
        enabled libvpx_vp8_decoder && { check_lib2 "vpx/vpx_decoder.h vpx/vp8dx.h" vpx_codec_dec_init_ver -lvpx ||
    
                                        die "ERROR: libvpx decoder version must be >=0.9.1"; }
    
        enabled libvpx_vp8_encoder && { check_lib2 "vpx/vpx_encoder.h vpx/vp8cx.h" "vpx_codec_enc_init_ver VPX_CQ" -lvpx ||
    
                                        die "ERROR: libvpx encoder version must be >=0.9.6"; }
        enabled libvpx_vp9_decoder && { check_lib2 "vpx/vpx_decoder.h vpx/vp8dx.h" "vpx_codec_vp9_dx" -lvpx || disable libvpx_vp9_decoder; }
    
        enabled libvpx_vp9_encoder && { check_lib2 "vpx/vpx_encoder.h vpx/vp8cx.h" "vpx_codec_vp9_cx" -lvpx || disable libvpx_vp9_encoder; } }
    
    enabled libwavpack        && require libwavpack wavpack/wavpack.h WavpackOpenFileOutput  -lwavpack
    enabled libx264           && require libx264 x264.h x264_encoder_encode -lx264 &&
                                 { check_cpp_condition x264.h "X264_BUILD >= 118" ||
                                   die "ERROR: libx264 version must be >= 0.118."; }
    enabled libxavs           && require libxavs xavs.h xavs_encoder_encode -lxavs
    enabled libxvid           && require libxvid xvid.h xvid_global -lxvidcore
    enabled openssl           && { check_lib openssl/ssl.h SSL_library_init -lssl -lcrypto ||
                                   check_lib openssl/ssl.h SSL_library_init -lssl32 -leay32 ||
                                   check_lib openssl/ssl.h SSL_library_init -lssl -lcrypto -lws2_32 -lgdi32 ||
                                   die "ERROR: openssl not found"; }
    
    Samuel Pitoiset's avatar
    Samuel Pitoiset committed
    if enabled gnutls; then
        { check_lib nettle/bignum.h nettle_mpz_get_str_256 -lnettle -lhogweed -lgmp && enable nettle; } ||
        { check_lib gcrypt.h gcry_mpi_new -lgcrypt && enable gcrypt; }
    fi
    
    
    # libdc1394 check
    if enabled libdc1394; then
        { check_lib dc1394/dc1394.h dc1394_new -ldc1394 -lraw1394 &&
            enable libdc1394_2; } ||
        { check_lib libdc1394/dc1394_control.h dc1394_create_handle -ldc1394_control -lraw1394 &&
            enable libdc1394_1; } ||
        die "ERROR: No version of libdc1394 found "
    fi
    
    
    if check_pkg_config sdl SDL_events.h SDL_PollEvent; then
    
        check_cpp_condition SDL.h "(SDL_MAJOR_VERSION<<16 | SDL_MINOR_VERSION<<8 | SDL_PATCHLEVEL) >= 0x010201" $sdl_cflags &&
    
        check_cpp_condition SDL.h "(SDL_MAJOR_VERSION<<16 | SDL_MINOR_VERSION<<8 | SDL_PATCHLEVEL) < 0x010300" $sdl_cflags &&
        enable sdl
    
    texi2html -version > /dev/null 2>&1 && enable texi2html || disable texi2html
    
    check_header linux/fb.h
    
    check_header linux/videodev2.h
    
    check_struct linux/videodev2.h "struct v4l2_frmivalenum" discrete
    
    
    check_header sys/videoio.h
    
    check_func_headers "windows.h vfw.h" capCreateCaptureWindow "$vfwcap_indev_extralibs"
    
    # check that WM_CAP_DRIVER_CONNECT is defined to the proper value
    # w32api 3.12 had it defined wrong
    check_cpp_condition vfw.h "WM_CAP_DRIVER_CONNECT > WM_USER" && enable vfwcap_defines
    
    Ramiro Polla's avatar
    Ramiro Polla committed
    
    
    # check for ioctl_meteor.h, ioctl_bt848.h and alternatives
    
    Ramiro Polla's avatar
    Ramiro Polla committed
    { check_header dev/bktr/ioctl_meteor.h &&
      check_header dev/bktr/ioctl_bt848.h; } ||
    { check_header machine/ioctl_meteor.h &&
      check_header machine/ioctl_bt848.h; } ||
    { check_header dev/video/meteor/ioctl_meteor.h &&
      check_header dev/video/bktr/ioctl_bt848.h; } ||
    check_header dev/ic/bt8xx.h
    
    check_header sndio.h
    
    check_header sys/soundcard.h
    check_header soundcard.h
    
    enabled_any alsa_indev alsa_outdev &&
        check_lib2 alsa/asoundlib.h snd_pcm_htimestamp -lasound
    
    enabled jack_indev && check_lib2 jack/jack.h jack_client_open -ljack &&
        check_func jack_port_get_latency_range -ljack
    
    enabled_any sndio_indev sndio_outdev && check_lib2 sndio.h sio_open -lsndio
    
    
    if enabled libcdio; then
    
        check_lib2 "cdio/cdda.h cdio/paranoia.h" cdio_cddap_open -lcdio_paranoia -lcdio_cdda -lcdio ||
        check_lib2 "cdio/paranoia/cdda.h cdio/paranoia/paranoia.h" cdio_cddap_open -lcdio_paranoia -lcdio_cdda -lcdio
    
    enabled x11grab                                           &&
    require X11 X11/Xlib.h XOpenDisplay -lX11                 &&
    require Xext X11/extensions/XShm.h XShmCreateImage -lXext &&
    require Xfixes X11/extensions/Xfixes.h XFixesGetCursorImage -lXfixes
    
    enabled vdpau &&
    
        check_cpp_condition vdpau/vdpau.h "defined VDP_DECODER_PROFILE_MPEG4_PART2_ASP" ||
    
        disable vdpau
    
    enabled debug && add_cflags -g"$debuglevel" && add_asflags -g"$debuglevel"
    
    
    # add some useful compiler flags if supported
    check_cflags -Wdeclaration-after-statement
    
    check_cflags -Wall
    
    Michael Niedermayer's avatar
    Michael Niedermayer committed
    check_cflags -Wdisabled-optimization
    check_cflags -Wpointer-arith
    check_cflags -Wredundant-decls
    
    check_cflags -Wcast-qual
    
    check_cflags -Wwrite-strings
    
    check_cflags -Wmissing-prototypes
    
    check_cflags -Wstrict-prototypes
    
    enabled extra_warnings && check_cflags -Winline
    
    check_disable_warning(){
        warning_flag=-W${1#-Wno-}
        test_cflags $warning_flag && add_cflags $1
    }
    
    check_disable_warning -Wno-parentheses
    check_disable_warning -Wno-switch
    check_disable_warning -Wno-format-zero-length
    check_disable_warning -Wno-pointer-sign
    
    
    check_ldflags -Wl,--warn-common
    
    check_ldflags -Wl,-rpath-link=libswscale:libavfilter:libavdevice:libavformat:libavcodec:libavutil:libavresample
    
    test_ldflags -Wl,-Bsymbolic && append SHFLAGS -Wl,-Bsymbolic
    
    enabled xmm_clobber_test &&
    
        check_ldflags -Wl,--wrap,avcodec_open2              \
                      -Wl,--wrap,avcodec_decode_audio4      \
                      -Wl,--wrap,avcodec_decode_video2      \
                      -Wl,--wrap,avcodec_decode_subtitle2   \
                      -Wl,--wrap,avcodec_encode_audio2      \
    
                      -Wl,--wrap,avcodec_encode_video2      \
    
                      -Wl,--wrap,avcodec_encode_subtitle    \
    
    echo "X{};" > $TMPV
    
    if test_ldflags -Wl,--version-script,$TMPV; then
    
        append SHFLAGS '-Wl,--version-script,\$(SUBDIR)lib\$(NAME).ver'
    
        check_cc <<EOF && enable symver_asm_label
    void ff_foo(void) __asm__ ("av_foo@VERSION");
    
    void ff_foo(void) { ${inline_asm+__asm__($quotes);} }
    
    EOF
        check_cc <<EOF && enable symver_gnu_asm
    __asm__(".symver ff_foo,av_foo@VERSION");
    void ff_foo(void) {}
    EOF
    fi
    
    if [ -z "$optflags" ]; then
        if enabled small; then
            optflags=$cflags_size
        elif enabled optimizations; then
            optflags=$cflags_speed
        else
            optflags=$cflags_noopt
        fi
    
    
    check_optflags(){
        check_cflags "$@"
        enabled lto && check_ldflags "$@"
    }
    
    
    if enabled lto; then
        test "$cc_type" != "$ld_type" && die "LTO requires same compiler and linker"
        check_cflags  -flto
        check_ldflags -flto $cpuflags
    fi
    
    check_optflags $optflags
    check_optflags -fno-math-errno
    check_optflags -fno-signed-zeros
    
    Måns Rullgård's avatar
    Måns Rullgård committed
        # Just warnings, no remarks