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

Diff of /eclass/eutils.eclass

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

Revision 1.417 Revision 1.418
1# Copyright 1999-2013 Gentoo Foundation 1# Copyright 1999-2013 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.417 2013/04/25 18:38:02 vapier Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/eutils.eclass,v 1.418 2013/05/15 19:01:36 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
1456 local queue=() 1456 local queue=()
1457 while IFS= read -r -d '' f; do # for all .la files 1457 while IFS= read -r -d '' f; do # for all .la files
1458 local archivefile=${f/%.la/.a} 1458 local archivefile=${f/%.la/.a}
1459 1459
1460 [[ ${f} != ${archivefile} ]] || die 'regex sanity check failed' 1460 [[ ${f} != ${archivefile} ]] || die 'regex sanity check failed'
1461
1462 local reason pkgconfig_scanned 1461 local reason pkgconfig_scanned
1462 local snotlink=$(sed -n -e 's:^shouldnotlink=::p' "${f}")
1463 1463
1464 if [[ ${snotlink} == yes ]]; then
1465
1464 # Remove static libs we're not supposed to link against. 1466 # Remove static libs we're not supposed to link against.
1465 if grep -q '^shouldnotlink=yes$' "${f}"; then
1466 if [[ -f ${archivefile} ]]; then 1467 if [[ -f ${archivefile} ]]; then
1467 einfo "Removing unnecessary ${archivefile#${D%/}} (static plugin)" 1468 einfo "Removing unnecessary ${archivefile#${D%/}} (static plugin)"
1468 queue+=( "${archivefile}" ) 1469 queue+=( "${archivefile}" )
1469 fi 1470 fi
1470 1471
1472 # unless explicitly requested. 1473 # unless explicitly requested.
1473 if [[ ${removing_modules} ]]; then 1474 if [[ ${removing_modules} ]]; then
1474 reason='module' 1475 reason='module'
1475 fi 1476 fi
1476 1477
1478 elif [[ ${snotlink} == no ]]; then
1479
1480 # A valid .la file must have a valid 'shouldnotlink='.
1481 # That assumption helps us avoid removing random files
1482 # which match '*.la', see bug #468380.
1483
1477 # Remove .la files when: 1484 # Remove .la files when:
1478 # - user explicitly wants us to remove all .la files, 1485 # - user explicitly wants us to remove all .la files,
1479 # - respective static archive doesn't exist, 1486 # - respective static archive doesn't exist,
1480 # - they are covered by a .pc file already, 1487 # - they are covered by a .pc file already,
1481 # - they don't provide any new information (no libs & no flags). 1488 # - they don't provide any new information (no libs & no flags).
1482 1489
1483 elif [[ ${removing_all} ]]; then 1490 if [[ ${removing_all} ]]; then
1484 reason='requested' 1491 reason='requested'
1485 elif [[ ! -f ${archivefile} ]]; then 1492 elif [[ ! -f ${archivefile} ]]; then
1486 reason='no static archive' 1493 reason='no static archive'
1487 elif [[ ! $(sed -nre \ 1494 elif [[ ! $(sed -nre \
1488 "s/^(dependency_libs|inherited_linker_flags)='(.*)'$/\2/p" \ 1495 "s/^(dependency_libs|inherited_linker_flags)='(.*)'$/\2/p" \
1489 "${f}") ]]; then 1496 "${f}") ]]; then
1490 reason='no libs & flags' 1497 reason='no libs & flags'
1491 else 1498 else
1492 if [[ ! ${pkgconfig_scanned} ]]; then 1499 if [[ ! ${pkgconfig_scanned} ]]; then
1493 # Create a list of all .pc-covered libs. 1500 # Create a list of all .pc-covered libs.
1494 local pc_libs=() 1501 local pc_libs=()
1495 if [[ ! ${removing_all} ]]; then 1502 if [[ ! ${removing_all} ]]; then
1496 local pc 1503 local pc
1497 local tf=${T}/prune-lt-files.pc 1504 local tf=${T}/prune-lt-files.pc
1498 local pkgconf=$(tc-getPKG_CONFIG) 1505 local pkgconf=$(tc-getPKG_CONFIG)
1499 1506
1500 while IFS= read -r -d '' pc; do # for all .pc files 1507 while IFS= read -r -d '' pc; do # for all .pc files
1501 local arg libs 1508 local arg libs
1502 1509
1503 # Use pkg-config if available (and works), 1510 # Use pkg-config if available (and works),
1504 # fallback to sed. 1511 # fallback to sed.
1505 if ${pkgconf} --exists "${pc}" &>/dev/null; then 1512 if ${pkgconf} --exists "${pc}" &>/dev/null; then
1506 sed -e '/^Requires:/d' "${pc}" > "${tf}" 1513 sed -e '/^Requires:/d' "${pc}" > "${tf}"
1507 libs=$(${pkgconf} --libs "${tf}") 1514 libs=$(${pkgconf} --libs "${tf}")
1508 else 1515 else
1509 libs=$(sed -ne 's/^Libs://p' "${pc}") 1516 libs=$(sed -ne 's/^Libs://p' "${pc}")
1510 fi 1517 fi
1511 1518
1512 for arg in ${libs}; do 1519 for arg in ${libs}; do
1513 if [[ ${arg} == -l* ]]; then 1520 if [[ ${arg} == -l* ]]; then
1514 if [[ ${arg} == '*$*' ]]; then 1521 if [[ ${arg} == '*$*' ]]; then
1515 eqawarn "${FUNCNAME}: variable substitution likely failed in ${pc}" 1522 eqawarn "${FUNCNAME}: variable substitution likely failed in ${pc}"
1516 eqawarn "(arg: ${arg})" 1523 eqawarn "(arg: ${arg})"
1517 eqawarn "Most likely, you need to add virtual/pkgconfig to DEPEND." 1524 eqawarn "Most likely, you need to add virtual/pkgconfig to DEPEND."
1525 fi
1526
1527 pc_libs+=( lib${arg#-l}.la )
1518 fi 1528 fi
1519
1520 pc_libs+=( lib${arg#-l}.la )
1521 fi
1522 done 1529 done
1523 done < <(find "${D}" -type f -name '*.pc' -print0) 1530 done < <(find "${D}" -type f -name '*.pc' -print0)
1524 1531
1525 rm -f "${tf}" 1532 rm -f "${tf}"
1526 fi 1533 fi
1527 1534
1528 pkgconfig_scanned=1 1535 pkgconfig_scanned=1
1529 fi 1536 fi # pkgconfig_scanned
1530 1537
1531 has "${f##*/}" "${pc_libs[@]}" && reason='covered by .pc' 1538 has "${f##*/}" "${pc_libs[@]}" && reason='covered by .pc'
1532 fi 1539 fi # removal due to .pc
1540
1541 fi # shouldnotlink==no
1533 1542
1534 if [[ ${reason} ]]; then 1543 if [[ ${reason} ]]; then
1535 einfo "Removing unnecessary ${f#${D%/}} (${reason})" 1544 einfo "Removing unnecessary ${f#${D%/}} (${reason})"
1536 queue+=( "${f}" ) 1545 queue+=( "${f}" )
1537 fi 1546 fi

Legend:
Removed from v.1.417  
changed lines
  Added in v.1.418

  ViewVC Help
Powered by ViewVC 1.1.20