public inbox for gentoo-dev@lists.gentoo.org
 help / color / mirror / Atom feed
Search results ordered by [date|relevance]  view[summary|nested|Atom feed]
thread overview below | download: 
* [gentoo-dev] [PATCH eutils] prune_libtool_files: make pkg-config optional, add a sed fallback.
@ 2013-02-22 16:04 99% Michał Górny
  0 siblings, 0 replies; 1+ results
From: Michał Górny @ 2013-02-22 16:04 UTC (permalink / raw
  To: gentoo-dev; +Cc: Michał Górny

---
 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



^ permalink raw reply related	[relevance 99%]

Results 1-1 of 1 | reverse | options above
-- pct% links below jump to the message on this page, permalinks otherwise --
2013-02-22 16:04 99% [gentoo-dev] [PATCH eutils] prune_libtool_files: make pkg-config optional, add a sed fallback Michał Górny

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox