]> git.sesse.net Git - ffmpeg/blobdiff - configure
build: Add name parameter to check_lib() helper function
[ffmpeg] / configure
index 118309061359d7a387fac91dfbd9d91c000d6dd7..365bbb2bf293dfcf04ef0d48719fce8f41f924fa 100755 (executable)
--- a/configure
+++ b/configure
@@ -1006,10 +1006,13 @@ EOF
 
 check_lib(){
     log check_lib "$@"
-    headers="$1"
-    funcs="$2"
-    shift 2
-    check_func_headers "$headers" "$funcs" "$@" && add_extralibs "$@"
+    name="$1"
+    headers="$2"
+    funcs="$3"
+    shift 3
+    disable $name
+    check_func_headers "$headers" "$funcs" "$@" &&
+        enable $name && add_extralibs "$@"
 }
 
 check_pkg_config(){
@@ -1023,8 +1026,8 @@ check_pkg_config(){
     pkg_cflags=$($pkg_config --cflags $pkg_config_flags $pkg)
     pkg_libs=$($pkg_config --libs $pkg_config_flags $pkg)
     check_func_headers "$headers" "$funcs" $pkg_cflags $pkg_libs "$@" &&
-        set_safe "${pkg}_cflags" $pkg_cflags   &&
-        set_safe "${pkg}_libs"   $pkg_libs
+        set_safe "${pkg}_cflags"    $pkg_cflags &&
+        set_safe "${pkg}_extralibs" $pkg_libs
 }
 
 check_exec(){
@@ -1105,10 +1108,11 @@ check_compile_assert(){
 require(){
     log require "$@"
     name_version="$1"
+    name="${1%% *}"
     headers="$2"
     func="$3"
     shift 3
-    check_lib "$headers" $func "$@" || die "ERROR: $name_version not found"
+    check_lib $name "$headers" $func "$@" || die "ERROR: $name_version not found"
 }
 
 require_pkg_config(){
@@ -1117,7 +1121,7 @@ require_pkg_config(){
     pkg="${1%% *}"
     check_pkg_config "$@" || die "ERROR: $pkg_version not found"
     add_cflags    $(get_safe "${pkg}_cflags")
-    add_extralibs $(get_safe "${pkg}_libs")
+    add_extralibs $(get_safe "${pkg}_extralibs")
 }
 
 hostcc_e(){
@@ -1514,6 +1518,7 @@ HEADERS_LIST="
     arpa_inet_h
     cdio_paranoia_h
     cdio_paranoia_paranoia_h
+    d3d11_h
     dispatch_dispatch_h
     dev_bktr_ioctl_bt848_h
     dev_bktr_ioctl_meteor_h
@@ -1522,7 +1527,6 @@ HEADERS_LIST="
     dev_video_meteor_ioctl_meteor_h
     direct_h
     dlfcn_h
-    d3d11_h
     dxva_h
     gsm_h
     io_h
@@ -1714,6 +1718,7 @@ CONFIG_EXTRA="
     h264parse
     h264pred
     h264qpel
+    hevc_ps
     hpeldsp
     huffman
     huffyuvdsp
@@ -1806,9 +1811,9 @@ CMDLINE_SET="
     extra_version
     host_cc
     host_cflags
+    host_extralibs
     host_ld
     host_ldflags
-    host_libs
     host_os
     ld
     logfile
@@ -1912,6 +1917,7 @@ error_resilience_select="me_cmp"
 faandct_deps="faan fdctdsp"
 faanidct_deps="faan idctdsp"
 h264dsp_select="startcode"
+hevc_ps_select="golomb"
 intrax8_select="blockdsp idctdsp"
 mdct_select="fft"
 rdft_select="fft"
@@ -1969,13 +1975,13 @@ eamad_decoder_select="aandcttables blockdsp bswapdsp idctdsp mpegvideo"
 eatgq_decoder_select="aandcttables idctdsp"
 eatqi_decoder_select="aandcttables blockdsp bswapdsp idctdsp"
 exr_decoder_deps="zlib"
-ffv1_decoder_select="golomb rangecoder"
+ffv1_decoder_select="rangecoder"
 ffv1_encoder_select="rangecoder"
 ffvhuff_decoder_select="huffyuv_decoder"
 ffvhuff_encoder_select="huffyuv_encoder"
 fic_decoder_select="golomb"
-flac_decoder_select="flacdsp golomb"
-flac_encoder_select="bswapdsp flacdsp golomb lpc"
+flac_decoder_select="flacdsp"
+flac_encoder_select="bswapdsp flacdsp lpc"
 flashsv_decoder_deps="zlib"
 flashsv_encoder_deps="zlib"
 flashsv2_decoder_deps="zlib"
@@ -1996,7 +2002,7 @@ h264_decoder_suggest="error_resilience"
 hap_decoder_select="snappy texturedsp"
 hap_encoder_deps="libsnappy"
 hap_encoder_select="texturedspenc"
-hevc_decoder_select="bswapdsp cabac golomb videodsp"
+hevc_decoder_select="bswapdsp cabac hevc_ps videodsp"
 huffyuv_decoder_select="bswapdsp huffyuvdsp"
 huffyuv_encoder_select="bswapdsp huffman huffyuvencdsp"
 iac_decoder_select="imc_decoder"
@@ -2005,12 +2011,10 @@ indeo3_decoder_select="hpeldsp"
 indeo4_decoder_select="ividsp"
 indeo5_decoder_select="ividsp"
 interplay_video_decoder_select="hpeldsp"
-jpegls_decoder_select="golomb mjpeg_decoder"
-jpegls_encoder_select="golomb"
+jpegls_decoder_select="mjpeg_decoder"
 jv_decoder_select="blockdsp"
 lagarith_decoder_select="huffyuvdsp"
 ljpeg_encoder_select="aandcttables idctdsp jpegtables"
-loco_decoder_select="golomb"
 magicyuv_decoder_select="huffyuvdsp"
 mdec_decoder_select="blockdsp idctdsp mpegvideo"
 metasound_decoder_select="lsp mdct sinewin"
@@ -2072,7 +2076,6 @@ rv20_encoder_select="h263_encoder"
 rv30_decoder_select="error_resilience golomb h264chroma h264pred h264qpel mpeg_er mpegvideo rv34dsp videodsp"
 rv40_decoder_select="error_resilience golomb h264chroma h264pred h264qpel mpeg_er mpegvideo rv34dsp videodsp"
 screenpresso_decoder_deps="zlib"
-shorten_decoder_select="golomb"
 sipr_decoder_select="lsp"
 sp5x_decoder_select="mjpeg_decoder"
 svq1_decoder_select="hpeldsp"
@@ -2106,7 +2109,7 @@ vp6a_decoder_select="vp6_decoder"
 vp6f_decoder_select="vp6_decoder"
 vp7_decoder_select="h264pred videodsp vp8dsp"
 vp8_decoder_select="h264pred videodsp vp8dsp"
-vp9_decoder_select="videodsp"
+vp9_decoder_select="videodsp vp9_superframe_split_bsf"
 webp_decoder_select="vp8_decoder"
 wmapro_decoder_select="mdct sinewin wma_freqs"
 wmav1_decoder_select="mdct sinewin wma_freqs"
@@ -2129,10 +2132,9 @@ zmbv_encoder_deps="zlib"
 # hardware accelerators
 d3d11va_deps="d3d11_h dxva_h ID3D11VideoDecoder"
 dxva2_deps="dxva2api_h DXVA2_ConfigPictureDecode"
-vaapi_deps="va_va_h"
+dxva2_lib_deps="dxva2"
 vda_deps="VideoDecodeAcceleration_VDADecoder_h pthreads"
 vda_extralibs="-framework CoreFoundation -framework VideoDecodeAcceleration -framework QuartzCore"
-vdpau_deps="vdpau_vdpau_h vdpau_vdpau_x11_h"
 
 h263_vaapi_hwaccel_deps="vaapi"
 h263_vaapi_hwaccel_select="h263_decoder"
@@ -2215,9 +2217,9 @@ h264_vaapi_encoder_deps="VAEncPictureParameterBufferH264"
 h264_vaapi_encoder_select="vaapi_encode golomb"
 hevc_nvenc_encoder_deps="nvenc"
 hevc_qsv_decoder_deps="libmfx"
-hevc_qsv_encoder_deps="libmfx"
 hevc_qsv_decoder_select="hevc_mp4toannexb_bsf hevc_parser hevc_qsv_hwaccel qsvdec"
-hevc_qsv_encoder_select="qsvenc"
+hevc_qsv_encoder_deps="libmfx"
+hevc_qsv_encoder_select="hevc_ps qsvenc"
 hevc_vaapi_encoder_deps="VAEncPictureParameterBufferHEVC"
 hevc_vaapi_encoder_select="vaapi_encode golomb"
 mjpeg_vaapi_encoder_deps="VAEncPictureParameterBufferJPEG"
@@ -2234,12 +2236,12 @@ vc1_qsv_decoder_select="qsvdec vc1_qsv_hwaccel vc1_parser"
 vp8_qsv_decoder_deps="libmfx"
 vp8_qsv_decoder_select="qsvdec vp8_qsv_hwaccel vp8_parser"
 
-nvenc_h264_encoder_deps="nvenc"
-nvenc_hevc_encoder_deps="nvenc"
+nvenc_h264_encoder_select="h264_nvenc_encoder"
+nvenc_hevc_encoder_select="hevc_nvenc_encoder"
 
 # parsers
 h264_parser_select="golomb h264dsp h264parse"
-hevc_parser_select="golomb"
+hevc_parser_select="hevc_ps"
 mpegaudio_parser_select="mpegaudioheader"
 mpegvideo_parser_select="mpegvideo"
 mpeg4video_parser_select="error_resilience h263dsp mpegvideo qpeldsp"
@@ -2370,26 +2372,25 @@ xmv_demuxer_select="riffdec"
 xwma_demuxer_select="riffdec"
 
 # indevs / outdevs
-alsa_indev_deps="alsa_asoundlib_h snd_pcm_htimestamp"
-alsa_outdev_deps="alsa_asoundlib_h"
+alsa_indev_deps="alsa"
+alsa_outdev_deps="alsa"
 avfoundation_indev_deps="AVFoundation_AVFoundation_h objc_arc pthreads"
 avfoundation_indev_extralibs="-framework Foundation -framework AVFoundation -framework CoreVideo -framework CoreMedia"
 bktr_indev_deps_any="dev_bktr_ioctl_bt848_h machine_ioctl_bt848_h dev_video_bktr_ioctl_bt848_h dev_ic_bt8xx_h"
 dv1394_indev_deps="dv1394"
 dv1394_indev_select="dv_demuxer"
 fbdev_indev_deps="linux_fb_h"
-jack_indev_deps="jack_jack_h"
+jack_indev_deps="jack"
 jack_indev_deps_any="sem_timedwait dispatch_dispatch_h"
 libcdio_indev_deps="libcdio"
 libdc1394_indev_deps="libdc1394"
 oss_indev_deps_any="soundcard_h sys_soundcard_h"
 oss_outdev_deps_any="soundcard_h sys_soundcard_h"
 pulse_indev_deps="libpulse"
-sndio_indev_deps="sndio_h"
-sndio_outdev_deps="sndio_h"
+sndio_indev_deps="sndio"
+sndio_outdev_deps="sndio"
 v4l2_indev_deps_any="linux_videodev2_h sys_videoio_h"
-vfwcap_indev_deps="capCreateCaptureWindow vfwcap_defines"
-vfwcap_indev_extralibs="-lavicap32"
+vfwcap_indev_deps="vfw32 vfwcap_defines"
 xcbgrab_indev_deps="libxcb"
 
 # protocols
@@ -2439,6 +2440,7 @@ boxblur_filter_deps="gpl"
 bs2b_filter_deps="libbs2b"
 cropdetect_filter_deps="gpl"
 deinterlace_qsv_filter_deps="libmfx"
+deinterlace_vaapi_filter_deps="vaapi"
 delogo_filter_deps="gpl"
 drawtext_filter_deps="libfreetype"
 frei0r_filter_deps="frei0r dlopen"
@@ -2468,6 +2470,7 @@ transcode_aac_example_deps="avcodec avformat avresample"
 
 # libraries, in linking order
 avcodec_deps="avutil"
+avcodec_select="null_bsf"
 avdevice_deps="avformat avcodec avutil"
 avfilter_deps="avutil"
 avformat_deps="avcodec avutil"
@@ -2480,7 +2483,7 @@ avconv_select="aformat_filter anull_filter asyncts_filter atrim_filter format_fi
                fps_filter null_filter resample_filter scale_filter
                trim_filter"
 avplay_deps="avcodec avfilter avformat avresample sdl"
-avplay_libs='$sdl_libs'
+avplay_extralibs='$sdl_extralibs'
 avplay_select="rdft format_filter transpose_filter hflip_filter vflip_filter"
 avprobe_deps="avcodec avformat"
 
@@ -2575,7 +2578,7 @@ HOSTCC_E='-E -o $@'
 HOSTCC_O='-o $@'
 HOSTLD_O='-o $@'
 
-host_libs='-lm'
+host_extralibs='-lm'
 host_cflags_filter=echo
 host_ldflags_filter=echo
 
@@ -3046,7 +3049,6 @@ msvc_common_flags(){
             -mthumb)              ;;
             -march=*)             ;;
             -lz)                  echo zlib.lib ;;
-            -lavicap32)           echo vfw32.lib user32.lib ;;
             -lx264)               echo libx264.lib ;;
             -l*)                  echo ${flag#-l}.lib ;;
             -L*)                  echo -libpath:${flag#-L} ;;
@@ -3279,6 +3281,7 @@ probe_cc(){
         _DEPFLAGS='$(CPPFLAGS) $(CFLAGS) -showIncludes -Zs'
         _cflags_speed="-O2"
         _cflags_size="-O1"
+        _cflags_noopt="-O1"
         if $_cc -nologo- 2>&1 | grep -q Linker; then
             _ld_o='-out:$@'
         else
@@ -3812,7 +3815,7 @@ case $target_os in
     haiku)
         prefix_default="/boot/common"
         network_extralibs="-lnetwork"
-        host_libs=
+        host_extralibs=
         ;;
     sunos)
         SHFLAGS='-shared -Wl,-h,$$(@F)'
