---
 eclass/autotools-utils.eclass |   25 +++++++++++++------------
 1 files changed, 13 insertions(+), 12 deletions(-)

diff --git a/eclass/autotools-utils.eclass b/eclass/autotools-utils.eclass
index 31d228b..ab8650f 100644
--- a/eclass/autotools-utils.eclass
+++ b/eclass/autotools-utils.eclass
@@ -132,13 +132,13 @@ _check_build_dir() {
 }
 
 # @FUNCTION: remove_libtool_files
-# @USAGE: [all|none]
+# @USAGE: [all]
 # @DESCRIPTION:
 # Determines unnecessary libtool files (.la) and libtool static archives (.a)
 # and removes them from installation image.
+#
 # To unconditionally remove all libtool files, pass 'all' as argument.
-# To leave all libtool files alone, pass 'none' as argument.
-# Unnecessary static archives are removed in any case.
+# Otherwise, libtool archives required for static linking will be preserved.
 #
 # In most cases it's not necessary to manually invoke this function.
 # See autotools-utils_src_install for reference.
@@ -147,14 +147,17 @@ remove_libtool_files() {
 
        local f
        find "${D}" -type f -name '*.la' -print0 | while read -r -d '' f; do
-               # Keep only .la files with shouldnotlink=yes - likely plugins
                local shouldnotlink=$(sed -ne '/^shouldnotlink=yes$/p' "${f}")
-               if [[  "$1" == 'all' || -z ${shouldnotlink} ]]; then
-                       if [[ "$1" != 'none' ]]; then
-                               einfo "Removing unnecessary ${f#${D%/}}"
-                               rm -f "${f}"
-                       fi
+               local archivefile=${f/%.la/.a}
+
+               # Keep .la files when:
+               # - they have shouldnotlink=yes - likely plugins,
+               # - respective static archive exists.
+               if [[ "$1" == 'all' || ( -z ${shouldnotlink} && ! -f 
${archivefile} ) ]]; then
+                       einfo "Removing unnecessary ${f#${D%/}}"
+                       rm -f "${f}"
                fi
+
                # Remove static libs we're not supposed to link against
                if [[ -n ${shouldnotlink} ]]; then
                        local remove=${f/%.la/.a}
@@ -245,9 +248,7 @@ autotools-utils_src_install() {
        popd > /dev/null
 
        # Remove libtool files and unnecessary static libs
-       local args
-       has static-libs ${IUSE//+} && ! use static-libs || args='none'
-       remove_libtool_files ${args}
+       remove_libtool_files
 }
 
 # @FUNCTION: autotools-utils_src_test
-- 
1.7.6.1


Reply via email to