Previously all external library dependencies were added as link-time
dependencies to all components. This adds bogus dependencies to some
components, so only add dependencies to components if said components
actually make use of a dependency.
---

This can still be improved a bit I guess.  Better function names welcome for
starters. Janne had some more substantive comments. Our pkg-config files have
many more issues, even after this patch...

 Makefile  |   2 +-
 configure | 247 +++++++++++++++++++++++++++++++++++---------------------------
 2 files changed, 141 insertions(+), 108 deletions(-)

diff --git a/Makefile b/Makefile
index 4e026b0..9786a4f 100644
--- a/Makefile
+++ b/Makefile
@@ -151,7 +151,7 @@ OBJS-$(1) += $(1).o $(EXEOBJS) $(OBJS-$(1)-yes)
 $(1)$(EXESUF): $$(OBJS-$(1))
 $$(OBJS-$(1)): CFLAGS  += $(CFLAGS-$(1))
 $(1)$(EXESUF): LDFLAGS += $(LDFLAGS-$(1))
-$(1)$(EXESUF): FF_EXTRALIBS += $(LIBS-$(1))
+$(1)$(EXESUF): FF_EXTRALIBS += $(EXTRALIBS-progs) $(EXTRALIBS-$(1)) 
$(LIBS-$(1))
 -include $$(OBJS-$(1):.o=.d)
 endef
 
diff --git a/configure b/configure
index 1484814..3ff0848 100755
--- a/configure
+++ b/configure
@@ -739,6 +739,14 @@ add_extralibs(){
     prepend extralibs $($ldflags_filter "$@")
 }
 
+add_extralibs_lib(){
+    libs=$1
+    shift
+    for lib in $libs; do
+        prepend extralibs_${lib} $($ldflags_filter "$@")
+    done
+}
+
 add_host_cppflags(){
     append host_cppflags "$@"
 }