@@ -4020,7 +4023,7 @@ probe_libc(){
     # MinGW headers can be installed on Cygwin, so check for newlib first.
     elif check_${pfx}cpp_condition newlib.h "defined _NEWLIB_VERSION"; then
         eval ${pfx}libc_type=newlib
-        add_${pfx}cppflags -U__STRICT_ANSI__
+        add_${pfx}cppflags -U__STRICT_ANSI__ -D_XOPEN_SOURCE=600
     # MinGW64 is backwards compatible with MinGW32, so check for it first.
     elif check_${pfx}cpp_condition _mingw.h "defined __MINGW64_VERSION_MAJOR"; then
         eval ${pfx}libc_type=mingw64
@@ -4493,7 +4496,7 @@ 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_lib time.h clock_gettime -lrt && LIBRT="-lrt"; }
+        { check_lib clock_gettime time.h clock_gettime -lrt && LIBRT="-lrt"; }
 
 check_func  fcntl
 check_func  fork
@@ -4509,7 +4512,7 @@ check_func  mkstemp
 check_func  mmap
 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_headers time.h nanosleep || check_lib nanosleep time.h nanosleep -lrt
 check_func  sched_getaffinity
 check_func  setrlimit
 check_func  strerror_r
@@ -4520,7 +4523,6 @@ 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
@@ -4531,9 +4533,9 @@ check_func_headers windows.h Sleep
 check_func_headers windows.h VirtualAlloc
 check_struct windows.h "CONDITION_VARIABLE" Ptr
 
