Skip to content
Snippets Groups Projects
configure 192 KiB
Newer Older
  • Learn to ignore specific revisions
  • Måns Rullgård's avatar
    Måns Rullgård committed
                cpuflags="-mcpu=603"
    
    Måns Rullgård's avatar
    Måns Rullgård committed
            ;;
    
            604*|ppc604*|powerpc604*)
    
    Måns Rullgård's avatar
    Måns Rullgård committed
                cpuflags="-mcpu=604"
    
    Måns Rullgård's avatar
    Måns Rullgård committed
            ;;
    
            g3|75*|ppc75*|powerpc75*)
    
                cpuflags="-mcpu=750"
    
    Måns Rullgård's avatar
    Måns Rullgård committed
            ;;
    
            g4|745*|ppc745*|powerpc745*)
    
                cpuflags="-mcpu=7450"
    
    Måns Rullgård's avatar
    Måns Rullgård committed
            ;;
    
            74*|ppc74*|powerpc74*)
    
                cpuflags="-mcpu=7400"
    
    Måns Rullgård's avatar
    Måns Rullgård committed
            ;;
    
            g5|970|ppc970|powerpc970)
    
                cpuflags="-mcpu=970"
    
    Måns Rullgård's avatar
    Måns Rullgård committed
            ;;
    
    Måns Rullgård's avatar
    Måns Rullgård committed
                cpuflags="-mcpu=$cpu"
    
                disable vsx
            ;;
            power[7-8]*)
                cpuflags="-mcpu=$cpu"
    
    Måns Rullgård's avatar
    Måns Rullgård committed
            ;;
    
    Måns Rullgård's avatar
    Måns Rullgård committed
                cpuflags="-mcpu=cell"
                enable ldbrx
    
    Måns Rullgård's avatar
    Måns Rullgård committed
            ;;
    
            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
    
            cypress|f93[04]|tsc701|sparcl*|supersparc|hypersparc|niagara|v[789])
                cpuflags="-mcpu=$cpu"
    
            ultrasparc*|niagara[234])
    
    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"
    
    Måns Rullgård's avatar
    Måns Rullgård committed
                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\
            |core*|atom|bonnell|nehalem|westmere|silvermont|sandybridge|ivybridge|haswell|broadwell|amdfam10|barcelona|b[dt]ver*)
    
    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
    
    
    Mohamed Naufal's avatar
    Mohamed Naufal committed
    add_cxxflags -D__STDC_CONSTANT_MACROS
    
    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'
    
        s390)
            check_64bit s390 s390x 'sizeof(void *) > 4'
            spic=$shared
        ;;
    
        sparc)
            check_64bit sparc sparc64 'sizeof(void *) > 4'
            spic=$shared
        ;;
    
            check_64bit x86_32 x86_64 'sizeof(void *) > 4'
    
            # Treat x32 as x64 for now. Note it also needs spic=$shared
            test "$subarch" = "x86_32" && check_cpp_condition stddef.h 'defined(__x86_64__)' &&
                subarch=x86_64
    
            if test "$subarch" = "x86_64"; then
    
                spic=$shared
    
        ppc)
            check_cc <<EOF && subarch="ppc64"
            int test[(int)sizeof(char*) - 7];
    EOF
        ;;
    
    enable $subarch
    
    enabled spic && enable_weak pic
    
            SHFLAGS=-shared
    
            add_cppflags '-I\$(SRC_PATH)/compat/aix'
    
            enabled shared && add_ldflags -Wl,-brtl
    
            enable section_data_rel_ro
    
            SLIB_INSTALL_NAME='$(SLIBNAME)'
            SLIB_INSTALL_LINKS=
            # soname not set on purpose
            SHFLAGS=-shared
            ;;
    
    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__
    
            # 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"
    
            enabled gcc || check_ldflags -Wl,-zmuldefs
    
    David Hill's avatar
    David Hill 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
    
            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 x86_64 ||
    
                { check_cflags -mdynamic-no-pic && add_asflags -mdynamic-no-pic; }
    
            if test $target_os = "mingw32ce"; then
    
            LIBTARGET=i386
    
            enabled shared && ! enabled small && check_cmd $windres --version && enable gnu_windres
    
            check_ldflags -Wl,--nxcompat
            check_ldflags -Wl,--dynamicbase
    
            enabled x86_32 && check_ldflags -Wl,--large-address-aware
    
            SLIBPREF=""
            SLIBSUF=".dll"
            SLIBNAME_WITH_VERSION='$(SLIBPREF)$(FULLNAME)-$(LIBVERSION)$(SLIBSUF)'
            SLIBNAME_WITH_MAJOR='$(SLIBPREF)$(FULLNAME)-$(LIBMAJOR)$(SLIBSUF)'
    
            if check_cmd lib.exe -list; then
    
                SLIB_EXTRA_CMD=-'sed -e "s/ @[^ ]*//" $$(@:$(SLIBSUF)=.orig.def) > $$(@:$(SLIBSUF)=.def); lib.exe /machine:$(LIBTARGET) /def:$$(@:$(SLIBSUF)=.def) /out:$(SUBDIR)$(SLIBNAME:$(SLIBSUF)=.lib)'
    
                if enabled x86_64; then
                    LIBTARGET=x64
                fi
            elif check_cmd $dlltool --version; then
    
                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"
    
            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.
    
            enabled x86_32 && check_ldflags -LARGEADDRESSAWARE
    
            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='$(SRC_PATH)/compat/windows/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"
    
            enabled shared && ! enabled small && check_cmd $windres --version && enable gnu_windres
    
    Michael Kostylev's avatar
    Michael Kostylev committed
        *-dos|freedos|opendos)
            network_extralibs="-lsocket"
    
            objformat="coff"
    
            add_cppflags -U__STRICT_ANSI__
    
            enable section_data_rel_ro
    
            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 CODE PRELOAD MOVEABLE DISCARDABLE >> $(SUBDIR)$(NAME).def; \
                echo DATA PRELOAD MOVEABLE MULTIPLE NONSHARED >> $(SUBDIR)$(NAME).def; \
                echo EXPORTS >> $(SUBDIR)$(NAME).def; \
    
    Dave Yeo's avatar
    Dave Yeo committed
                emxexp $(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'
    
            enable_weak os2threads
    
            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
    
    Mans Rullgard's avatar
    Mans Rullgard committed
            cp_f='cp'
            ;;
    
            die "Unknown OS '$target_os'."
    
    # determine libc flavour
    
    
        # uclibc defines __GLIBC__, so it needs to be checked before glibc.
        if check_${pfx}cpp_condition features.h "defined __UCLIBC__"; then
            eval ${pfx}libc_type=uclibc
            add_${pfx}cppflags -D_POSIX_C_SOURCE=200112 -D_XOPEN_SOURCE=600
        elif check_${pfx}cpp_condition features.h "defined __GLIBC__"; then
            eval ${pfx}libc_type=glibc
            add_${pfx}cppflags -D_POSIX_C_SOURCE=200112 -D_XOPEN_SOURCE=600
        # MinGW headers can be installed on Cygwin, so check for newlib first.
        elif check_${pfx}cpp_condition newlib.h "defined _NEWLIB_VERSION"; then
            eval ${pfx}libc_type=newlib
            add_${pfx}cppflags -U__STRICT_ANSI__
        # MinGW64 is backwards compatible with MinGW32, so check for it first.
        elif check_${pfx}cpp_condition _mingw.h "defined __MINGW64_VERSION_MAJOR"; then
            eval ${pfx}libc_type=mingw64
    
            if check_${pfx}cpp_condition _mingw.h "__MINGW64_VERSION_MAJOR < 3"; then
                add_compat msvcrt/snprintf.o
                add_cflags "-include $source_path/compat/msvcrt/snprintf.h"
            fi
    
            add_${pfx}cppflags -U__STRICT_ANSI__ -D__USE_MINGW_ANSI_STDIO=1
    
            eval test \$${pfx_no_}cc_type = "gcc" &&
                add_${pfx}cppflags -D__printf__=__gnu_printf__
    
        elif check_${pfx}cpp_condition _mingw.h "defined __MINGW_VERSION"  ||
             check_${pfx}cpp_condition _mingw.h "defined __MINGW32_VERSION"; then
    
            eval ${pfx}libc_type=mingw32
            check_${pfx}cpp_condition _mingw.h "__MINGW32_MAJOR_VERSION > 3 || \
                (__MINGW32_MAJOR_VERSION == 3 && __MINGW32_MINOR_VERSION >= 15)" ||
                die "ERROR: MinGW32 runtime version must be >= 3.15."
    
            add_${pfx}cppflags -U__STRICT_ANSI__ -D__USE_MINGW_ANSI_STDIO=1
    
            eval test \$${pfx_no_}cc_type = "gcc" &&
                add_${pfx}cppflags -D__printf__=__gnu_printf__
    
        elif check_${pfx}cpp_condition crtversion.h "defined _VC_CRT_MAJOR_VERSION"; then
            eval ${pfx}libc_type=msvcrt
    
            if check_${pfx}cpp_condition crtversion.h "_VC_CRT_MAJOR_VERSION < 14"; then
                if [ "$pfx" = host_ ]; then
                    add_host_cppflags -Dsnprintf=_snprintf
                else
                    add_compat strtod.o strtod=avpriv_strtod
                    add_compat msvcrt/snprintf.o snprintf=avpriv_snprintf   \
                                                 _snprintf=avpriv_snprintf  \
                                                 vsnprintf=avpriv_vsnprintf
                fi
            fi
    
            # 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_${pfx}cpp_condition stdlib.h "defined(_WIN32_WINNT)" ||
                add_${pfx}cppflags -D_WIN32_WINNT=0x0502
        elif check_${pfx}cpp_condition stddef.h "defined __KLIBC__"; then
            eval ${pfx}libc_type=klibc
        elif check_${pfx}cpp_condition sys/cdefs.h "defined __BIONIC__"; then
            eval ${pfx}libc_type=bionic
    
        elif check_${pfx}cpp_condition sys/brand.h "defined LABELED_BRAND_NAME"; then
    
            eval ${pfx}libc_type=solaris
            add_${pfx}cppflags -D__EXTENSIONS__ -D_XOPEN_SOURCE=600
    
        check_${pfx}cc <<EOF
    #include <time.h>
    void *v = localtime_r;
    EOF
    test "$?" != 0 && check_${pfx}cc -D_POSIX_C_SOURCE=200112 -D_XOPEN_SOURCE=600 <<EOF && add_${pfx}cppflags -D_POSIX_C_SOURCE=200112 -D_XOPEN_SOURCE=600
    #include <time.h>
    void *v = localtime_r;
    EOF
    
    
    test -n "$libc_type" && enable libc_$libc_type
    
    probe_libc host_
    test -n "$host_libc_type" && enable host_libc_$host_libc_type
    
    case $libc_type in
        bionic)
            add_compat strtod.o strtod=avpriv_strtod
            ;;
    esac
    
    
    # hacks for compiler/libc/os combinations
    
    
    if enabled_all tms470 libc_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 libc_glibc; then
    
        add_ldflags -Wl,-z,now  # calls to libots crash without this
    fi
    
    
    check_compile_assert flt_lim "float.h limits.h" "DBL_MAX == (double)DBL_MAX" ||
        add_cppflags '-I\$(SRC_PATH)/compat/float'
    
    
    esc(){
        echo "$*" | sed 's/%/%25/g;s/:/%3a/g'
    }
    
    
    echo "config:$arch:$subarch:$cpu:$target_os:$(esc $cc_ident):$(esc $FFMPEG_CONFIGURATION)" >config.fate
    
    check_cpp_condition stdlib.h "defined(__PIC__) || defined(__pic__) || defined(PIC)" && enable_weak pic
    
    set_default libdir
    : ${shlibdir_default:="$libdir"}
    
    : ${pkgconfigdir_default:="$libdir/pkgconfig"}
    
    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() {
        enabled $1 || { enabled $2 && die "$2 is incompatible with the gpl and --enable-$1 is not specified."; }
    }
    
    
    die_license_disabled gpl frei0r
    
    die_license_disabled gpl libcdio
    
    die_license_disabled gpl libsmbclient
    
    die_license_disabled gpl libutvideo
    
    die_license_disabled gpl libvidstab
    
    die_license_disabled gpl libx264
    
    Derek Buitenhuis's avatar
    Derek Buitenhuis committed
    die_license_disabled gpl libx265
    
    die_license_disabled gpl libxavs
    
    die_license_disabled gpl libxvid
    
    die_license_disabled gpl libzvbi
    
    tipok's avatar
    tipok committed
    die_license_disabled nonfree libaacplus
    
    die_license_disabled nonfree libfaac
    
    die_license_disabled nonfree nvenc
    
    enabled gpl && die_license_disabled_gpl nonfree libfdk_aac
    
    enabled gpl && die_license_disabled_gpl nonfree openssl
    
    die_license_disabled version3 libopencore_amrnb
    die_license_disabled version3 libopencore_amrwb
    
    die_license_disabled version3 libsmbclient
    
    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
    
    if ! enabled ppc64 || enabled bigendian; then
        disable vsx
    fi
    
    check_gas() {
        log "check_gas using '$as' as AS"
        # :vararg is used on aarch64, arm and ppc altivec
        check_as <<EOF || return 1
    .macro m n, y:vararg=0
    \n: .int \y
    
        # .altmacro is only used in arm asm
        ! enabled arm || check_as <<EOF || return 1
    
    if enabled_any arm aarch64 || enabled_all ppc altivec && enabled asm; then
    
        enabled_any arm aarch64 && nogas=die
    
        enabled_all ppc altivec && [ $target_os_default != aix ] && nogas=warn
    
        as_noop=-v
    
        case $as_type in
            arm*) gaspp_as_type=armasm; as_noop=-h ;;
            gcc)  gaspp_as_type=gas ;;
            *)    gaspp_as_type=$as_type ;;
        esac
    
        [ $target_os = "darwin" ] && gaspp_as_type="apple-$gaspp_as_type"
    
    
        test "${as#*gas-preprocessor.pl}" != "$as" ||
        check_cmd gas-preprocessor.pl -arch $arch -as-type $gaspp_as_type -- ${as:=$cc} $as_noop &&
            gas="${gas:=gas-preprocessor.pl} -arch $arch -as-type $gaspp_as_type -- ${as:=$cc}"
    
    
        if ! check_gas ; then
            as=${gas:=$as}
            check_gas || \
    
                $nogas "GNU assembler not found, install/update gas-preprocessor"
    
    
        check_as <<EOF && enable as_func
    .func test
    .endfunc
    
    check_inline_asm inline_asm_labels '"1:\n"'
    
    
    check_inline_asm inline_asm_nonlocal_labels '"Label:\n"'
    
    
    if enabled aarch64; then
    
        enabled armv8 && check_insn armv8 'prfm   pldl1strm, [x0]'
    
        # internal assembler in clang 3.3 does not support this instruction
        enabled neon && check_insn neon 'ext   v0.8B, v0.8B, v1.8B, #1'
        enabled vfp  && check_insn vfp  'fmadd d0,    d0,    d1,    d2'
    
        map 'enabled_any ${v}_external ${v}_inline || disable $v' $ARCH_EXT_LIST_ARM
    
    elif enabled alpha; then
    
    
        check_cflags -mieee
    
    elif enabled arm; then
    
        check_cpp_condition stddef.h "defined __thumb__" && check_cc <<EOF && enable_weak thumb
    float func(float a, float b){ return a+b; }
    EOF
    
    
        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 ;;
    
    Mohamed Naufal's avatar
    Mohamed Naufal committed
                *) check_ld "cc" <<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'
    
        enabled setend  && check_insn setend  'setend be'
    
        [ $target_os = linux ] || [ $target_os = android ] ||
    
            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_as <<EOF && enable as_dn_directive
    ra .dn d0.i16
    .unreq ra
    
    EOF
    
        # llvm's integrated assembler supports .object_arch from llvm 3.5
        [ "$objformat" = elf ] && check_as <<EOF && enable as_object_arch
    .object_arch armv4
    
        [ $target_os != win32 ] && enabled_all armv6t2 shared !pic && enable_weak_pic
    
    elif enabled mips; then
    
        # Enable minimum ISA based on selected options
        if enabled mips64 && (enabled mipsdspr1 || enabled mipsdspr2); then
            add_cflags "-mips64r2"
            add_asflags "-mips64r2"
    
        elif enabled mips64 && enabled mipsfpu && disabled loongson3; then
    
            add_cflags "-mips64"
            add_asflags "-mips64"
    
        elif enabled mipsdspr1 || enabled mipsdspr2; then
            add_cflags "-mips32r2 -mfp32"
            add_asflags "-mips32r2 -mfp32"
    
        elif enabled mips32r5 || enabled mips64r6; then
    
            check_cflags "-mfp64"
            check_ldflags "-mfp64"
    
        enabled mips32r5  && check_cflags "-mips32r5 -msched-weight -mload-store-pairs -funroll-loops" &&
         check_ldflags "-mips32r5" &&
         check_inline_asm mips32r5  '"ulw $t0, ($t1)"'
    
        enabled mips64r6  && check_cflags "-mips64r6 -msched-weight -mload-store-pairs -funroll-loops" &&
         check_ldflags "-mips64r6" &&
         check_inline_asm mips64r6  '"aui $t0, $t1, 1"'
    
        enabled mipsdspr1 && add_cflags "-mdsp" && add_asflags "-mdsp" &&
    
         check_inline_asm mipsdspr1 '"addu.qb $t0, $t1, $t2"'
    
        enabled mipsdspr2 && add_cflags "-mdspr2" && add_asflags "-mdspr2" &&
    
         check_inline_asm mipsdspr2 '"absq_s.qb $t0, $t1"'
    
        enabled mipsfpu   && add_cflags "-mhard-float" && add_asflags "-mhard-float" &&
    
         check_inline_asm mipsfpu   '"madd.d $f0, $f2, $f4, $f6"'
    
        enabled msa       && check_cflags "-mmsa" && check_ldflags "-mmsa" &&
         check_inline_asm msa       '"addvi.b $w0, $w1, 1"'
    
        enabled loongson3 && check_inline_asm loongson3 '"gsldxc1 $f0, 0($2, $3)"'
    
    
        enabled mips32r5 && add_asflags "-mips32r5 -mfp64"
    
        enabled mips64r6 && add_asflags "-mips64r6 -mfp64"
    
        enabled msa && add_asflags "-mmsa"
    
    elif enabled parisc; then
    
        if enabled gcc; then
            case $($cc -dumpversion) in
    
                4.[3-9].*) check_cflags -fno-optimize-sibling-calls ;;
    
    elif enabled ppc; then
    
    James Almer's avatar
    James Almer committed
        enable local_aligned_8 local_aligned_16 local_aligned_32
    
        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"
    
            check_cflags -mvsx &&
            check_builtin vec_vsx_ld "altivec.h" "__builtin_vec_vsx_ld" || disable vsx
    
    
        if enabled power8; then
            check_cpp_condition "altivec.h" "defined(_ARCH_PWR8)" || disable power8
        fi
    
    
    elif enabled x86; then
    
        check_builtin rdtsc    intrin.h   "__rdtsc()"
        check_builtin mm_empty mmintrin.h "_mm_empty()"
    
    James Almer's avatar
    James Almer committed
        enable local_aligned_8 local_aligned_16 local_aligned_32
    
        # 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_inline_asm inline_asm_direct_symbol_refs '"movl '$extern_prefix'test, %eax"' ||
            check_inline_asm inline_asm_direct_symbol_refs '"movl '$extern_prefix'test(%rip), %eax"'
    
        # 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"
    
                if enabled x86_64; then
                    case "$objformat" in
                        elf)   objformat=elf64 ;;
                        win32) objformat=win64 ;;
                    esac
                fi
    
            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 "vextracti128 xmm0, ymm0, 0"      || disable avx2_external
    
            check_yasm "vpmacsdd xmm0, xmm1, xmm2, xmm3" || disable xop_external
    
            check_yasm "vfmaddps ymm0, ymm1, ymm2, ymm3" || disable fma4_external
    
            check_yasm "CPU amdnop" || disable cpunop
    
        case "$cpu" in
            athlon*|opteron*|k8*|pentium|pentium-mmx|prescott|nocona|atom|geode)
                disable fast_clz
            ;;
        esac
    
    
    check_code cc arm_neon.h "int16x8_t test = vdupq_n_s16(0)" && enable intrinsics_neon
    
    check_ldflags -Wl,--as-needed
    
    check_ldflags -Wl,-z,noexecstack
    
    if check_func dlopen; then
        ldl=
    elif check_func dlopen -ldl; then
        ldl=-ldl
    
    frei0r_filter_extralibs='$ldl'
    frei0r_src_filter_extralibs='$ldl'
    ladspa_filter_extralibs='$ldl'
    
    nvenc_encoder_extralibs='$ldl'
    
        check_func getaddrinfo $network_extralibs
        check_func getservbyport $network_extralibs
        check_func inet_aton $network_extralibs
    
    
        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 poll.h "struct pollfd"
    
        check_type netinet/sctp.h "struct sctp_event_subscribe"
    
        check_struct "sys/types.h sys/socket.h" "struct sockaddr" sa_len
        check_type netinet/in.h "struct sockaddr_in6"
        check_type "sys/types.h sys/socket.h" "struct sockaddr_storage"
        check_type "sys/types.h sys/socket.h" socklen_t
    
    
        # 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"; } || disable winsock2_h network
    
            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_struct winsock2.h "struct sockaddr" sa_len
    
            check_type ws2tcpip.h "struct sockaddr_in6"
            check_type ws2tcpip.h "struct sockaddr_storage"
        else
            disable network
        fi
    fi
    
    
    check_builtin atomic_cas_ptr atomic.h "void **ptr; void *oldval, *newval; atomic_cas_ptr(ptr, oldval, newval)"
    
    check_builtin atomic_compare_exchange "" "int *ptr, *oldval; int newval; __atomic_compare_exchange_n(ptr, oldval, newval, 0, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST)"
    
    check_builtin machine_rw_barrier mbarrier.h "__machine_rw_barrier()"
    check_builtin MemoryBarrier windows.h "MemoryBarrier()"
    
    check_builtin sarestart signal.h "SA_RESTART"
    
    check_builtin sync_val_compare_and_swap "" "int *ptr; int oldval, newval; __sync_val_compare_and_swap(ptr, oldval, newval)"
    
    check_builtin gmtime_r time.h "time_t *time; struct tm *tm; gmtime_r(time, tm)"
    check_builtin localtime_r time.h "time_t *time; struct tm *tm; localtime_r(time, tm)"
    
    
    check_func_headers malloc.h _aligned_malloc     && enable aligned_malloc
    check_func  ${malloc_prefix}memalign            && enable memalign
    check_func  ${malloc_prefix}posix_memalign      && enable posix_memalign
    
    check_func  access
    
    check_func_headers time.h clock_gettime || { check_func_headers time.h clock_gettime -lrt && add_extralibs -lrt && LIBRT="-lrt"; }
    
    Måns Rullgård's avatar
    Måns Rullgård committed
    check_func  fcntl
    
    check_func  gettimeofday
    
    check_func  isatty
    
    check_func  mach_absolute_time
    
    check_func  mprotect
    
    # Solaris has nanosleep in -lrt, OpenSolaris no longer needs that
    
    check_func_headers time.h nanosleep || { check_func_headers time.h nanosleep -lrt && add_extralibs -lrt && LIBRT="-lrt"; }
    
    check_func  sched_getaffinity
    
    Måns Rullgård's avatar
    Måns Rullgård committed
    check_func  setrlimit
    
    check_struct "sys/stat.h" "struct stat" st_mtim.tv_nsec -D_BSD_SOURCE
    
    check_func  strerror_r
    
    check_func  usleep
    
    check_func_headers conio.h kbhit
    
    check_func_headers io.h setmode
    
    check_func_headers lzo/lzo1x.h lzo1x_999_compress
    
    check_func_headers stdlib.h getenv
    
    
    check_func_headers windows.h CoTaskMemFree -lole32
    
    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 PeekNamedPipe
    
    check_func_headers windows.h SetConsoleTextAttribute
    
    check_func_headers windows.h SetConsoleCtrlHandler
    
    check_func_headers windows.h Sleep
    
    check_func_headers windows.h VirtualAlloc
    
    check_struct windows.h "CONDITION_VARIABLE" Ptr
    
    check_func_headers glob.h glob
    
    enabled xlib &&
        check_func_headers "X11/Xlib.h X11/extensions/Xvlib.h" XvGetPortAttribute -lXv -lX11 -lXext