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

Diff of /eclass/eutils.eclass

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

Revision 1.401 Revision 1.402
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.401 2012/08/20 19:45:57 vapier Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/eutils.eclass,v 1.402 2012/08/29 13:42:42 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
1393# 1393#
1394# The .a files are only removed whenever corresponding .la files state 1394# The .a files are only removed whenever corresponding .la files state
1395# that they should not be linked to, i.e. whenever these files 1395# that they should not be linked to, i.e. whenever these files
1396# correspond to plugins. 1396# correspond to plugins.
1397# 1397#
1398# Note: if your package installs any .pc files, this function implicitly 1398# Note: if your package installs both static libraries and .pc files,
1399# calls pkg-config. You should add it to your DEPEND in that case. 1399# you need to add pkg-config to your DEPEND.
1400prune_libtool_files() { 1400prune_libtool_files() {
1401 debug-print-function ${FUNCNAME} "$@" 1401 debug-print-function ${FUNCNAME} "$@"
1402 1402
1403 local removing_all opt 1403 local removing_all opt
1404 for opt; do 1404 for opt; do
1409 *) 1409 *)
1410 die "Invalid argument to ${FUNCNAME}(): ${opt}" 1410 die "Invalid argument to ${FUNCNAME}(): ${opt}"
1411 esac 1411 esac
1412 done 1412 done
1413 1413
1414 # Create a list of all .pc-covered libs.
1415 local pc_libs=()
1416 if [[ ! ${removing_all} ]]; then
1417 local f
1418 local tf=${T}/prune-lt-files.pc
1419 local pkgconf=$(tc-getPKG_CONFIG)
1420
1421 while IFS= read -r -d '' f; do # for all .pc files
1422 local arg
1423
1424 sed -e '/^Requires:/d' "${f}" > "${tf}"
1425 for arg in $("${pkgconf}" --libs "${tf}"); do
1426 [[ ${arg} == -l* ]] && pc_libs+=( lib${arg#-l}.la )
1427 done
1428 done < <(find "${D}" -type f -name '*.pc' -print0)
1429
1430 rm -f "${tf}"
1431 fi
1432
1433 local f 1414 local f
1434 while IFS= read -r -d '' f; do # for all .la files 1415 while IFS= read -r -d '' f; do # for all .la files
1435 local archivefile=${f/%.la/.a} 1416 local archivefile=${f/%.la/.a}
1436 1417
1437 [[ ${f} != ${archivefile} ]] || die 'regex sanity check failed' 1418 [[ ${f} != ${archivefile} ]] || die 'regex sanity check failed'
1451 # Remove .la files when: 1432 # Remove .la files when:
1452 # - user explicitly wants us to remove all .la files, 1433 # - user explicitly wants us to remove all .la files,
1453 # - respective static archive doesn't exist, 1434 # - respective static archive doesn't exist,
1454 # - they are covered by a .pc file already, 1435 # - they are covered by a .pc file already,
1455 # - they don't provide any new information (no libs & no flags). 1436 # - they don't provide any new information (no libs & no flags).
1456 local reason 1437 local reason pkgconfig_scanned
1457 if [[ ${removing_all} ]]; then 1438 if [[ ${removing_all} ]]; then
1458 reason='requested' 1439 reason='requested'
1459 elif [[ ! -f ${archivefile} ]]; then 1440 elif [[ ! -f ${archivefile} ]]; then
1460 reason='no static archive' 1441 reason='no static archive'
1461 elif has "${f##*/}" "${pc_libs[@]}"; then
1462 reason='covered by .pc'
1463 elif [[ ! $(sed -nre \ 1442 elif [[ ! $(sed -nre \
1464 "s/^(dependency_libs|inherited_linker_flags)='(.*)'$/\2/p" \ 1443 "s/^(dependency_libs|inherited_linker_flags)='(.*)'$/\2/p" \
1465 "${f}") ]]; then 1444 "${f}") ]]; then
1466 reason='no libs & flags' 1445 reason='no libs & flags'
1446 else
1447 if [[ ! ${pkgconfig_scanned} ]]; then
1448 # Create a list of all .pc-covered libs.
1449 local pc_libs=()
1450 if [[ ! ${removing_all} ]]; then
1451 local f
1452 local tf=${T}/prune-lt-files.pc
1453 local pkgconf=$(tc-getPKG_CONFIG)
1454
1455 while IFS= read -r -d '' f; do # for all .pc files
1456 local arg
1457
1458 sed -e '/^Requires:/d' "${f}" > "${tf}"
1459 for arg in $("${pkgconf}" --libs "${tf}"); do
1460 [[ ${arg} == -l* ]] && pc_libs+=( lib${arg#-l}.la )
1461 done
1462 done < <(find "${D}" -type f -name '*.pc' -print0)
1463
1464 rm -f "${tf}"
1465 fi
1466
1467 pkgconfig_scanned=1
1468 fi
1469
1470 has "${f##*/}" "${pc_libs[@]}" && reason='covered by .pc'
1467 fi 1471 fi
1468 1472
1469 if [[ ${reason} ]]; then 1473 if [[ ${reason} ]]; then
1470 einfo "Removing unnecessary ${f#${D%/}} (${reason})" 1474 einfo "Removing unnecessary ${f#${D%/}} (${reason})"
1471 rm -f "${f}" 1475 rm -f "${f}"

Legend:
Removed from v.1.401  
changed lines
  Added in v.1.402

  ViewVC Help
Powered by ViewVC 1.1.20