+check_header d3d11.h
 check_header direct.h
 check_header dlfcn.h
-check_header d3d11.h
 check_header dxva.h
 check_header dxva2api.h
 check_header io.h
@@ -4548,8 +4550,6 @@ check_header sys/time.h
 check_header sys/un.h
 check_header unistd.h
 check_header valgrind/valgrind.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
@@ -4559,9 +4559,9 @@ check_header X11/extensions/XvMClib.h
 # so we also check that atomics actually work here
 check_builtin stdatomic_h stdatomic.h "atomic_int foo; atomic_store(&foo, 0)"
 
-check_lib "windows.h shellapi.h" CommandLineToArgvW   -lshell32
-check_lib "windows.h wincrypt.h" CryptGenRandom       -ladvapi32
-check_lib "windows.h psapi.h"    GetProcessMemoryInfo -lpsapi
+check_lib shell32  "windows.h shellapi.h" CommandLineToArgvW   -lshell32
+check_lib wincrypt "windows.h wincrypt.h" CryptGenRandom       -ladvapi32
+check_lib psapi    "windows.h psapi.h"    GetProcessMemoryInfo -lpsapi
 
 check_struct "sys/time.h sys/resource.h" "struct rusage" ru_maxrss
 
@@ -4578,36 +4578,32 @@ check_type "va/va.h va/va_enc_jpeg.h" "VAEncPictureParameterBufferJPEG"
 check_type "vdpau/vdpau.h" "VdpPictureInfoHEVC"
 
 if ! disabled w32threads && ! enabled pthreads; then
