Gentoo Archives: gentoo-commits

From: "Michal Gorny (mgorny)" <mgorny@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] gentoo-x86 commit in eclass: ChangeLog eutils.eclass
Date: Wed, 06 Jun 2012 15:38:00
Message-Id: 20120606153750.9490B2004B@flycatcher.gentoo.org
1 mgorny 12/06/06 15:37:50
2
3 Modified: ChangeLog eutils.eclass
4 Log:
5 Introduce prune_libtool_files() for .la file removal. Based on one used by autotools-utils.
6
7 Revision Changes Path
8 1.291 eclass/ChangeLog
9
10 file : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/eclass/ChangeLog?rev=1.291&view=markup
11 plain: http://sources.gentoo.org/viewvc.cgi/gentoo-x86/eclass/ChangeLog?rev=1.291&content-type=text/plain
12 diff : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/eclass/ChangeLog?r1=1.290&r2=1.291
13
14 Index: ChangeLog
15 ===================================================================
16 RCS file: /var/cvsroot/gentoo-x86/eclass/ChangeLog,v
17 retrieving revision 1.290
18 retrieving revision 1.291
19 diff -u -r1.290 -r1.291
20 --- ChangeLog 5 Jun 2012 18:31:54 -0000 1.290
21 +++ ChangeLog 6 Jun 2012 15:37:50 -0000 1.291
22 @@ -1,6 +1,10 @@
23 # ChangeLog for eclass directory
24 # Copyright 1999-2012 Gentoo Foundation; Distributed under the GPL v2
25 -# $Header: /var/cvsroot/gentoo-x86/eclass/ChangeLog,v 1.290 2012/06/05 18:31:54 grobian Exp $
26 +# $Header: /var/cvsroot/gentoo-x86/eclass/ChangeLog,v 1.291 2012/06/06 15:37:50 mgorny Exp $
27 +
28 + 06 Jun 2012; Michał Górny <mgorny@g.o> eutils.eclass:
29 + Introduce prune_libtool_files() for .la file removal. Based on one used
30 + by autotools-utils.
31
32 05 Jun 2012; Fabian Groffen <grobian@g.o> autotools.eclass:
33 Avoid type -P output for glibtoolize, bug #419641
34
35
36
37 1.395 eclass/eutils.eclass
38
39 file : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/eclass/eutils.eclass?rev=1.395&view=markup
40 plain: http://sources.gentoo.org/viewvc.cgi/gentoo-x86/eclass/eutils.eclass?rev=1.395&content-type=text/plain
41 diff : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/eclass/eutils.eclass?r1=1.394&r2=1.395
42
43 Index: eutils.eclass
44 ===================================================================
45 RCS file: /var/cvsroot/gentoo-x86/eclass/eutils.eclass,v
46 retrieving revision 1.394
47 retrieving revision 1.395
48 diff -u -r1.394 -r1.395
49 --- eutils.eclass 5 Jun 2012 17:40:12 -0000 1.394
50 +++ eutils.eclass 6 Jun 2012 15:37:50 -0000 1.395
51 @@ -1,6 +1,6 @@
52 # Copyright 1999-2012 Gentoo Foundation
53 # Distributed under the terms of the GNU General Public License v2
54 -# $Header: /var/cvsroot/gentoo-x86/eclass/eutils.eclass,v 1.394 2012/06/05 17:40:12 hasufell Exp $
55 +# $Header: /var/cvsroot/gentoo-x86/eclass/eutils.eclass,v 1.395 2012/06/06 15:37:50 mgorny Exp $
56
57 # @ECLASS: eutils.eclass
58 # @MAINTAINER:
59 @@ -18,7 +18,7 @@
60 if [[ ${___ECLASS_ONCE_EUTILS} != "recur -_+^+_- spank" ]] ; then
61 ___ECLASS_ONCE_EUTILS="recur -_+^+_- spank"
62
63 -inherit multilib user
64 +inherit multilib toolchain-funcs user
65
66 DESCRIPTION="Based on the ${ECLASS} eclass"
67
68 @@ -1399,6 +1399,100 @@
69 echo ${jobs:-1}
70 }
71
72 +# @FUNCTION: prune_libtool_files
73 +# @USAGE: [--all]
74 +# @DESCRIPTION:
75 +# Locate unnecessary libtool files (.la) and libtool static archives
76 +# (.a) and remove them from installation image.
77 +#
78 +# By default, .la files are removed whenever the static linkage can
79 +# either be performed using pkg-config or doesn't introduce additional
80 +# flags.
81 +#
82 +# If '--all' argument is passed, all .la files are removed. This is
83 +# usually useful when the package installs plugins and does not use .la
84 +# files for loading them.
85 +#
86 +# The .a files are only removed whenever corresponding .la files state
87 +# that they should not be linked to, i.e. whenever these files
88 +# correspond to plugins.
89 +#
90 +# Note: if your package installs any .pc files, this function implicitly
91 +# calls pkg-config. You should add it to your DEPEND in that case.
92 +prune_libtool_files() {
93 + debug-print-function ${FUNCNAME} "$@"
94 +
95 + local removing_all opt
96 + for opt; do
97 + case "${opt}" in
98 + --all)
99 + removing_all=1
100 + ;;
101 + *)
102 + die "Invalid argument to ${FUNCNAME}(): ${opt}"
103 + esac
104 + done
105 +
106 + # Create a list of all .pc-covered libs.
107 + local pc_libs=()
108 + if [[ ! ${removing_all} ]]; then
109 + local f
110 + local tf=${T}/prune-lt-files.pc
111 + local pkgconf=$(tc-getPKG_CONFIG)
112 +
113 + while IFS= read -r -d '' f; do # for all .pc files
114 + local arg
115 +
116 + sed -e '/^Requires:/d' "${f}" > "${tf}"
117 + for arg in $("${pkgconf}" --libs "${tf}"); do
118 + [[ ${arg} == -l* ]] && pc_libs+=( lib${arg#-l}.la )
119 + done
120 + done < <(find "${D}" -type f -name '*.pc' -print0)
121 +
122 + rm -f "${tf}"
123 + fi
124 +
125 + local f
126 + while IFS= read -r -d '' f; do # for all .la files
127 + local archivefile=${f/%.la/.a}
128 +
129 + [[ ${f} != ${archivefile} ]] || die 'regex sanity check failed'
130 +
131 + # Remove static libs we're not supposed to link against.
132 + if grep -q '^shouldnotlink=yes$' "${f}"; then
133 + einfo "Removing unnecessary ${archivefile#${D%/}}"
134 + rm -f "${archivefile}"
135 +
136 + # The .la file may be used by a module loader, so avoid removing it
137 + # unless explicitly requested.
138 + [[ ${removing_all} ]] || continue
139 + fi
140 +
141 + # Remove .la files when:
142 + # - user explicitly wants us to remove all .la files,
143 + # - respective static archive doesn't exist,
144 + # - they are covered by a .pc file already,
145 + # - they don't provide any new information (no libs & no flags).
146 + local reason
147 + if [[ ${removing_all} ]]; then
148 + reason='requested'
149 + elif [[ ! -f ${archivefile} ]]; then
150 + reason='no static archive'
151 + elif has "${f##*/}" "${pc_libs[@]}"; then
152 + reason='covered by .pc'
153 + elif [[ ! $(sed -nre \
154 + "s/^(dependency_libs|inherited_linker_flags)='(.*)'$/\2/p" \
155 + "${f}") ]]; then
156 + reason='no libs & flags'
157 + fi
158 +
159 + if [[ ${reason} ]]; then
160 + einfo "Removing unnecessary ${f#${D%/}} (${reason})"
161 + rm -f "${f}"
162 + fi
163 + done < <(find "${D}" -type f -name '*.la' -print0)
164 +}
165 +
166 check_license() { die "you no longer need this as portage supports ACCEPT_LICENSE itself"; }
167
168 fi