@@ -991,7 +999,24 @@ check_lib(){
     headers="$1"
     funcs="$2"
     shift 2
-    check_func_headers "$headers" "$funcs" "$@" && add_extralibs "$@"
+    check_func_headers "$headers" "$funcs" "$@"
+}
+
+check_lib_global(){
+    log check_lib_global "$@"
+    headers="$1"
+    funcs="$2"
+    shift 2
+    check_lib "$headers" "$funcs" "$@" && add_extralibs "$@"
+}
+
+check_lib_libs(){
+    log check_lib_libs "$@"
+    libs="$1"
+    headers="$2"
+    funcs="$3"
+    shift 3
+    check_lib "$headers" "$funcs" "$@" && add_extralibs_lib "$libs" "$@"
 }
 
 check_pkg_config(){
@@ -1083,18 +1108,21 @@ check_compile_assert(){
 }
 
 require(){
-    name="$1"
-    headers="$2"
-    func="$3"
-    shift 3
-    check_lib "$headers" $func "$@" || die "ERROR: $name not found"
+    lib="$1"
+    name="$2"
+    headers="$3"
+    func="$4"
+    shift 4
+    check_lib_libs $lib "$headers" $func "$@" || die "ERROR: $name not found"
 }
 
 require_pkg_config(){
+    lib="$1"
+    shift
     pkg="$1"
     check_pkg_config "$@" || die "ERROR: $pkg not found"
-    add_cflags    $(get_safe "${pkg}_cflags")
-    add_extralibs $(get_safe "${pkg}_libs")
+    add_cflags             $(get_safe "${pkg}_cflags")
+    add_extralibs_lib $lib $(get_safe "${pkg}_libs")
 }
 
 hostcc_e(){
@@ -2110,7 +2138,7 @@ d3d11va_deps="d3d11_h dxva_h ID3D11VideoDecoder"
 dxva2_deps="dxva2api_h DXVA2_ConfigPictureDecode"
 vaapi_deps="va_va_h"
 vda_deps="VideoDecodeAcceleration_VDADecoder_h pthreads"
-vda_extralibs="-framework CoreFoundation -framework VideoDecodeAcceleration 
-framework QuartzCore"
+vda_extralibs_avcodec="-framework CoreFoundation -framework 
VideoDecodeAcceleration -framework QuartzCore"
 vdpau_deps="vdpau_vdpau_h vdpau_vdpau_x11_h"
 
 h263_vaapi_hwaccel_deps="vaapi"
@@ -2176,9 +2204,9 @@ wmv3_vdpau_hwaccel_select="vc1_vdpau_hwaccel"
 
 # hardware-accelerated codecs
 nvenc_deps_any="dlopen LoadLibrary"
-nvenc_extralibs='$ldl'
+nvenc_extralibs_avcodec='$ldl'
 omx_deps="dlopen pthreads"
-omx_extralibs='$ldl'
+omx_extralibs_avcodec='$ldl'
 qsvdec_select="qsv"
 qsvenc_select="qsv"
 vaapi_encode_deps="vaapi"
@@ -2355,7 +2383,7 @@ sndio_indev_deps="sndio_h"
 sndio_outdev_deps="sndio_h"
 v4l2_indev_deps_any="linux_videodev2_h sys_videoio_h"
 vfwcap_indev_deps="capCreateCaptureWindow vfwcap_defines"
-vfwcap_indev_extralibs="-lavicap32"
+vfwcap_indev_extralibs_avdevice="-lavicap32"
 xcbgrab_indev_deps="libxcb"
 
 # protocols
@@ -2407,9 +2435,9 @@ deinterlace_qsv_filter_deps="libmfx"
 delogo_filter_deps="gpl"
 drawtext_filter_deps="libfreetype"
 frei0r_filter_deps="frei0r dlopen"
-frei0r_filter_extralibs='$ldl'
+frei0r_filter_extralibs_avfilter='$ldl'
 frei0r_src_filter_deps="frei0r dlopen"
-frei0r_src_filter_extralibs='$ldl'
+frei0r_src_filter_extralibs_avfilter='$ldl'
 hdcd_filter_deps="libhdcd"
 hqdn3d_filter_deps="gpl"
 interlace_filter_deps="gpl"
@@ -3775,16 +3803,16 @@ case $target_os in
         ;;
     netbsd)
         disable symver
-        oss_indev_extralibs="-lossaudio"
-        oss_outdev_extralibs="-lossaudio"
+        oss_indev_extralibs_avdevice="-lossaudio"
+        oss_outdev_extralibs_avdevice="-lossaudio"
         ;;
     openbsd|bitrig)
         disable symver
         SHFLAGS='-shared'
         SLIB_INSTALL_NAME='$(SLIBNAME).$(LIBMAJOR).$(LIBMINOR)'
         SLIB_INSTALL_LINKS=
-        oss_indev_extralibs="-lossaudio"
-        oss_outdev_extralibs="-lossaudio"
+        oss_indev_extralibs_avdevice="-lossaudio"
+        oss_outdev_extralibs_avdevice="-lossaudio"
         ;;
     dragonfly)
         disable symver
@@ -4457,7 +4485,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_lib2 time.h clock_gettime -lrt && LIBRT="-lrt"; }
+        { check_lib_libs avutil time.h clock_gettime -lrt && LIBRT="-lrt"; }
 
 check_func  fcntl
 check_func  fork
@@ -4473,7 +4501,11 @@ 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; }
+# only needed for fbdev in libavdevice
+check_func_headers time.h nanosleep ||
+    { check_func_headers time.h nanosleep -lrt &&
+        add_extralibs_lib avutil   -lrt &&
+        add_extralibs_lib avdevice -lrt; }
 check_func  sched_getaffinity
 check_func  setrlimit
 check_func  strerror_r
@@ -4518,9 +4550,9 @@ check_header VideoDecodeAcceleration/VDADecoder.h
 check_header windows.h
 check_header X11/extensions/XvMClib.h
 
-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_libs progs  "windows.h shellapi.h" CommandLineToArgvW   -lshell32
+check_lib_libs avutil "windows.h wincrypt.h" CryptGenRandom       -ladvapi32
+check_lib_libs avconv "windows.h psapi.h"    GetProcessMemoryInfo -lpsapi
 
 check_struct "sys/time.h sys/resource.h" "struct rusage" ru_maxrss
 