-    check_func_headers "windows.h process.h" _beginthreadex &&
-        enable w32threads || disable w32threads
+    check_lib w32threads "windows.h process.h" _beginthreadex
 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 ! disabled pthreads && ! enabled w32threads; then
-    enable pthreads
-    if check_func pthread_join -pthread; then
+    if check_lib pthreads pthread.h pthread_join -pthread; then
         add_cflags -pthread
-        add_extralibs -pthread
-    elif check_func pthread_join -pthreads; then
+    elif check_lib pthreads pthread.h pthread_join -pthreads; then
         add_cflags -pthreads
-        add_extralibs -pthreads
-    elif check_func pthread_join -lpthreadGC2; then
-        add_extralibs -lpthreadGC2
-    elif check_lib pthread.h pthread_join -lpthread; then
+    elif check_lib pthreads pthread.h pthread_join -lpthreadGC2; then
+        :
+    elif check_lib pthreads pthread.h pthread_join -lpthread; then
         :
-    elif check_func pthread_join; then
-        disable pthreads
+    elif check_func pthread_join; then
+        enable pthreads
     fi
 fi
 
 enabled pthreads &&
     check_builtin sem_timedwait semaphore.h "sem_t *s; sem_init(s,0,0); sem_timedwait(s,0); sem_destroy(s)"
 
