/[gentoo-x86]/eclass/eutils.eclass
Gentoo

Diff of /eclass/eutils.eclass

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

Revision 1.407 Revision 1.408
1# Copyright 1999-2012 Gentoo Foundation 1# Copyright 1999-2012 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/eutils.eclass,v 1.407 2012/10/11 16:50:53 mgorny Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/eutils.eclass,v 1.408 2012/10/11 16:52:05 mgorny Exp $
4 4
5# @ECLASS: eutils.eclass 5# @ECLASS: eutils.eclass
6# @MAINTAINER: 6# @MAINTAINER:
7# base-system@gentoo.org 7# base-system@gentoo.org
8# @BLURB: many extra (but common) functions that are used in ebuilds 8# @BLURB: many extra (but common) functions that are used in ebuilds
1378if has "${EAPI:-0}" 0 1 2 3 4; then 1378if has "${EAPI:-0}" 0 1 2 3 4; then
1379 usex() { use "$1" && echo "${2-yes}$4" || echo "${3-no}$5" ; } #382963 1379 usex() { use "$1" && echo "${2-yes}$4" || echo "${3-no}$5" ; } #382963
1380fi 1380fi
1381 1381
1382# @FUNCTION: prune_libtool_files 1382# @FUNCTION: prune_libtool_files
1383# @USAGE: [--all] 1383# @USAGE: [--all|--modules]
1384# @DESCRIPTION: 1384# @DESCRIPTION:
1385# Locate unnecessary libtool files (.la) and libtool static archives 1385# Locate unnecessary libtool files (.la) and libtool static archives
1386# (.a) and remove them from installation image. 1386# (.a) and remove them from installation image.
1387# 1387#
1388# By default, .la files are removed whenever the static linkage can 1388# By default, .la files are removed whenever the static linkage can
1389# either be performed using pkg-config or doesn't introduce additional 1389# either be performed using pkg-config or doesn't introduce additional
1390# flags. 1390# flags.
1391# 1391#
1392# If '--modules' argument is passed, .la files for modules (plugins) are
1393# removed as well. This is usually useful when the package installs
1394# plugins and the plugin loader does not use .la files.
1395#
1392# If '--all' argument is passed, all .la files are removed. This is 1396# If '--all' argument is passed, all .la files are removed without
1393# usually useful when the package installs plugins and does not use .la 1397# performing any heuristic on them. You shouldn't ever use that,
1394# files for loading them. 1398# and instead report a bug in the algorithm instead.
1395# 1399#
1396# The .a files are only removed whenever corresponding .la files state 1400# The .a files are only removed whenever corresponding .la files state
1397# that they should not be linked to, i.e. whenever these files 1401# that they should not be linked to, i.e. whenever these files
1398# correspond to plugins. 1402# correspond to plugins.
1399# 1403#
1400# Note: if your package installs both static libraries and .pc files, 1404# Note: if your package installs both static libraries and .pc files,
1401# you need to add pkg-config to your DEPEND. 1405# you need to add pkg-config to your DEPEND.
1402prune_libtool_files() { 1406prune_libtool_files() {
1403 debug-print-function ${FUNCNAME} "$@" 1407 debug-print-function ${FUNCNAME} "$@"
1404 1408
1405 local removing_all opt 1409 local removing_all removing_modules opt
1406 for opt; do 1410 for opt; do
1407 case "${opt}" in 1411 case "${opt}" in
1408 --all) 1412 --all)
1409 removing_all=1 1413 removing_all=1
1414 removing_modules=1
1415 ;;
1416 --modules)
1417 removing_modules=1
1410 ;; 1418 ;;
1411 *) 1419 *)
1412 die "Invalid argument to ${FUNCNAME}(): ${opt}" 1420 die "Invalid argument to ${FUNCNAME}(): ${opt}"
1413 esac 1421 esac
1414 done 1422 done
1417 local queue=() 1425 local queue=()
1418 while IFS= read -r -d '' f; do # for all .la files 1426 while IFS= read -r -d '' f; do # for all .la files
1419 local archivefile=${f/%.la/.a} 1427 local archivefile=${f/%.la/.a}
1420 1428
1421 [[ ${f} != ${archivefile} ]] || die 'regex sanity check failed' 1429 [[ ${f} != ${archivefile} ]] || die 'regex sanity check failed'
1430
1431 local reason pkgconfig_scanned
1422 1432
1423 # Remove static libs we're not supposed to link against. 1433 # Remove static libs we're not supposed to link against.
1424 if grep -q '^shouldnotlink=yes$' "${f}"; then 1434 if grep -q '^shouldnotlink=yes$' "${f}"; then
1425 if [[ -f ${archivefile} ]]; then 1435 if [[ -f ${archivefile} ]]; then
1426 einfo "Removing unnecessary ${archivefile#${D%/}} (static plugin)" 1436 einfo "Removing unnecessary ${archivefile#${D%/}} (static plugin)"
1427 queue+=( "${archivefile}" ) 1437 queue+=( "${archivefile}" )
1428 fi 1438 fi
1429 1439
1430 # The .la file may be used by a module loader, so avoid removing it 1440 # The .la file may be used by a module loader, so avoid removing it
1431 # unless explicitly requested. 1441 # unless explicitly requested.
1432 [[ ${removing_all} ]] || continue 1442 if [[ ${removing_modules} ]]; then
1443 reason='module'
1433 fi 1444 fi
1434 1445
1435 # Remove .la files when: 1446 # Remove .la files when:
1436 # - user explicitly wants us to remove all .la files, 1447 # - user explicitly wants us to remove all .la files,
1437 # - respective static archive doesn't exist, 1448 # - respective static archive doesn't exist,
1438 # - they are covered by a .pc file already, 1449 # - they are covered by a .pc file already,
1439 # - they don't provide any new information (no libs & no flags). 1450 # - they don't provide any new information (no libs & no flags).
1440 local reason pkgconfig_scanned 1451
1441 if [[ ${removing_all} ]]; then 1452 elif [[ ${removing_all} ]]; then
1442 reason='requested' 1453 reason='requested'
1443 elif [[ ! -f ${archivefile} ]]; then 1454 elif [[ ! -f ${archivefile} ]]; then
1444 reason='no static archive' 1455 reason='no static archive'
1445 elif [[ ! $(sed -nre \ 1456 elif [[ ! $(sed -nre \
1446 "s/^(dependency_libs|inherited_linker_flags)='(.*)'$/\2/p" \ 1457 "s/^(dependency_libs|inherited_linker_flags)='(.*)'$/\2/p" \

Legend:
Removed from v.1.407  
changed lines
  Added in v.1.408

  ViewVC Help
Powered by ViewVC 1.1.20