/[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.412
1# Copyright 1999-2012 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.407 2012/10/11 16:50:53 mgorny Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/eutils.eclass,v 1.412 2013/03/09 17:55:39 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
1267# http://bugs.gentoo.org/73450 1267# http://bugs.gentoo.org/73450
1268epunt_cxx() { 1268epunt_cxx() {
1269 local dir=$1 1269 local dir=$1
1270 [[ -z ${dir} ]] && dir=${S} 1270 [[ -z ${dir} ]] && dir=${S}
1271 ebegin "Removing useless C++ checks" 1271 ebegin "Removing useless C++ checks"
1272 local f 1272 local f any_found
1273 find "${dir}" -name configure | while read f ; do 1273 while IFS= read -r -d '' f; do
1274 patch --no-backup-if-mismatch -p0 "${f}" "${PORTDIR}/eclass/ELT-patches/nocxx/nocxx.patch" > /dev/null 1274 patch --no-backup-if-mismatch -p0 "${f}" \
1275 done 1275 "${PORTDIR}/eclass/ELT-patches/nocxx/nocxx.patch" > /dev/null \
1276 && any_found=1
1277 done < <(find "${dir}" -name configure -print0)
1278
1279 if [[ -z ${any_found} ]]; then
1280 eqawarn "epunt_cxx called unnecessarily (no C++ checks to punt)."
1281 fi
1276 eend 0 1282 eend 0
1277} 1283}
1278 1284
1279# @FUNCTION: make_wrapper 1285# @FUNCTION: make_wrapper
1280# @USAGE: <wrapper> <target> [chdir] [libpaths] [installpath] 1286# @USAGE: <wrapper> <target> [chdir] [libpaths] [installpath]
1378if has "${EAPI:-0}" 0 1 2 3 4; then 1384if has "${EAPI:-0}" 0 1 2 3 4; then
1379 usex() { use "$1" && echo "${2-yes}$4" || echo "${3-no}$5" ; } #382963 1385 usex() { use "$1" && echo "${2-yes}$4" || echo "${3-no}$5" ; } #382963
1380fi 1386fi
1381 1387
1382# @FUNCTION: prune_libtool_files 1388# @FUNCTION: prune_libtool_files
1383# @USAGE: [--all] 1389# @USAGE: [--all|--modules]
1384# @DESCRIPTION: 1390# @DESCRIPTION:
1385# Locate unnecessary libtool files (.la) and libtool static archives 1391# Locate unnecessary libtool files (.la) and libtool static archives
1386# (.a) and remove them from installation image. 1392# (.a) and remove them from installation image.
1387# 1393#
1388# By default, .la files are removed whenever the static linkage can 1394# By default, .la files are removed whenever the static linkage can
1389# either be performed using pkg-config or doesn't introduce additional 1395# either be performed using pkg-config or doesn't introduce additional
1390# flags. 1396# flags.
1391# 1397#
1398# If '--modules' argument is passed, .la files for modules (plugins) are
1399# removed as well. This is usually useful when the package installs
1400# plugins and the plugin loader does not use .la files.
1401#
1392# If '--all' argument is passed, all .la files are removed. This is 1402# If '--all' argument is passed, all .la files are removed without
1393# usually useful when the package installs plugins and does not use .la 1403# performing any heuristic on them. You shouldn't ever use that,
1394# files for loading them. 1404# and instead report a bug in the algorithm instead.
1395# 1405#
1396# The .a files are only removed whenever corresponding .la files state 1406# The .a files are only removed whenever corresponding .la files state
1397# that they should not be linked to, i.e. whenever these files 1407# that they should not be linked to, i.e. whenever these files
1398# correspond to plugins. 1408# correspond to plugins.
1399# 1409#
1400# Note: if your package installs both static libraries and .pc files, 1410# Note: if your package installs both static libraries and .pc files
1411# which use variable substitution for -l flags, you need to add
1401# you need to add pkg-config to your DEPEND. 1412# pkg-config to your DEPEND.
1402prune_libtool_files() { 1413prune_libtool_files() {
1403 debug-print-function ${FUNCNAME} "$@" 1414 debug-print-function ${FUNCNAME} "$@"
1404 1415
1405 local removing_all opt 1416 local removing_all removing_modules opt
1406 for opt; do 1417 for opt; do
1407 case "${opt}" in 1418 case "${opt}" in
1408 --all) 1419 --all)
1409 removing_all=1 1420 removing_all=1
1421 removing_modules=1
1422 ;;
1423 --modules)
1424 removing_modules=1
1410 ;; 1425 ;;
1411 *) 1426 *)
1412 die "Invalid argument to ${FUNCNAME}(): ${opt}" 1427 die "Invalid argument to ${FUNCNAME}(): ${opt}"
1413 esac 1428 esac
1414 done 1429 done
1417 local queue=() 1432 local queue=()
1418 while IFS= read -r -d '' f; do # for all .la files 1433 while IFS= read -r -d '' f; do # for all .la files
1419 local archivefile=${f/%.la/.a} 1434 local archivefile=${f/%.la/.a}
1420 1435
1421 [[ ${f} != ${archivefile} ]] || die 'regex sanity check failed' 1436 [[ ${f} != ${archivefile} ]] || die 'regex sanity check failed'
1437
1438 local reason pkgconfig_scanned
1422 1439
1423 # Remove static libs we're not supposed to link against. 1440 # Remove static libs we're not supposed to link against.
1424 if grep -q '^shouldnotlink=yes$' "${f}"; then 1441 if grep -q '^shouldnotlink=yes$' "${f}"; then
1425 if [[ -f ${archivefile} ]]; then 1442 if [[ -f ${archivefile} ]]; then
1426 einfo "Removing unnecessary ${archivefile#${D%/}} (static plugin)" 1443 einfo "Removing unnecessary ${archivefile#${D%/}} (static plugin)"
1427 queue+=( "${archivefile}" ) 1444 queue+=( "${archivefile}" )
1428 fi 1445 fi
1429 1446
1430 # The .la file may be used by a module loader, so avoid removing it 1447 # The .la file may be used by a module loader, so avoid removing it
1431 # unless explicitly requested. 1448 # unless explicitly requested.
1432 [[ ${removing_all} ]] || continue 1449 if [[ ${removing_modules} ]]; then
1450 reason='module'
1433 fi 1451 fi
1434 1452
1435 # Remove .la files when: 1453 # Remove .la files when:
1436 # - user explicitly wants us to remove all .la files, 1454 # - user explicitly wants us to remove all .la files,
1437 # - respective static archive doesn't exist, 1455 # - respective static archive doesn't exist,
1438 # - they are covered by a .pc file already, 1456 # - they are covered by a .pc file already,
1439 # - they don't provide any new information (no libs & no flags). 1457 # - they don't provide any new information (no libs & no flags).
1440 local reason pkgconfig_scanned 1458
1441 if [[ ${removing_all} ]]; then 1459 elif [[ ${removing_all} ]]; then
1442 reason='requested' 1460 reason='requested'
1443 elif [[ ! -f ${archivefile} ]]; then 1461 elif [[ ! -f ${archivefile} ]]; then
1444 reason='no static archive' 1462 reason='no static archive'
1445 elif [[ ! $(sed -nre \ 1463 elif [[ ! $(sed -nre \
1446 "s/^(dependency_libs|inherited_linker_flags)='(.*)'$/\2/p" \ 1464 "s/^(dependency_libs|inherited_linker_flags)='(.*)'$/\2/p" \
1449 else 1467 else
1450 if [[ ! ${pkgconfig_scanned} ]]; then 1468 if [[ ! ${pkgconfig_scanned} ]]; then
1451 # Create a list of all .pc-covered libs. 1469 # Create a list of all .pc-covered libs.
1452 local pc_libs=() 1470 local pc_libs=()
1453 if [[ ! ${removing_all} ]]; then 1471 if [[ ! ${removing_all} ]]; then
1454 local f 1472 local pc
1455 local tf=${T}/prune-lt-files.pc 1473 local tf=${T}/prune-lt-files.pc
1456 local pkgconf=$(tc-getPKG_CONFIG) 1474 local pkgconf=$(tc-getPKG_CONFIG)
1457 1475
1458 while IFS= read -r -d '' f; do # for all .pc files 1476 while IFS= read -r -d '' pc; do # for all .pc files
1459 local arg 1477 local arg libs
1460 1478
1479 # Use pkg-config if available (and works),
1480 # fallback to sed.
1481 if ${pkgconf} --exists "${pc}" &>/dev/null; then
1461 sed -e '/^Requires:/d' "${f}" > "${tf}" 1482 sed -e '/^Requires:/d' "${pc}" > "${tf}"
1462 for arg in $("${pkgconf}" --libs "${tf}"); do 1483 libs=$(${pkgconf} --libs "${tf}")
1463 [[ ${arg} == -l* ]] && pc_libs+=( lib${arg#-l}.la ) 1484 else
1485 libs=$(sed -ne 's/^Libs://p' "${pc}")
1486 fi
1487
1488 for arg in ${libs}; do
1489 if [[ ${arg} == -l* ]]; then
1490 if [[ ${arg} == '*$*' ]]; then
1491 eqawarn "${FUNCNAME}: variable substitution likely failed in ${pc}"
1492 eqawarn "(arg: ${arg})"
1493 eqawarn "Most likely, you need to add virtual/pkgconfig to DEPEND."
1494 fi
1495
1496 pc_libs+=( lib${arg#-l}.la )
1497 fi
1464 done 1498 done
1465 done < <(find "${D}" -type f -name '*.pc' -print0) 1499 done < <(find "${D}" -type f -name '*.pc' -print0)
1466 1500
1467 rm -f "${tf}" 1501 rm -f "${tf}"
1468 fi 1502 fi

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

  ViewVC Help
Powered by ViewVC 1.1.20