1 |
As autotools-utils exports phase functions, it will be better if |
2 |
remove_libtool_files() functions would be somewhere else. |
3 |
--- |
4 |
eutils.eclass | 68 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
5 |
1 file changed, 68 insertions(+) |
6 |
|
7 |
diff --git a/eutils.eclass b/eutils.eclass |
8 |
index c88ef35..fb92256 100644 |
9 |
--- a/eutils.eclass |
10 |
+++ b/eutils.eclass |
11 |
@@ -1330,6 +1330,74 @@ makeopts_jobs() { |
12 |
echo ${jobs:-1} |
13 |
} |
14 |
|
15 |
+# @FUNCTION: remove_libtool_files |
16 |
+# @USAGE: [all] |
17 |
+# @DESCRIPTION: |
18 |
+# Determines unnecessary libtool files (.la) and libtool static archives (.a), |
19 |
+# and removes them from installation image. |
20 |
+# |
21 |
+# To unconditionally remove all libtool files, pass 'all' as an argument. |
22 |
+# Otherwise, libtool archives required for static linking will be preserved. |
23 |
+remove_libtool_files() { |
24 |
+ debug-print-function ${FUNCNAME} "$@" |
25 |
+ local removing_all |
26 |
+ [[ ${#} -le 1 ]] || die "Invalid number of args to ${FUNCNAME}()" |
27 |
+ if [[ ${#} -eq 1 ]]; then |
28 |
+ case "${1}" in |
29 |
+ all) |
30 |
+ removing_all=1 |
31 |
+ ;; |
32 |
+ *) |
33 |
+ die "Invalid argument to ${FUNCNAME}(): ${1}" |
34 |
+ esac |
35 |
+ fi |
36 |
+ |
37 |
+ local pc_libs=() |
38 |
+ if [[ ! ${removing_all} ]]; then |
39 |
+ local arg |
40 |
+ for arg in $(find "${D}" -name '*.pc' -exec \ |
41 |
+ sed -n -e 's;^Libs:;;p' {} +); do |
42 |
+ [[ ${arg} == -l* ]] && pc_libs+=(lib${arg#-l}.la) |
43 |
+ done |
44 |
+ fi |
45 |
+ |
46 |
+ local f |
47 |
+ find "${D}" -type f -name '*.la' -print0 | while read -r -d '' f; do |
48 |
+ local shouldnotlink=$(sed -ne '/^shouldnotlink=yes$/p' "${f}") |
49 |
+ local archivefile=${f/%.la/.a} |
50 |
+ [[ "${f}" != "${archivefile}" ]] || die 'regex sanity check failed' |
51 |
+ |
52 |
+ # Remove static libs we're not supposed to link against. |
53 |
+ if [[ ${shouldnotlink} ]]; then |
54 |
+ einfo "Removing unnecessary ${archivefile#${D%/}}" |
55 |
+ rm -f "${archivefile}" || die |
56 |
+ # The .la file may be used by a module loader, so avoid removing it |
57 |
+ # unless explicitly requested. |
58 |
+ [[ ${removing_all} ]] || continue |
59 |
+ fi |
60 |
+ |
61 |
+ # Remove .la files when: |
62 |
+ # - user explicitly wants us to remove all .la files, |
63 |
+ # - respective static archive doesn't exist, |
64 |
+ # - they are covered by a .pc file already, |
65 |
+ # - they don't provide any new information (no libs & no flags). |
66 |
+ local removing |
67 |
+ if [[ ${removing_all} ]]; then removing='forced' |
68 |
+ elif [[ ! -f ${archivefile} ]]; then removing='no static archive' |
69 |
+ elif has "$(basename "${f}")" "${pc_libs[@]}"; then |
70 |
+ removing='covered by .pc' |
71 |
+ elif [[ ! $(sed -n -e \ |
72 |
+ "s/^\(dependency_libs\|inherited_linker_flags\)='\(.*\)'$/\2/p" \ |
73 |
+ "${f}") ]]; then removing='no libs & flags' |
74 |
+ fi |
75 |
+ |
76 |
+ if [[ ${removing} ]]; then |
77 |
+ einfo "Removing unnecessary ${f#${D%/}} (${removing})" |
78 |
+ rm -f "${f}" || die |
79 |
+ fi |
80 |
+ done |
81 |
+} |
82 |
+ |
83 |
check_license() { die "you no longer need this as portage supports ACCEPT_LICENSE itself"; } |
84 |
|
85 |
fi |
86 |
-- |
87 |
1.7.10.2 |