Skip to content
Snippets Groups Projects
configure 152 KiB
Newer Older
  • Learn to ignore specific revisions
  • 
        map 'enabled_any ${v}_external ${v}_inline || disable $v' $ARCH_EXT_LIST_ARM
    
    elif enabled alpha; then
    
    
        check_cflags -mieee
    
    elif enabled arm; then
    
        enabled msvc && check_cpp_condition stddef.h "defined _M_ARMT" && enable thumb
    
        check_cpp_condition stddef.h "defined __thumb__" && enable_weak thumb
    
        enabled thumb && check_cflags -mthumb || check_cflags -marm
    
        if     check_cpp_condition stddef.h "defined __ARM_PCS_VFP"; then
            enable vfp_args
    
        elif check_cpp_condition stddef.h "defined _M_ARM_FP && _M_ARM_FP >= 30"; then
            enable vfp_args
    
        elif ! check_cpp_condition stddef.h "defined __ARM_PCS || defined __SOFTFP__"; then
            case "${cross_prefix:-$cc}" in
                *hardfloat*)         enable vfp_args;   fpabi=vfp ;;
                *) check_ld <<EOF && enable vfp_args && fpabi=vfp || fpabi=soft ;;
    
    __asm__ (".eabi_attribute 28, 1");
    int main(void) { return 0; }
    EOF
    
            esac
            warn "Compiler does not indicate floating-point ABI, guessing $fpabi."
        fi
    
        enabled armv5te && check_insn armv5te 'qadd r0, r0, r0'
        enabled armv6   && check_insn armv6   'sadd16 r0, r0, r0'
        enabled armv6t2 && check_insn armv6t2 'movt r0, #0'
        enabled neon    && check_insn neon    'vadd.i16 q0, q0, q0'
    
        enabled vfp     && check_insn vfp     'fadds s0, s0, s0'
    
        enabled vfpv3   && check_insn vfpv3   'vmov.f32 s0, #1.0'
    
    
        [ $target_os = linux ] || [ $target_os = android ] ||
    
            map 'enabled_any ${v}_external ${v}_inline || disable $v' \
                $ARCH_EXT_LIST_ARM
    
        check_inline_asm asm_mod_q '"add r0, %Q0, %R0" :: "r"((long long)0)'
    
        check_as <<EOF && enable as_dn_directive
    ra .dn d0.i16
    .unreq ra
    
    EOF
    
        # llvm's integrated assembler supports .object_arch from llvm 3.5
        [ "$objformat" = elf ] && check_as <<EOF && enable as_object_arch
    .object_arch armv4
    
        [ $target_os != win32 ] && enabled_all armv6t2 shared !pic && enable_weak_pic
    
    elif enabled mips; then
    
        check_inline_asm loongson '"dmult.g $1, $2, $3"'
    
    elif enabled parisc; then
    
        if enabled gcc; then
            case $($cc -dumpversion) in
                4.[3-8].*) check_cflags -fno-optimize-sibling-calls ;;
            esac
        fi
    
    
    elif enabled ppc; then
    
        enable local_aligned_8 local_aligned_16
    
    
        check_inline_asm dcbzl     '"dcbzl 0, %0" :: "r"(0)'
        check_inline_asm ibm_asm   '"add 0, 0, 0"'
        check_inline_asm ppc4xx    '"maclhw r10, r11, r12"'
        check_inline_asm xform_asm '"lwzx %1, %y0" :: "Z"(*(int*)0), "r"(0)'
    
    
        # AltiVec flags: The FSF version of GCC differs from the Apple version
        if enabled altivec; then
            check_cflags -maltivec -mabi=altivec &&
            { check_header altivec.h && inc_altivec_h="#include <altivec.h>" ; } ||
            check_cflags -faltivec
    
            # check if our compiler supports Motorola AltiVec C API
            check_cc <<EOF || disable altivec
    $inc_altivec_h
    int main(void) {
    
        vector signed int v1 = (vector signed int) { 0 };
        vector signed int v2 = (vector signed int) { 1 };
        v1 = vec_add(v1, v2);
    
            enabled altivec || warn "Altivec disabled, possibly missing --cpu flag"
    
        if enabled vsx; then
            check_cflags -mvsx &&
            check_builtin vec_vsx_ld "altivec.h" "__builtin_vec_vsx_ld" || disable vsx
        fi
    
        if enabled power8; then
            check_cpp_condition "altivec.h" "defined(_ARCH_PWR8)" || disable power8
        fi
    
    
    elif enabled x86; then
    
        check_builtin rdtsc    intrin.h   "__rdtsc()"
        check_builtin mm_empty mmintrin.h "_mm_empty()"
    
        enable local_aligned_8 local_aligned_16
    
    
        # check whether EBP is available on x86
        # As 'i' is stored on the stack, this program will crash
        # if the base pointer is used to access it because the
        # base pointer is cleared in the inline assembly code.
    
        check_exec_crash <<EOF && enable ebp_available
    
    volatile int i=0;
    __asm__ volatile ("xorl %%ebp, %%ebp" ::: "%ebp");
    return i;
    
    Reimar Döffinger's avatar
    Reimar Döffinger committed
        # check whether EBX is available on x86
    
        check_inline_asm ebx_available '""::"b"(0)' &&
            check_inline_asm ebx_available '"":::"%ebx"'
    
        # check whether xmm clobbers are supported
    
        check_inline_asm xmm_clobbers '"":::"%xmm0"'
    
        # check whether binutils is new enough to compile SSSE3/MMXEXT
    
        enabled ssse3  && check_inline_asm ssse3_inline  '"pabsw %xmm0, %xmm0"'
        enabled mmxext && check_inline_asm mmxext_inline '"pmaxub %mm0, %mm1"'
    
            if check_cmd $yasmexe --version; then
                enabled x86_64 && yasm_extra="-m amd64"
                yasm_debug="-g dwarf2"
            elif check_cmd nasm -v; then
                yasmexe=nasm
                yasm_debug="-g -F dwarf"
                enabled x86_64 && test "$objformat" = elf && objformat=elf64
            fi
    
            YASMFLAGS="-f $objformat $yasm_extra"
            enabled pic               && append YASMFLAGS "-DPIC"
            test -n "$extern_prefix"  && append YASMFLAGS "-DPREFIX"
            case "$objformat" in
                elf*) enabled debug && append YASMFLAGS $yasm_debug ;;
            esac
    
    
            check_yasm "movbe ecx, [5]" && enable yasm ||
                die "yasm/nasm not found or too old. Use --disable-yasm for a crippled build."
    
            check_yasm "vpmacsdd xmm0, xmm1, xmm2, xmm3" || disable xop_external
    
            check_yasm "vfmadd132ps ymm0, ymm1, ymm2"    || disable fma3_external
    
            check_yasm "vfmaddps ymm0, ymm1, ymm2, ymm3" || disable fma4_external
    
            check_yasm "CPU amdnop" || disable cpunop
    
        case "$cpu" in
            athlon*|opteron*|k8*|pentium|pentium-mmx|prescott|nocona|atom|geode)
                disable fast_clz
            ;;
        esac
    
    
    check_code cc arm_neon.h "int16x8_t test = vdupq_n_s16(0)" && enable intrinsics_neon
    
    check_ldflags -Wl,--as-needed
    
    
    if check_func dlopen; then
        ldl=
    elif check_func dlopen -ldl; then
        ldl=-ldl
    
        check_func getaddrinfo $network_extralibs
        check_func getservbyport $network_extralibs
        check_func inet_aton $network_extralibs
    
    
        check_type netdb.h "struct addrinfo"
    
        check_type netinet/in.h "struct group_source_req" -D_BSD_SOURCE
        check_type netinet/in.h "struct ip_mreq_source" -D_BSD_SOURCE
    
        check_type netinet/in.h "struct ipv6_mreq" -D_DARWIN_C_SOURCE
    
        check_type poll.h "struct pollfd"
    
        check_type netinet/sctp.h "struct sctp_event_subscribe"
    
        check_struct "sys/types.h sys/socket.h" "struct sockaddr" sa_len
        check_type netinet/in.h "struct sockaddr_in6"
        check_type "sys/types.h sys/socket.h" "struct sockaddr_storage"
        check_type "sys/types.h sys/socket.h" socklen_t
    
    
        # Prefer arpa/inet.h over winsock2
        if check_header arpa/inet.h ; then
            check_func closesocket
        elif check_header winsock2.h ; then
    
            check_func_headers winsock2.h closesocket -lws2 &&
                network_extralibs="-lws2" ||
            { check_func_headers winsock2.h closesocket -lws2_32 &&
    
                network_extralibs="-lws2_32"; } || disable winsock2_h network
    
            check_func_headers ws2tcpip.h getaddrinfo $network_extralibs
    
            check_type ws2tcpip.h socklen_t
            check_type ws2tcpip.h "struct addrinfo"
    
            check_type ws2tcpip.h "struct group_source_req"
            check_type ws2tcpip.h "struct ip_mreq_source"
    
            check_type ws2tcpip.h "struct ipv6_mreq"
    
            check_type winsock2.h "struct pollfd"
    
            check_struct winsock2.h "struct sockaddr" sa_len
    
            check_type ws2tcpip.h "struct sockaddr_in6"
            check_type ws2tcpip.h "struct sockaddr_storage"
        else
            disable network
        fi
    fi
    
    
    check_builtin atomic_cas_ptr atomic.h "void **ptr; void *oldval, *newval; atomic_cas_ptr(ptr, oldval, newval)"
    check_builtin machine_rw_barrier mbarrier.h "__machine_rw_barrier()"
    check_builtin MemoryBarrier windows.h "MemoryBarrier()"
    check_builtin sync_val_compare_and_swap "" "int *ptr; int oldval, newval; __sync_val_compare_and_swap(ptr, oldval, newval)"
    
    check_func_headers malloc.h _aligned_malloc     && enable aligned_malloc
    check_func  ${malloc_prefix}memalign            && enable memalign
    check_func  ${malloc_prefix}posix_memalign      && enable posix_memalign
    
    check_cpp_condition unistd.h "defined(_POSIX_MONOTONIC_CLOCK)" &&
    
        check_func_headers time.h clock_gettime || { check_func_headers time.h clock_gettime -lrt && add_extralibs -lrt && LIBRT="-lrt"; }
    
    Måns Rullgård's avatar
    Måns Rullgård committed
    check_func  fcntl
    
    check_func  gettimeofday
    
    check_func  isatty
    
    check_func  mach_absolute_time
    
    check_func  mprotect
    
    # Solaris has nanosleep in -lrt, OpenSolaris no longer needs that
    
    check_func_headers time.h nanosleep || { check_func_headers time.h nanosleep -lrt && add_extralibs -lrt; }
    
    check_func  sched_getaffinity
    
    Måns Rullgård's avatar
    Måns Rullgård committed
    check_func  setrlimit
    
    check_func  strerror_r
    
    check_func  usleep
    
    check_func_headers io.h setmode
    
    check_func_headers stdlib.h getenv
    
    
    check_func_headers windows.h CoTaskMemFree -lole32
    
    check_func_headers windows.h GetProcessAffinityMask
    
    check_func_headers windows.h GetProcessTimes
    
    check_func_headers windows.h GetSystemTimeAsFileTime
    
    check_func_headers windows.h LoadLibrary
    
    check_func_headers windows.h MapViewOfFile
    
    check_func_headers windows.h SetConsoleTextAttribute
    
    check_func_headers windows.h Sleep
    
    check_func_headers windows.h VirtualAlloc
    
    check_struct windows.h "CONDITION_VARIABLE" Ptr
    
    check_header dlfcn.h
    
    check_header dxva.h
    
    Laurent Aimar's avatar
    Laurent Aimar committed
    check_header dxva2api.h
    
    check_header io.h
    
    check_header mach/mach_time.h
    
    check_header malloc.h
    
    check_header sys/resource.h
    
    check_header sys/time.h
    
    Luca Barbato's avatar
    Luca Barbato committed
    check_header sys/un.h
    
    check_header unistd.h
    
    check_header vdpau/vdpau.h
    check_header vdpau/vdpau_x11.h
    
    check_header VideoDecodeAcceleration/VDADecoder.h
    
    check_header windows.h
    
    check_header X11/extensions/XvMClib.h
    
    check_lib2 "windows.h shellapi.h" CommandLineToArgvW -lshell32
    check_lib2 "windows.h wincrypt.h" CryptGenRandom -ladvapi32
    check_lib2 "windows.h psapi.h" GetProcessMemoryInfo -lpsapi
    
    check_struct "sys/time.h sys/resource.h" "struct rusage" ru_maxrss
    
    
    check_type "windows.h dxva.h" "DXVA_PicParams_HEVC" -DWINAPI_FAMILY=WINAPI_FAMILY_DESKTOP_APP -D_CRT_BUILD_DESKTOP_APP=0
    
    check_type "windows.h d3d11.h" "ID3D11VideoDecoder"
    
    check_type "d3d9.h dxva2api.h" DXVA2_ConfigPictureDecode -D_WIN32_WINNT=0x0602
    
    if ! disabled w32threads && ! enabled pthreads; then
    
        check_func_headers "windows.h process.h" _beginthreadex &&
            enable w32threads || disable w32threads
    
    # check for some common methods of building with pthread support
    # do this before the optional library checks as some of them require pthreads
    
    if ! disabled pthreads && ! enabled w32threads; then
        enable pthreads
    
        if check_func pthread_join -pthread; then
    
    Måns Rullgård's avatar
    Måns Rullgård committed
            add_cflags -pthread
    
        elif check_func pthread_join -pthreads; then
    
    Måns Rullgård's avatar
    Måns Rullgård committed
            add_cflags -pthreads
    
        elif check_func pthread_join -lpthreadGC2; then
    
            add_extralibs -lpthreadGC2
    
        elif check_lib pthread.h pthread_join -lpthread; then
            :
        elif ! check_func pthread_join; then
    
    disabled  zlib || check_lib   zlib.h      zlibVersion -lz   || disable  zlib
    disabled bzlib || check_lib2 bzlib.h BZ2_bzlibVersion -lbz2 || disable bzlib
    
    
    check_lib math.h sin -lm && LIBM="-lm"
    
    enabled vaapi && require vaapi va/va.h vaInitialize -lva
    
    Måns Rullgård's avatar
    Måns Rullgård committed
    
    
    atan2f_args=2
    ldexpf_args=2
    powf_args=2
    
    
    for func in $MATH_FUNCS; do
    
        eval check_mathfunc $func \${${func}_args:-1}
    
    # these are off by default, so fail if requested and not available
    
    enabled avisynth          && { check_lib2 "avisynth/avisynth_c.h windows.h" LoadLibrary ||
                                   check_lib2 "avxsynth/avxsynth_c.h dlfcn.h" dlopen -ldl   ||
    
    d s's avatar
    d s committed
                                   die "ERROR: LoadLibrary/dlopen not found, or avisynth header not found"; }
    
    enabled frei0r            && { check_header frei0r.h || die "ERROR: frei0r.h header not found"; }
    enabled gnutls            && require_pkg_config gnutls gnutls/gnutls.h gnutls_global_init
    
    enabled libbs2b           && require_pkg_config libbs2b bs2b.h bs2b_open
    
    enabled libdcadec         && require libdcadec libdcadec/dca_context.h dcadec_context_create -ldcadec
    
    enabled libfaac           && require2 libfaac "stdint.h faac.h" faacEncGetVersion -lfaac
    
    enabled libfdk_aac        && require_pkg_config fdk-aac "fdk-aac/aacenc_lib.h" aacEncOpen
    
    enabled libfontconfig     && require_pkg_config fontconfig "fontconfig/fontconfig.h" FcInit
    
    enabled libfreetype       && require_pkg_config freetype2 "ft2build.h FT_FREETYPE_H" FT_Init_FreeType
    
    enabled libgsm            && { for gsm_hdr in "gsm.h" "gsm/gsm.h"; do
                                       check_lib "${gsm_hdr}" gsm_create -lgsm && break;
                                   done || die "ERROR: libgsm not found"; }
    enabled libilbc           && require libilbc ilbc.h WebRtcIlbcfix_InitDecode -lilbc
    
    enabled libmfx            && require_pkg_config libmfx "mfx/mfxvideo.h" MFXInit
    
    enabled libmp3lame        && require "libmp3lame >= 3.98.3" lame/lame.h lame_set_VBR_quality -lmp3lame
    enabled libopencore_amrnb && require libopencore_amrnb opencore-amrnb/interf_dec.h Decoder_Interface_init -lopencore-amrnb
    enabled libopencore_amrwb && require libopencore_amrwb opencore-amrwb/dec_if.h D_IF_init -lopencore-amrwb
    enabled libopencv         && require_pkg_config opencv opencv/cv.h cvCreateImageHeader
    
    enabled libopenh264       && require_pkg_config openh264 wels/codec_api.h WelsGetCodecVersion
    
    enabled libopenjpeg       && { { check_header openjpeg.h && check_lib2 openjpeg.h opj_version -lopenjpeg -DOPJ_STATIC; } ||
                                   { require_pkg_config libopenjpeg1 openjpeg.h opj_version -DOPJ_STATIC; } }
    
    enabled libopus           && require_pkg_config opus opus_multistream.h opus_multistream_decoder_create
    enabled libpulse          && require_pkg_config libpulse-simple pulse/simple.h pa_simple_new
    enabled librtmp           && require_pkg_config librtmp librtmp/rtmp.h RTMP_Socket
    enabled libschroedinger   && require_pkg_config schroedinger-1.0 schroedinger/schro.h schro_init
    
    enabled libsnappy         && require snappy snappy-c.h snappy_compress -lsnappy
    
    enabled libspeex          && require_pkg_config speex speex/speex.h speex_decoder_init -lspeex
    
    enabled libtheora         && require libtheora theora/theoraenc.h th_info_init -ltheoraenc -ltheoradec -logg
    
    enabled libtwolame        && require libtwolame twolame.h twolame_init -ltwolame
    
    enabled libvo_aacenc      && require libvo_aacenc vo-aacenc/voAAC.h voGetAACEncAPI -lvo-aacenc
    enabled libvo_amrwbenc    && require libvo_amrwbenc vo-amrwbenc/enc_if.h E_IF_init -lvo-amrwbenc
    enabled libvorbis         && require libvorbis vorbis/vorbisenc.h vorbis_info_init -lvorbisenc -lvorbis -logg
    
    enabled libvpx            && require_pkg_config "vpx >= 1.3.0" vpx/vpx_codec.h vpx_codec_version && {
        enabled libvpx_vp8_decoder && {
            check_pkg_config vpx "vpx/vpx_decoder.h vpx/vp8dx.h" vpx_codec_vp8_dx ||
                disable libvpx_vp8_decoder;
        }
        enabled libvpx_vp8_encoder && {
            check_pkg_config vpx "vpx/vpx_encoder.h vpx/vp8cx.h" vpx_codec_vp8_cx ||
                disable libvpx_vp8_encoder;
        }
        enabled libvpx_vp9_decoder && {
            check_pkg_config vpx "vpx/vpx_decoder.h vpx/vp8dx.h" vpx_codec_vp9_dx ||
                disable libvpx_vp9_decoder;
        }
        enabled libvpx_vp9_encoder && {
            check_pkg_config vpx "vpx/vpx_encoder.h vpx/vp8cx.h" vpx_codec_vp9_cx ||
                disable libvpx_vp9_encoder;
        }
        if disabled_all libvpx_vp8_decoder libvpx_vp9_decoder libvpx_vp8_encoder libvpx_vp9_encoder; then
            die "libvpx enabled but no supported decoders found"
        fi
    }
    
    enabled libwavpack        && require libwavpack wavpack/wavpack.h WavpackOpenFileOutput  -lwavpack
    
    Justin Ruggles's avatar
    Justin Ruggles committed
    enabled libwebp           && require_pkg_config libwebp webp/encode.h WebPGetEncoderVersion
    
    enabled libx264           && require_pkg_config x264 "stdint.h x264.h" x264_encoder_encode &&
    
                                 { check_cpp_condition x264.h "X264_BUILD >= 118" ||
    
                                   die "ERROR: libx264 version must be >= 0.118."; } &&
                                 { check_cpp_condition x264.h "X264_MPEG2" &&
                                   enable libx262; }
    
    enabled libx265           && require_pkg_config x265 x265.h x265_api_get &&
    
                                 { check_cpp_condition x265.h "X265_BUILD >= 57" ||
                                   die "ERROR: libx265 version must be >= 57."; }
    
    enabled libxavs           && require libxavs xavs.h xavs_encoder_encode -lxavs
    enabled libxvid           && require libxvid xvid.h xvid_global -lxvidcore
    
    enabled mmal              && { check_lib interface/mmal/mmal.h mmal_port_connect -lmmal_core -lmmal_util -lmmal_vc_client -lbcm_host ||
                                    { ! enabled cross_compile && {
                                        add_cflags -isystem/opt/vc/include/ -isystem/opt/vc/include/interface/vmcs_host/linux -isystem/opt/vc/include/interface/vcos/pthreads -fgnu89-inline ;
                                        add_extralibs -L/opt/vc/lib/ -lmmal_core -lmmal_util -lmmal_vc_client -lbcm_host ;
                                        check_lib interface/mmal/mmal.h mmal_port_connect ; }
                                    check_lib interface/mmal/mmal.h mmal_port_connect ; } ||
                                   die "ERROR: mmal not found"; }
    
    enabled openssl           && { check_lib openssl/ssl.h SSL_library_init -lssl -lcrypto ||
                                   check_lib openssl/ssl.h SSL_library_init -lssl32 -leay32 ||
                                   check_lib openssl/ssl.h SSL_library_init -lssl -lcrypto -lws2_32 -lgdi32 ||
                                   die "ERROR: openssl not found"; }
    
    Samuel Pitoiset's avatar
    Samuel Pitoiset committed
    if enabled gnutls; then
    
        { check_lib2 gmp.h mpz_export -lgmp && enable gmp; } ||
    
    Samuel Pitoiset's avatar
    Samuel Pitoiset committed
        { check_lib gcrypt.h gcry_mpi_new -lgcrypt && enable gcrypt; }
    fi
    
    
        { require_pkg_config libdc1394-2 dc1394/dc1394.h dc1394_new &&
    
            enable libdc1394_2; } ||
        { check_lib libdc1394/dc1394_control.h dc1394_create_handle -ldc1394_control -lraw1394 &&
            enable libdc1394_1; } ||
        die "ERROR: No version of libdc1394 found "
    fi
    
    
    if enabled nvenc; then
        check_header cuda.h || die "ERROR: cuda.h not found.";
        check_header nvEncodeAPI.h || die "ERROR: nvEncodeAPI.h not found.";
        check_cpp_condition nvEncodeAPI.h "NVENCAPI_MAJOR_VERSION >= 5" ||
            die "ERROR: NVENC API version 4 or older is not supported";
    fi
    
    
    if check_pkg_config sdl SDL_events.h SDL_PollEvent; then
    
        check_cpp_condition SDL.h "(SDL_MAJOR_VERSION<<16 | SDL_MINOR_VERSION<<8 | SDL_PATCHLEVEL) >= 0x010201" $sdl_cflags &&
    
        check_cpp_condition SDL.h "(SDL_MAJOR_VERSION<<16 | SDL_MINOR_VERSION<<8 | SDL_PATCHLEVEL) < 0x010300" $sdl_cflags &&
        enable sdl
    
    pod2man --help     > /dev/null 2>&1 && enable pod2man   || disable pod2man
    
    texi2html -version > /dev/null 2>&1 && enable texi2html || disable texi2html
    
    check_header linux/fb.h
    
    check_header linux/videodev2.h
    
    check_struct linux/videodev2.h "struct v4l2_frmivalenum" discrete
    
    
    check_header sys/videoio.h
    
    check_func_headers "windows.h vfw.h" capCreateCaptureWindow "$vfwcap_indev_extralibs"
    
    # check that WM_CAP_DRIVER_CONNECT is defined to the proper value
    # w32api 3.12 had it defined wrong
    check_cpp_condition vfw.h "WM_CAP_DRIVER_CONNECT > WM_USER" && enable vfwcap_defines
    
    Ramiro Polla's avatar
    Ramiro Polla committed
    
    
    # check for ioctl_meteor.h, ioctl_bt848.h and alternatives
    
    Ramiro Polla's avatar
    Ramiro Polla committed
    { check_header dev/bktr/ioctl_meteor.h &&
      check_header dev/bktr/ioctl_bt848.h; } ||
    { check_header machine/ioctl_meteor.h &&
      check_header machine/ioctl_bt848.h; } ||
    { check_header dev/video/meteor/ioctl_meteor.h &&
      check_header dev/video/bktr/ioctl_bt848.h; } ||
    check_header dev/ic/bt8xx.h
    
    check_header sndio.h
    
    check_header sys/soundcard.h
    check_header soundcard.h
    
    enabled_any alsa_indev alsa_outdev &&
        check_lib2 alsa/asoundlib.h snd_pcm_htimestamp -lasound
    
    enabled jack_indev && check_lib2 jack/jack.h jack_client_open -ljack &&
        check_func jack_port_get_latency_range -ljack
    
    enabled_any sndio_indev sndio_outdev && check_lib2 sndio.h sio_open -lsndio
    
    
    if enabled libcdio; then
    
        check_lib2 "cdio/cdda.h cdio/paranoia.h" cdio_cddap_open -lcdio_paranoia -lcdio_cdda -lcdio ||
    
        check_lib2 "cdio/paranoia/cdda.h cdio/paranoia/paranoia.h" cdio_cddap_open -lcdio_paranoia -lcdio_cdda -lcdio ||
        die "ERROR: No usable libcdio/cdparanoia found"
    
    check_lib X11/Xlib.h XOpenDisplay -lX11 && enable xlib
    
    
    if enabled libxcb || enabled x11grab && ! disabled libxcb; then
    
        check_pkg_config xcb-shape xcb/shape.h xcb_shape_rectangles || {
    
            enabled libxcb && die "ERROR: libxcb not found";
        } && disable x11grab && enable libxcb
    
        disabled libxcb_shm ||
            check_pkg_config xcb-shm xcb/shm.h xcb_shm_attach || {
                enabled libxcb_shm && die "ERROR: libxcb_shm not found";
            } && check_header sys/shm.h && enable libxcb_shm
    
        disabled libxcb_xfixes ||
            check_pkg_config xcb-xfixes xcb/xfixes.h xcb_xfixes_get_cursor_image || {
                enabled libxcb_xfixes && die "ERROR: libxcb_xfixes not found";
            } && enable libxcb_xfixes
    
        add_cflags "$xcb_event_cflags $xcb_shm_cflags $xcb_xfixes_cflags"
        add_extralibs "$xcb_event_libs $xcb_shm_libs $xcb_xfixes_libs"
    fi
    
    if enabled x11grab; then
        enabled xlib || die "ERROR: Xlib not found"
        require Xext X11/extensions/XShm.h XShmCreateImage -lXext
        require Xfixes X11/extensions/Xfixes.h XFixesGetCursorImage -lXfixes
    fi
    
    enabled vaapi && enabled xlib &&
        check_lib2 "va/va.h va/va_x11.h" vaGetDisplay -lva -lva-x11 &&
        enable vaapi_x11
    
    
    enabled vdpau &&
    
        check_cpp_condition vdpau/vdpau.h "defined VDP_DECODER_PROFILE_MPEG4_PART2_ASP" ||
    
        disable vdpau
    
    enabled vdpau && enabled xlib &&
    
        check_func_headers "vdpau/vdpau.h vdpau/vdpau_x11.h" vdp_device_create_x11 -lvdpau &&
        prepend avconv_libs $($ldflags_filter "-lvdpau") &&
    
    enabled debug && add_cflags -g"$debuglevel" && add_asflags -g"$debuglevel"
    
    
    # add some useful compiler flags if supported
    check_cflags -Wdeclaration-after-statement
    
    check_cflags -Wall
    
    Michael Niedermayer's avatar
    Michael Niedermayer committed
    check_cflags -Wdisabled-optimization
    check_cflags -Wpointer-arith
    check_cflags -Wredundant-decls
    
    check_cflags -Wcast-qual
    
    check_cflags -Wwrite-strings
    
    check_cflags -Wmissing-prototypes
    
    check_cflags -Wstrict-prototypes
    
    enabled extra_warnings && check_cflags -Winline
    
    check_disable_warning(){
        warning_flag=-W${1#-Wno-}
        test_cflags $warning_flag && add_cflags $1
    }
    
    check_disable_warning -Wno-parentheses
    check_disable_warning -Wno-switch
    check_disable_warning -Wno-format-zero-length
    check_disable_warning -Wno-pointer-sign
    
    
    check_ldflags -Wl,--warn-common
    
    check_ldflags -Wl,-rpath-link=libswscale:libavfilter:libavdevice:libavformat:libavcodec:libavutil:libavresample
    
    enabled rpath && add_ldexeflags -Wl,-rpath,$libdir
    
    test_ldflags -Wl,-Bsymbolic && append SHFLAGS -Wl,-Bsymbolic
    
    # add some strip flags
    # -wN '..@*' is more selective than -x, but not available everywhere.
    check_stripflags -wN \'..@*\' || check_stripflags -x || strip='true'
    
    
    enabled neon_clobber_test &&
        check_ldflags -Wl,--wrap,avcodec_open2              \
                      -Wl,--wrap,avcodec_decode_audio4      \
                      -Wl,--wrap,avcodec_decode_video2      \
                      -Wl,--wrap,avcodec_decode_subtitle2   \
                      -Wl,--wrap,avcodec_encode_audio2      \
                      -Wl,--wrap,avcodec_encode_video2      \
    
                      -Wl,--wrap,avcodec_encode_subtitle    \
                      -Wl,--wrap,avresample_convert ||
    
    enabled xmm_clobber_test &&
    
        check_ldflags -Wl,--wrap,avcodec_open2              \
                      -Wl,--wrap,avcodec_decode_audio4      \
                      -Wl,--wrap,avcodec_decode_video2      \
                      -Wl,--wrap,avcodec_decode_subtitle2   \
                      -Wl,--wrap,avcodec_encode_audio2      \
    
                      -Wl,--wrap,avcodec_encode_video2      \
    
                      -Wl,--wrap,avcodec_encode_subtitle    \
    
                      -Wl,--wrap,avresample_convert         \
    
    echo "X{};" > $TMPV
    
    if test_ldflags -Wl,--version-script,$TMPV; then
    
        append SHFLAGS '-Wl,--version-script,\$(SUBDIR)lib\$(NAME).ver'
    
        check_cc <<EOF && enable symver_asm_label
    void ff_foo(void) __asm__ ("av_foo@VERSION");
    
    void ff_foo(void) { ${inline_asm+__asm__($quotes);} }
    
    EOF
        check_cc <<EOF && enable symver_gnu_asm
    __asm__(".symver ff_foo,av_foo@VERSION");
    void ff_foo(void) {}
    EOF
    fi
    
    if [ -z "$optflags" ]; then
        if enabled small; then
            optflags=$cflags_size
        elif enabled optimizations; then
            optflags=$cflags_speed
        else
            optflags=$cflags_noopt
        fi
    
    
    check_optflags(){
        check_cflags "$@"
        enabled lto && check_ldflags "$@"
    }
    
    
    if enabled lto; then
        test "$cc_type" != "$ld_type" && die "LTO requires same compiler and linker"
        check_cflags  -flto
        check_ldflags -flto $cpuflags
    fi
    
    check_optflags $optflags
    check_optflags -fno-math-errno
    check_optflags -fno-signed-zeros
    
    Måns Rullgård's avatar
    Måns Rullgård committed
        # Just warnings, no remarks
        check_cflags -w1
        # -wd: Disable following warnings
        # 144, 167, 556: -Wno-pointer-sign
    
        # 1292: attribute "foo" ignored
    
        # 1419: external declaration in primary source file
    
    Måns Rullgård's avatar
    Måns Rullgård committed
        # 10006: ignoring unknown option -fno-signed-zeros
    
        # 10148: ignoring unknown option -Wno-parentheses
    
    Måns Rullgård's avatar
    Måns Rullgård committed
        # 10156: ignoring option '-W'; no argument required
    
        check_cflags -wd144,167,556,1292,1419,10006,10148,10156
    
    Måns Rullgård's avatar
    Måns Rullgård committed
        # 11030: Warning unknown option --as-needed
        # 10156: ignoring option '-export'; no argument required
        check_ldflags -wd10156,11030
    
        # icc 11.0 and 11.1 work with ebp_available, but don't pass the test
        enable ebp_available
    
        if enabled x86_32; then
    
            icc_version=$($cc -dumpversion)
    
            test ${icc_version%%.*} -ge 11 &&
                check_cflags -falign-stack=maintain-16-byte ||
    
    elif enabled ccc; then
        # disable some annoying warnings
    
        add_cflags -msg_disable bitnotint
        add_cflags -msg_disable mixfuncvoid
        add_cflags -msg_disable nonstandcast
        add_cflags -msg_disable unsupieee
    
    elif enabled gcc; then
    
        check_optflags -fno-tree-vectorize
    
        check_cflags -Werror=implicit-function-declaration
    
        check_cflags -Werror=missing-prototypes
    
        check_cflags -Werror=return-type
    
        check_cflags -Werror=declaration-after-statement
    
        check_cflags -Werror=vla
    
        check_cflags -Werror=format-security
    
        check_cflags -fdiagnostics-color=auto
    
        enabled extra_warnings || check_disable_warning -Wno-maybe-uninitialized
    
    elif enabled llvm_gcc; then
        check_cflags -mllvm -stack-alignment=16
    
    elif enabled clang; then
    
        check_cflags -mllvm -stack-alignment=16
    
        check_cflags -Qunused-arguments
    
        check_cflags -Werror=implicit-function-declaration
        check_cflags -Werror=missing-prototypes
    
        check_cflags -Werror=return-type
    
    Luca Barbato's avatar
    Luca Barbato committed
    elif enabled cparser; then
        add_cflags -Wno-missing-variable-declarations
        add_cflags -Wno-empty-statement
    
    elif enabled armcc; then
    
        add_cflags -W${armcc_opt},--diag_suppress=4343 # hardfp compat
        add_cflags -W${armcc_opt},--diag_suppress=3036 # using . as system include dir
    
        # 2523: use of inline assembly is deprecated
    
        add_cflags -W${armcc_opt},--diag_suppress=2523
        add_cflags -W${armcc_opt},--diag_suppress=1207
    
        add_cflags -W${armcc_opt},--diag_suppress=1293 # assignment in condition
    
        add_cflags -W${armcc_opt},--diag_suppress=3343 # hardfp compat
    
        add_cflags -W${armcc_opt},--diag_suppress=167  # pointer sign
        add_cflags -W${armcc_opt},--diag_suppress=513  # pointer sign
    
    elif enabled tms470; then
        add_cflags -pds=824 -pds=837
    
    elif enabled pathscale; then
        add_cflags -fstrict-overflow -OPT:wrap_around_unsafe_opt=OFF
    
    elif enabled_any msvc icl; then
    
        enabled x86_32 && disable aligned_stack
    
        enabled_all x86_32 debug && add_cflags -Oy-
    
        enabled debug && add_ldflags -debug
    
        enable pragma_deprecated
    
        if enabled icl; then
    
            # -Qansi-alias is basically -fstrict-aliasing, but does not work
            # (correctly) on icl 13.x.
            check_cpp_condition "windows.h" "__ICL < 1300 || __ICL >= 1400" &&
                add_cflags -Qansi-alias
    
            # icl will pass the inline asm tests but inline asm is currently
            # not supported (build will fail)
    
            disable inline_asm
        fi
    
        # msvcrt10 x64 incorrectly enables log2, only msvcrt12 (MSVC 2013) onwards actually has log2.
        check_cpp_condition crtversion.h "_VC_CRT_MAJOR_VERSION >= 12" || disable log2
    
        # The CRT headers contain __declspec(restrict) in a few places, but if redefining
        # restrict, this might break. MSVC 2010 and 2012 fail with __declspec(__restrict)
        # (as it ends up if the restrict redefine is done before including stdlib.h), while
        # MSVC 2013 and newer can handle it fine.
        # If this declspec fails, force including stdlib.h before the restrict redefinition
        # happens in config.h.
        if [ $_restrict != restrict ]; then
            check_cc <<EOF || add_cflags -FIstdlib.h
    __declspec($_restrict) void* foo(int);
    EOF
        fi
    
        check_func strtoll || add_cflags -Dstrtoll=_strtoi64
    
        eval "type=\$$varname"
        if [ $type = "msvc" ]; then
            check_${pfx}cc <<EOF || add_${pfx}cflags -Dinline=__inline
    static inline int foo(int a) { return a; }
    EOF
        fi
    done
    
    
    case $as_type in
        clang)
            add_asflags -Qunused-arguments
        ;;
    esac
    
    case $ld_type in
        clang)
            check_ldflags -Qunused-arguments
        ;;
    esac
    
    
    Mans Rullgard's avatar
    Mans Rullgard committed
    case $target_os in
    
        osf1)
            enabled ccc && add_ldflags '-Wl,-expect_unresolved,*'
        ;;
    
    Mans Rullgard's avatar
    Mans Rullgard committed
        plan9)
            add_cppflags -Dmain=plan9_main
        ;;
    esac
    
    
    enabled asm || { arch=c; disable $ARCH_LIST $ARCH_EXT_LIST; }
    
    
    enabled_all dxva2 CoTaskMemFree &&
        prepend avconv_libs $($ldflags_filter "-lole32") &&
        enable dxva2_lib
    
    
    ! enabled_any memalign posix_memalign aligned_malloc &&
    
        enabled simd_align_16 && enable memalign_hack
    
    map 'enabled $v && intrinsics=${v#intrinsics_}' $INTRINSICS_LIST
    
    
    for thread in $THREADS_LIST; do
        if enabled $thread; then
            test -n "$thread_type" &&
                die "ERROR: Only one thread type must be selected." ||
                thread_type="$thread"
        fi
    done
    
    
    enabled zlib && add_cppflags -DZLIB_CONST
    
    
    # conditional library dependencies, in linking order
    enabled movie_filter    && prepend avfilter_deps "avformat avcodec"
    enabled resample_filter && prepend avfilter_deps "avresample"
    enabled scale_filter    && prepend avfilter_deps "swscale"
    
    
    enabled opus_decoder    && prepend avcodec_deps "avresample"
    
    
    expand_deps(){
        lib_deps=${1}_deps
        eval "deps=\$$lib_deps"
        append $lib_deps $(map 'eval echo \$${v}_deps' $deps)
        unique $lib_deps
    }
    
    map 'expand_deps $v' $LIBRARY_LIST
    
    
    echo "install prefix            $prefix"
    
    Diego Biurrun's avatar
    Diego Biurrun committed
    echo "source path               $source_path"
    echo "C compiler                $cc"
    
    echo "C library                 $libc_type"
    
    if test "$host_cc" != "$cc"; then
        echo "host C compiler           $host_cc"
    
        echo "host C library            $host_libc_type"
    
    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 "${yasmexe}                      ${yasm-no}"
    
        echo "MMX enabled               ${mmx-no}"
    
        echo "MMXEXT enabled            ${mmxext-no}"
    
        echo "3DNow! extended enabled   ${amd3dnowext-no}"
    
        echo "SSE enabled               ${sse-no}"
    
        echo "SSSE3 enabled             ${ssse3-no}"
    
        echo "AVX enabled               ${avx-no}"
    
        echo "XOP enabled               ${xop-no}"
    
        echo "FMA3 enabled              ${fma3-no}"
    
        echo "i686 features enabled     ${i686-no}"
    
        echo "CMOV is fast              ${fast_cmov-no}"
    
        echo "EBX available             ${ebx_available-no}"
        echo "EBP available             ${ebp_available-no}"
    
    if enabled aarch64; then
        echo "NEON enabled              ${neon-no}"
        echo "VFP enabled               ${vfp-no}"
    fi
    
        echo "ARMv5TE enabled           ${armv5te-no}"
        echo "ARMv6 enabled             ${armv6-no}"
    
        echo "ARMv6T2 enabled           ${armv6t2-no}"
    
        echo "VFP enabled               ${vfp-no}"
    
        echo "NEON enabled              ${neon-no}"
    
        echo "AltiVec enabled           ${altivec-no}"
    
        echo "VSX enabled               ${vsx-no}"
        echo "POWER8 enabled            ${power8-no}"
    
        echo "PPC 4xx optimizations     ${ppc4xx-no}"
    
        echo "dcbzl available           ${dcbzl-no}"
    
    echo "debug symbols             ${debug-no}"
    
    echo "optimize for size         ${small-no}"
    
    echo "optimizations             ${optimizations-no}"
    
    echo "static                    ${static-no}"
    echo "shared                    ${shared-no}"
    
    echo "network support           ${network-no}"
    echo "threading support         ${thread_type-no}"
    
    echo "safe bitstream reader     ${safe_bitstream_reader-no}"
    
    echo "SDL support               ${sdl-no}"
    
    test -n "$random_seed" &&
        echo "random seed               ${random_seed}"
    
    Fabrice Bellard's avatar
    Fabrice Bellard committed
    
    
    echo "External libraries:"
    print_enabled '' $EXTERNAL_LIBRARY_LIST | print_3_columns
    echo
    
    
    for type in decoder encoder hwaccel parser demuxer muxer protocol filter bsf indev outdev; do
    
        echo "Enabled ${type}s:"
    
        eval list=\$$(toupper $type)_LIST
    
        print_enabled '_*' $list | print_3_columns
    
    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..."
    
    
    test -e Makefile || echo "include $source_path/Makefile" > Makefile
    
    config_files="$TMPH config.mak"
    
    
    cat > config.mak <<EOF
    # Automatically generated by configure - do not modify!
    
    LIBAV_CONFIGURATION=$LIBAV_CONFIGURATION
    
    prefix=$prefix
    LIBDIR=\$(DESTDIR)$libdir
    SHLIBDIR=\$(DESTDIR)$shlibdir
    INCDIR=\$(DESTDIR)$incdir
    BINDIR=\$(DESTDIR)$bindir
    DATADIR=\$(DESTDIR)$datadir
    
    DOCDIR=\$(DESTDIR)$docdir
    
    SRC_PATH=$source_path
    
    INTRINSICS=$intrinsics
    
    DEPCCFLAGS=$DEPCCFLAGS \$(CPPFLAGS)
    DEPAS=$as
    DEPASFLAGS=$DEPASFLAGS \$(CPPFLAGS)
    
    ARFLAGS=$arflags
    AR_O=$ar_o
    
    STRIP=$strip
    
    LN_S=$ln_s
    CPPFLAGS=$CPPFLAGS
    CFLAGS=$CFLAGS
    ASFLAGS=$ASFLAGS
    
    LD_LIB=$LD_LIB
    LD_PATH=$LD_PATH
    
    DLLTOOL=$dlltool
    
    LDEXEFLAGS=$LDEXEFLAGS
    
    SHFLAGS=$(echo $($ldflags_filter $SHFLAGS))
    
    STRIPFLAGS=$STRIPFLAGS
    
    YASMFLAGS=$YASMFLAGS
    BUILDSUF=$build_suffix
    FULLNAME=$FULLNAME
    LIBPREF=$LIBPREF
    LIBSUF=$LIBSUF
    LIBNAME=$LIBNAME
    SLIBPREF=$SLIBPREF
    SLIBSUF=$SLIBSUF
    EXESUF=$EXESUF
    EXTRA_VERSION=$extra_version
    CCDEP=$CCDEP
    
    CC_DEPFLAGS=$CC_DEPFLAGS
    AS_DEPFLAGS=$AS_DEPFLAGS
    HOSTCC=$host_cc
    
    HOSTEXESUF=$HOSTEXESUF
    HOSTLDFLAGS=$host_ldflags
    HOSTLIBS=$host_libs
    
    DEPHOSTCC=$host_cc
    DEPHOSTCCFLAGS=$DEPHOSTCCFLAGS \$(HOSTCCFLAGS)
    HOSTCCDEP=$HOSTCCDEP
    HOSTCCDEP_FLAGS=$HOSTCCDEP_FLAGS
    HOSTCC_DEPFLAGS=$HOSTCC_DEPFLAGS
    
    HOSTLD_O=$HOSTLD_O
    
    TARGET_EXEC=$target_exec $target_exec_args
    
    TARGET_SAMPLES=${target_samples:-\$(SAMPLES)}
    
    ZLIB=$($ldflags_filter -lz)
    
    LIB_INSTALL_EXTRA_CMD=$LIB_INSTALL_EXTRA_CMD
    EXTRALIBS=$extralibs
    
    COMPAT_OBJS=$compat_objs
    
    INSTALL=install
    
    LIBTARGET=${LIBTARGET}
    SLIBNAME=${SLIBNAME}
    SLIBNAME_WITH_VERSION=${SLIBNAME_WITH_VERSION}
    SLIBNAME_WITH_MAJOR=${SLIBNAME_WITH_MAJOR}
    SLIB_CREATE_DEF_CMD=${SLIB_CREATE_DEF_CMD}
    SLIB_EXTRA_CMD=${SLIB_EXTRA_CMD}
    
    SLIB_INSTALL_NAME=${SLIB_INSTALL_NAME}
    SLIB_INSTALL_LINKS=${SLIB_INSTALL_LINKS}
    SLIB_INSTALL_EXTRA_LIB=${SLIB_INSTALL_EXTRA_LIB}
    SLIB_INSTALL_EXTRA_SHLIB=${SLIB_INSTALL_EXTRA_SHLIB}
    
    SAMPLES:=${samples:-\$(LIBAV_SAMPLES)}
    
        name=$(toupper $lcname)
        file=$source_path/$lcname/version.h
    
        eval $(awk "/#define ${name}_VERSION_M/ { print \$2 \"=\" \$3 }" "$file")
    
        eval ${name}_VERSION=\$${name}_VERSION_MAJOR.\$${name}_VERSION_MINOR.\$${name}_VERSION_MICRO
    
        eval echo "${lcname}_VERSION=\$${name}_VERSION" >> config.mak
        eval echo "${lcname}_VERSION_MAJOR=\$${name}_VERSION_MAJOR" >> config.mak
    
        eval echo "${lcname}_VERSION_MINOR=\$${name}_VERSION_MINOR" >> config.mak
    
    map 'get_version $v' $LIBRARY_LIST
    
    map 'eval echo "${v}_FFLIBS=\$${v}_deps" >> config.mak' $LIBRARY_LIST
    
    print_program_libs(){
        eval "program_libs=\$${1}_libs"
        eval echo "LIBS-${1}=${program_libs}" >> config.mak