Previously, all link-time dependencies were added for all libraries,
resulting in bogus link-time dependencies since not all dependencies
are shared across libraries. Also, in some cases like libavutil, not
all dependencies were taken into account, resulting in some cases of
underlinking.

To address all this mess a machinery is added for tracking which
dependency belongs to which library component and then leveraged
to determine correct dependencies for all individual libraries.
---

The main course:

- check_deps() is now simplified by not handling extralibs anymore
- extralibs are resolved according to Janne's idea

- If you look closely, you may notice that I use "foo_libs" instead
  of "foo_extralibs" in a few places. That's due to the way that
  the pkg-config-related checks function. Maybe it's time to change
  that, dunno.
- Possibly I should still investigate Janne's idea of using the
  function name as variable name instead of adding a library name
  parameter to things like check_lib().


 Makefile                |   2 +-
 common.mak              |   2 +-
 configure               | 303 ++++++++++++++++++++++++++++++++++++------------
 tests/checkasm/Makefile |   2 +-
 4 files changed, 232 insertions(+), 77 deletions(-)

diff --git a/Makefile b/Makefile
index cb5a88f..e0cf1e3 100644
--- a/Makefile
+++ b/Makefile
@@ -161,7 +161,7 @@ OBJS-$(1) += $(1).o $(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-$(1))
 -include $$(OBJS-$(1):.o=.d)
 endef
 
diff --git a/common.mak b/common.mak
index 9eb8e05..27b6130 100644
--- a/common.mak
+++ b/common.mak
@@ -11,7 +11,7 @@ OBJS      += $(OBJS-yes)
 FFLIBS    := $($(NAME)_FFLIBS) $(FFLIBS-yes) $(FFLIBS)
 TESTPROGS += $(TESTPROGS-yes)
 
-FFEXTRALIBS := $(FFLIBS:%=$(LD_LIB)) $(EXTRALIBS)
+FFEXTRALIBS := $(FFLIBS:%=$(LD_LIB)) $(foreach lib,EXTRALIBS-$(NAME) 
$(FFLIBS:%=EXTRALIBS-%),$($(lib))) $(EXTRALIBS)
 
 OBJS      := $(sort $(OBJS:%=$(SUBDIR)%))
 TESTOBJS  := $(TESTOBJS:%=$(SUBDIR)tests/%) $(TESTPROGS:%=$(SUBDIR)tests/%.o)
diff --git a/configure b/configure
index eed12bf..3fa159f 100755
--- a/configure
+++ b/configure
@@ -608,7 +608,7 @@ is_in(){
     return 1
 }
 