@@ -4552,7 +4584,7 @@ if ! disabled pthreads && ! enabled w32threads; then
         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_global pthread.h pthread_join -lpthread; then
         :
     elif ! check_func pthread_join; then
         disable pthreads
@@ -4562,59 +4594,59 @@ 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_libs "avcodec avformat"  zlib.h  zlibVersion      
-lz    || disable  zlib
+disabled bzlib || check_lib_libs avformat            bzlib.h BZ2_bzlibVersion 
-lbz2  || disable bzlib
 
-check_lib math.h sin -lm && LIBM="-lm"
+check_lib_libs "avfilter swscale avformat avcodec avresample avutil" math.h 
sin -lm && LIBM="-lm"
 
 atan2f_args=2
 ldexpf_args=2
 powf_args=2
 
 for func in $MATH_FUNCS; do
-    eval check_mathfunc $func \${${func}_args:-1}
+    eval check_mathfunc $func \${${func}_args:-1} $LIBM
 done
 
 # these are off by default, so fail if requested and not available
-enabled avisynth          && { check_lib "avisynth/avisynth_c.h windows.h" 
LoadLibrary ||
-                               check_lib "avxsynth/avxsynth_c.h dlfcn.h" 
dlopen -ldl   ||
+enabled avisynth          && { check_lib_libs avformat "avisynth/avisynth_c.h 
windows.h" LoadLibrary ||
+                               check_lib_libs avformat "avxsynth/avxsynth_c.h 
dlfcn.h" dlopen -ldl   ||
                                die "ERROR: LoadLibrary/dlopen not found, or 
avisynth header not found"; }
-enabled cuda              && check_lib cuda.h cuInit -lcuda
+enabled cuda              && check_lib_libs "avfilter avcodec avutil" 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
-enabled libdcadec         && require libdcadec libdcadec/dca_context.h 
dcadec_context_create -ldcadec
-enabled libfaac           && require 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 gnutls            && require_pkg_config avformat gnutls 
gnutls/gnutls.h gnutls_global_init
+enabled libbs2b           && require_pkg_config avfilter libbs2b bs2b.h 
bs2b_open
+enabled libdcadec         && require avcodec libdcadec libdcadec/dca_context.h 
dcadec_context_create -ldcadec
+enabled libfaac           && require avcodec libfaac "stdint.h faac.h" 
faacEncGetVersion -lfaac
+enabled libfdk_aac        && require_pkg_config avcodec fdk-aac 
"fdk-aac/aacenc_lib.h" aacEncOpen
+enabled libfontconfig     && require_pkg_config avfilter fontconfig 
"fontconfig/fontconfig.h" FcInit
+enabled libfreetype       && require_pkg_config avfilter 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_libs avcodec "${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
-enabled libkvazaar        && require_pkg_config "kvazaar >= 0.8.1" kvazaar.h 
kvz_api_get
-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 libnpp            && require libnpp npp.h nppGetLibVersion -lnppi 
-lnppc
-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_lib 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 libhdcd           && require_pkg_config avfilter libhdcd 
"hdcd/hdcd_simple.h" hdcd_new
+enabled libilbc           && require avcodec libilbc ilbc.h 
WebRtcIlbcfix_InitDecode -lilbc
+enabled libkvazaar        && require_pkg_config avcodec "kvazaar >= 0.8.1" 
kvazaar.h kvz_api_get
+enabled libmfx            && require_pkg_config avcodec libmfx 
"mfx/mfxvideo.h" MFXInit
+enabled libmp3lame        && require avcodec "libmp3lame >= 3.98.3" 
lame/lame.h lame_set_VBR_quality -lmp3lame
+enabled libnpp            && require avfilter libnpp npp.h nppGetLibVersion 
-lnppi -lnppc
+enabled libopencore_amrnb && require avcodec libopencore_amrnb 
opencore-amrnb/interf_dec.h Decoder_Interface_init -lopencore-amrnb
+enabled libopencore_amrwb && require avcodec libopencore_amrwb 
opencore-amrwb/dec_if.h D_IF_init -lopencore-amrwb
+enabled libopencv         && require_pkg_config avfilter opencv opencv/cv.h 
cvCreateImageHeader
+enabled libopenh264       && require_pkg_config avcodec openh264 
wels/codec_api.h WelsGetCodecVersion
+enabled libopenjpeg       && { check_lib_libs avcodec openjpeg.h opj_version 
-lopenjpeg -DOPJ_STATIC ||
+                               require_pkg_config avcodec libopenjpeg1 
openjpeg.h opj_version -DOPJ_STATIC; }
+enabled libopus           && require_pkg_config avcodec opus 
opus_multistream.h opus_multistream_decoder_create
+enabled libpulse          && require_pkg_config avdevice libpulse-simple 
pulse/simple.h pa_simple_new
+enabled librtmp           && require_pkg_config avformat librtmp 
librtmp/rtmp.h RTMP_Socket
+enabled libschroedinger   && require_pkg_config avcodec schroedinger-1.0 
schroedinger/schro.h schro_init
+enabled libsnappy         && require avcodec snappy snappy-c.h snappy_compress 
-lsnappy
+enabled libspeex          && require_pkg_config avcodec speex speex/speex.h 
speex_decoder_init -lspeex
+enabled libtheora         && require avcodec libtheora theora/theoraenc.h 
th_info_init -ltheoraenc -ltheoradec -logg
+enabled libtwolame        && require avcodec libtwolame twolame.h twolame_init 
-ltwolame
+enabled libvo_aacenc      && require avcodec libvo_aacenc vo-aacenc/voAAC.h 
voGetAACEncAPI -lvo-aacenc
+enabled libvo_amrwbenc    && require avcodec libvo_amrwbenc 
vo-amrwbenc/enc_if.h E_IF_init -lvo-amrwbenc
+enabled libvorbis         && require avcodec libvorbis vorbis/vorbisenc.h 
vorbis_info_init -lvorbisenc -lvorbis -logg
+enabled libvpx            && require_pkg_config avcodec "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;
@@ -4632,52 +4664,45 @@ enabled libvpx            && require_pkg_config "vpx >= 
1.3.0" vpx/vpx_codec.h v
             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"
+        die "libvpx enabled but no supported decoders/encoders found"
     fi
 }
-enabled libwavpack        && require libwavpack wavpack/wavpack.h 
WavpackOpenFileOutput  -lwavpack
-enabled libwebp           && require_pkg_config libwebp webp/encode.h 
WebPGetEncoderVersion
-enabled libx264           && require_pkg_config x264 "stdint.h x264.h" 
x264_encoder_encode &&
+enabled libwavpack        && require avcodec libwavpack wavpack/wavpack.h 
WavpackOpenFileOutput  -lwavpack
+enabled libwebp           && require_pkg_config avcodec libwebp webp/encode.h 
WebPGetEncoderVersion
+enabled libx264           && require_pkg_config avcodec 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 &&
+enabled libx265           && require_pkg_config avcodec 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 libxavs           && require avcodec libxavs xavs.h 
xavs_encoder_encode -lxavs
+enabled libxvid           && require avcodec libxvid xvid.h xvid_global 
-lxvidcore
+enabled mmal              && { check_lib_libs avcodec 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 ; } ||
+                                    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_lib avcodec -L/opt/vc/lib/ 
-lmmal_core -lmmal_util -lmmal_vc_client -lbcm_host;
+                                    check_lib_libs avcodec 
interface/mmal/mmal.h mmal_port_connect; }
+                                check_lib_libs avcodec interface/mmal/mmal.h 
mmal_port_connect; } ||
                                die "ERROR: mmal not found"; }
