Skip to content
Snippets Groups Projects
configure 81.5 KiB
Newer Older
  • Learn to ignore specific revisions
  •         die "Unknown OS '$target_os'."
    
    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."
    
        enabled $1 || { enabled $2 && die "$2 is $1 and --enable-$1 is not specified."; }
    
    }
    
    die_license_disabled gpl libfaad2
    die_license_disabled gpl libx264
    die_license_disabled gpl libxvid
    die_license_disabled gpl postproc
    die_license_disabled gpl x11grab
    
    
    die_license_disabled nonfree libfaac
    
    die_license_disabled version3 libopencore_amrnb
    die_license_disabled version3 libopencore_amrwb
    
    
    enabled version3 && { enabled gpl && enable gplv3 || enable lgplv3; }
    
    check_deps $ARCH_EXT_LIST
    
    disabled optimizations || check_cflags -fomit-frame-pointer
    
    if enabled pic; then
        add_cppflags -DPIC
        add_cflags   -fPIC
        add_asflags  -fPIC
    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_cc <<EOF && enable 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 attribute_packed
    struct { int x; } __attribute__((packed)) x;
    EOF
    
    check_cc <<EOF || die "endian test failed"
    unsigned int endian = 'B' << 24 | 'I' << 16 | 'G' << 8 | 'E';
    EOF
    od -A n -t x1 $TMPO | grep -q '42 *49 *47 *45' && enable bigendian
    
    
        check_ld <<EOF && enable vfp_args
    __asm__ (".eabi_attribute 28, 1");
    int main(void) { return 0; }
    EOF
    
        # We have to check if pld is a nop and disable it.
        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 neon    && check_asm neon    '"vadd.i16 q0, q0, q0"'
    
    elif enabled mips; then
    
        check_asm loongson '"dmult.g $1, $2, $3"'
        enabled mmi     && check_asm mmi     '"lq $2, 0($2)"'
    
    elif enabled ppc; then
    
        check_asm dcbzl     '"dcbzl 0, 1"'
        check_asm ppc4xx    '"maclhw r10, r11, r12"'
        check_asm xform_asm '"lwzx 0, %y0" :: "Z"(*(int*)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, 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."
    $inc_altivec_h
    int main (void) { (vector int) {1}; return 0; }
    EOF
        fi
    
    elif enabled sparc; then
    
        enabled vis && check_asm vis '"pdist %f0, %f0, %f0"' -mcpu=ultrasparc &&
            add_cflags -mcpu=ultrasparc -mtune=ultrasparc
    
    elif 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 (
    
    Reimar Döffinger's avatar
    Reimar Döffinger committed
        # check whether EBX is available on x86
    
        check_asm ebx_available '""::"b"(0)' &&
            check_asm ebx_available '"":::"%ebx"'
    
        # check whether more than 10 operands are supported
        check_cc <<EOF && enable ten_operands
    int main(void) {
        int x=0;
        __asm__ volatile(
            ""
            :"+&rm"(x), "+&rm"(x), "+&rm"(x), "+&rm"(x), "+&rm"(x), "+&rm"(x)
        );
        return 0;
    }
    EOF
    
    
        # check whether binutils is new enough to compile SSSE3/MMX2
    
        enabled ssse3 && check_asm ssse3 '"pabsw %xmm0, %xmm0"'
    
        enabled mmx2  && check_asm mmx2  '"pmaxub %mm0, %mm1"'
    
    
        check_asm bswap '"bswap %%eax" ::: "%eax"'
    
    Loren Merritt's avatar
    Loren Merritt committed
    
    
        YASMFLAGS="-f $objformat -DARCH_$(toupper $subarch)"
    
    Loren Merritt's avatar
    Loren Merritt committed
        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
    
        disabled yasm || { check_yasm "pabsw xmm0, xmm0" && enable yasm; }
    
    if check_func dlopen; then
        ldl=
    elif check_func dlopen -ldl; then
        ldl=-ldl
    
    # Solaris has nanosleep in -lrt, OpenSolaris no longer needs that
    check_func nanosleep || { check_func nanosleep -lrt && add_extralibs -lrt; }
    
    
    check_func  fork
    check_func  gethrtime
    check_func  getrusage
    
    check_func  inet_aton $network_extralibs
    
    check_func  isatty
    
    check_func  posix_memalign
    
    check_func_headers io.h setmode
    
    check_func_headers lzo/lzo1x.h lzo1x_999_compress
    
    check_func_headers windows.h GetProcessTimes
    
    check_func_headers windows.h VirtualAlloc
    
    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 posix_memalign malloc_aligned &&
         enabled_any $need_memalign ; then
    
        die "Error, no aligned memory allocator but SSE enabled, disable it or use --enable-memalign-hack."
    
    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
    
    Gwenole Beauchesne's avatar
    Gwenole Beauchesne committed
    check_lib va/va.h vaInitialize -lva
    
    Måns Rullgård's avatar
    Måns Rullgård committed
    
    
    check_func llrint
    check_func log2
    check_func lrint
    check_func lrintf
    check_func round
    check_func roundf
    check_func truncf
    
    # these are off by default, so fail if requested and not available
    
    enabled avisynth   && require2 vfw32 "windows.h vfw.h" AVIFileInit -lvfw32
    
    enabled libdirac   && add_cflags $(pkg-config --cflags dirac) &&
    
                          require  libdirac libdirac_decoder/dirac_parser.h dirac_decoder_init $(pkg-config --libs dirac) &&
                          require  libdirac libdirac_encoder/dirac_encoder.h dirac_encoder_init $(pkg-config --libs dirac)
    
    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 libopencore_amrnb  && require libopencore_amrnb opencore-amrnb/interf_dec.h Decoder_Interface_init -lopencore-amrnb -lm
    enabled libopencore_amrwb  && require libopencore_amrwb opencore-amrwb/dec_if.h D_IF_init -lopencore-amrwb -lm
    
    enabled libopenjpeg && require libopenjpeg openjpeg.h opj_version -lopenjpeg
    
    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_encode -lx264 -lm &&
    
                          { check_cpp_condition x264.h "X264_BUILD >= 76" ||
                            die "ERROR: libx264 version must be >= 0.76."; }
    
    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
    
    
    disable sdl_too_old
    disable sdl
    
    SDL_CONFIG="${cross_prefix}sdl-config"
    
    if "${SDL_CONFIG}" --version > /dev/null 2>&1; then
    
        sdl_cflags=$("${SDL_CONFIG}" --cflags)
    
    Måns Rullgård's avatar
    Måns Rullgård committed
        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
    
    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
    
            check_func_headers winsock2.h closesocket -lws2 && \
                network_extralibs="-lws2" || \
            { check_func_headers winsock2.h closesocket -lws2_32 && \
                network_extralibs="-lws2_32"; }
    
            check_type ws2tcpip.h socklen_t
    
    enabled_all network ipv6 && check_ld <<EOF || 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_header sys/videoio.h
    
    check_func_headers "windows.h vfw.h" capCreateCaptureWindow -lvfw32
    
    Ramiro Polla's avatar
    Ramiro Polla committed
    
    
    # check for ioctl_meteor.h, ioctl_bt848.h and alternatives
    
    Ramiro Polla's avatar
    Ramiro Polla committed
    { check_header dev/bktr/ioctl_meteor.h &&
      check_header dev/bktr/ioctl_bt848.h; } ||
    { check_header machine/ioctl_meteor.h &&
      check_header machine/ioctl_bt848.h; } ||
    { check_header dev/video/meteor/ioctl_meteor.h &&
      check_header dev/video/bktr/ioctl_bt848.h; } ||
    check_header dev/ic/bt8xx.h
    
    check_header sys/soundcard.h
    check_header soundcard.h
    
    enabled_any alsa_indev alsa_outdev && check_lib2 alsa/asoundlib.h snd_pcm_htimestamp -lasound
    
    enabled jack_indev && check_lib2 jack/jack.h jack_client_open -ljack
    
    check_header X11/Xlib.h                 &&
    check_header X11/extensions/XShm.h      &&
    check_func XOpenDisplay -lX11           &&
    
    check_func XShmCreateImage -lX11 -lXext
    
    enabled debug && add_cflags -g"$debuglevel" && add_asflags -g"$debuglevel"
    
    
    # add some useful compiler flags if supported
    check_cflags -Wdeclaration-after-statement
    
    check_cflags -Wall
    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
    
    check_cflags -Wcast-qual
    
    check_cflags -Wwrite-strings
    
    enabled extra_warnings && check_cflags -Winline
    
    check_ldflags -Wl,--warn-common
    
    check_ldflags -Wl,--as-needed
    check_ldflags '-Wl,-rpath-link,\$(BUILD_ROOT)/libpostproc -Wl,-rpath-link,\$(BUILD_ROOT)/libswscale -Wl,-rpath-link,\$(BUILD_ROOT)/libavfilter -Wl,-rpath-link,\$(BUILD_ROOT)/libavdevice -Wl,-rpath-link,\$(BUILD_ROOT)/libavformat -Wl,-rpath-link,\$(BUILD_ROOT)/libavcodec -Wl,-rpath-link,\$(BUILD_ROOT)/libavutil'
    
    check_ldflags -Wl,-Bsymbolic
    
    if enabled small; then
        check_cflags -Os            # not all compilers support -Os
    
        optimizations="small"
    elif enabled optimizations; then
    
            add_cflags  -O5
            add_ldflags -O5
    
        elif enabled ccc; then
            add_cflags -fast
    
            add_cflags -O3
    
    check_cflags -fno-math-errno
    
    Måns Rullgård's avatar
    Måns Rullgård committed
        # Just warnings, no remarks
        check_cflags -w1
        # -wd: Disable following warnings
        # 144, 167, 556: -Wno-pointer-sign
        # 10006: ignoring unknown option -fno-signed-zeros
        # 10156: ignoring option '-W'; no argument required
        check_cflags -wd144,167,556,10006,10156
        # 11030: Warning unknown option --as-needed
        # 10156: ignoring option '-export'; no argument required
        check_ldflags -wd10156,11030
        # Allow to compile with optimizations
        check_ldflags -march=$cpu
    
        # icc 11.0 and 11.1 work with ebp_available, but don't pass the test
        enable ebp_available
    
    elif enabled ccc; then
        # disable some annoying warnings
        add_cflags -msg_disable cvtu32to64
        add_cflags -msg_disable embedcomment
        add_cflags -msg_disable needconstext
        add_cflags -msg_disable nomainieee
        add_cflags -msg_disable ptrmismatch1
        add_cflags -msg_disable unreachcode
    
    elif enabled gcc; then
        check_cflags -fno-tree-vectorize
    
        add_cflags  -p
        add_ldflags -p
    
    Diego Biurrun's avatar
    Diego Biurrun committed
    # Find out if the .align argument is a power of two or not.
    
    check_asm asmalign_pot '".align 3"'
    
    enabled_any $DECODER_LIST      && enable decoders
    enabled_any $ENCODER_LIST      && enable encoders
    
    enabled_any $HWACCEL_LIST      && enable hwaccels
    
    enabled_any $BSF_LIST          && enable bsfs
    enabled_any $DEMUXER_LIST      && enable demuxers
    enabled_any $MUXER_LIST        && enable muxers
    
    enabled_any $INDEV_LIST        && enable indevs
    enabled_any $OUTDEV_LIST       && enable outdevs
    
    enabled_any $PROTOCOL_LIST     && enable protocols
    
    enabled_any $THREADS_LIST      && enable threads
    
    check_deps $CONFIG_LIST       \
    
               $PARSER_LIST       \
               $BSF_LIST          \
               $DEMUXER_LIST      \
               $MUXER_LIST        \
    
    echo "install prefix            $prefix"
    
    Diego Biurrun's avatar
    Diego Biurrun committed
    echo "source path               $source_path"
    echo "C compiler                $cc"
    
    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 "$build_suffix" != ""; then
        echo "build suffix              $build_suffix"
    
    if test "$extra_version" != ""; then
        echo "version string suffix     $extra_version"
    fi
    
    echo "big-endian                ${bigendian-no}"
    
    echo "runtime cpu detection     ${runtime_cpudetect-no}"
    
        echo "yasm                      ${yasm-no}"
    
        echo "MMX enabled               ${mmx-no}"
    
        echo "MMX2 enabled              ${mmx2-no}"
    
        echo "3DNow! extended enabled   ${amd3dnowext-no}"
    
        echo "SSE enabled               ${sse-no}"
    
        echo "SSSE3 enabled             ${ssse3-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 "10 operands supported     ${ten_operands-no}"
    
        echo "ARMv5TE enabled           ${armv5te-no}"
        echo "ARMv6 enabled             ${armv6-no}"
    
        echo "ARMv6T2 enabled           ${armv6t2-no}"
    
        echo "ARM VFP enabled           ${armvfp-no}"
    
        echo "IWMMXT enabled            ${iwmmxt-no}"
    
        echo "NEON enabled              ${neon-no}"
    
        echo "MMI enabled               ${mmi-no}"
    
        echo "AltiVec enabled           ${altivec-no}"
    
        echo "PPC 4xx optimizations     ${ppc4xx-no}"
    
        echo "dcbzl available           ${dcbzl-no}"
    
        echo "performance report        ${powerpc_perf-no}"
    fi
    if enabled sparc; then
        echo "VIS enabled               ${vis-no}"
    
    echo "gprof enabled             ${gprof-no}"
    echo "debug symbols             ${debug-no}"
    
    echo "strip symbols             ${stripping-no}"
    
    echo "optimizations             ${optimizations-no}"
    
    echo "static                    ${static-no}"
    echo "shared                    ${shared-no}"
    
    echo "postprocessing support    ${postproc-no}"
    
    echo "filters using lavformat   ${avfilter_lavf-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}"
    
    Ramiro Polla's avatar
    Ramiro Polla committed
    echo "libdc1394 support         ${libdc1394-no}"
    
    echo "libdirac enabled          ${libdirac-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 "libopencore-amrnb support ${libopencore_amrnb-no}"
    echo "libopencore-amrwb support ${libopencore_amrwb-no}"
    
    echo "libopenjpeg enabled       ${libopenjpeg-no}"
    
    echo "libschroedinger enabled   ${libschroedinger-no}"
    
    echo "libspeex enabled          ${libspeex-no}"
    
    echo "libtheora enabled         ${libtheora-no}"
    echo "libvorbis enabled         ${libvorbis-no}"
    
    echo "libx264 enabled           ${libx264-no}"
    echo "libxvid enabled           ${libxvid-no}"
    
    echo "zlib enabled              ${zlib-no}"
    
    echo "bzlib enabled             ${bzlib-no}"
    
    Fabrice Bellard's avatar
    Fabrice Bellard committed
    
    
    for type in decoder encoder hwaccel parser demuxer muxer protocol filter bsf indev outdev; do
    
        echo "Enabled ${type}s:"
    
        eval list=\$$(toupper $type)_LIST
    
        for part in $list; do
    
            enabled $part && echo ${part%_*}
        done | sort | pr -3 -t
        echo
    
    license="LGPL version 2.1 or later"
    
    if enabled nonfree; then
    
        license="nonfree and unredistributable"
    
    elif enabled gplv3; then
        license="GPL version 3 or later"
    elif enabled lgplv3; then
        license="LGPL version 3 or later"
    
    elif enabled gpl; then
    
        license="GPL version 2 or later"
    
    echo "Creating config.mak and config.h..."
    
    
    Diego Biurrun's avatar
    Diego Biurrun committed
    echo "# Automatically generated by configure - do not modify!" > config.mak
    
    echo "ifndef FFMPEG_CONFIG_MAK" >> config.mak
    echo "FFMPEG_CONFIG_MAK=1" >> config.mak
    
    
    echo "FFMPEG_CONFIGURATION=$FFMPEG_CONFIGURATION" >> config.mak
    
    echo "prefix=$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 "DATADIR=\$(DESTDIR)$datadir" >> config.mak
    
    echo "MANDIR=\$(DESTDIR)$mandir" >> config.mak
    
    echo "SRC_PATH=\"$source_path\"" >> config.mak
    echo "SRC_PATH_BARE=$source_path" >> config.mak
    echo "BUILD_ROOT=\"$PWD\"" >> config.mak
    
    echo "CC=$cc" >> config.mak
    
    echo "AS=$as" >> config.mak
    
    echo "LD=$ld" >> config.mak
    
    echo "DEPCC=$dep_cc" >> config.mak
    
    Loren Merritt's avatar
    Loren Merritt committed
    echo "YASM=$yasmexe" >> config.mak
    
    echo "AR=$ar" >> config.mak
    
    Michael Niedermayer's avatar
    Michael Niedermayer committed
    echo "RANLIB=$ranlib" >> config.mak
    
    echo "LN_S=$ln_s" >> config.mak
    
        echo "STRIP=$strip" >> config.mak ||
    
    Måns Rullgård's avatar
    Måns Rullgård committed
        echo "STRIP=echo ignoring strip" >> config.mak
    
    echo "CPPFLAGS=$CPPFLAGS" >> config.mak
    
    echo "CFLAGS=$CFLAGS" >> config.mak
    
    echo "ASFLAGS=$ASFLAGS" >> config.mak
    
    echo "CC_O=$CC_O" >> config.mak
    
    echo "FFSERVERLDFLAGS=$FFSERVERLDFLAGS" >> config.mak
    
    echo "SHFLAGS=$SHFLAGS" >> config.mak
    
    Loren Merritt's avatar
    Loren Merritt committed
    echo "YASMFLAGS=$YASMFLAGS" >> config.mak
    
    echo "BUILDSUF=$build_suffix" >> 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
    
    echo "EXTRA_VERSION=$extra_version" >> config.mak
    
    echo "DEPFLAGS=$DEPFLAGS" >> config.mak
    
    echo "CCDEP=$CCDEP" >> config.mak
    echo "ASDEP=$ASDEP" >> config.mak
    echo "CC_DEPFLAGS=$CC_DEPFLAGS" >> config.mak
    echo "AS_DEPFLAGS=$AS_DEPFLAGS" >> config.mak
    
    echo "HOSTCC=$host_cc" >> config.mak
    echo "HOSTCFLAGS=$host_cflags" >> config.mak
    
    echo "HOSTEXESUF=$HOSTEXESUF" >> config.mak
    
    echo "HOSTLDFLAGS=$host_ldflags" >> config.mak
    echo "HOSTLIBS=$host_libs" >> config.mak
    
    echo "TARGET_EXEC=$target_exec" >> config.mak
    echo "TARGET_PATH=$target_path" >> config.mak
    
        echo "SDL_LIBS=$("${SDL_CONFIG}" --libs)" >> config.mak
        echo "SDL_CFLAGS=$("${SDL_CONFIG}" --cflags)" >> config.mak
    
    if enabled texi2html; then
    
    get_version(){
        name=$1
        file=$source_path/$2
    
        eval $(grep "#define ${name}_VERSION_M" "$file" | awk '{ print $2"="$3 }')
        eval ${name}_VERSION=\$${name}_VERSION_MAJOR.\$${name}_VERSION_MINOR.\$${name}_VERSION_MICRO
    
        lcname=$(tolower $name)
        eval echo "${lcname}_VERSION=\$${name}_VERSION" >> config.mak
        eval echo "${lcname}_VERSION_MAJOR=\$${name}_VERSION_MAJOR" >> config.mak
    
    get_version LIBSWSCALE  libswscale/swscale.h
    get_version LIBPOSTPROC libpostproc/postprocess.h
    get_version LIBAVCODEC  libavcodec/avcodec.h
    get_version LIBAVDEVICE libavdevice/avdevice.h
    get_version LIBAVFORMAT libavformat/avformat.h
    get_version LIBAVUTIL   libavutil/avutil.h
    
    get_version LIBAVFILTER libavfilter/avfilter.h
    
        echo "LIBTARGET=${LIBTARGET}" >> 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_CREATE_DEF_CMD=${SLIB_CREATE_DEF_CMD}" >> 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
    
    
    echo "/* Automatically generated by configure - do not modify! */" > $TMPH
    echo "#ifndef FFMPEG_CONFIG_H" >> $TMPH
    echo "#define FFMPEG_CONFIG_H" >> $TMPH
    echo "#define FFMPEG_CONFIGURATION \"$(c_escape $FFMPEG_CONFIGURATION)\"" >> $TMPH
    echo "#define FFMPEG_DATADIR \"$(eval c_escape $datadir)\"" >> $TMPH
    
    
    echo "#define CC_TYPE \"$cc_type\"" >> $TMPH
    echo "#define CC_VERSION $cc_version" >> $TMPH
    
    echo "#define restrict $_restrict" >> $TMPH
    
    if enabled small || disabled optimizations; then
        echo "#define av_always_inline"  >> $TMPH
    fi
    
    
    # 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 "#define EXTERN_PREFIX \"${extern_prefix}\"" >> $TMPH
    
    
    print_config ARCH_   $TMPH config.mak $ARCH_LIST
    print_config HAVE_   $TMPH config.mak $HAVE_LIST
    
    print_config CONFIG_ $TMPH config.mak $CONFIG_LIST       \
    
                                          $PARSER_LIST       \
                                          $BSF_LIST          \
                                          $DEMUXER_LIST      \
                                          $MUXER_LIST        \
    
    echo "#endif /* FFMPEG_CONFIG_H */" >> $TMPH
    
    echo "endif # FFMPEG_CONFIG_MAK" >> config.mak
    
    Diego Biurrun's avatar
    Diego Biurrun committed
    # Do not overwrite an unchanged config.h to avoid superfluous rebuilds.
    
    cmp -s $TMPH config.h &&
        echo "config.h is unchanged" ||
        mv -f $TMPH config.h
    
    # build tree in object directory if source path is different from current one
    
    if enabled source_path_used; then
    
        DIRS="
            doc
            libavcodec
            libavcodec/$arch
            libavdevice
            libavfilter
            libavformat
            libavutil
            libavutil/$arch
            libpostproc
            libswscale
            libswscale/$arch
            tests
            tools
        "
        FILES="
            Makefile
            common.mak
            subdir.mak
            doc/texi2pod.pl
            libavcodec/Makefile
            libavdevice/Makefile
            libavfilter/Makefile
            libavformat/Makefile
            libavutil/Makefile
            libpostproc/Makefile
            libswscale/Makefile
        "
    
        for dir in $DIRS ; do
    
        done
        for f in $FILES ; do
    
    # build pkg-config files
    
    pkgconfig_generate(){
    name=$1
    
    shortname=${name#lib}${build_suffix}
    
    comment=$2
    version=$3
    libs=$4
    requires=$5
    
    exec_prefix=\${prefix}
    
    Name: $name
    Description: $comment
    Version: $version
    
    Requires: $(enabled shared || echo $requires)
    
    Requires.private: $(enabled shared && echo $requires)
    
    Libs: -L\${libdir} -l${shortname} $(enabled shared || echo $libs)
    
    Libs.private: $(enabled shared && echo $libs)
    
    Cflags: -I\${includedir}
    
    cat <<EOF > $name/$name-uninstalled.pc
    
    libdir=\${pcfiledir}
    
    includedir=${source_path}
    
    Name: $name
    Description: $comment
    Version: $version
    Requires: $requires
    
    Libs: \${libdir}/${LIBPREF}${shortname}${LIBSUF} $libs
    
    pkgconfig_generate libavutil "FFmpeg utility library" "$LIBAVUTIL_VERSION"
    
    pkgconfig_generate libavcodec "FFmpeg codec library" "$LIBAVCODEC_VERSION" "$extralibs" "libavutil = $LIBAVUTIL_VERSION"
    pkgconfig_generate libavformat "FFmpeg container format library" "$LIBAVFORMAT_VERSION" "$extralibs" "libavcodec = $LIBAVCODEC_VERSION"
    pkgconfig_generate libavdevice "FFmpeg device handling library" "$LIBAVDEVICE_VERSION" "$extralibs" "libavformat = $LIBAVFORMAT_VERSION"
    
    enabled avfilter &&
    
        pkgconfig_generate libavfilter "FFmpeg video filtering library" "$LIBAVFILTER_VERSION" "$extralibs" "libavutil = $LIBAVUTIL_VERSION"
    
    enabled postproc &&
    
        pkgconfig_generate libpostproc "FFmpeg post processing library" "$LIBPOSTPROC_VERSION"
    
    pkgconfig_generate libswscale "FFmpeg image rescaling library" "$LIBSWSCALE_VERSION" "" "libavutil = $LIBAVUTIL_VERSION"