/[gentoo-x86]/eclass/autotools-utils.eclass
Gentoo

Diff of /eclass/autotools-utils.eclass

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 1.74 Revision 1.75
1# Copyright 1999-2014 Gentoo Foundation 1# Copyright 1999-2015 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.74 2014/07/31 23:24:56 reavertm Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/autotools-utils.eclass,v 1.75 2015/06/07 12:55:46 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>
213 fi 213 fi
214 214
215 # Backwards compatibility for getting the value. 215 # Backwards compatibility for getting the value.
216 AUTOTOOLS_BUILD_DIR=${BUILD_DIR} 216 AUTOTOOLS_BUILD_DIR=${BUILD_DIR}
217 echo ">>> Working in BUILD_DIR: \"${BUILD_DIR}\"" 217 echo ">>> Working in BUILD_DIR: \"${BUILD_DIR}\""
218}
219
220# @FUNCTION: remove_libtool_files
221# @USAGE: [all]
222# @DESCRIPTION:
223# Determines unnecessary libtool files (.la) and libtool static archives (.a)
224# and removes them from installation image.
225#
226# To unconditionally remove all libtool files, pass 'all' as argument.
227# Otherwise, libtool archives required for static linking will be preserved.
228#
229# In most cases it's not necessary to manually invoke this function.
230# See autotools-utils_src_install for reference.
231remove_libtool_files() {
232 debug-print-function ${FUNCNAME} "$@"
233 local removing_all
234
235 eqawarn "The remove_libtool_files() function was deprecated."
236 eqawarn "Please use prune_libtool_files() from eutils eclass instead."
237
238 [[ ${#} -le 1 ]] || die "Invalid number of args to ${FUNCNAME}()"
239 if [[ ${#} -eq 1 ]]; then
240 case "${1}" in
241 all)
242 removing_all=1
243 ;;
244 *)
245 die "Invalid argument to ${FUNCNAME}(): ${1}"
246 esac
247 fi
248
249 local pc_libs=()
250 if [[ ! ${removing_all} ]]; then
251 local arg
252 for arg in $(find "${D}" -name '*.pc' -exec \
253 sed -n -e 's;^Libs:;;p' {} +); do
254 [[ ${arg} == -l* ]] && pc_libs+=(lib${arg#-l}.la)
255 done
256 fi
257
258 local f
259 find "${D}" -type f -name '*.la' -print0 | while read -r -d '' f; do
260 local shouldnotlink=$(sed -ne '/^shouldnotlink=yes$/p' "${f}")
261 local archivefile=${f/%.la/.a}
262 [[ "${f}" != "${archivefile}" ]] || die 'regex sanity check failed'
263
264 # Remove static libs we're not supposed to link against.
265 if [[ ${shouldnotlink} ]]; then
266 einfo "Removing unnecessary ${archivefile#${D%/}}"
267 rm -f "${archivefile}" || die
268 # The .la file may be used by a module loader, so avoid removing it
269 # unless explicitly requested.
270 [[ ${removing_all} ]] || continue
271 fi
272
273 # Remove .la files when:
274 # - user explicitly wants us to remove all .la files,
275 # - respective static archive doesn't exist,
276 # - they are covered by a .pc file already,
277 # - they don't provide any new information (no libs & no flags).
278 local removing
279 if [[ ${removing_all} ]]; then removing='forced'
280 elif [[ ! -f ${archivefile} ]]; then removing='no static archive'
281 elif has "$(basename "${f}")" "${pc_libs[@]}"; then
282 removing='covered by .pc'
283 elif [[ ! $(sed -n -e \
284 "s/^\(dependency_libs\|inherited_linker_flags\)='\(.*\)'$/\2/p" \
285 "${f}") ]]; then removing='no libs & flags'
286 fi
287
288 if [[ ${removing} ]]; then
289 einfo "Removing unnecessary ${f#${D%/}} (${removing})"
290 rm -f "${f}" || die
291 fi
292 done
293} 218}
294 219
295# @FUNCTION: autotools-utils_src_prepare 220# @FUNCTION: autotools-utils_src_prepare
296# @DESCRIPTION: 221# @DESCRIPTION:
297# The src_prepare function. 222# The src_prepare function.

Legend:
Removed from v.1.74  
changed lines
  Added in v.1.75

  ViewVC Help
Powered by ViewVC 1.1.20