-disabled  zlib || check_lib  zlib.h      zlibVersion -lz   || disable  zlib
-disabled bzlib || check_lib bzlib.h BZ2_bzlibVersion -lbz2 || disable bzlib
+disabled  zlib || check_lib  zlib  zlib.h      zlibVersion -lz
+disabled bzlib || check_lib bzlib bzlib.h BZ2_bzlibVersion -lbz2
 
-check_lib math.h sin -lm && LIBM="-lm"
+check_lib libm math.h sin -lm && LIBM="-lm"
 
 atan2f_args=2
 ldexpf_args=2
@@ -4620,7 +4616,7 @@ done
 # these are off by default, so fail if requested and not available
 enabled avisynth          && { check_header avisynth/avisynth_c.h || die "ERROR: avisynth/avisynth_c.h header not found"; }
 enabled avxsynth          && require avxsynth "avxsynth/avxsynth_c.h dlfcn.h" dlopen -ldl
-enabled cuda              && check_lib cuda.h cuInit -lcuda
+enabled cuda              && require cuda cuda.h cuInit -lcuda
 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
@@ -4631,7 +4627,7 @@ enabled libfdk_aac        && require_pkg_config fdk-aac "fdk-aac/aacenc_lib.h" a
 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;
+                                   check_lib libgsm "${gsm_hdr}" gsm_create -lgsm && break;
                                done || die "ERROR: libgsm not found"; }
 enabled libhdcd           && require_pkg_config libhdcd "hdcd/hdcd_simple.h" hdcd_new
 enabled libilbc           && require libilbc ilbc.h WebRtcIlbcfix_InitDecode -lilbc
