From ee367eb084ead51167111f74f2629aea315f6e59 Mon Sep 17 00:00:00 2001 From: "Kevin F. Quinn" Date: Thu, 15 Mar 2007 15:55:59 +0000 Subject: [PATCH] Upgrade gcc-specs-directive to handle spec string substitutions. --- eclass/toolchain-funcs.eclass | 42 +++++++++++++++++++++++++++++++---- 1 file changed, 38 insertions(+), 4 deletions(-) diff --git a/eclass/toolchain-funcs.eclass b/eclass/toolchain-funcs.eclass index be6557bfd452..c3e8bd6d1273 100644 --- a/eclass/toolchain-funcs.eclass +++ b/eclass/toolchain-funcs.eclass @@ -1,6 +1,6 @@ # Copyright 1999-2007 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 -# $Header: /var/cvsroot/gentoo-x86/eclass/toolchain-funcs.eclass,v 1.67 2007/03/04 21:03:58 vapier Exp $ +# $Header: /var/cvsroot/gentoo-x86/eclass/toolchain-funcs.eclass,v 1.68 2007/03/15 15:55:59 kevquinn Exp $ # # Maintainer: Toolchain Ninjas # @@ -192,13 +192,29 @@ gcc-minor-version() { gcc-micro-version() { gcc-fullversion "$@" | cut -f3 -d. | cut -f1 -d- } +# Returns the installation directory - internal toolchain +# function for use by _gcc-specs-exists (for flag-o-matic). +_gcc-install-dir() { + echo "$($(tc-getCC) -print-search-dirs 2> /dev/null |\ + awk '$1=="install:" {print $2}')" +} +# Returns true if the indicated specs file exists - internal toolchain +# function for use by flag-o-matic. +_gcc-specs-exists() { + [[ -f $(_gcc-install-dir)/$1 ]] +} -# Returns requested gcc specs directive +# Returns requested gcc specs directive unprocessed - for used by +# gcc-specs-directive() # Note; later specs normally overwrite earlier ones; however if a later # spec starts with '+' then it appends. # gcc -dumpspecs is parsed first, followed by files listed by "gcc -v" -# as "Reading ", in order. -gcc-specs-directive() { +# as "Reading ", in order. Strictly speaking, if there's a +# $(gcc_install_dir)/specs, the built-in specs aren't read, however by +# the same token anything from 'gcc -dumpspecs' is overridden by +# the contents of $(gcc_install_dir)/specs so the result is the +# same either way. +_gcc-specs-directive_raw() { local cc=$(tc-getCC) local specfiles=$(LC_ALL=C ${cc} -v 2>&1 | awk '$1=="Reading" {print $NF}') ${cc} -dumpspecs 2> /dev/null | cat - ${specfiles} | awk -v directive=$1 \ @@ -211,6 +227,24 @@ END { print spec }' return 0 } +# Return the requested gcc specs directive, with all included +# specs expanded. +# Note, it does not check for inclusion loops, which cause it +# to never finish - but such loops are invalid for gcc and we're +# assuming gcc is operational. +gcc-specs-directive() { + local directive subdname subdirective + directive="$(_gcc-specs-directive_raw $1)" + while [[ ${directive} == *%\(*\)* ]]; do + subdname=${directive/*%\(} + subdname=${subdname/\)*} + subdirective="$(_gcc-specs-directive_raw ${subdname})" + directive="${directive//\%(${subdname})/${subdirective}}" + done + echo "${directive}" + return 0 +} + # Returns true if gcc sets relro gcc-specs-relro() { local directive -- 2.26.2