-enabled mmal && check_func_headers interface/mmal/mmal.h 
"MMAL_PARAMETER_VIDEO_MAX_NUM_CALLBACKS"
-enabled omx_rpi && enable omx
-enabled omx               && { check_header OMX_Core.h ||
-                                { ! enabled cross_compile && enabled omx_rpi 
&& {
-                                    add_cflags -isystem/opt/vc/include/IL ; }
-                                check_header OMX_Core.h ; } ||
-                               die "ERROR: OpenMAX IL headers not found"; }
 enabled openssl           && { 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_libs; } ||
+                               check_lib_libs avformat openssl/ssl.h 
SSL_library_init -lssl -lcrypto  ||
+                               check_lib_libs avformat openssl/ssl.h 
SSL_library_init -lssl32 -leay32 ||
+                               check_lib_libs avformat openssl/ssl.h 
SSL_library_init -lssl -lcrypto -lws2_32 -lgdi32 ||
                                die "ERROR: openssl not found"; }
 
 if enabled gnutls; then
-    { check_lib2 gmp.h mpz_export -lgmp && enable gmp; } ||
-    { check_lib gcrypt.h gcry_mpi_new -lgcrypt && enable gcrypt; }
+    { check_lib_libs avformat nettle/bignum.h nettle_mpz_get_str_256 -lnettle 
-lhogweed -lgmp && enable nettle; } ||
+    { check_lib_libs avformat gcrypt.h gcry_mpi_new -lgcrypt && enable gcrypt; 
}
 fi
 
 # libdc1394 check
 if enabled libdc1394; then