@@ -4643,7 +4639,7 @@ enabled libopencore_amrnb && require libopencore_amrnb opencore-amrnb/interf_dec
 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_lib openjpeg.h opj_version -lopenjpeg -DOPJ_STATIC ||
+enabled libopenjpeg       && { check_lib libopenjpeg 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
@@ -4689,11 +4685,11 @@ enabled libx265           && require_pkg_config x265 x265.h x265_api_get &&
                                die "ERROR: libx265 version must be >= 57."; }
 enabled libxavs           && require libxavs "stdint.h 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 mmal              && { check_lib mmal 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_ldflags -L/opt/vc/lib/ &&
-                                 check_lib interface/mmal/mmal.h mmal_port_connect -lmmal_core -lmmal_util -lmmal_vc_client -lbcm_host; } ||
+                                 check_lib mmal interface/mmal/mmal.h mmal_port_connect -lmmal_core -lmmal_util -lmmal_vc_client -lbcm_host; } ||
                                die "ERROR: mmal not found" &&
                                check_func_headers interface/mmal/mmal.h "MMAL_PARAMETER_VIDEO_MAX_NUM_CALLBACKS"; }
 enabled omx_rpi           && { check_header OMX_Core.h ||
@@ -4702,13 +4698,13 @@ enabled omx_rpi           && { check_header OMX_Core.h ||
 enabled omx               && { check_header OMX_Core.h || die "ERROR: OpenMAX IL headers not found"; }
 enabled openssl           && { { check_pkg_config openssl openssl/ssl.h OPENSSL_init_ssl ||
                                  check_pkg_config openssl openssl/ssl.h SSL_library_init; } && {
-                               add_cflags $openssl_cflags && add_extralibs $openssl_libs; }||
-                               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 ||
+                               add_cflags $openssl_cflags && add_extralibs $openssl_extralibs; } ||
+                               check_lib openssl openssl/ssl.h SSL_library_init -lssl -lcrypto ||
+                               check_lib openssl openssl/ssl.h SSL_library_init -lssl32 -leay32 ||
+                               check_lib openssl openssl/ssl.h SSL_library_init -lssl -lcrypto -lws2_32 -lgdi32 ||
                                die "ERROR: openssl not found"; }
 
-enabled gnutls            && check_lib gmp.h mpz_export -lgmp && enable gmp
+enabled gnutls            && check_lib gmp gmp.h mpz_export -lgmp
 
 if enabled nvenc; then
     check_header nvEncodeAPI.h || die "ERROR: nvEncodeAPI.h not found."
@@ -4733,7 +4729,8 @@ check_header AVFoundation/AVFoundation.h
 
 check_header sys/videoio.h
 
-check_func_headers "windows.h vfw.h" capCreateCaptureWindow "$vfwcap_indev_extralibs"
+check_lib user32 "windows.h winuser.h" GetShellWindow -luser32
+check_lib vfw32 "windows.h vfw.h" capCreateCaptureWindow -lvfw32
 # 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
@@ -4747,21 +4744,20 @@ check_cpp_condition vfw.h "WM_CAP_DRIVER_CONNECT > WM_USER" && enable vfwcap_def
   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_lib alsa/asoundlib.h snd_pcm_htimestamp -lasound
+    check_lib alsa alsa/asoundlib.h snd_pcm_htimestamp -lasound
 
-enabled jack_indev && check_lib jack/jack.h jack_client_open -ljack &&
+enabled jack_indev && check_lib jack jack/jack.h jack_client_open -ljack &&
     check_func jack_port_get_latency_range -ljack
 
-enabled_any sndio_indev sndio_outdev && check_lib sndio.h sio_open -lsndio
+enabled_any sndio_indev sndio_outdev && check_lib sndio sndio.h sio_open -lsndio
 
 if enabled libcdio; then
-    check_lib "cdio/cdda.h cdio/paranoia.h" cdio_cddap_open -lcdio_paranoia -lcdio_cdda -lcdio ||
-    check_lib "cdio/paranoia/cdda.h cdio/paranoia/paranoia.h" cdio_cddap_open -lcdio_paranoia -lcdio_cdda -lcdio ||
+    check_lib libcdio "cdio/cdda.h cdio/paranoia.h" cdio_cddap_open -lcdio_paranoia -lcdio_cdda -lcdio ||
+    check_lib libcdio "cdio/paranoia/cdda.h cdio/paranoia/paranoia.h" cdio_cddap_open -lcdio_paranoia -lcdio_cdda -lcdio ||
     die "ERROR: No usable libcdio/cdparanoia found"
 fi
 
@@ -4781,9 +4777,12 @@ if enabled libxcb; then
         } && enable libxcb_xfixes
 
     add_cflags "$xcb_shape_cflags $xcb_shm_cflags $xcb_xfixes_cflags"
