Skip to content
Snippets Groups Projects
configure 57.3 KiB
Newer Older
  • Learn to ignore specific revisions
  •   --disable-bsfs) disable $BSF_LIST
      ;;
    
      --disable-protocols) disable $PROTOCOL_LIST
      ;;
    
      --enable-*=*|--disable-*=*)
      eval `echo "$opt" | sed 's/=/-/;s/--/action=/;s/-/ thing=/;s/-/ name=/'`
      case "$thing" in
    
          encoder|decoder|muxer|demuxer|parser|bsf|protocol) $action ${optval}_${thing} ;;
    
          *) die_unknown "$opt" ;;
      esac
      ;;
      --enable-?*|--disable-?*)
      eval `echo "$opt" | sed 's/--/action=/;s/-/ option=/;s/-/_/g'`
      echo "$CMDLINE_SELECT" | grep -q "^ *$option\$" || die_unknown $opt
      $action $option
      ;;
    
        is_in $NAME $COMPONENT_LIST || die_unknown $opt
    
        NAME=$(toupper ${NAME%s})
        eval show_list \$${NAME}_LIST
      ;;
    
      --help|-h) show_help
    
    case "$arch" in
      i386|i486|i586|i686|i86pc|BePC)
        arch="x86_32"
    
        enable fast_unaligned
    
      ;;
      x86_64|amd64)
        arch="x86_32"
    
        enable fast_unaligned
    
        canon_arch="`$cc -dumpmachine | sed -e 's,\([^-]*\)-.*,\1,'`"
        if [ x"$canon_arch" = x"x86_64" -o x"$canon_arch" = x"amd64" ]; then
          if [ -z "`echo $CFLAGS | grep -- -m32`"  ]; then
            arch="x86_64"
    
          fi
        fi
      ;;
      # armv4l is a subset of armv[567]*l
      arm|armv[4567]*l)
        arch="armv4l"
      ;;
      alpha)
        arch="alpha"
    
      "Power Macintosh"|ppc|powerpc)
    
      ppc64)
        arch="powerpc"
        enable fast_64bit
      ;;
    
        arch="mips"
      ;;
      sun4u|sparc64)
        arch="sparc64"
    
      parisc)
        arch="parisc"
      ;;
      parisc64)
    
      ;;
      s390|s390x)
        arch="s390"
      ;;
      m68k)
        arch="m68k"
      ;;
      ia64)
        arch="ia64"
    
    enable $arch
    enabled_any x86_32 x86_64 && enable x86
    enabled     sparc64       && enable sparc
    
    
    case $targetos in
    
      beos|haiku|zeta)
    
    Måns Rullgård's avatar
    Måns Rullgård committed
        # 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"
    
    Måns Rullgård's avatar
    Måns Rullgård committed
            ;;
          *20010315*) echo "BeBits gcc"
            add_cflags "-fno-expensive-optimizations"
            ;;
        esac
    
    Måns Rullgård's avatar
    Måns Rullgård committed
        SHFLAGS=-nostart
        # enable BeOS things
    
    Måns Rullgård's avatar
    Måns Rullgård committed
        # no need for libm, but the inet stuff
        # Check for BONE
    
        # XXX: actually should check for NOT net_server
    
    Måns Rullgård's avatar
    Måns Rullgård committed
        if (echo $BEINCLUDES|grep 'headers/be/bone' >/dev/null); then
    
            network_extralibs="-lbind -lsocket"
    
    Måns Rullgård's avatar
    Måns Rullgård committed
        else
    
            enable beos_netserver
    
            network_extralibs="-lnet"
    
    Måns Rullgård's avatar
    Måns Rullgård committed
        fi ;;
    
      sunos)
    
    Måns Rullgård's avatar
    Måns Rullgård committed
        FFSERVERLDFLAGS=""
    
        network_extralibs="-lsocket -lnsl"
    
    Måns Rullgård's avatar
    Måns Rullgård committed
        ;;
    
      netbsd)
    
        oss_demuxer_extralibs="-lossaudio"
        oss_muxer_extralibs="-lossaudio"
    
    Måns Rullgård's avatar
    Måns Rullgård committed
        ;;
    
      openbsd)
    
        disable need_memalign
    
        LIBOBJFLAGS='$(PIC)'
        LDCONFIG='ldconfig -m $(SHLIBDIR)'
    
    Måns Rullgård's avatar
    Måns Rullgård committed
        SHFLAGS='-shared'
    
        SLIBNAME='$(SLIBPREF)$(FULLNAME)$(SLIBSUF).$(LIBVERSION)'
    
    Måns Rullgård's avatar
    Måns Rullgård committed
        SLIBNAME_WITH_VERSION='$(SLIBNAME)'
        SLIBNAME_WITH_MAJOR='$(SLIBNAME)'
    
        oss_demuxer_extralibs="-lossaudio"
        oss_muxer_extralibs="-lossaudio"
    
    Måns Rullgård's avatar
    Måns Rullgård committed
        ;;
    
      freebsd)
    
        disable need_memalign
    
    Måns Rullgård's avatar
    Måns Rullgård committed
        ;;
    
      bsd/os)
    
    Ramiro Polla's avatar
    Ramiro Polla committed
        osextralibs="-lpoll -lgnugetopt"
    
    Måns Rullgård's avatar
    Måns Rullgård committed
        strip="strip -d"
        ;;
    
      darwin)
    
        disable need_memalign
    
        SHFLAGS='-dynamiclib -Wl,-single_module -Wl,-install_name,$(SHLIBDIR)/$(SLIBNAME),-current_version,$(SPPVERSION),-compatibility_version,$(SPPVERSION) -Wl,-read_only_relocs,suppress'
    
        VHOOKSHFLAGS='-dynamiclib -Wl,-single_module -flat_namespace -undefined suppress -Wl,-install_name,$(SHLIBDIR)/vhook/$@'
    
    Måns Rullgård's avatar
    Måns Rullgård committed
        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)'
    
    Måns Rullgård's avatar
    Måns Rullgård committed
        FFSERVERLDFLAGS=-Wl,-bind_at_load
        ;;
    
      mingw32*)
    
        shlibdir="$bindir"
    
        VHOOKSHFLAGS='-shared -L$(BUILD_ROOT)/libavformat -L$(BUILD_ROOT)/libavcodec -L$(BUILD_ROOT)/libavutil'
        VHOOKLIBS='-lavformat$(BUILDSUF) -lavcodec$(BUILDSUF) -lavutil$(BUILDSUF) $(EXTRALIBS)'
        if enabled swscaler; then
            VHOOKSHFLAGS="$VHOOKSHFLAGS -L\$(BUILD_ROOT)/libswscale"
            VHOOKLIBS="$VHOOKLIBS -lswscale\$(BUILDSUF)"
        fi
    
        SLIBPREF=""
        SLIBSUF=".dll"
        EXESUF=".exe"
    
        SLIBNAME_WITH_VERSION='$(SLIBPREF)$(FULLNAME)-$(LIBVERSION)$(SLIBSUF)'
        SLIBNAME_WITH_MAJOR='$(SLIBPREF)$(FULLNAME)-$(LIBMAJOR)$(SLIBSUF)'
    
        SLIB_EXTRA_CMD='-lib /machine:i386 /def:$(@:$(SLIBSUF)=.def)'
    
        SLIB_INSTALL_EXTRA_CMD='-install -m 644 $(SLIBNAME_WITH_MAJOR:$(SLIBSUF)=.lib) "$(SHLIBDIR)/$(SLIBNAME:$(SLIBSUF)=.lib)"'
        SLIB_UNINSTALL_EXTRA_CMD='rm -f "$(SHLIBDIR)/$(SLIBNAME:$(SLIBSUF)=.lib)"'
    
        SHFLAGS='-shared -Wl,--output-def,$(@:$(SLIBSUF)=.def) -Wl,--enable-runtime-pseudo-reloc -Wl,--enable-auto-image-base'
    
    Måns Rullgård's avatar
    Måns Rullgård committed
        ;;
    
      cygwin*)
    
        targetos=cygwin
    
    Måns Rullgård's avatar
    Måns Rullgård committed
        shlibdir="$bindir"
    
        VHOOKSHFLAGS='-shared -L$(BUILD_ROOT)/libavformat -L$(BUILD_ROOT)/libavcodec -L$(BUILD_ROOT)/libavutil'
        VHOOKLIBS='-lavformat$(BUILDSUF) -lavcodec$(BUILDSUF) -lavutil$(BUILDSUF) $(EXTRALIBS)'
        if enabled swscaler; then
            VHOOKSHFLAGS="$VHOOKSHFLAGS -L\$(BUILD_ROOT)/libswscale"
            VHOOKLIBS="$VHOOKLIBS -lswscale\$(BUILDSUF)"
        fi
    
    Måns Rullgård's avatar
    Måns Rullgård committed
        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'
    
    Måns Rullgård's avatar
    Måns Rullgård committed
        ;;
    
      linux)
    
    Måns Rullgård's avatar
    Måns Rullgård committed
        LDLATEFLAGS="-Wl,--as-needed $LDLATEFLAGS"
    
    Måns Rullgård's avatar
    Måns Rullgård committed
        ;;
    
      irix*)
    
        targetos=irix
    
    Måns Rullgård's avatar
    Måns Rullgård committed
        ranlib="echo ignoring ranlib"
        ;;
      *)
        targetos="${targetos}-UNKNOWN"
        ;;
    
    Fabrice Bellard's avatar
    Fabrice Bellard committed
    
    
    Fabrice Bellard's avatar
    Fabrice Bellard committed
    
    
    if ! disabled logging ; then
    
        enabled logging || logfile="$logging"
    
    # Combine FFLDFLAGS and the LDFLAGS environment variable.
    LDFLAGS="$FFLDFLAGS $LDFLAGS"
    
    test -n "$cross_prefix" && enable cross_compile
    
    cc="${cross_prefix}${cc}"
    ar="${cross_prefix}${ar}"
    ranlib="${cross_prefix}${ranlib}"
    strip="${cross_prefix}${strip}"
    
    
    # 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 libogg; then
    
        enabled libtheora && die "libogg must be enabled to enable libtheora."
        enabled libvorbis && die "libogg must be enabled to enable libvorbis."
    
    if enabled_any libfaad libfaadbin ; then
        if check_header faad.h; then
            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" pp
    
        die_gpl_disabled "liba52"                  liba52
    
        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"     swscaler
    
    check_deps $ARCH_EXT_LIST
    
    test -z "$need_memalign" && need_memalign="$mmx"
    
    
    if test $targetos = darwin; then
    
        if test -n "`$cc -v 2>&1 | grep xlc`"; then
    
            add_cflags "-qpdf2 -qlanglvl=extc99 -qmaxmem=-1 -qarch=auto -qtune=auto"
    
            add_cflags "-no-cpp-precomp -pipe"
            check_cflags "-force_cpusubtype_ALL"
            check_cflags "-Wno-sign-compare"
    
    Diego Biurrun's avatar
    Diego Biurrun committed
            disabled shared && add_cflags -mdynamic-no-pic
    
    disabled optimizations || add_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|prescott|nocona)
                add_cflags "-march=$cpu"
    
                enable cmov
                disable fast_cmov
    
                add_cflags "-mcpu=v9"
    
            bf*) #bf531 bf532 bf533 bf561 bf5xx all get this config
                add_cflags "-mfdpic"
    
    Måns Rullgård's avatar
    Måns Rullgård committed
            arm*)
                add_cflags "-mcpu=$cpu"
            ;;
    
    Måns Rullgård's avatar
    Måns Rullgård committed
    gnu_make(){
        $1 --version 2>&1 | grep -q GNU
    }
    
    if ! gnu_make $make; then
        gnu_make gmake && make=gmake || die "GNU make not found."
    fi
    
    
    # make sure we can execute files in $TMPDIR
    cat >$TMPE 2>>$logfile <<EOF
    #! /bin/sh
    EOF
    chmod +x $TMPE >>$logfile 2>&1
    if ! $TMPE >>$logfile 2>&1; then
        cat <<EOF
    Unable to create and execute files in $TMPDIR1.  Set the TMPDIR environment
    
    variable to another directory and make sure that $TMPDIR1 is not mounted
    noexec.
    
    Måns Rullgård's avatar
    Måns Rullgård committed
    # compiler sanity check
    check_exec <<EOF
    int main(){
        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
    
    Måns Rullgård's avatar
    Måns Rullgård committed
            echo "If $cc is a cross-compiler, use the --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
    
    
    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
    
        volatile int i=0;
        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
    
        enabled ssse3 && check_asm ssse3 '"pabsw %xmm0, %xmm0"'
    
    # check for assembler specific support
    
    
    check_cc <<EOF && enable dcbzl
    
    int main(void) {
        register long zero = 0;
        char data[1024];
        asm volatile("dcbzl %0, %1" : : "b" (data), "r" (zero));
    return 0;
    }
    EOF
    fi
    
    
    # AltiVec flags: The FSF version of GCC differs from the Apple version
    
    if enabled altivec; then
    
        test -n "`$cc -v 2>&1 | grep version | grep Apple`" &&
            add_cflags "-faltivec" ||
    
    Måns Rullgård's avatar
    Måns Rullgård committed
            add_cflags "-maltivec -mabi=altivec"
    
    Måns Rullgård's avatar
    Måns Rullgård committed
        check_header altivec.h
    
    Måns Rullgård's avatar
    Måns Rullgård committed
        # check if our compiler supports Motorola AltiVec C API
    
        enabled altivec_h &&
            inc_altivec_h="#include <altivec.h>" ||
    
    Måns Rullgård's avatar
    Måns Rullgård committed
            inc_altivec_h=
    
        check_cc <<EOF || disable altivec
    
    int main(void) {
        vector signed int v1, v2, v3;
        v1 = vec_add(v2,v3);
        return 0;
    }
    EOF
    fi
    
    enabled armv5te && check_asm armv5te '"qadd r0, r0, r0"'
    enabled armv6   && check_asm armv6   '"sadd16 r0, r0, r0"'
    enabled iwmmxt  && check_asm iwmmxt  '"wunpckelub wr6, wr4"'
    enabled mmi     && check_asm mmi     '"lq $2, 0($2)"'
    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';
    
    grep -q BIGE $TMPO && 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 getrusage
    check_func inet_aton
    check_func memalign
    check_func mkstemp
    check_func2 windows.h GetProcessTimes
    
    check_header byteswap.h
    
    check_header dlfcn.h
    check_header malloc.h
    check_header termios.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
    
    enabled zlib && check_lib zlib.h zlibVersion -lz || disable zlib
    
    # ffserver uses poll(),
    # if it's not found we can emulate it using select().
    if enabled ffserver; then
        check_header sys/poll.h
    fi
    
    
    # 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
            add_ldflags -pthread
        elif check_func pthread_create -pthreads; then
            add_cflags -pthreads
            add_ldflags -pthreads
        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
    
    
    check_exec <<EOF && enable lrintf || disable lrintf
    
    #define _ISOC9X_SOURCE  1
    #include <math.h>
    int main( void ) { return (lrintf(3.999f) > 0)?0:1; }
    EOF
    
    
    enabled_any libamr_nb libamr_wb && enable libamr
    
    # these are off by default, so fail if requested and not available
    
    enabled avisynth   && require2 vfw32 "windows.h vfw.h" AVIFileInit -lvfw32
    
    enabled liba52     && require liba52 a52dec/a52.h a52_init -la52
    
    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
    
    Ramiro Polla's avatar
    Ramiro Polla committed
    enabled libdc1394  && require libdc1394 libdc1394/dc1394_control.h dc1394_create_handle -ldc1394_control -lraw1394
    
    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 LAME lame/lame.h lame_init -lmp3lame -lm
    
    enabled libnut     && require libnut libnut.h nut_demuxer_init -lnut
    enabled libogg     && require libogg ogg/ogg.h ogg_sync_init -logg
    
    enabled libtheora  && require libtheora theora/theora.h theora_info_init -ltheora -logg
    enabled libvorbis  && require libvorbis vorbis/vorbisenc.h vorbis_info_init -lvorbis -lvorbisenc -logg
    
    enabled libx264    && require x264 x264.h x264_encoder_open -lx264
    enabled libxvid    && require Xvid xvid.h xvid_global -lxvidcore
    
    enabled mlib       && require mediaLib mlib_types.h mlib_VectorSub_S16_U8_Mod -lmlib
    
    # disable the native AC-3 decoder if liba52 is enabled
    enabled liba52 && disable ac3_decoder
    
    
    _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 "$targetos" = cygwin -o "$targetos" = 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"
    
    Måns Rullgård's avatar
    Måns Rullgård committed
    if "${SDL_CONFIG}" --version >/dev/null 2>&1; then
        sdl_cflags=`"${SDL_CONFIG}" --cflags`
        temp_cflags $sdl_cflags
    
        temp_extralibs `"${SDL_CONFIG}" --libs`
    
    Måns Rullgård's avatar
    Måns Rullgård committed
        if check_lib 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
    
    #include <SDL.h>
    int main(void){
        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
        # 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_func2 winsock2.h closesocket
        fi
    fi
    
    
    ##########################################
    
    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
    check_header linux/videodev2.h
    
    # 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 sys/soundcard.h
    check_header soundcard.h
    
    # Deal with the x11 frame grabber
    
    check_header X11/Xlib.h                 &&
    check_header X11/extensions/XShm.h      &&
    check_func XOpenDisplay -lX11           &&
    
    check_func XShmCreateImage -lX11 -lXext
    
    enabled debug && add_cflags -g
    
    # add some useful compiler flags if supported
    check_cflags -Wdeclaration-after-statement
    
    check_cflags -Wall
    check_cflags -Wno-switch
    
    Michael Niedermayer's avatar
    Michael Niedermayer committed
    check_cflags -Wdisabled-optimization
    check_cflags -Wpointer-arith
    check_cflags -Wredundant-decls
    
    check_cflags -Wno-pointer-sign
    
    enabled extra_warnings && check_cflags -Winline
    
    check_ldflags -Wl,--warn-common
    
    if enabled small; then
        check_cflags -Os            # not all compilers support -Os
    
        optimizations="small"
    elif enabled optimizations; then
    
        if test -n "`$cc -v 2>&1 | grep xlc`"; then
    
    # PIC flags for shared library objects where they are needed
    
    Måns Rullgård's avatar
    Måns Rullgård committed
        # LIBOBJFLAGS may have already been set in the OS configuration
        if test -z "$LIBOBJFLAGS" ; then
    
                x86_64|ia64|alpha|sparc*|power*) LIBOBJFLAGS='$(PIC)' ;;
    
    VHOOKCFLAGS="-fPIC"
    
    Diego Biurrun's avatar
    Diego Biurrun committed
    # Find out if the .align argument is a power of two or not.
    
    if test $asmalign_pot = "unknown"; then
    
        disable asmalign_pot
        echo 'asm (".align 3");' | check_cc && enable asmalign_pot
    
    enabled_any $ENCODER_LIST  && enable encoders
    enabled_any $DECODER_LIST  && enable decoders
    enabled_any $MUXER_LIST    && enable muxers
    enabled_any $DEMUXER_LIST  && enable demuxers
    
    enabled_any $PROTOCOL_LIST && enable protocols
    
    enabled_any $BSF_LIST      && enable bsfs
    
    enabled_any $THREADS_LIST  && enable threads
    
    
    check_deps $CONFIG_LIST $HAVE_LIST $DECODER_LIST $ENCODER_LIST $PARSER_LIST \
    
        $BSF_LIST $DEMUXER_LIST $MUXER_LIST $PROTOCOL_LIST
    
    Ramiro Polla's avatar
    Ramiro Polla committed
    enabled libdc1394 && append pkg_requires "libraw1394"
    
    enabled libogg    && append pkg_requires "ogg >= 1.1"
    enabled libtheora && append pkg_requires "theora"
    enabled libvorbis && append pkg_requires "vorbis vorbisenc"
    
    
    Diego Biurrun's avatar
    Diego Biurrun committed
    echo "install prefix            $PREFIX"
    echo "source path               $source_path"
    echo "C compiler                $cc"
    echo "make                      $make"
    
    Diego Biurrun's avatar
    Diego Biurrun committed
    echo ".align is power-of-two    $asmalign_pot"
    
    Diego Biurrun's avatar
    Diego Biurrun committed
    echo "ARCH                      $arch ($cpu)"
    
    if test "$BUILDSUF" != ""; then
    
    Diego Biurrun's avatar
    Diego Biurrun committed
        echo "build suffix              $BUILDSUF"
    
    echo "big-endian                ${bigendian-no}"
    
    if test $arch = "x86_32" -o $arch = "x86_64"; then
    
        echo "MMX enabled               ${mmx-no}"
        echo "CMOV enabled              ${cmov-no}"
        echo "CMOV is fast              ${fast_cmov-no}"
    
        echo "EBX available             ${ebx_available-no}"
        echo "EBP available             ${ebp_available-no}"
    
        echo "ARMv5TE enabled           ${armv5te-no}"
        echo "ARMv6 enabled             ${armv6-no}"
        echo "IWMMXT enabled            ${iwmmxt-no}"
    
        echo "MMI enabled               ${mmi-no}"
    
        echo "AltiVec enabled           ${altivec-no}"
        echo "dcbzl available           ${dcbzl-no}"
    
    echo "gprof enabled             ${gprof-no}"
    echo "debug symbols             ${debug-no}"
    echo "strip symbols             ${dostrip-no}"
    
    echo "optimizations             ${optimizations-no}"
    
    echo "static                    ${static-no}"
    echo "shared                    ${shared-no}"
    echo "postprocessing support    ${pp-no}"
    echo "software scaler enabled   ${swscaler-no}"
    echo "video hooking             ${vhook-no}"
    
        echo "Imlib2 support            ${imlib2-no}"
        echo "FreeType support          ${freetype2-no}"
    
    echo "network support           ${network-no}"
    
        echo "IPv6 support              ${ipv6-no}"
    
    echo "threading support         ${thread_type-no}"
    echo "SDL support               ${sdl-no}"
    
    if enabled sdl_too_old; then
    
    Diego Biurrun's avatar
    Diego Biurrun committed
        echo "-> Your SDL version is too old - please upgrade to have FFplay/SDL support."
    fi
    
    echo "Sun medialib support      ${mlib-no}"
    echo "AVISynth enabled          ${avisynth-no}"
    echo "liba52 support            ${liba52-no}"
    echo "liba52 dlopened           ${liba52bin-no}"
    echo "libamr-nb support         ${libamr_nb-no}"
    echo "libamr-wb support         ${libamr_wb-no}"
    
    Ramiro Polla's avatar
    Ramiro Polla committed
    echo "libdc1394 support         ${libdc1394-no}"
    
    echo "libfaac enabled           ${libfaac-no}"
    echo "libfaad enabled           ${libfaad-no}"
    
    echo "libfaad dlopened          ${libfaadbin-no}"
    
    echo "libgsm enabled            ${libgsm-no}"
    echo "libmp3lame enabled        ${libmp3lame-no}"
    echo "libnut enabled            ${libnut-no}"
    echo "libogg enabled            ${libogg-no}"
    echo "libtheora enabled         ${libtheora-no}"
    echo "libvorbis enabled         ${libvorbis-no}"
    echo "x264 enabled              ${libx264-no}"
    echo "XviD enabled              ${libxvid-no}"
    echo "zlib enabled              ${zlib-no}"
    
    enabled gpl &&
        echo "License: GPL" ||
    
    Måns Rullgård's avatar
    Måns Rullgård committed
        echo "License: LGPL"
    
    Fabrice Bellard's avatar
    Fabrice Bellard committed
    
    
    Diego Biurrun's avatar
    Diego Biurrun committed
    echo "Creating config.mak and config.h..."
    
    Fabrice Bellard's avatar
    Fabrice Bellard committed
    
    
    Diego Biurrun's avatar
    Diego Biurrun committed
    echo "# Automatically generated by configure - do not modify!" > config.mak
    echo "/* Automatically generated by configure - do not modify! */" > $TMPH
    
    echo "#ifndef FFMPEG_CONFIG_H" >> $TMPH
    echo "#define FFMPEG_CONFIG_H" >> $TMPH
    
    Diego Biurrun's avatar
    Diego Biurrun committed
    echo "#define FFMPEG_CONFIGURATION \"$FFMPEG_CONFIGURATION\"" >> $TMPH
    
    Fabrice Bellard's avatar
    Fabrice Bellard committed
    
    
    echo "PREFIX=$PREFIX" >> config.mak
    
    echo "prefix=\$(DESTDIR)\$(PREFIX)" >> config.mak
    
    echo "LIBDIR=\$(DESTDIR)$libdir" >> config.mak
    echo "SHLIBDIR=\$(DESTDIR)$shlibdir" >> config.mak
    echo "INCDIR=\$(DESTDIR)$incdir" >> config.mak
    echo "BINDIR=\$(DESTDIR)$bindir" >> config.mak
    echo "MANDIR=\$(DESTDIR)$mandir" >> config.mak
    
    echo "MAKE=$make" >> config.mak
    
    echo "CC=$cc" >> config.mak
    echo "AR=$ar" >> config.mak
    
    Michael Niedermayer's avatar
    Michael Niedermayer committed
    echo "RANLIB=$ranlib" >> config.mak
    
    echo "LDCONFIG=$LDCONFIG" >> config.mak
    
    echo "LN_S=$ln_s" >> config.mak
    
    enabled dostrip &&
        echo "STRIP=$strip" >> config.mak ||
    
    Måns Rullgård's avatar
    Måns Rullgård committed
        echo "STRIP=echo ignoring strip" >> config.mak
    
    Nick Kurshev's avatar
    Nick Kurshev committed
    echo "OPTFLAGS=$CFLAGS" >> config.mak
    
    echo "VHOOKCFLAGS=$VHOOKCFLAGS">>config.mak
    
    echo "FFSERVERLDFLAGS=$FFSERVERLDFLAGS" >> config.mak
    
    echo "SHFLAGS=$SHFLAGS" >> config.mak
    
    echo "VHOOKSHFLAGS=$VHOOKSHFLAGS" >> config.mak
    
    echo "VHOOKLIBS=$VHOOKLIBS" >> config.mak
    
    echo "LIBOBJFLAGS=$LIBOBJFLAGS" >> config.mak
    
    echo "BUILD_STATIC=$static" >> config.mak
    
    echo "BUILDSUF=$BUILDSUF" >> config.mak
    
    echo "FULLNAME=$FULLNAME" >> config.mak
    
    echo "LIBPREF=$LIBPREF" >> config.mak
    
    echo "LIBSUF=$LIBSUF" >> config.mak
    
    echo "LIBNAME=$LIBNAME" >> config.mak
    
    echo "SLIBPREF=$SLIBPREF" >> config.mak
    
    echo "SLIBSUF=$SLIBSUF" >> config.mak
    echo "EXESUF=$EXESUF" >> config.mak
    
    if enabled bigendian; then
    
      echo "WORDS_BIGENDIAN=yes" >> config.mak
      echo "#define WORDS_BIGENDIAN 1" >> $TMPH
    
      echo "#define __CPU__ 586" >> $TMPH
    
    Fabrice Bellard's avatar
    Fabrice Bellard committed
    fi
    
      echo "SDL_LIBS=`"${SDL_CONFIG}" --libs`" >> config.mak
      echo "SDL_CFLAGS=`"${SDL_CONFIG}" --cflags`" >> config.mak
    
    if enabled texi2html; then
    
    sws_version=`grep '#define LIBSWSCALE_VERSION ' "$source_path/libswscale/swscale.h" | sed 's/[^0-9\.]//g'`
    
    pp_version=`grep '#define LIBPOSTPROC_VERSION ' "$source_path/libpostproc/postprocess.h" | sed 's/[^0-9\.]//g'`
    
    lavc_version=`grep '#define LIBAVCODEC_VERSION ' "$source_path/libavcodec/avcodec.h" | sed 's/[^0-9\.]//g'`
    lavf_version=`grep '#define LIBAVFORMAT_VERSION ' "$source_path/libavformat/avformat.h" | sed 's/[^0-9\.]//g'`
    lavu_version=`grep '#define LIBAVUTIL_VERSION ' "$source_path/libavutil/avutil.h" | sed 's/[^0-9\.]//g'`
    
    
    
    
    Nick Kurshev's avatar
    Nick Kurshev committed
      echo "BUILD_SHARED=yes" >> config.mak
    
      echo "PIC=-fPIC -DPIC" >> config.mak
    
      echo "SPPMAJOR=${pp_version%%.*}" >> config.mak
      echo "SPPVERSION=$pp_version" >> config.mak
    
      echo "LAVCMAJOR=${lavc_version%%.*}" >> config.mak
    
      echo "LAVCVERSION=$lavc_version" >> config.mak
    
      echo "LAVFMAJOR=${lavf_version%%.*}" >> config.mak
    
      echo "LAVFVERSION=$lavf_version" >> config.mak
    
      echo "LAVUMAJOR=${lavu_version%%.*}" >> config.mak
    
      echo "LAVUVERSION=$lavu_version" >> config.mak
    
      echo "SWSMAJOR=${sws_version%%.*}" >> config.mak
      echo "SWSVERSION=$sws_version" >> config.mak
    
      echo "SLIBNAME=${SLIBNAME}" >> config.mak
    
      echo "SLIBNAME_WITH_VERSION=${SLIBNAME_WITH_VERSION}" >> config.mak
      echo "SLIBNAME_WITH_MAJOR=${SLIBNAME_WITH_MAJOR}" >> config.mak
    
      echo "SLIB_EXTRA_CMD=${SLIB_EXTRA_CMD}" >> config.mak
    
      echo "SLIB_INSTALL_EXTRA_CMD=${SLIB_INSTALL_EXTRA_CMD}" >> config.mak
    
      echo "SLIB_UNINSTALL_EXTRA_CMD=${SLIB_UNINSTALL_EXTRA_CMD}" >> config.mak
    
    Nick Kurshev's avatar
    Nick Kurshev committed
    fi
    
    echo "LIB_INSTALL_EXTRA_CMD=${LIB_INSTALL_EXTRA_CMD}" >> config.mak
    
    echo "EXTRALIBS=$extralibs" >> config.mak
    
    print_config ARCH_   $TMPH config.mak $ARCH_LIST
    print_config HAVE_   $TMPH config.mak $HAVE_LIST
    print_config CONFIG_ $TMPH config.mak $CONFIG_LIST   \
                                          $DECODER_LIST  \
                                          $ENCODER_LIST  \
                                          $PARSER_LIST   \
                                          $BSF_LIST      \
                                          $DEMUXER_LIST  \
                                          $MUXER_LIST    \
                                          $PROTOCOL_LIST \
    
    echo "#define restrict $_restrict" >> $TMPH
    
    
    Michael Niedermayer's avatar
    Michael Niedermayer committed
      echo "#define av_always_inline"  >> $TMPH
    
    echo "SRC_PATH=\"$source_path\"" >> config.mak
    echo "SRC_PATH_BARE=$source_path" >> config.mak
    echo "BUILD_ROOT=\"$PWD\"" >> config.mak
    
    # Apparently it's not possible to portably echo a backslash.
    
    enabled asmalign_pot &&
      printf '#define ASMALIGN(ZEROBITS) ".align " #ZEROBITS "\\n\\t"\n' >> $TMPH ||
    
      printf '#define ASMALIGN(ZEROBITS) ".align 1<<" #ZEROBITS "\\n\\t"\n' >> $TMPH
    
    echo "#endif /* FFMPEG_CONFIG_H */" >> $TMPH
    
    
    # Do not overwrite config.h if unchanged to avoid superfluous rebuilds.
    
    cmp -s $TMPH config.h &&
        echo "config.h is unchanged" ||
        mv -f $TMPH config.h
    
    rm -f $TMPO $TMPC $TMPE $TMPS $TMPH
    
    # build tree in object directory if source path is different from current one
    
    if enabled source_path_used; then
    
        DIRS="\
             doc \
             libavcodec \
             libavcodec/alpha \
             libavcodec/armv4l \
             libavcodec/bfin \
             libavcodec/i386 \
             libavcodec/mlib \
             libavcodec/ppc \
    
             libavcodec/sparc \
             libavformat \
    
             libpostproc \
    
             vhook \
             "
        FILES="\
              Makefile \
              common.mak \
    
              doc/texi2pod.pl \
    
              libavcodec/Makefile \
    
              libavformat/Makefile \
    
              libavutil/Makefile \
    
              libpostproc/Makefile \
    
              libswscale/Makefile \
              "
        for dir in $DIRS ; do
                mkdir -p $dir
        done
        for f in $FILES ; do
    
    # build pkg-config files
    
    # FIXME: libdir and includedir are hardcoded and may differ from the real path.
    
    pkgconfig_generate(){
    name=$1