-    { require_pkg_config libdc1394-2 dc1394/dc1394.h dc1394_new &&
+    { require_pkg_config avdevice libdc1394-2 dc1394/dc1394.h dc1394_new &&
         enable libdc1394_2; } ||
-    { check_lib libdc1394/dc1394_control.h dc1394_create_handle 
-ldc1394_control -lraw1394 &&
+    { check_lib_libs avdevice libdc1394/dc1394_control.h dc1394_create_handle 
-ldc1394_control -lraw1394 &&
         enable libdc1394_1; } ||
     die "ERROR: No version of libdc1394 found "
 fi
@@ -4708,7 +4733,7 @@ check_header AVFoundation/AVFoundation.h &&
 
 check_header sys/videoio.h
 
-check_func_headers "windows.h vfw.h" capCreateCaptureWindow 
"$vfwcap_indev_extralibs"
+check_func_headers "windows.h vfw.h" capCreateCaptureWindow 
"$vfwcap_indev_extralibs_avdevice"
 # 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
@@ -4727,20 +4752,21 @@ 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_libs avdevice alsa/asoundlib.h snd_pcm_htimestamp -lasound
 
-enabled jack_indev && check_lib jack/jack.h jack_client_open -ljack &&
+enabled jack_indev &&
+    check_lib_libs avdevice 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_libs avdevice 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_libs avdevice "cdio/cdda.h cdio/paranoia.h" cdio_cddap_open 
-lcdio_paranoia -lcdio_cdda -lcdio ||
+    check_lib_libs avdevice "cdio/paranoia/cdda.h cdio/paranoia/paranoia.h" 
cdio_cddap_open -lcdio_paranoia -lcdio_cdda -lcdio ||
     die "ERROR: No usable libcdio/cdparanoia found"
 fi
 
-check_lib X11/Xlib.h XOpenDisplay -lX11 && enable xlib
+check_lib_libs avdevice X11/Xlib.h XOpenDisplay -lX11 && enable xlib
 
 if enabled libxcb; then
     check_pkg_config xcb-shape xcb/shape.h xcb_shape_rectangles || {
@@ -4758,10 +4784,10 @@ if enabled libxcb; then
         } && 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"
+    add_extralibs_lib avdevice "$xcb_event_libs $xcb_shm_libs $xcb_xfixes_libs"
 fi
 
-enabled vaapi && require vaapi va/va.h vaInitialize -lva
+enabled vaapi && require avcodec vaapi va/va.h vaInitialize -lva
 
 enabled vaapi &&
     check_code cc "va/va.h" "vaCreateSurfaces(0, 0, 0, 0, 0, 0, 0, 0)" ||
@@ -4769,10 +4795,10 @@ enabled vaapi &&
 
 if enabled vaapi ; then
     enabled xlib &&
-    check_lib "va/va.h va/va_x11.h" vaGetDisplay -lva -lva-x11 &&
+    check_lib_libs "avcodec avutil" "va/va.h va/va_x11.h" vaGetDisplay -lva 
-lva-x11 &&
     enable vaapi_x11
 
-    check_lib "va/va.h va/va_drm.h" vaGetDisplayDRM -lva -lva-drm &&
+    check_lib_libs "avcodec avutil" "va/va.h va/va_drm.h" vaGetDisplayDRM -lva 
-lva-drm &&
     enable vaapi_drm
 fi
 
@@ -4781,7 +4807,7 @@ enabled vdpau &&
     disable vdpau
 
 enabled vdpau && enabled xlib &&
-    check_lib "vdpau/vdpau.h vdpau/vdpau_x11.h" vdp_device_create_x11 -lvdpau 
&&
+    check_lib_libs "avutil avcodec" "vdpau/vdpau.h vdpau/vdpau_x11.h" 
vdp_device_create_x11 -lvdpau &&
     enable vdpau_x11
 
 enabled debug && add_cflags -g"$debuglevel" && add_asflags -g"$debuglevel"
@@ -5245,7 +5271,14 @@ TARGET_SAMPLES=${target_samples:-\$(SAMPLES)}
 CFLAGS-avplay=$sdl_cflags
 ZLIB=$($ldflags_filter -lz)
 LIB_INSTALL_EXTRA_CMD=$LIB_INSTALL_EXTRA_CMD
-EXTRALIBS=$extralibs
+EXTRALIBS=$extralibs_avfilter $extralibs_avdevice $extralibs_avformat 
$extralibs_avcodec $extralibs_avutil $extralibs
+EXTRALIBS-avcodec=$extralibs_avcodec
+EXTRALIBS-avdevice=$extralibs_avdevice
+EXTRALIBS-avfilter=$extralibs_avfilter
+EXTRALIBS-avformat=$extralibs_avformat
+EXTRALIBS-avutil=$extralibs_avutil
+EXTRALIBS-progs=$extralibs_progs
+EXTRALIBS-avconv=$extralibs_avconv
 COMPAT_OBJS=$compat_objs
 EXEOBJS=$exeobjs
 INSTALL=install
@@ -5403,9 +5436,9 @@ EOF
 }
 
 pkgconfig_generate libavutil     "Libav utility library"          
"$LIBAVUTIL_VERSION"     "$LIBRT $LIBM"
-pkgconfig_generate libavcodec    "Libav codec library"            
"$LIBAVCODEC_VERSION"    "$extralibs"
-pkgconfig_generate libavformat   "Libav container format library" 
"$LIBAVFORMAT_VERSION"   "$extralibs"
-pkgconfig_generate libavdevice   "Libav device handling library"  
"$LIBAVDEVICE_VERSION"   "$extralibs"
-pkgconfig_generate libavfilter   "Libav video filtering library"  
"$LIBAVFILTER_VERSION"   "$extralibs"
+pkgconfig_generate libavcodec    "Libav codec library"            
"$LIBAVCODEC_VERSION"    "$extralibs_avcodec"
+pkgconfig_generate libavformat   "Libav container format library" 
"$LIBAVFORMAT_VERSION"   "$extralibs_avformat"
+pkgconfig_generate libavdevice   "Libav device handling library"  
"$LIBAVDEVICE_VERSION"   "$extralibs_avdevice"
+pkgconfig_generate libavfilter   "Libav video filtering library"  
"$LIBAVFILTER_VERSION"   "$extralibs_avfilter"
 pkgconfig_generate libavresample "Libav audio resampling library" 
"$LIBAVRESAMPLE_VERSION" "$LIBM"
 pkgconfig_generate libswscale    "Libav image rescaling library"  
"$LIBSWSCALE_VERSION"    "$LIBM"
-- 
2.1.4

_______________________________________________
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel

Reply via email to