Skip to content
Snippets Groups Projects
configure 71.2 KiB
Newer Older
  • Learn to ignore specific revisions
  • shorten_decoder_select="golomb"
    sonic_decoder_select="golomb"
    sonic_encoder_select="golomb"
    sonic_ls_encoder_select="golomb"
    svq3_decoder_select="golomb"
    
    svq3_decoder_suggest="zlib"
    
    tiff_decoder_suggest="zlib"
    tiff_encoder_suggest="zlib"
    tscc_decoder_select="zlib"
    
    vorbis_decoder_select="fft mdct"
    vorbis_encoder_select="fft mdct"
    wmav1_decoder_select="fft mdct"
    wmav1_encoder_select="fft mdct"
    wmav2_decoder_select="fft mdct"
    wmav2_encoder_select="fft mdct"
    
    wmv1_encoder_select="aandct"
    wmv2_encoder_select="aandct"
    
    zlib_decoder_select="zlib"
    zlib_encoder_select="zlib"
    zmbv_decoder_select="zlib"
    zmbv_encoder_select="zlib"
    
    # external libraries
    
    libamr_nb_decoder_deps="libamr_nb"
    libamr_nb_encoder_deps="libamr_nb"
    libamr_wb_decoder_deps="libamr_wb"
    libamr_wb_encoder_deps="libamr_wb"
    
    libdirac_decoder_deps="libdirac !libschroedinger"
    
    libdirac_encoder_deps="libdirac"
    
    libfaadbin_decoder_extralibs='$ldl'
    
    libgsm_decoder_deps="libgsm"
    libgsm_encoder_deps="libgsm"
    
    libgsm_ms_decoder_deps="libgsm"
    libgsm_ms_encoder_deps="libgsm"
    
    libschroedinger_decoder_deps="libschroedinger"
    libschroedinger_encoder_deps="libschroedinger"
    
    libspeex_decoder_deps="libspeex"
    
    libtheora_encoder_deps="libtheora"
    
    libvorbis_encoder_deps="libvorbis"
    
    libx264_encoder_deps="libx264"
    libxvid_encoder_deps="libxvid"
    
    Diego Biurrun's avatar
    Diego Biurrun committed
    mpeg4aac_decoder_deps="libfaad"
    
    vdpau_deps="vdpau_vdpau_h vdpau_vdpau_x11_h"
    
    # demuxers / muxers
    
    ac3_demuxer_deps="ac3_parser"
    
    audio_beos_demuxer_deps="audio_beos"
    
    audio_beos_demuxer_extralibs="-lmedia -lbe"
    
    audio_beos_muxer_deps="audio_beos"
    
    audio_beos_muxer_extralibs="-lmedia -lbe"
    
    avisynth_demuxer_deps="avisynth"
    
    bktr_demuxer_deps_any="dev_bktr_ioctl_bt848_h machine_ioctl_bt848_h dev_video_bktr_ioctl_bt848_h dev_ic_bt8xx_h"
    
    dirac_demuxer_deps="dirac_parser"
    
    dv1394_demuxer_deps="dv1394 dv_demuxer"
    
    Ramiro Polla's avatar
    Ramiro Polla committed
    libdc1394_demuxer_deps="libdc1394"
    
    libnut_demuxer_deps="libnut"
    libnut_muxer_deps="libnut"
    
    matroska_demuxer_suggest="zlib bzlib"
    mov_demuxer_suggest="zlib"
    
    mp3_demuxer_deps="mpegaudio_parser"
    
    oss_demuxer_deps_any="soundcard_h sys_soundcard_h"
    oss_muxer_deps_any="soundcard_h sys_soundcard_h"
    
    redir_demuxer_deps="network"
    
    rtsp_demuxer_deps="sdp_demuxer"
    sdp_demuxer_deps="rtp_protocol mpegts_demuxer"
    
    v4l_demuxer_deps="linux_videodev_h"
    
    v4l2_demuxer_deps_any="linux_videodev2_h sys_videoio_h"
    
    Ramiro Polla's avatar
    Ramiro Polla committed
    vfwcap_demuxer_deps="capCreateCaptureWindow"
    vfwcap_demuxer_extralibs="-lvfw32"
    
    x11_grab_device_demuxer_deps="x11grab XShmCreateImage"
    
    x11_grab_device_demuxer_extralibs="-lX11 -lXext"
    
    # protocols
    
    http_protocol_deps="network"
    rtp_protocol_deps="udp_protocol"
    tcp_protocol_deps="network"
    udp_protocol_deps="network"
    
    
    movie_filter_deps="avfilter_lavf"
    
    # programs
    
    ffplay_deps="sdl"
    
    ffserver_deps="ffm_muxer rtp_protocol rtsp_demuxer"
    
    ffserver_extralibs='$ldl'
    vhook_extralibs='$ldl'
    
    Fabrice Bellard's avatar
    Fabrice Bellard committed
    # default parameters
    
    
    # installation paths
    
    prefix_default="/usr/local"
    bindir_default='${prefix}/bin'
    incdir_default='${prefix}/include'
    libdir_default='${prefix}/lib'
    mandir_default='${prefix}/share/man'
    shlibdir_default="$libdir_default"
    
    host_cc_default="gcc"
    
    ln_s="ln -sf"
    
    objformat="elf"
    
    Michael Niedermayer's avatar
    Michael Niedermayer committed
    ranlib="ranlib"
    
    yasmexe="yasm"
    
    target_os=$(tolower $(uname -s))
    
    
    # configurable options
    
    enable debug
    enable ffmpeg
    enable ffplay
    enable ffserver
    enable ipv6
    enable mpegaudio_hp
    enable network
    
    enable static
    
    vhook="default"
    
    # build settings
    
    add_cflags -D_ISOC99_SOURCE -D_POSIX_C_SOURCE=200112
    
    SHFLAGS='-shared -Wl,-soname,$$(@F)'
    
    FULLNAME='$(NAME)$(BUILDSUF)'
    LIBNAME='$(LIBPREF)$(FULLNAME)$(LIBSUF)'
    
    SLIBNAME='$(SLIBPREF)$(FULLNAME)$(SLIBSUF)'
    
    SLIBNAME_WITH_VERSION='$(SLIBNAME).$(LIBVERSION)'
    SLIBNAME_WITH_MAJOR='$(SLIBNAME).$(LIBMAJOR)'
    
    LIB_INSTALL_EXTRA_CMD='$(RANLIB) "$(LIBDIR)/$(LIBNAME)"'
    
    host_cflags='-O3 -g -Wall'
    host_libs='-lm'
    
    
    # gcc stupidly only outputs the basename of targets with -MM, but we need the
    # full relative path for objects in subdirectories for non-recursive Make.
    
    DEPEND_CMD='$(CC) $(CFLAGS) -MM -MG $< | sed -e "/^\#.*/d" -e "s,^[[:space:]]*$(*F)\\.o,$(@D)/$(*F).o," -e "s,\\([[:space:]]\\)\\(version\\.h\\),\\1\$$(BUILD_ROOT_REL)/\\2,"'
    
    # find source path
    source_path="`dirname \"$0\"`"
    
    enable source_path_used
    
    if test -z "$source_path" -o "$source_path" = "." ; then
        source_path="`pwd`"
    
        disable source_path_used
    
    else
        source_path="`cd \"$source_path\"; pwd`"
        echo "$source_path" | grep -q '[[:blank:]]' &&
    
            die "Out of tree builds are impossible with whitespace in source path."
    
    find_things(){
        thing=$1
        pattern=$2
        file=$source_path/$3
    
        sed -n "s/^[^#]*$pattern.*([^,]*, *\([^,]*\)\(,.*\)*).*/\1_$thing/p" "$file"
    
    }
    
    ENCODER_LIST=$(find_things  encoder  ENC      libavcodec/allcodecs.c)
    DECODER_LIST=$(find_things  decoder  DEC      libavcodec/allcodecs.c)
    PARSER_LIST=$(find_things   parser   PARSER   libavcodec/allcodecs.c)
    BSF_LIST=$(find_things      bsf      BSF      libavcodec/allcodecs.c)
    MUXER_LIST=$(find_things    muxer    _MUX     libavformat/allformats.c)
    DEMUXER_LIST=$(find_things  demuxer  DEMUX    libavformat/allformats.c)
    OUTDEV_LIST=$(find_things   muxer    _MUX     libavdevice/alldevices.c)
    INDEV_LIST=$(find_things    demuxer  DEMUX    libavdevice/alldevices.c)
    PROTOCOL_LIST=$(find_things protocol PROTOCOL libavformat/allformats.c)
    
    FILTER_LIST=$(find_things   filter   FILTER   libavfilter/allfilters.c)
    
    enable $ARCH_EXT_LIST \
           $DECODER_LIST \
           $ENCODER_LIST \
           $PARSER_LIST \
           $BSF_LIST \
           $DEMUXER_LIST \
           $MUXER_LIST \
    
    
    die_unknown(){
        echo "Unknown option \"$1\"."
        echo "See $0 --help for available options."
        exit 1
    }
    
    
    Ramiro Polla's avatar
    Ramiro Polla committed
        suffix=_$1
        shift
        echo $* | sed s/$suffix//g | tr ' ' '\n' | sort
    
        optval="${opt#*=}"
        case "$opt" in
        --extra-cflags=*) add_cflags "$optval"
        ;;
        --extra-ldflags=*) add_ldflags "$optval"
        ;;
        --extra-libs=*) add_extralibs "$optval"
        ;;
    
        --disable-devices) disable $INDEV_LIST $OUTDEV_LIST
    
        --enable-debug=*) debuglevel="$optval"
        ;;
    
        --enable-*=*|--disable-*=*)
        eval `echo "$opt" | sed 's/=/-/;s/--/action=/;s/-/ thing=/;s/-/ name=/'`
        case "$thing" in
    
            encoder|decoder|muxer|demuxer|parser|bsf|protocol|filter) $action ${optval}_${thing} ;;
    
            *) die_unknown "$opt" ;;
        esac
        ;;
        --enable-?*|--disable-?*)
        eval `echo "$opt" | sed 's/--/action=/;s/-/ option=/;s/-/_/g'`
    
        if is_in $option $COMPONENT_LIST; then
            eval $action \$$(toupper ${option%s})_LIST
        elif is_in $option $CMDLINE_SELECT; then
            $action $option
        else
            die_unknown $opt
        fi
    
        ;;
        --list-*)
            NAME="${opt#--list-}"
            is_in $NAME $COMPONENT_LIST || die_unknown $opt
            NAME=${NAME%s}
            eval show_list $NAME \$$(toupper $NAME)_LIST
        ;;
        --help|-h) show_help
        ;;
        *)
    
        optname="${optname#--}"
        optname=$(echo "$optname" | sed 's/-/_/g')
        is_in $optname $CMDLINE_SET || die_unknown $opt
        eval $optname='$optval'
    
    Måns Rullgård's avatar
    Måns Rullgård committed
    disabled logging && logfile=/dev/null
    
    echo "# $0 $@" > $logfile
    set >> $logfile
    
    
    test -n "$cross_prefix" && enable cross_compile
    
    
    ar="${cross_prefix}${ar}"
    
    cc_default="${cross_prefix}${cc_default}"
    
    Måns Rullgård's avatar
    Måns Rullgård committed
    nm_default="${cross_prefix}${nm_default}"
    
    ranlib="${cross_prefix}${ranlib}"
    strip="${cross_prefix}${strip}"
    
    
    enabled cross_compile || host_cc_default=$cc
    set_default host_cc
    
    # set temporary file name
    
    : ${TMPDIR:=$TEMPDIR}
    
    : ${TMPDIR:=/tmp}
    
    TMPC="${TMPDIR}/ffmpeg-conf-${RANDOM}-$$-${RANDOM}.c"
    TMPE="${TMPDIR}/ffmpeg-conf-${RANDOM}-$$-${RANDOM}${EXESUF}"
    TMPH="${TMPDIR}/ffmpeg-conf-${RANDOM}-$$-${RANDOM}.h"
    TMPO="${TMPDIR}/ffmpeg-conf-${RANDOM}-$$-${RANDOM}.o"
    TMPS="${TMPDIR}/ffmpeg-conf-${RANDOM}-$$-${RANDOM}.S"
    TMPSH="${TMPDIR}/ffmpeg-conf-${RANDOM}-$$-${RANDOM}.sh"
    
    case "$arch" in
        i386|i486|i586|i686|i86pc|BePC)
            arch="x86_32"
            enable fast_unaligned
        ;;
        x86_64|amd64)
            arch="x86_32"
    
            enable fast_unaligned
            check_cc <<EOF && enable fast_64bit && arch="x86_64"
            int test[sizeof(char*) - 7];
    EOF
        ;;
        arm|armv[4567]*l)
    
            arch="arm"
    
        ;;
        alpha)
            arch="alpha"
            enable fast_64bit
        ;;
        "Power Macintosh"|ppc|powerpc)
    
            enable fast_unaligned
    
            enable fast_64bit
    
            enable fast_unaligned
    
            arch="mips"
        ;;
    
        mips64)
            arch="mips"
            enable fast_64bit
        ;;
    
        sun4u|sparc64)
            arch="sparc64"
            enable fast_64bit
        ;;
        sparc)
            arch="sparc"
        ;;
    
            arch="sh4"
        ;;
    
            arch="parisc"
        ;;
    
            arch="parisc"
            enable fast_64bit
        ;;
        s390|s390x)
            arch="s390"
        ;;
        m68k)
            arch="m68k"
        ;;
        ia64)
            arch="ia64"
            enable fast_64bit
        ;;
        bfin)
            arch="bfin"
        ;;
        *)
            arch="unknown"
        ;;
    esac
    
    enable $arch
    enabled_any x86_32 x86_64 && enable x86
    enabled     sparc64       && enable sparc
    
    
            prefix_default="$HOME/config"
    
            # helps building libavcodec
            add_cflags "-DPIC -fomit-frame-pointer"
            # 3 gcc releases known for BeOS, each with ugly bugs
            gcc_version="`$cc -v 2>&1 | grep version | cut -d ' ' -f3-`"
            case "$gcc_version" in
              2.9-beos-991026*|2.9-beos-000224*) echo "R5/GG gcc"
                disable mmx
                ;;
              *20010315*) echo "BeBits gcc"
                add_cflags "-fno-expensive-optimizations"
                ;;
            esac
            SHFLAGS=-nostart
            # enable BeOS things
            enable audio_beos
            # no need for libm, but the inet stuff
            # Check for BONE
            # XXX: actually should check for NOT net_server
    
            if echo $BEINCLUDES | grep -q 'headers/be/bone'; then
    
                network_extralibs="-lbind -lsocket"
            else
                enable beos_netserver
                network_extralibs="-lnet"
            fi ;;
        sunos)
            FFSERVERLDFLAGS=""
    
            SHFLAGS='-shared -Wl,-h,$$(@F)'
    
            ;;
        netbsd)
            oss_demuxer_extralibs="-lossaudio"
            oss_muxer_extralibs="-lossaudio"
            ;;
        openbsd)
            disable need_memalign
            LIBOBJFLAGS='$(PIC)'
            SHFLAGS='-shared'
            oss_demuxer_extralibs="-lossaudio"
            oss_muxer_extralibs="-lossaudio"
            ;;
        freebsd)
            disable need_memalign
            ;;
        bsd/os)
            osextralibs="-lpoll -lgnugetopt"
            strip="strip -d"
            ;;
        darwin)
            disable need_memalign
    
            SHFLAGS='-dynamiclib -Wl,-single_module -Wl,-install_name,$(SHLIBDIR)/$(SLIBNAME),-current_version,$(LIBVERSION),-compatibility_version,$(LIBMAJOR) -Wl,-read_only_relocs,suppress'
    
            VHOOKSHFLAGS='-dynamiclib -Wl,-single_module -flat_namespace -undefined suppress -Wl,-install_name,$(SHLIBDIR)/vhook/$$(@F)'
    
            strip="strip -x"
            FFLDFLAGS="-Wl,-dynamic,-search_paths_first"
            SLIBSUF=".dylib"
            SLIBNAME_WITH_VERSION='$(SLIBPREF)$(FULLNAME).$(LIBVERSION)$(SLIBSUF)'
            SLIBNAME_WITH_MAJOR='$(SLIBPREF)$(FULLNAME).$(LIBMAJOR)$(SLIBSUF)'
            FFSERVERLDFLAGS=-Wl,-bind_at_load
    
    Loren Merritt's avatar
    Loren Merritt committed
            objformat="macho"
    
            enabled x86_64 && objformat="macho64"
    
            LIBTARGET=i386
            if test $arch = x86_64; then
                disable need_memalign
                LIBTARGET=x64
            fi
    
            VHOOKSHFLAGS='-shared -L$(BUILD_ROOT)/libavformat -L$(BUILD_ROOT)/libavcodec -L$(BUILD_ROOT)/libavutil'
            VHOOKLIBS='-lavformat$(BUILDSUF) -lavcodec$(BUILDSUF) -lavutil$(BUILDSUF) $(EXTRALIBS)'
    
                VHOOKSHFLAGS="$VHOOKSHFLAGS -L\$(BUILD_ROOT)/libswscale"
                VHOOKLIBS="$VHOOKLIBS -lswscale\$(BUILDSUF)"
            fi
            disable ffserver
            SLIBPREF=""
            SLIBSUF=".dll"
            EXESUF=".exe"
            SLIBNAME_WITH_VERSION='$(SLIBPREF)$(FULLNAME)-$(LIBVERSION)$(SLIBSUF)'
            SLIBNAME_WITH_MAJOR='$(SLIBPREF)$(FULLNAME)-$(LIBMAJOR)$(SLIBSUF)'
    
            SLIB_EXTRA_CMD='-lib /machine:$(LIBTARGET) /def:$$(@:$(SLIBSUF)=.def) /out:$(SUBDIR)$(SLIBNAME_WITH_MAJOR:$(SLIBSUF)=.lib)'
    
            SLIB_INSTALL_EXTRA_CMD='-install -m 644 $(SUBDIR)$(SLIBNAME_WITH_MAJOR:$(SLIBSUF)=.lib) "$(SHLIBDIR)/$(SLIBNAME:$(SLIBSUF)=.lib)"; \
                install -m 644 $(SUBDIR)$(SLIBNAME_WITH_MAJOR:$(SLIBSUF)=.lib) "$(SHLIBDIR)/$(SLIBNAME_WITH_MAJOR:$(SLIBSUF)=.lib)"'
    
            SLIB_UNINSTALL_EXTRA_CMD='rm -f "$(SHLIBDIR)/$(SLIBNAME:$(SLIBSUF)=.lib)"'
    
    Måns Rullgård's avatar
    Måns Rullgård committed
            SHFLAGS='-shared -Wl,--output-def,$$(@:$(SLIBSUF)=.def) -Wl,--enable-runtime-pseudo-reloc -Wl,--enable-auto-image-base'
    
    Loren Merritt's avatar
    Loren Merritt committed
            objformat="win32"
    
            check_cpp_condition _mingw.h "(__MINGW32_MAJOR_VERSION > 3) || (__MINGW32_MAJOR_VERSION == 3 && __MINGW32_MINOR_VERSION >= 15)" ||
                die "ERROR: MinGW runtime version must be >= 3.15."
            enabled_any avisynth vfwcap_demuxer &&
    
                { check_cpp_condition w32api.h "(__W32API_MAJOR_VERSION > 3) || (__W32API_MAJOR_VERSION == 3 && __W32API_MINOR_VERSION >= 13)" ||
                  die "ERROR: avisynth and vfwcap_demuxer require w32api version 3.13 or later."; }
    
            VHOOKSHFLAGS='-shared -L$(BUILD_ROOT)/libavformat -L$(BUILD_ROOT)/libavcodec -L$(BUILD_ROOT)/libavutil'
            VHOOKLIBS='-lavformat$(BUILDSUF) -lavcodec$(BUILDSUF) -lavutil$(BUILDSUF) $(EXTRALIBS)'
    
                VHOOKSHFLAGS="$VHOOKSHFLAGS -L\$(BUILD_ROOT)/libswscale"
                VHOOKLIBS="$VHOOKLIBS -lswscale\$(BUILDSUF)"
            fi
            EXESUF=".exe"
            SLIBPREF="cyg"
            SLIBSUF=".dll"
            SLIBNAME_WITH_VERSION='$(SLIBPREF)$(FULLNAME)-$(LIBVERSION)$(SLIBSUF)'
            SLIBNAME_WITH_MAJOR='$(SLIBPREF)$(FULLNAME)-$(LIBMAJOR)$(SLIBSUF)'
            SHFLAGS='-shared -Wl,--enable-auto-image-base'
    
    Loren Merritt's avatar
    Loren Merritt committed
            objformat="win32"
    
    Michael Kostylev's avatar
    Michael Kostylev committed
        *-dos|freedos|opendos)
            disable ffplay ffserver vhook
            disable $INDEV_LIST $OUTDEV_LIST
            network_extralibs="-lsocket"
            EXESUF=".exe"
    
    Loren Merritt's avatar
    Loren Merritt committed
            objformat="win32"
    
        os/2*)
            strip="lxlite"
            ln_s="cp -f"
            EXESUF=".exe"
            FFLDFLAGS="-Zomf -Zbin-files -Zargs-wild -Zmap"
    
    Måns Rullgård's avatar
    Måns Rullgård committed
            SHFLAGS='$(SUBDIR)$(NAME).def -Zdll -Zomf'
    
            FFSERVERLDFLAGS=""
    
            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'
            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_CMD='install -m 644 $(SUBDIR)$(LIBPREF)$(NAME)_dll.a $(SUBDIR)$(LIBPREF)$(NAME)_dll.lib "$(LIBDIR)"'
    
            SLIB_UNINSTALL_EXTRA_CMD='rm -f "$(LIBDIR)"/$(LIBPREF)$(NAME)_dll.a "$(LIBDIR)"/$(LIBPREF)$(NAME)_dll.lib'
    
            disable vhook
    
            target_os="${target_os}-UNKNOWN"
    
    set_default $PATHS_LIST
    
    
    Fabrice Bellard's avatar
    Fabrice Bellard committed
    
    
    # Combine FFLDFLAGS and the LDFLAGS environment variable.
    LDFLAGS="$FFLDFLAGS $LDFLAGS"
    
    # 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
    
    
    disabled static && LIBNAME=""
    
    if enabled_any libfaad libfaadbin ; then
        if check_header faad.h; then
    
    Diego Biurrun's avatar
    Diego Biurrun committed
            check_cc <<EOF
    
    #include <faad.h>
    #ifndef FAAD2_VERSION
    ok faad1
    #endif
    
    int main(void) { return 0; }
    
    EOF
            test $? = 0 && enable libfaad2
        else
    
            die "FAAD test failed."
    
    if ! enabled gpl; then
    
    Ramiro Polla's avatar
    Ramiro Polla committed
        die_gpl_disabled(){
            name=$1
            shift
            enabled_any $@ && die "$name is under GPL and --enable-gpl is not specified."
        }
    
        die_gpl_disabled "The Postprocessing code" postproc
    
        die_gpl_disabled "libx264"                 libx264
        die_gpl_disabled "libxvidcore"             libxvid
    
    Ramiro Polla's avatar
    Ramiro Polla committed
        die_gpl_disabled "FAAD2"                   libfaad2
        die_gpl_disabled "The X11 grabber"         x11grab
    
        die_gpl_disabled "The software scaler"     swscale
    
    if ! enabled nonfree && enabled_any libamr_nb libamr_wb; then
        die "libamr is nonfree and --enable-nonfree is not specified."
    fi
    
    
    check_deps $ARCH_EXT_LIST
    
    test -z "$need_memalign" && need_memalign="$mmx"
    
    
    if test $target_os = darwin; then
    
        if $cc -v 2>&1 | grep -q xlc; then
    
            add_cflags "-qpdf2 -qlanglvl=extc99 -qmaxmem=-1 -qarch=auto -qtune=auto"
    
            check_cflags "-force_cpusubtype_ALL"
            check_cflags "-Wno-sign-compare"
    
            enabled shared || check_cflags -mdynamic-no-pic
    
    disabled optimizations || check_cflags -fomit-frame-pointer
    
        warn_altivec(){
            $1 altivec && echo "WARNING: Tuning for $2 but AltiVec $1.";
    
            601|ppc601|PowerPC601)
    
                add_cflags "-mcpu=601"
    
                warn_altivec enabled PPC601
    
            ;;
            603*|ppc603*|PowerPC603*)
    
                add_cflags "-mcpu=603"
    
                warn_altivec enabled PPC603
    
            ;;
            604*|ppc604*|PowerPC604*)
    
                add_cflags "-mcpu=604"
    
                warn_altivec enabled PPC604
    
            ;;
            G3|g3|75*|ppc75*|PowerPC75*)
    
                add_cflags "-mcpu=750 -mpowerpc-gfxopt"
    
                warn_altivec enabled PPC75x
    
            ;;
            G4|g4|745*|ppc745*|PowerPC745*)
    
                add_cflags "-mcpu=7450 -mpowerpc-gfxopt"
    
                warn_altivec disabled PPC745x
    
            ;;
            74*|ppc74*|PowerPC74*)
    
                add_cflags "-mcpu=7400 -mpowerpc-gfxopt"
    
                warn_altivec disabled PPC74xx
    
            ;;
            G5|g5|970|ppc970|PowerPC970|power4*|Power4*)
    
                add_cflags "-mcpu=970 -mpowerpc-gfxopt -mpowerpc64"
    
                warn_altivec disabled PPC970
    
    Måns Rullgård's avatar
    Måns Rullgård committed
                enable ppc64
    
            Cell|CELL|cell)
                add_cflags "-mcpu=cell"
                warn_altivec disabled Cell
    
    Måns Rullgård's avatar
    Måns Rullgård committed
                enable ppc64
    
            # targets that do NOT support conditional mov (cmov)
            i[345]86|pentium|pentium-mmx|k6|k6-[23]|winchip-c6|winchip2|c3)
    
            ;;
            # targets that do support conditional mov (cmov)
    
            i686|pentiumpro|pentium[23]|pentium-m|athlon|athlon-tbird|athlon-4|athlon-[mx]p|athlon64|k8|opteron|athlon-fx|core2)
    
                enable cmov
                enable fast_cmov
    
            ;;
            # targets that do support conditional mov but on which it's slow
    
            pentium4|pentium4m|prescott|nocona)
    
                enable cmov
                disable fast_cmov
    
                add_cflags "-mcpu=v9"
    
            arm11*|cortex*)
                add_cflags "-mcpu=$cpu"
                enable fast_unaligned
            ;;
    
            armv*)
                add_cflags "-march=$cpu"
            ;;
    
    Måns Rullgård's avatar
    Måns Rullgård committed
                add_cflags "-mcpu=$cpu"
            ;;
    
                echo "WARNING: Unknown CPU \"$cpu\", ignored."
    
    # make sure we can execute files in $TMPDIR
    
    cat > $TMPSH 2>> $logfile <<EOF
    
    chmod +x $TMPSH >> $logfile 2>&1
    if ! $TMPSH >> $logfile 2>&1; then
    
    Unable to create and execute files in $TMPDIR.  Set the TMPDIR environment
    variable to another directory and make sure that it is not mounted noexec.
    
    Måns Rullgård's avatar
    Måns Rullgård committed
    # compiler sanity check
    check_exec <<EOF
    
    Måns Rullgård's avatar
    Måns Rullgård committed
    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."
    
    Måns Rullgård's avatar
    Måns Rullgård committed
        fi
        die "C compiler test failed."
    fi
    
    
    check_cc <<EOF || die "Symbol mangling check failed."
    int ff_extern;
    EOF
    
    sym=$($nm -P -g $TMPO | grep ff_extern)
    
    extern_prefix=${sym%%ff_extern*}
    
    
    check_asm inline_asm '""'
    
    
    if enabled x86; then
    
        # 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
    
        __asm__ volatile (
    
            "xorl %%ebp, %%ebp"
        ::: "%ebp");
        return i;
    EOF
    
        # check wether EBX is available on x86
    
        check_asm ebx_available '"":::"%ebx"'
    
        # check whether binutils is new enough to compile SSSE3/MMX2
    
        enabled ssse3 && check_asm ssse3 '"pabsw %xmm0, %xmm0"'
    
        enabled mmx2  && check_asm mmx2  '"movss %xmm0, %xmm0"'
    
    
        check_asm bswap '"bswap %%eax" ::: "%eax"'
    
    Loren Merritt's avatar
    Loren Merritt committed
    
        YASMFLAGS="-f $objformat -DARCH_$(toupper $arch)"
        enabled     x86_64        && append YASMFLAGS "-m amd64"
        enabled_all x86_64 shared && append YASMFLAGS "-DPIC"
        case "$objformat" in
            elf) enabled debug && append YASMFLAGS "-g dwarf2" ;;
    
            macho64)              append YASMFLAGS "-DPIC -DPREFIX" ;;
    
    Loren Merritt's avatar
    Loren Merritt committed
            *)                    append YASMFLAGS "-DPREFIX"  ;;
        esac
        check_yasm "pabsw xmm0, xmm0" && enable yasm
    
    # check for assembler specific support
    
    
    if test $arch = "ppc"; then
    
        check_asm dcbzl '"dcbzl 0, 1"'
    
    # 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>" ; } ||
    
    Måns Rullgård's avatar
    Måns Rullgård committed
        # check if our compiler supports Motorola AltiVec C API
    
        check_cc <<EOF || disable altivec
    
    int main(void) {
        vector signed int v1, v2, v3;
        v1 = vec_add(v2,v3);
        return 0;
    }
    
    EOF
    
        # check if our compiler supports braces for vector declarations
    
        check_cc <<EOF || die "You need a compiler that supports {} in AltiVec vector declarations."
    
    int main (void) { (vector int) {1}; return 0; }
    
    # We have to check if pld is a nop and disable it.
    
    enabled arm     && check_asm pld     '"pld [r0]"'
    
    enabled armv5te && check_asm armv5te '"qadd r0, r0, r0"'
    enabled armv6   && check_asm armv6   '"sadd16 r0, r0, r0"'
    
    enabled armv6t2 && check_asm armv6t2 '"movt r0, #0"'
    
    enabled armvfp  && check_asm armvfp  '"fadds s0, s0, s0"'
    
    enabled iwmmxt  && check_asm iwmmxt  '"wunpckelub wr6, wr4"'
    enabled mmi     && check_asm mmi     '"lq $2, 0($2)"'
    
    enabled neon    && check_asm neon    '"vadd.i16 q0, q0, q0"'
    
    enabled vis     && check_asm vis     '"pdist %f0, %f0, %f0"' -mcpu=ultrasparc
    
    enabled vis && add_cflags "-mcpu=ultrasparc -mtune=ultrasparc"
    
    
    check_cc <<EOF || die "endian test failed"
    unsigned int endian = 'B' << 24 | 'I' << 16 | 'G' << 8 | 'E';
    
    od -A n -t x1 $TMPO | grep -q '42 *49 *47 *45' && enable bigendian
    
    Nick Kurshev's avatar
    Nick Kurshev committed
    # ---
    # check availability of some header files
    
    
    if check_func dlopen; then
        ldl=
    elif check_func dlopen -ldl; then
        ldl=-ldl
    
    check_func  fork
    check_func  gethrtime
    check_func  getrusage
    
    check_func  inet_aton $network_extralibs
    
    check_func_headers windows.h GetProcessTimes
    
    check_header dlfcn.h
    check_header malloc.h
    
    check_header sys/resource.h
    
    check_header termios.h
    
    check_header vdpau/vdpau.h
    check_header vdpau/vdpau_x11.h
    
    check_header X11/extensions/XvMClib.h
    
    
    if ! enabled_any memalign memalign_hack && enabled need_memalign ; then
        die "Error, no memalign() but SSE enabled, disable it or use --enable-memalign-hack."
    fi
    
    disabled  zlib || check_lib   zlib.h      zlibVersion -lz   || disable  zlib
    
    disabled bzlib || check_lib2 bzlib.h BZ2_bzlibVersion -lbz2 || disable bzlib
    
    
    # check for some common methods of building with pthread support
    # do this before the optional library checks as some of them require pthreads
    if enabled pthreads; then
    
    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
            die "ERROR: can't find pthreads library"
        fi
    
            test -n "$thread_type" &&
                die "ERROR: Only one thread type must be selected." ||
    
    Måns Rullgård's avatar
    Måns Rullgård committed
    check_lib math.h sin -lm
    
    
    # test for C99 functions in math.h
    for func in llrint lrint lrintf round roundf; do
        check_exec <<EOF && enable $func || disable $func
    
    int main(void) { return ($func(3.999f) > 0)?0:1; }
    
    # these are off by default, so fail if requested and not available
    
    enabled avisynth   && require2 vfw32 "windows.h vfw.h" AVIFileInit -lvfw32
    
    enabled libamr_nb  && require  libamrnb amrnb/interf_dec.h Speech_Decode_Frame_init -lamrnb -lm
    enabled libamr_wb  && require  libamrwb amrwb/dec_if.h D_IF_init -lamrwb -lm
    
    enabled libdirac   && add_cflags $(pkg-config --cflags dirac) &&
    
                          require  libdirac libdirac_decoder/dirac_parser.h dirac_decoder_init -ldirac_decoder &&
                          require  libdirac libdirac_encoder/dirac_encoder.h dirac_encoder_init -ldirac_encoder
    
    enabled libfaac    && require2 libfaac "stdint.h faac.h" faacEncGetVersion -lfaac
    enabled libfaad    && require2 libfaad faad.h faacDecOpen -lfaad
    
    enabled libgsm     && require  libgsm gsm.h gsm_create -lgsm
    
    enabled libmp3lame && require  libmp3lame lame/lame.h lame_init -lmp3lame -lm
    
    enabled libnut     && require  libnut libnut.h nut_demuxer_init -lnut
    
    enabled libschroedinger && add_cflags $(pkg-config --cflags schroedinger-1.0) &&
                               require libschroedinger schroedinger/schro.h schro_init $(pkg-config --libs schroedinger-1.0)
    
    enabled libspeex   && require  libspeex speex/speex.h speex_decoder_init -lspeex
    
    enabled libtheora  && require  libtheora theora/theora.h theora_info_init -ltheora -logg
    enabled libvorbis  && require  libvorbis vorbis/vorbisenc.h vorbis_info_init -lvorbisenc -lvorbis -logg
    
    enabled libx264    && require  libx264 x264.h x264_encoder_open -lx264 -lm &&
    
                          { check_cpp_condition x264.h "X264_BUILD >= 65" ||
                            die "ERROR: libx264 version must be >= 0.65."; }
    
    enabled libxvid    && require  libxvid xvid.h xvid_global -lxvidcore
    
    enabled mlib       && require  mediaLib mlib_types.h mlib_VectorSub_S16_U8_Mod -lmlib
    
    # 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
    
    
    
    _restrict=
    for restrict_keyword in restrict __restrict__ __restrict; do
    
        check_cc <<EOF && _restrict=$restrict_keyword && break
    
    void foo(char * $restrict_keyword p);
    EOF
    
    test "$vhook" = "default" && vhook="$dlopen"
    
    if test "$target_os" = cygwin -o "$target_os" = mingw32 && enabled_all static vhook ; then
    
        echo "At the moment vhooks don't work on Cygwin or MinGW static builds."
    
    if enabled vhook; then
        check_ldflags -rdynamic
        check_ldflags -export-dynamic
    fi
    
    Michael Niedermayer's avatar
    Michael Niedermayer committed
    
    
    check_foo_config imlib2 imlib2 Imlib2.h imlib_load_font
    check_foo_config freetype2 freetype ft2build.h FT_Init_FreeType
    
    ##########################################
    
    Diego Biurrun's avatar
    Diego Biurrun committed
    # SDL check
    
    disable sdl_too_old
    disable sdl
    
    SDL_CONFIG="${cross_prefix}sdl-config"
    
    if "${SDL_CONFIG}" --version > /dev/null 2>&1; then
    
    Måns Rullgård's avatar
    Måns Rullgård committed
        sdl_cflags=`"${SDL_CONFIG}" --cflags`
        temp_cflags $sdl_cflags
    
        temp_extralibs `"${SDL_CONFIG}" --libs`
    
        if check_lib2 SDL.h SDL_Init; then
    
            _sdlversion=`"${SDL_CONFIG}" --version | sed 's/[^0-9]//g'`
    
            if test "$_sdlversion" -lt 121 ; then
    
                enable sdl_too_old
    
    Måns Rullgård's avatar
    Måns Rullgård committed
                check_cc $sdl_cflags <<EOF && enable sdl_video_size
    
    int main(int argc, char **argv){
    
        const SDL_VideoInfo *vi = SDL_GetVideoInfo();
        int w = vi->current_w;
        return 0;
    }
    EOF
    
    texi2html -version > /dev/null 2>&1 && enable texi2html || disable texi2html
    
    ##########################################
    # Network check
    
    if enabled network; then
    
        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
    
            network_extralibs="-lws2_32"
    
            check_type ws2tcpip.h socklen_t
    
            check_func_headers winsock2.h closesocket
    
    ##########################################
    
    Diego Biurrun's avatar
    Diego Biurrun committed
    # IPv6 check
    
    enabled network && enabled ipv6 && check_ld <<EOF && enable ipv6 || disable ipv6
    
    #include <sys/types.h>
    #include <sys/socket.h>
    #include <netinet/in.h>
    #include <netdb.h>
    
    int main(void) {
    
        struct sockaddr_storage saddr;
        struct ipv6_mreq mreq6;
        getaddrinfo(0,0,0,0);
        getnameinfo(0,0,0,0,0,0,0);
        IN6_IS_ADDR_MULTICAST((const struct in6_addr *)0);
    
    check_header linux/videodev.h