| 1 | # Copyright 1999-2010 Gentoo Foundation |
1 | # Copyright 1999-2010 Gentoo Foundation |
| 2 | # Distributed under the terms of the GNU General Public License v2 |
2 | # Distributed under the terms of the GNU General Public License v2 |
| 3 | # $Header: /var/cvsroot/gentoo-x86/eclass/autotools-utils.eclass,v 1.17 2011/09/16 15:38:13 mgorny Exp $ |
3 | # $Header: /var/cvsroot/gentoo-x86/eclass/autotools-utils.eclass,v 1.18 2011/09/16 15:38:26 mgorny Exp $ |
| 4 | |
4 | |
| 5 | # @ECLASS: autotools-utils.eclass |
5 | # @ECLASS: autotools-utils.eclass |
| 6 | # @MAINTAINER: |
6 | # @MAINTAINER: |
| 7 | # Maciej Mrozowski <reavertm@gentoo.org> |
7 | # Maciej Mrozowski <reavertm@gentoo.org> |
| 8 | # Michał Górny <mgorny@gentoo.org> |
8 | # Michał Górny <mgorny@gentoo.org> |
| … | |
… | |
| 160 | find "${D}" -type f -name '*.la' -print0 | while read -r -d '' f; do |
160 | find "${D}" -type f -name '*.la' -print0 | while read -r -d '' f; do |
| 161 | local shouldnotlink=$(sed -ne '/^shouldnotlink=yes$/p' "${f}") |
161 | local shouldnotlink=$(sed -ne '/^shouldnotlink=yes$/p' "${f}") |
| 162 | local archivefile=${f/%.la/.a} |
162 | local archivefile=${f/%.la/.a} |
| 163 | [[ "${f}" != "${archivefile}" ]] || die 'regex sanity check failed' |
163 | [[ "${f}" != "${archivefile}" ]] || die 'regex sanity check failed' |
| 164 | |
164 | |
| 165 | # Remove static libs we're not supposed to link against |
165 | # Remove static libs we're not supposed to link against. |
| 166 | if [[ ${shouldnotlink} ]]; then |
166 | if [[ ${shouldnotlink} ]]; then |
| 167 | einfo "Removing unnecessary ${archivefile#${D%/}}" |
167 | einfo "Removing unnecessary ${archivefile#${D%/}}" |
| 168 | rm -f "${archivefile}" || die |
168 | rm -f "${archivefile}" || die |
| 169 | # We're never going to remove the .la file. |
169 | # The .la file may be used by a module loader, so avoid removing it |
|
|
170 | # unless explicitly requested. |
| 170 | [[ ${removing_all} ]] || continue |
171 | [[ ${removing_all} ]] || continue |
| 171 | fi |
172 | fi |
| 172 | |
173 | |
| 173 | # Keep .la files when: |
174 | # Remove .la files when: |
| 174 | # - they have shouldnotlink=yes - likely plugins (handled above), |
175 | # - user explicitly wants us to remove all .la files, |
| 175 | # - respective static archive exists. |
176 | # - respective static archive doesn't exist, |
| 176 | if [[ ${removing_all} || ! -f ${archivefile} ]]; then |
177 | # - they don't provide any new information (no libs & no flags). |
|
|
178 | local removing |
|
|
179 | if [[ ${removing_all} ]]; then removing=1 |
|
|
180 | elif [[ ! -f ${archivefile} ]]; then removing=1 |
|
|
181 | elif [[ ! $(sed -n -e \ |
|
|
182 | "s/^\(dependency_libs\|inherited_linker_flags\)='\(.*\)'$/\2/p" \ |
|
|
183 | "${f}") ]]; then removing=1 |
|
|
184 | fi |
|
|
185 | |
|
|
186 | if [[ ${removing} ]]; then |
| 177 | einfo "Removing unnecessary ${f#${D%/}}" |
187 | einfo "Removing unnecessary ${f#${D%/}}" |
| 178 | rm -f "${f}" || die |
188 | rm -f "${f}" || die |
| 179 | fi |
189 | fi |
| 180 | done |
190 | done |
| 181 | } |
191 | } |