Instead of setting FFLIBS in each library Makefile configure
exports $LIBNAME_FFLIBS in config.mak.
---
 common.mak             |  2 +-
 configure              | 55 +++++++++++++++++++++++++++++++++++---------------
 libavcodec/Makefile    |  1 -
 libavdevice/Makefile   |  1 -
 libavfilter/Makefile   |  5 -----
 libavformat/Makefile   |  1 -
 libavresample/Makefile |  1 -
 libswscale/Makefile    |  1 -
 8 files changed, 40 insertions(+), 27 deletions(-)

diff --git a/common.mak b/common.mak
index ade9376..9244fd3 100644
--- a/common.mak
+++ b/common.mak
@@ -8,7 +8,7 @@ all: all-yes
 include $(SRC_PATH)/arch.mak
 
 OBJS      += $(OBJS-yes)
-FFLIBS    := $(FFLIBS-yes) $(FFLIBS)
+FFLIBS    := $($(NAME)_FFLIBS) $(FFLIBS-yes) $(FFLIBS)
 TESTPROGS += $(TESTPROGS-yes)
 
 LDLIBS       = $(FFLIBS:%=%$(BUILDSUF))
diff --git a/configure b/configure
index 47fd690..bb163ab 100755
--- a/configure
+++ b/configure
@@ -655,6 +655,16 @@ prepend(){
     eval "$var=\"$* \$$var\""
 }
 
+unique(){
+    varname=$1
+    uniq_list=""
+    for tok in $(eval echo \$$var); do
+        uniq_list="$(filter_out $tok $uniq_list) $tok"
+    done
+    eval "$varname=\"${uniq_list# }\""
+    unset uniq_list
+}
+
 add_cppflags(){
     append CPPFLAGS "$@"
 }
@@ -2108,11 +2118,11 @@ metadata_example_deps="avformat avutil"
 output_example_deps="avcodec avformat avutil swscale"
 transcode_aac_example_deps="avcodec avformat avresample"
 
-# libraries
+# libraries, in linking order
 avcodec_deps="avutil"
-avdevice_deps="avutil avcodec avformat"
+avdevice_deps="avformat avcodec avutil"
 avfilter_deps="avutil"
-avformat_deps="avutil avcodec"
+avformat_deps="avcodec avutil"
 avresample_deps="avutil"
 swscale_deps="avutil"
 
@@ -4371,6 +4381,19 @@ for thread in $THREADS_LIST; do
     fi
 done
 
+# 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"
+
+expand_deps(){
+    eval "deps=\$${1}_deps"
+    append ${1}_deps $(map 'eval echo \$${v}_deps' $deps)
+    unique ${1}_deps
+}
+
+map 'expand_deps $v' $LIBRARY_LIST
+
 echo "install prefix            $prefix"
 echo "source path               $source_path"
 echo "C compiler                $cc"
@@ -4572,6 +4595,7 @@ get_version(){
     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
+    eval echo "${1}_FFLIBS=\$${1}_deps" >> config.mak
 }
 
 map 'get_version $v' $LIBRARY_LIST
@@ -4637,13 +4661,17 @@ test -n "$WARNINGS" && printf "\n$WARNINGS"
 
 # build pkg-config files
 