-    add_extralibs "$xcb_shape_libs $xcb_shm_libs $xcb_xfixes_libs"
+    add_extralibs "$xcb_shape_extralibs $xcb_shm_extralibs $xcb_xfixes_extralibs"
 fi
 
+enabled dxva2 &&
+    check_lib dxva2_lib windows.h CoTaskMemFree -lole32
+
 enabled vaapi && require vaapi va/va.h vaInitialize -lva
 
 enabled vaapi &&
@@ -4791,20 +4790,17 @@ enabled vaapi &&
     disable vaapi
 
 enabled vaapi &&
-    check_lib "va/va.h va/va_drm.h" vaGetDisplayDRM -lva -lva-drm &&
-    enable vaapi_drm
+    check_lib vaapi_drm "va/va.h va/va_drm.h" vaGetDisplayDRM -lva -lva-drm
 
 enabled vaapi &&
-    check_lib "va/va.h va/va_x11.h" vaGetDisplay -lva -lva-x11 -lX11 &&
-    enable vaapi_x11
+    check_lib vaapi_x11 "va/va.h va/va_x11.h" vaGetDisplay -lva -lva-x11 -lX11
 
 enabled vdpau &&
     check_cpp_condition vdpau/vdpau.h "defined VDP_DECODER_PROFILE_MPEG4_PART2_ASP" ||
     disable vdpau
 
 enabled vdpau &&
-    check_lib "vdpau/vdpau.h vdpau/vdpau_x11.h" vdp_device_create_x11 -lvdpau -lX11 &&
-    enable vdpau_x11
+    check_lib vdpau_x11 "vdpau/vdpau.h vdpau/vdpau_x11.h" vdp_device_create_x11 -lvdpau -lX11
 
 enabled debug && add_cflags -g"$debuglevel" && add_asflags -g"$debuglevel"
 
@@ -5062,10 +5058,6 @@ check_deps $CONFIG_LIST       \
            $HAVE_LIST         \
            $ALL_COMPONENTS    \
 
-enabled_all dxva2 CoTaskMemFree &&
-    prepend avconv_libs $($ldflags_filter "-lole32") &&
-    enable dxva2_lib
-
 map 'enabled $v && intrinsics=${v#intrinsics_}' $INTRINSICS_LIST
 
 for thread in $THREADS_LIST; do
@@ -5289,7 +5281,7 @@ HOSTCFLAGS=$host_cflags
 HOSTCPPFLAGS=$host_cppflags
 HOSTEXESUF=$HOSTEXESUF
 HOSTLDFLAGS=$host_ldflags
-HOSTLIBS=$host_libs
+HOSTEXTRALIBS=$host_extralibs
 DEPHOSTCC=$host_cc
 DEPHOSTCCFLAGS=$DEPHOSTCCFLAGS \$(HOSTCCFLAGS)
 HOSTCCDEP=$HOSTCCDEP
@@ -5337,12 +5329,12 @@ 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
+print_program_extralibs(){
+    eval "program_extralibs=\$${1}_extralibs"
+    eval echo "EXTRALIBS-${1}=${program_extralibs}" >> config.mak
 }
 
-map 'print_program_libs $v' $PROGRAM_LIST
+map 'print_program_extralibs $v' $PROGRAM_LIST
 
 cat > $TMPH <<EOF
 /* Automatically generated by configure - do not modify! */