-do_check_deps(){
+check_deps(){
     for cfg; do
         cfg="${cfg#!}"
         enabled ${cfg}_checking && die "Circular dependency for $cfg."
@@ -624,7 +624,7 @@ do_check_deps(){
         eval dep_ifn="\$${cfg}_if_any"
 
         pushvar cfg dep_all dep_any dep_sel dep_sgs dep_ifa dep_ifn
-        do_check_deps $dep_all $dep_any $dep_sel $dep_sgs $dep_ifa $dep_ifn
+        check_deps $dep_all $dep_any $dep_sel $dep_sgs $dep_ifa $dep_ifn
         popvar cfg dep_all dep_any dep_sel dep_sgs dep_ifa dep_ifn
 
         [ -n "$dep_ifa" ] && { enabled_all $dep_ifa && enable_weak $cfg; }
@@ -642,15 +642,19 @@ do_check_deps(){
     done
 }
 
-check_deps(){
-    unset allopts
-
-    do_check_deps "$@"
-
-    for cfg in $allopts; do
+set_component_extralibs(){
+    unset dep_libs
+    linkunit=$1
+    shift 1
+    for cfg in $@; do
         enabled $cfg || continue
-        eval dep_extralibs="\$${cfg}_extralibs"
-        test -n "$dep_extralibs" && add_extralibs $dep_extralibs
+        eval dep_lbs="\$${cfg}_extralibs"
+        for lib in $dep_lbs; do
+            eval append dep_libs "\$${lib}"
+        done
+        if test -n "$dep_libs"; then
+            add_extralibs_lib $linkunit $dep_libs
+        fi
     done
 }
 
@@ -740,6 +744,13 @@ add_extralibs(){
     prepend extralibs $($ldflags_filter "$@")
 }
 
+add_extralibs_lib(){
+    lib=$1
+    shift
+    prepend extralibs_${lib} $($ldflags_filter "$@")
+    unique  extralibs_${lib}
+}
+
 add_host_cppflags(){
     append host_cppflags "$@"
 }
@@ -1002,10 +1013,11 @@ EOF
 
 check_lib(){
     log check_lib "$@"
-    headers="$1"
-    funcs="$2"
-    shift 2
-    check_func_headers "$headers" "$funcs" "$@" && add_extralibs "$@"
+    name="$1"
+    headers="$2"
+    func="$3"
+    shift 3
+    check_func_headers "$headers" "$func" "$@" && eval ${name}_extralibs="\$@"
 }
 
 check_pkg_config(){
@@ -1101,10 +1113,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(){
@@ -1113,7 +1126,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")
+    eval $(sanitize_var_name ${pkg}_extralibs)="\$(get_safe ${pkg}_libs)"
 }
 
 hostcc_e(){
@@ -1947,6 +1960,7 @@ cavs_decoder_select="blockdsp golomb h264chroma idctdsp 
qpeldsp videodsp"
 cllc_decoder_select="bswapdsp"
 comfortnoise_encoder_select="lpc"
 cook_decoder_select="audiodsp mdct sinewin"
+cscd_decoder_extralibs="zlib_extralibs"
 cscd_decoder_select="lzo"
 cscd_decoder_suggest="zlib"
 dca_decoder_select="fmtconvert mdct"
@@ -1956,6 +1970,7 @@ dnxhd_encoder_select="aandcttables blockdsp fdctdsp 
idctdsp mpegvideoenc pixbloc
 dvvideo_decoder_select="dvprofile idctdsp"
 dvvideo_encoder_select="dvprofile fdctdsp me_cmp pixblockdsp"
 dxa_decoder_deps="zlib"
+dxa_decoder_extralibs="zlib_extralibs"
 dxv_decoder_select="lzf texturedsp"
 eac3_decoder_select="ac3_decoder"
 eac3_encoder_select="ac3_encoder"
@@ -1963,6 +1978,7 @@ eamad_decoder_select="aandcttables blockdsp bswapdsp 
idctdsp mpegvideo"
 eatgq_decoder_select="aandcttables idctdsp"
 eatqi_decoder_select="aandcttables blockdsp bswapdsp idctdsp"
 exr_decoder_deps="zlib"
+exr_decoder_extralibs="zlib_extralibs"
 ffv1_decoder_select="golomb rangecoder"
 ffv1_encoder_select="rangecoder"
 ffvhuff_decoder_select="huffyuv_decoder"
@@ -1971,13 +1987,17 @@ fic_decoder_select="golomb"
 flac_decoder_select="flacdsp golomb"
 flac_encoder_select="bswapdsp flacdsp golomb lpc"
 flashsv_decoder_deps="zlib"
+flashsv_decoder_extralibs="zlib_extralibs"
 flashsv_encoder_deps="zlib"
+flashsv_encoder_extralibs="zlib_extralibs"
 flashsv2_decoder_deps="zlib"
+flashsv2_decoder_extralibs="zlib_extralibs"
 flv_decoder_select="h263_decoder"
 flv_encoder_select="h263_encoder"
 fourxm_decoder_select="blockdsp bswapdsp"
 fraps_decoder_select="bswapdsp huffman"
 g2m_decoder_deps="zlib"
+g2m_decoder_extralibs="zlib_extralibs"
 g2m_decoder_select="blockdsp idctdsp jpegtables"
 h261_decoder_select="mpeg_er mpegvideo"
 h261_encoder_select="aandcttables mpegvideoenc"
@@ -1989,6 +2009,7 @@ h264_decoder_select="cabac golomb h264chroma h264dsp 
h264parse h264pred h264qpel
 h264_decoder_suggest="error_resilience"
 hap_decoder_select="snappy texturedsp"
 hap_encoder_deps="libsnappy"
+hap_encoder_extralibs="libsnappy_extralibs"
 hap_encoder_select="texturedspenc"
 hevc_decoder_select="bswapdsp cabac golomb videodsp"
 huffyuv_decoder_select="bswapdsp huffyuvdsp"
@@ -2050,7 +2071,9 @@ on2avc_decoder_select="mdct"
 opus_decoder_deps="avresample"
 opus_decoder_select="imdct15"
 png_decoder_deps="zlib"
+png_decoder_extralibs="zlib_extralibs"
 png_encoder_deps="zlib"
+png_encoder_extralibs="zlib_extralibs"
 png_encoder_select="huffyuvencdsp"
 prores_decoder_select="idctdsp"
 prores_encoder_select="fdctdsp"
@@ -2059,6 +2082,7 @@ qdm2_decoder_select="mdct rdft mpegaudiodsp"
 ra_144_encoder_select="audio_frame_queue lpc"
 ralf_decoder_select="golomb"
 rscc_decoder_deps="zlib"
+rscc_decoder_extralibs="zlib_extralibs"
 rv10_decoder_select="error_resilience h263_decoder h263dsp mpeg_er"
 rv10_encoder_select="h263_encoder"
 rv20_decoder_select="error_resilience h263_decoder h263dsp mpeg_er"
@@ -2066,6 +2090,7 @@ 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"
+screenpresso_decoder_extralibs="zlib_extralibs"
 shorten_decoder_select="golomb"
 sipr_decoder_select="lsp"
 sp5x_decoder_select="mjpeg_decoder"
@@ -2073,17 +2098,22 @@ svq1_decoder_select="hpeldsp"
 svq1_encoder_select="aandcttables hpeldsp me_cmp mpegvideoenc"
 svq3_decoder_select="golomb h264dsp h264parse h264pred hpeldsp tpeldsp 
videodsp"
 svq3_decoder_suggest="zlib"
+svq3_decoder_extralibs="zlib_extralibs"
 tak_decoder_select="audiodsp"
 tdsc_decoder_deps="zlib"
+tdsc_decoder_extralibs="zlib_extralibs"
 tdsc_decoder_select="mjpeg_decoder"
 theora_decoder_select="vp3_decoder"
 thp_decoder_select="mjpeg_decoder"
+tiff_decoder_extralibs="zlib_extralibs"
 tiff_decoder_suggest="zlib"
+tiff_encoder_extralibs="zlib_extralibs"
 tiff_encoder_suggest="zlib"
 truehd_decoder_select="mlp_decoder"
 truemotion2_decoder_select="bswapdsp"
 truespeech_decoder_select="bswapdsp"
 tscc_decoder_deps="zlib"
+tscc_decoder_extralibs="zlib_extralibs"
 txd_decoder_select="texturedsp"
 twinvq_decoder_select="mdct lsp sinewin"
 utvideo_decoder_select="bswapdsp"
@@ -2115,70 +2145,106 @@ wmv2_encoder_select="h263_encoder wmv2dsp"
 wmv3_decoder_select="vc1_decoder"
 wmv3image_decoder_select="wmv3_decoder"
 zerocodec_decoder_deps="zlib"
+zerocodec_decoder_extralibs="zlib_extralibs"
 zlib_decoder_deps="zlib"
+zlib_decoder_extralibs="zlib_extralibs"
 zlib_encoder_deps="zlib"
+zlib_encoder_extralibs="zlib_extralibs"
 zmbv_decoder_deps="zlib"
+zmbv_decoder_extralibs="zlib_extralibs"
 zmbv_encoder_deps="zlib"
+zmbv_encoder_extralibs="zlib_extralibs"
 
 # hardware accelerators
 d3d11va_deps="d3d11_h dxva_h ID3D11VideoDecoder"
 dxva2_deps="dxva2api_h DXVA2_ConfigPictureDecode"
 vaapi_deps="va_va_h"
+vaapi_extralibs='$vaapi_extralibs $vaapi_drm_extralibs $vaapi_x11_extralibs'
 vda_deps="VideoDecodeAcceleration_VDADecoder_h pthreads"
-vda_extralibs="-framework CoreFoundation -framework VideoDecodeAcceleration 
-framework QuartzCore"
+vda_extralibs="-framework CoreFoundation -framework VideoDecodeAcceleration 
-framework QuartzCore pthreads_extralibs"
 vdpau_deps="vdpau_vdpau_h vdpau_vdpau_x11_h"
 
 h263_vaapi_hwaccel_deps="vaapi"
+h263_vaapi_hwaccel_extralibs="vaapi_extralibs"
 h263_vaapi_hwaccel_select="h263_decoder"
 h264_d3d11va_hwaccel_deps="d3d11va"
+h264_d3d11va_hwaccel_extralibs="d3d11va_extralibs"
 h264_d3d11va_hwaccel_select="h264_decoder"
 h264_dxva2_hwaccel_deps="dxva2"
+h264_dxva2_hwaccel_extralibs="dxva2_extralibs"
 h264_dxva2_hwaccel_select="h264_decoder"
 h264_mmal_hwaccel_deps="mmal"
+h264_mmal_hwaccel_extralibs="mmal_extralibs"
 h264_qsv_hwaccel_deps="libmfx"
+h264_qsv_hwaccel_extralibs="libmfx_extralibs"
 h264_vaapi_hwaccel_deps="vaapi"
+h264_vaapi_hwaccel_extralibs="vaapi_extralibs"
 h264_vaapi_hwaccel_select="h264_decoder"
 h264_vda_hwaccel_deps="vda"
+h264_vda_hwaccel_extralibs="vda_extralibs"
 h264_vda_hwaccel_select="h264_decoder"
 h264_vda_old_hwaccel_deps="vda"
+h264_vda_old_hwaccel_extralibs="vda_extralibs"
 h264_vda_old_hwaccel_select="h264_decoder"
 h264_vdpau_hwaccel_deps="vdpau"
+h264_vdpau_hwaccel_extralibs="vdpau_extralibs"
 h264_vdpau_hwaccel_select="h264_decoder"
 hevc_d3d11va_hwaccel_deps="d3d11va DXVA_PicParams_HEVC"
+hevc_d3d11va_hwaccel_extralibs="d3d11va_extralibs"
 hevc_d3d11va_hwaccel_select="hevc_decoder"
 hevc_dxva2_hwaccel_deps="dxva2 DXVA_PicParams_HEVC"
+hevc_dxva2_hwaccel_extralibs="dxva2_extralibs"
 hevc_dxva2_hwaccel_select="hevc_decoder"
 hevc_qsv_hwaccel_deps="libmfx"
+hevc_qsv_hwaccel_extralibs="libmfx_extralibs"
 hevc_vdpau_hwaccel_deps="vdpau VdpPictureInfoHEVC"
+hevc_vdpau_hwaccel_extralibs="vdpau_extralibs"
 hevc_vdpau_hwaccel_select="hevc_decoder"
 mpeg1_vdpau_hwaccel_deps="vdpau"
+mpeg1_vdpau_hwaccel_extralibs="vdpau_extralibs"
 mpeg1_vdpau_hwaccel_select="mpeg1video_decoder"
 mpeg2_d3d11va_hwaccel_deps="d3d11va"
+mpeg2_d3d11va_hwaccel_extralibs="d3d11va_extralibs"
 mpeg2_d3d11va_hwaccel_select="mpeg2video_decoder"
 mpeg2_dxva2_hwaccel_deps="dxva2"
+mpeg2_dxva2_hwaccel_extralibs="dxva2_extralibs"
 mpeg2_dxva2_hwaccel_select="mpeg2video_decoder"
 mpeg2_mmal_hwaccel_deps="mmal"
+mpeg2_mmal_hwaccel_extralibs="mmal_extralibs"
 mpeg2_qsv_hwaccel_deps="libmfx"
+mpeg2_qsv_hwaccel_extralibs="libmfx_extralibs"
 mpeg2_vaapi_hwaccel_deps="vaapi"
+mpeg2_vaapi_hwaccel_extralibs="vaapi_extralibs"
 mpeg2_vaapi_hwaccel_select="mpeg2video_decoder"
 mpeg2_vdpau_hwaccel_deps="vdpau"
+mpeg2_vdpau_hwaccel_extralibs="vdpau_extralibs"
 mpeg2_vdpau_hwaccel_select="mpeg2video_decoder"
 mpeg4_vaapi_hwaccel_deps="vaapi"
+mpeg4_vaapi_hwaccel_extralibs="vaapi_extralibs"
 mpeg4_vaapi_hwaccel_select="mpeg4_decoder"
 mpeg4_vdpau_hwaccel_deps="vdpau"
+mpeg4_vdpau_hwaccel_extralibs="vdpau_extralibs"
 mpeg4_vdpau_hwaccel_select="mpeg4_decoder"
 vc1_d3d11va_hwaccel_deps="d3d11va"
+vc1_d3d11va_hwaccel_extralibs="d3d11va_extralibs"
 vc1_d3d11va_hwaccel_select="vc1_decoder"
 vc1_dxva2_hwaccel_deps="dxva2"
+vc1_dxva2_hwaccel_extralibs="dxva2_extralibs"
 vc1_dxva2_hwaccel_select="vc1_decoder"
 vc1_mmal_hwaccel_deps="mmal"
+vc1_mmal_hwaccel_extralibs="mmal_extralibs"
 vc1_qsv_hwaccel_deps="libmfx"
+vc1_qsv_hwaccel_extralibs="libmfx_extralibs"
 vc1_vaapi_hwaccel_deps="vaapi"
+vc1_vaapi_hwaccel_extralibs="vaapi_extralibs"
 vc1_vaapi_hwaccel_select="vc1_decoder"
 vc1_vdpau_hwaccel_deps="vdpau"
+vc1_vdpau_hwaccel_extralibs="vdpau_extralibs"
 vc1_vdpau_hwaccel_select="vc1_decoder"
 vp8_qsv_hwaccel_deps="libmfx"
+vp8_qsv_hwaccel_extralibs="libmfx_extralibs"
 vp8_vaapi_hwaccel_deps="vaapi VAPictureParameterBufferVP8"
+vp8_vaapi_hwaccel_extralibs="vaapi_extralibs"
 vp8_vaapi_hwaccel_select="vp8_decoder"
 wmv3_d3d11va_hwaccel_select="vc1_d3d11va_hwaccel"
 wmv3_dxva2_hwaccel_select="vc1_dxva2_hwaccel"
@@ -2187,15 +2253,17 @@ wmv3_vdpau_hwaccel_select="vc1_vdpau_hwaccel"
 
 # hardware-accelerated codecs
 nvenc_deps_any="cuda dlopen LoadLibrary"
-nvenc_extralibs='$ldl'
+nvenc_extralibs="cuda_extralibs dlopen_extralibs"
 omx_deps="dlopen pthreads"
-omx_extralibs='$ldl'
+omx_extralibs="dlopen_extralibs pthreads_extralibs"
 qsvdec_select="qsv"
 qsvenc_select="qsv"
 vaapi_encode_deps="vaapi"
 
 hwupload_cuda_filter_deps="cuda"
+hwupload_cuda_filter_extralibs="cuda_extralibs"
 scale_npp_filter_deps="cuda libnpp"
+scale_npp_filter_extralibs="cuda_extralibs libnpp_extralibs"
 
 h264_mmal_decoder_deps="mmal"
 h264_nvenc_encoder_deps="nvenc"
@@ -2244,57 +2312,98 @@ mjpeg2jpeg_bsf_select="jpegtables"
 avisynth_deps="LoadLibrary"
 avxsynth_deps="dlopen"
 avisynth_demuxer_deps_any="avisynth avxsynth"
+avisynth_demuxer_extralibs="dlopen_extralibs"
 avisynth_demuxer_select="riffdec"
 libdcadec_decoder_deps="libdcadec"
+libdcadec_decoder_extralibs="libdcadec_extralibs"
 libfaac_encoder_deps="libfaac"
+libfaac_encoder_extralibs="libfaac_extralibs"
 libfaac_encoder_select="audio_frame_queue"
 libfdk_aac_decoder_deps="libfdk_aac"
+libfdk_aac_decoder_extralibs="fdk_aac_extralibs"
 libfdk_aac_encoder_deps="libfdk_aac"
+libfdk_aac_encoder_extralibs="fdk_aac_extralibs"
 libfdk_aac_encoder_select="audio_frame_queue"
 libgsm_decoder_deps="libgsm"
+libgsm_decoder_extralibs="libgsm_extralibs"
 libgsm_encoder_deps="libgsm"
+libgsm_encoder_extralibs="libgsm_extralibs"
 libgsm_ms_decoder_deps="libgsm"
+libgsm_ms_decoder_extralibs="libgsm_extralibs"
 libgsm_ms_encoder_deps="libgsm"
+libgsm_ms_encoder_extralibs="libgsm_extralibs"
 libilbc_decoder_deps="libilbc"
+libilbc_decoder_extralibs="libilbc_extralibs"
 libilbc_encoder_deps="libilbc"
+libilbc_encoder_extralibs="libilbc_extralibs"
 libkvazaar_encoder_deps="libkvazaar"
+libkvazaar_encoder_extralibs="kvazaar_extralibs"
 libmp3lame_encoder_deps="libmp3lame"
+libmp3lame_encoder_extralibs="libmp3lame_extralibs"
 libmp3lame_encoder_select="audio_frame_queue"
 libopencore_amrnb_decoder_deps="libopencore_amrnb"
+libopencore_amrnb_decoder_extralibs="libopencore_amrnb_extralibs"
 libopencore_amrnb_encoder_deps="libopencore_amrnb"
+libopencore_amrnb_encoder_extralibs="libopencore_amrnb_extralibs"
 libopencore_amrnb_encoder_select="audio_frame_queue"
 libopencore_amrwb_decoder_deps="libopencore_amrwb"
+libopencore_amrwb_decoder_extralibs="libopencore_amrwb_extralibs"
 libopenh264_decoder_deps="libopenh264"
+libopenh264_decoder_extralibs="openh264_extralibs"
 libopenh264_decoder_select="h264_mp4toannexb_bsf"
 libopenh264_encoder_deps="libopenh264"
+libopenh264_encoder_extralibs="openh264_extralibs"
 libopenjpeg_decoder_deps="libopenjpeg"
+libopenjpeg_decoder_extralibs="libopenjpeg_extralibs libopenjpeg1_extralibs"
 libopenjpeg_encoder_deps="libopenjpeg"
+libopenjpeg_encoder_extralibs="libopenjpeg_extralibs libopenjpeg1_extralibs"
 libopus_decoder_deps="libopus"
+libopus_decoder_extralibs="opus_extralibs"
 libopus_encoder_deps="libopus"
+libopus_encoder_extralibs="opus_extralibs"
 libopus_encoder_select="audio_frame_queue"
 libschroedinger_decoder_deps="libschroedinger"
+libschroedinger_decoder_extralibs="schroedinger_1_0_extralibs"
 libschroedinger_encoder_deps="libschroedinger"
+libschroedinger_encoder_extralibs="schroedinger_1_0_extralibs"
 libspeex_decoder_deps="libspeex"
+libspeex_decoder_extralibs="speex_extralibs"
 libspeex_encoder_deps="libspeex"
+libspeex_encoder_extralibs="speex_extralibs"
 libspeex_encoder_select="audio_frame_queue"
 libtheora_encoder_deps="libtheora"
+libtheora_encoder_extralibs="libtheora_extralibs"
 libtwolame_encoder_deps="libtwolame"
+libtwolame_encoder_extralibs="libtwolame_extralibs"
 libvo_aacenc_encoder_deps="libvo_aacenc"
+libvo_aacenc_encoder_extralibs="libvo_aacenc_extralibs"
 libvo_aacenc_encoder_select="audio_frame_queue"
 libvo_amrwbenc_encoder_deps="libvo_amrwbenc"
+libvo_amrwbenc_encoder_extralibs="libvo_amrwbenc_extralibs"
 libvorbis_encoder_deps="libvorbis"
+libvorbis_encoder_extralibs="libvorbis_extralibs"
 libvorbis_encoder_select="audio_frame_queue"
 libvpx_vp8_decoder_deps="libvpx"
+libvpx_vp8_decoder_extralibs="vpx_extralibs"
 libvpx_vp8_encoder_deps="libvpx"
+libvpx_vp8_encoder_extralibs="vpx_extralibs"
 libvpx_vp9_decoder_deps="libvpx"
+libvpx_vp9_decoder_extralibs="vpx_extralibs"
 libvpx_vp9_encoder_deps="libvpx"
+libvpx_vp9_encoder_extralibs="vpx_extralibs"
 libwavpack_encoder_deps="libwavpack"
+libwavpack_encoder_extralibs="libwavpack_extralibs"
 libwebp_encoder_deps="libwebp"
+libwebp_encoder_extralibs="libwebp_extralibs"
 libx262_encoder_deps="libx262"
 libx264_encoder_deps="libx264"
+libx264_encoder_extralibs="x264_extralibs"
 libx265_encoder_deps="libx265"
+libx265_encoder_extralibs="x265_extralibs"
 libxavs_encoder_deps="libxavs"
+libxavs_encoder_extralibs="libxavs_extralibs"
 libxvid_encoder_deps="libxvid mkstemp"
+libxvid_encoder_extralibs="libxvid_extralibs"
 
 # demuxers / muxers
 ac3_demuxer_select="ac3_parser"
@@ -2317,10 +2426,12 @@ hls_muxer_select="mpegts_muxer"
 ipod_muxer_select="mov_muxer"
 ismv_muxer_select="mov_muxer"
 matroska_audio_muxer_select="matroska_muxer"
+matroska_demuxer_extralibs="bzlib_extralibs zlib_extralibs"
 matroska_demuxer_select="iso_media riffdec"
 matroska_demuxer_suggest="bzlib lzo zlib"
 matroska_muxer_select="iso_media riffenc"
 mmf_muxer_select="riffenc"
+mov_demuxer_extralibs="zlib_extralibs"
 mov_demuxer_select="iso_media riffdec"
 mov_demuxer_suggest="zlib"
 mov_muxer_select="iso_media riffenc rtpenc_chain"
@@ -2346,6 +2457,7 @@ sdp_demuxer_select="rtpdec"
 smoothstreaming_muxer_select="ismv_muxer"
 spdif_muxer_select="aac_parser"
 spx_muxer_select="ogg_muxer"
+swf_demuxer_extralibs="zlib_extralibs"
 swf_demuxer_suggest="zlib"
 tak_demuxer_select="tak_parser"
 tg2_muxer_select="mov_muxer"
@@ -2361,24 +2473,33 @@ xwma_demuxer_select="riffdec"
 
 # indevs / outdevs
 alsa_indev_deps="alsa_asoundlib_h snd_pcm_htimestamp"
+alsa_indev_extralibs="alsa_extralibs"
 alsa_outdev_deps="alsa_asoundlib_h"
+alsa_outdev_extralibs="alsa_extralibs"
 avfoundation_indev_deps="AVFoundation_AVFoundation_h pthreads"
+avfoundation_indev_extralibs="pthreads_extralibs"
 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_any="sem_timedwait dispatch_dispatch_h"
+jack_indev_extralibs="jack_extralibs"
 libcdio_indev_deps="libcdio"
+libcdio_indev_extralibs="libcdio_extralibs"
 libdc1394_indev_deps="libdc1394"
+libdc1394_indev_extralibs="libdc1394_2_extralibs"
 oss_indev_deps_any="soundcard_h sys_soundcard_h"
 oss_outdev_deps_any="soundcard_h sys_soundcard_h"
 pulse_indev_deps="libpulse"
+pulse_indev_extralibs="libpulse_simple_extralibs"
 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_deps="vfw32 vfwcap_defines"
+vfwcap_indev_extralibs="vfw32_extralibs"
 xcbgrab_indev_deps="libxcb"
+xcbgrab_indev_extralibs="xcb_shape_libs xcb_shm_libs xcb_xfixes_libs"
 
 # protocols
 ffrtmpcrypt_protocol_deps="!librtmp_protocol"
@@ -2386,17 +2507,24 @@ ffrtmpcrypt_protocol_deps_any="gmp openssl"
 ffrtmpcrypt_protocol_select="tcp_protocol"
 ffrtmphttp_protocol_deps="!librtmp_protocol"
 ffrtmphttp_protocol_select="http_protocol"
+gopher_protocol_extralibs="network_extralibs"
 gopher_protocol_select="network"
 http_protocol_select="tcp_protocol"
 httpproxy_protocol_select="tcp_protocol"
 https_protocol_select="tls_protocol"
 icecast_protocol_select="http_protocol"
 librtmp_protocol_deps="librtmp"
+librtmp_protocol_extralibs="librtmp_extralibs"
 librtmpe_protocol_deps="librtmp"
+librtmpe_protocol_extralibs="librtmp_extralibs"
 librtmps_protocol_deps="librtmp"
+librtmps_protocol_extralibs="librtmp_extralibs"
 librtmpt_protocol_deps="librtmp"
+librtmpt_protocol_extralibs="librtmp_extralibs"
 librtmpte_protocol_deps="librtmp"
+librtmpte_protocol_extralibs="librtmp_extralibs"
 mmsh_protocol_select="http_protocol"
+mmst_protocol_extralibs="network_extralibs"
 mmst_protocol_select="network"
 rtmp_protocol_deps="!librtmp_protocol"
 rtmp_protocol_select="tcp_protocol"
@@ -2408,16 +2536,22 @@ rtmpte_protocol_select="ffrtmpcrypt_protocol 
ffrtmphttp_protocol"
 rtmpts_protocol_select="ffrtmphttp_protocol https_protocol"
 rtp_protocol_select="udp_protocol"
 sctp_protocol_deps="struct_sctp_event_subscribe"
+sctp_protocol_extralibs="network_extralibs"
 sctp_protocol_select="network"
 srtp_protocol_select="rtp_protocol srtp"
+tcp_protocol_extralibs="network_extralibs"
 tcp_protocol_select="network"
 tls_gnutls_protocol_deps="gnutls"
+tls_gnutls_protocol_extralibs="gmp_extralibs gnutls_extralibs"
 tls_gnutls_protocol_select="tcp_protocol"
 tls_openssl_protocol_deps="openssl !tls_gnutls_protocol"
+tls_openssl_protocol_extralibs="pthreads_extralibs"
 tls_openssl_protocol_select="tcp_protocol"
 tls_protocol_deps_any="tls_gnutls_protocol tls_openssl_protocol"
+udp_protocol_extralibs="network_extralibs"
 udp_protocol_select="network"
 unix_protocol_deps="sys_un_h"
+unix_protocol_extralibs="network_extralibs"
 unix_protocol_select="network"
 
 # filters
@@ -2425,23 +2559,30 @@ asyncts_filter_deps="avresample"
 blackframe_filter_deps="gpl"
 boxblur_filter_deps="gpl"
 bs2b_filter_deps="libbs2b"
+bs2b_filter_extralibs="libbs2b_extralibs"
 cropdetect_filter_deps="gpl"
 deinterlace_qsv_filter_deps="libmfx"
+deinterlace_qsv_filter_extralibs="libmfx_extralibs"
 delogo_filter_deps="gpl"
 drawtext_filter_deps="libfreetype"
+drawtext_filter_extralibs="freetype2_extralibs fontconfig_extralibs"
 frei0r_filter_deps="frei0r dlopen"
-frei0r_filter_extralibs='$ldl'
+frei0r_filter_extralibs="frei0r_extralibs dlopen_extralibs"
 frei0r_src_filter_deps="frei0r dlopen"
-frei0r_src_filter_extralibs='$ldl'
+frei0r_src_filter_extralibs="frei0r_extralibs dlopen_extralibs"
 hdcd_filter_deps="libhdcd"
+hdcd_filter_extralibs="libhdcd_extralibs"
 hqdn3d_filter_deps="gpl"
 interlace_filter_deps="gpl"
 movie_filter_deps="avcodec avformat"
 ocv_filter_deps="libopencv"
+ocv_filter_extralibs="opencv_extralibs"
 resample_filter_deps="avresample"
 scale_filter_deps="swscale"
 scale_qsv_filter_deps="libmfx"
+scale_qsv_filter_extralibs="libmfx_extralibs"
 scale_vaapi_filter_deps="vaapi VAProcPipelineParameterBuffer"
+scale_vaapi_filter_extralibs="vaapi_extralibs"
 
 # examples
 decode_audio_example_deps="avcodec avutil"
@@ -2462,15 +2603,20 @@ avformat_deps="avcodec avutil"
 avresample_deps="avutil"
 swscale_deps="avutil"
 
+avcodec_extralibs="pthreads_extralibs"
+avutil_extralibs="clock_gettime_extralibs cuda_extralibs libm_extralibs 
libmfx_extralibs user32_extralibs vaapi_drm_extralibs vaapi_x11_extralibs 
vdpau_x11_extralibs wincrypt_extralibs"
+
 # programs
 avconv_deps="avcodec avfilter avformat avresample swscale"
+avconv_extralibs="ole32_extralibs psapi_extralibs shell32_extralibs"
 avconv_select="aformat_filter anull_filter asyncts_filter atrim_filter 
format_filter
                fps_filter null_filter resample_filter scale_filter
                trim_filter"
 avplay_deps="avcodec avfilter avformat avresample sdl"
-avplay_libs='$sdl_libs'
+avplay_extralibs="sdl_libs shell32_extralibs"
 avplay_select="rdft format_filter transpose_filter hflip_filter vflip_filter"
 avprobe_deps="avcodec avformat"
+avprobe_extralibs="shell32_extralibs"
 
 # documentation
 pod2man_deps="doc"
@@ -4414,9 +4560,9 @@ check_code cc arm_neon.h "int16x8_t test = 
vdupq_n_s16(0)" && enable intrinsics_
 check_ldflags -Wl,--as-needed
 
 if check_func dlopen; then
-    ldl=
+    dlopen_extralibs=
 elif check_func dlopen -ldl; then
-    ldl=-ldl
+    dlopen_extralibs=-ldl
 fi
 
 if ! disabled network; then
@@ -4480,7 +4626,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
 
 check_func  fcntl
 check_func  fork
@@ -4545,9 +4691,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
 
@@ -4574,13 +4720,13 @@ if ! disabled pthreads && ! enabled w32threads; then
     enable pthreads
     if check_func pthread_join -pthread; then
         add_cflags -pthread
-        add_extralibs -pthread
+        pthreads_extralibs=-pthread
     elif check_func pthread_join -pthreads; then
         add_cflags -pthreads
-        add_extralibs -pthreads
+        pthreads_extralibs=-pthreads
     elif check_func pthread_join -lpthreadGC2; then
-        add_extralibs -lpthreadGC2
-    elif check_lib pthread.h pthread_join -lpthread; then
+        pthreads_extralibs=-lpthreadGC2
+    elif check_lib pthreads pthread.h pthread_join -lpthread; then
         :
     elif ! check_func pthread_join; then
         disable pthreads
@@ -4590,23 +4736,23 @@ 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   || disable  
zlib
+disabled bzlib || check_lib bzlib bzlib.h BZ2_bzlibVersion -lbz2 || disable 
bzlib
 
-check_lib math.h sin -lm && LIBM="-lm"
+check_lib libm math.h sin -lm
 
 atan2f_args=2
 ldexpf_args=2
 powf_args=2
 
 for func in $MATH_FUNCS; do
-    eval check_mathfunc $func \${${func}_args:-1} $LIBM
+    eval check_mathfunc $func \${${func}_args:-1} $libm_extralibs
 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 avxsynth          && { check_header avxsynth/avxsynth_c.h || die 
"ERROR: avxsynth/avxsynth_c.h header not found"; }
+enabled cuda              && check_lib 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
@@ -4617,7 +4763,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
@@ -4629,7 +4775,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
@@ -4675,12 +4821,12 @@ 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 -lm
 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_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 ; } ||
+                                    check_lib mmal interface/mmal/mmal.h 
mmal_port_connect ; }
+                                check_lib mmal 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
@@ -4692,12 +4838,12 @@ enabled omx               && { check_header OMX_Core.h 
||
 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 ||
+                               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 && enable gmp
 
 if enabled nvenc; then
     check_header nvEncodeAPI.h || die "ERROR: nvEncodeAPI.h not found."
@@ -4725,7 +4871,7 @@ check_header AVFoundation/AVFoundation.h &&
 
 check_header sys/videoio.h
 
-check_lib "windows.h vfw.h" capCreateCaptureWindow -lvfw32
+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
@@ -4744,16 +4890,16 @@ 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
 
@@ -4773,15 +4919,14 @@ 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"
 fi
 
 enabled dxva2 &&
-    check_lib "windows.h winuser.h" GetShellWindow -luser32 ||
+    check_lib user32 "windows.h winuser.h" GetShellWindow -luser32 ||
     disable dxva2
 
 enabled dxva2 &&
-    check_lib windows.h CoTaskMemFree -lole32 &&
+    check_lib ole32 windows.h CoTaskMemFree -lole32 &&
     enable dxva2_lib
 
 enabled vaapi && require vaapi va/va.h vaInitialize -lva
@@ -4791,11 +4936,11 @@ enabled vaapi &&
     disable vaapi
 
 enabled vaapi &&
-    check_lib "va/va.h va/va_drm.h" vaGetDisplayDRM -lva -lva-drm &&
+    check_lib vaapi_drm "va/va.h va/va_drm.h" vaGetDisplayDRM -lva -lva-drm &&
     enable vaapi_drm
 
 enabled vaapi &&
-    check_lib "va/va.h va/va_x11.h" vaGetDisplay -lva -lva-x11 -lX11 &&
+    check_lib vaapi_x11 "va/va.h va/va_x11.h" vaGetDisplay -lva -lva-x11 -lX11 
&&
     enable vaapi_x11
 
 enabled vdpau &&
@@ -4803,7 +4948,7 @@ enabled vdpau &&
     disable vdpau
 
 enabled vdpau &&
-    check_lib "vdpau/vdpau.h vdpau/vdpau_x11.h" vdp_device_create_x11 -lvdpau 
-lX11 &&
+    check_lib vdpau_x11 "vdpau/vdpau.h vdpau/vdpau_x11.h" 
vdp_device_create_x11 -lvdpau -lX11 &&
     enable vdpau_x11
 
 enabled debug && add_cflags -g"$debuglevel" && add_asflags -g"$debuglevel"
@@ -5048,6 +5193,14 @@ check_deps $CONFIG_LIST       \
            $HAVE_LIST         \
            $ALL_COMPONENTS    \
 
+for linkunit in $LIBRARY_LIST $PROGRAM_LIST; do
+    set_component_extralibs $linkunit $linkunit
+    eval components=\$$(toupper ${linkunit})_COMPONENTS}
+    for comp in ${components}; do
+        eval set_component_extralibs \$linkunit \$$(toupper ${comp%s})_LIST
+    done
+done
+
 map 'enabled $v && intrinsics=${v#intrinsics_}' $INTRINSICS_LIST
 
 for thread in $THREADS_LIST; do
@@ -5287,6 +5440,15 @@ CFLAGS-avplay=$sdl_cflags
 ZLIB=$($ldflags_filter -lz)
 LIB_INSTALL_EXTRA_CMD=$LIB_INSTALL_EXTRA_CMD
 EXTRALIBS=$extralibs
+EXTRALIBS-avcodec=$extralibs_avcodec
+EXTRALIBS-avdevice=$extralibs_avdevice
+EXTRALIBS-avfilter=$extralibs_avfilter
+EXTRALIBS-avformat=$extralibs_avformat
+EXTRALIBS-avresample=$extralibs_avresample
+EXTRALIBS-avutil=$extralibs_avutil
+EXTRALIBS-avconv=$extralibs_avconv
+EXTRALIBS-avplay=$extralibs_avplay
+EXTRALIBS-avprobe=$extralibs_avprobe
 COMPAT_OBJS=$compat_objs
 INSTALL=install
 LIBTARGET=${LIBTARGET}
@@ -5318,13 +5480,6 @@ 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
-}
-
-map 'print_program_libs $v' $PROGRAM_LIST
-
 cat > $TMPH <<EOF
 /* Automatically generated by configure - do not modify! */
 #ifndef LIBAV_CONFIG_H
@@ -5442,10 +5597,10 @@ Cflags: -I\${includedir}
 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 libavresample "Libav audio resampling library" 
"$LIBAVRESAMPLE_VERSION" "$LIBM"
-pkgconfig_generate libswscale    "Libav image rescaling library"  
"$LIBSWSCALE_VERSION"    "$LIBM"
+pkgconfig_generate libavutil     "Libav utility library"          
"$LIBAVUTIL_VERSION"     "$extralibs_avutil"
+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" "$extralibs_avresample"
+pkgconfig_generate libswscale    "Libav image rescaling library"  
"$LIBSWSCALE_VERSION"    "$extralibs_swscale"
diff --git a/tests/checkasm/Makefile b/tests/checkasm/Makefile
index 639a08e..1b3f634 100644
--- a/tests/checkasm/Makefile
+++ b/tests/checkasm/Makefile
@@ -35,7 +35,7 @@ OBJDIRS += $(CHECKASMDIRS)
 CHECKASM := tests/checkasm/checkasm$(EXESUF)
 
 $(CHECKASM): $(CHECKASMOBJS) $(FF_STATIC_DEP_LIBS)
-       $(LD) $(LDFLAGS) $(LDEXEFLAGS) $(LD_O) $(CHECKASMOBJS) 
$(FF_STATIC_DEP_LIBS) $(EXTRALIBS)
+       $(LD) $(LDFLAGS) $(LDEXEFLAGS) $(LD_O) $(CHECKASMOBJS) 
$(FF_STATIC_DEP_LIBS) $(EXTRALIBS-avutil) $(EXTRALIBS)
 
 checkasm: $(CHECKASM)
 
-- 
2.1.4


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

Reply via email to