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

Diff of /eclass/eutils.eclass

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

Revision 1.394 Revision 1.395
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.394 2012/06/05 17:40:12 hasufell Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/eutils.eclass,v 1.395 2012/06/06 15:37:50 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
16# different from the overall eclass! 16# different from the overall eclass!
17 17
18if [[ ${___ECLASS_ONCE_EUTILS} != "recur -_+^+_- spank" ]] ; then 18if [[ ${___ECLASS_ONCE_EUTILS} != "recur -_+^+_- spank" ]] ; then
19___ECLASS_ONCE_EUTILS="recur -_+^+_- spank" 19___ECLASS_ONCE_EUTILS="recur -_+^+_- spank"
20 20
21inherit multilib user 21inherit multilib toolchain-funcs user
22 22
23DESCRIPTION="Based on the ${ECLASS} eclass" 23DESCRIPTION="Based on the ${ECLASS} eclass"
24 24
25if has "${EAPI:-0}" 0 1 2; then 25if has "${EAPI:-0}" 0 1 2; then
26 26
1397 -e 's:.*[[:space:]](-j|--jobs[=[:space:]])[[:space:]]*([0-9]+).*:\2:p' \ 1397 -e 's:.*[[:space:]](-j|--jobs[=[:space:]])[[:space:]]*([0-9]+).*:\2:p' \
1398 -e 's:.*[[:space:]](-j|--jobs)[[:space:]].*:999:p') 1398 -e 's:.*[[:space:]](-j|--jobs)[[:space:]].*:999:p')
1399 echo ${jobs:-1} 1399 echo ${jobs:-1}
1400} 1400}
1401 1401
1402# @FUNCTION: prune_libtool_files
1403# @USAGE: [--all]
1404# @DESCRIPTION:
1405# Locate unnecessary libtool files (.la) and libtool static archives
1406# (.a) and remove them from installation image.
1407#
1408# By default, .la files are removed whenever the static linkage can
1409# either be performed using pkg-config or doesn't introduce additional
1410# flags.
1411#
1412# If '--all' argument is passed, all .la files are removed. This is
1413# usually useful when the package installs plugins and does not use .la
1414# files for loading them.
1415#
1416# The .a files are only removed whenever corresponding .la files state
1417# that they should not be linked to, i.e. whenever these files
1418# correspond to plugins.
1419#
1420# Note: if your package installs any .pc files, this function implicitly
1421# calls pkg-config. You should add it to your DEPEND in that case.
1422prune_libtool_files() {
1423 debug-print-function ${FUNCNAME} "$@"
1424
1425 local removing_all opt
1426 for opt; do
1427 case "${opt}" in
1428 --all)
1429 removing_all=1
1430 ;;
1431 *)
1432 die "Invalid argument to ${FUNCNAME}(): ${opt}"
1433 esac
1434 done
1435
1436 # Create a list of all .pc-covered libs.
1437 local pc_libs=()
1438 if [[ ! ${removing_all} ]]; then
1439 local f
1440 local tf=${T}/prune-lt-files.pc
1441 local pkgconf=$(tc-getPKG_CONFIG)
1442
1443 while IFS= read -r -d '' f; do # for all .pc files
1444 local arg
1445
1446 sed -e '/^Requires:/d' "${f}" > "${tf}"
1447 for arg in $("${pkgconf}" --libs "${tf}"); do
1448 [[ ${arg} == -l* ]] && pc_libs+=( lib${arg#-l}.la )
1449 done
1450 done < <(find "${D}" -type f -name '*.pc' -print0)
1451
1452 rm -f "${tf}"
1453 fi
1454
1455 local f
1456 while IFS= read -r -d '' f; do # for all .la files
1457 local archivefile=${f/%.la/.a}
1458
1459 [[ ${f} != ${archivefile} ]] || die 'regex sanity check failed'
1460
1461 # Remove static libs we're not supposed to link against.
1462 if grep -q '^shouldnotlink=yes$' "${f}"; then
1463 einfo "Removing unnecessary ${archivefile#${D%/}}"
1464 rm -f "${archivefile}"
1465
1466 # The .la file may be used by a module loader, so avoid removing it
1467 # unless explicitly requested.
1468 [[ ${removing_all} ]] || continue
1469 fi
1470
1471 # Remove .la files when:
1472 # - user explicitly wants us to remove all .la files,
1473 # - respective static archive doesn't exist,
1474 # - they are covered by a .pc file already,
1475 # - they don't provide any new information (no libs & no flags).
1476 local reason
1477 if [[ ${removing_all} ]]; then
1478 reason='requested'
1479 elif [[ ! -f ${archivefile} ]]; then
1480 reason='no static archive'
1481 elif has "${f##*/}" "${pc_libs[@]}"; then
1482 reason='covered by .pc'
1483 elif [[ ! $(sed -nre \
1484 "s/^(dependency_libs|inherited_linker_flags)='(.*)'$/\2/p" \
1485 "${f}") ]]; then
1486 reason='no libs & flags'
1487 fi
1488
1489 if [[ ${reason} ]]; then
1490 einfo "Removing unnecessary ${f#${D%/}} (${reason})"
1491 rm -f "${f}"
1492 fi
1493 done < <(find "${D}" -type f -name '*.la' -print0)
1494}
1495
1402check_license() { die "you no longer need this as portage supports ACCEPT_LICENSE itself"; } 1496check_license() { die "you no longer need this as portage supports ACCEPT_LICENSE itself"; }
1403 1497
1404fi 1498fi

Legend:
Removed from v.1.394  
changed lines
  Added in v.1.395

  ViewVC Help
Powered by ViewVC 1.1.20