+lib_version(){
+    eval echo "lib${1} \>\= \$LIB$(toupper ${1})_VERSION,"
+}
+
 pkgconfig_generate(){
     name=$1
     shortname=${name#lib}${build_suffix}
     comment=$2
     version=$3
     libs=$4
-    requires=$5
+    requires=$(map 'lib_version $v' $(eval echo \$${name#lib}_deps))
     enabled ${name#lib} || return 0
     mkdir -p $name
     cat <<EOF > $name/$name.pc
@@ -4655,7 +4683,7 @@ includedir=$incdir
 Name: $name
 Description: $comment
 Version: $version
-Requires: $(enabled shared || echo $requires)
+Requires: $(enabled shared || echo ${requires%,})
 Requires.private: $(enabled shared && echo $requires)
 Conflicts:
 Libs: -L\${libdir} -l${shortname} $(enabled shared || echo $libs)
@@ -4678,15 +4706,10 @@ Cflags: -I\${includedir}
 EOF
 }
 
-lavfi_libs="libavutil = $LIBAVUTIL_VERSION"
-enabled movie_filter    && prepend lavfi_libs "libavformat >= 
$LIBAVFORMAT_VERSION, libavcodec >= $LIBAVCODEC_VERSION,"
-enabled resample_filter && prepend lavfi_libs "libavresample >= 
$LIBAVRESAMPLE_VERSION,"
-enabled scale_filter    && prepend lavfi_libs "libswscale >= 
$LIBSWSCALE_VERSION,"
-
 pkgconfig_generate libavutil     "Libav utility library"          
"$LIBAVUTIL_VERSION"     "$LIBM"
-pkgconfig_generate libavcodec    "Libav codec library"            
"$LIBAVCODEC_VERSION"    "$extralibs" "libavutil = $LIBAVUTIL_VERSION"
-pkgconfig_generate libavformat   "Libav container format library" 
"$LIBAVFORMAT_VERSION"   "$extralibs" "libavcodec = $LIBAVCODEC_VERSION"
-pkgconfig_generate libavdevice   "Libav device handling library"  
"$LIBAVDEVICE_VERSION"   "$extralibs" "libavformat = $LIBAVFORMAT_VERSION"
-pkgconfig_generate libavfilter   "Libav video filtering library"  
"$LIBAVFILTER_VERSION"   "$extralibs" "$lavfi_libs"
-pkgconfig_generate libavresample "Libav audio resampling library" 
"$LIBAVRESAMPLE_VERSION" "$extralibs" "libavutil = $LIBAVUTIL_VERSION"
-pkgconfig_generate libswscale    "Libav image rescaling library"  
"$LIBSWSCALE_VERSION"    "$LIBM"      "libavutil = $LIBAVUTIL_VERSION"
+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" "$extralibs"
+pkgconfig_generate libswscale    "Libav image rescaling library"  
"$LIBSWSCALE_VERSION"    "$LIBM"
diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index 2bce954..2003262 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -1,5 +1,4 @@
 NAME = avcodec
-FFLIBS = avutil
 
 HEADERS = avcodec.h                                                     \
           avfft.h                                                       \
diff --git a/libavdevice/Makefile b/libavdevice/Makefile
index 02de216..2eb2f8e 100644
--- a/libavdevice/Makefile
+++ b/libavdevice/Makefile
@@ -1,5 +1,4 @@
 NAME    = avdevice
-FFLIBS  = avformat avcodec avutil
 
 HEADERS = avdevice.h                                                    \
           version.h                                                     \
diff --git a/libavfilter/Makefile b/libavfilter/Makefile
index 6537a8a..7b94f22 100644
--- a/libavfilter/Makefile
+++ b/libavfilter/Makefile
@@ -1,9 +1,4 @@
 NAME = avfilter
-FFLIBS = avutil
-FFLIBS-$(CONFIG_ASYNCTS_FILTER) += avresample
-FFLIBS-$(CONFIG_MOVIE_FILTER) += avformat avcodec
-FFLIBS-$(CONFIG_RESAMPLE_FILTER) += avresample
-FFLIBS-$(CONFIG_SCALE_FILTER)   += swscale
 
 HEADERS = avfilter.h                                                    \
           avfiltergraph.h                                               \
diff --git a/libavformat/Makefile b/libavformat/Makefile
index 0ef6d83..2a68120 100644
--- a/libavformat/Makefile
+++ b/libavformat/Makefile
@@ -1,5 +1,4 @@
 NAME = avformat
-FFLIBS = avcodec avutil
 
 HEADERS = avformat.h                                                    \
           avio.h                                                        \
diff --git a/libavresample/Makefile b/libavresample/Makefile
index 6805280..b9ca491 100644
--- a/libavresample/Makefile
+++ b/libavresample/Makefile
@@ -1,5 +1,4 @@
 NAME = avresample
-FFLIBS = avutil
 
 HEADERS = avresample.h                                                  \
           version.h                                                     \
diff --git a/libswscale/Makefile b/libswscale/Makefile
index 0799b45..3e8614d 100644
--- a/libswscale/Makefile
+++ b/libswscale/Makefile
@@ -1,5 +1,4 @@
 NAME = swscale
-FFLIBS = avutil
 
 HEADERS = swscale.h                                                     \
           version.h                                                     \
-- 
1.9.2

_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel

Reply via email to