---
 gx86/eclass/eutils.eclass | 33 +++++++++++++++++++++++++--------
 1 file changed, 25 insertions(+), 8 deletions(-)

diff --git a/gx86/eclass/eutils.eclass b/gx86/eclass/eutils.eclass
index f662041..a8bf512 100644
--- a/gx86/eclass/eutils.eclass
+++ b/gx86/eclass/eutils.eclass
@@ -1407,8 +1407,9 @@ fi
 # that they should not be linked to, i.e. whenever these files
 # correspond to plugins.
 #
-# Note: if your package installs both static libraries and .pc files,
-# you need to add pkg-config to your DEPEND.
+# Note: if your package installs both static libraries and .pc files
+# which use variable substitution for -l flags, you need to add
+# pkg-config to your DEPEND.
 prune_libtool_files() {
        debug-print-function ${FUNCNAME} "$@"
 
@@ -1470,14 +1471,30 @@ prune_libtool_files() {
                                if [[ ! ${removing_all} ]]; then
                                        local pc
                                        local tf=${T}/prune-lt-files.pc
-                                       local pkgconf=$(tc-getPKG_CONFIG)
+                                       local pkgconf=$(tc-getPKG_CONFIG)1
 
                                        while IFS= read -r -d '' pc; do # for 
all .pc files
-                                               local arg
-
-                                               sed -e '/^Requires:/d' "${pc}" 
> "${tf}"
-                                               for arg in $("${pkgconf}" 
--libs "${tf}"); do
-                                                       [[ ${arg} == -l* ]] && 
pc_libs+=( lib${arg#-l}.la )
+                                               local arg libs
+
+                                               # Use pkg-config if available 
(and works),
+                                               # fallback to sed.
+                                               if ${pkgconf} --exists "${pc}" 
&>/dev/null; then
+                                                       sed -e '/^Requires:/d' 
"${pc}" > "${tf}"
+                                                       libs=$(${pkgconf} 
--libs "${tf}")
+                                               else
+                                                       libs=$(sed -ne 
's/^Libs://p' "${pc}")
+                                               fi
+
+                                               for arg in ${libs}; do
+                                                       if [[ ${arg} == -l* ]]; 
then
+                                                               if [[ ${arg} == 
'*$*' ]]; then
+                                                                       eqawarn 
"${FUNCNAME}: variable substitution likely failed in ${pc}"
+                                                                       eqawarn 
"(arg: ${arg})"
+                                                                       eqawarn 
"Most likely, you need to add virtual/pkgconfig to DEPEND."
+                                                               fi
+
+                                                               pc_libs+=( 
lib${arg#-l}.la )
+                                                       fi
                                                done
                                        done < <(find "${D}" -type f -name 
'*.pc' -print0)
 
-- 
1.8.1.4


Reply via email to