summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAron Griffis <agriffis@gentoo.org>2004-07-22 15:29:10 +0000
committerAron Griffis <agriffis@gentoo.org>2004-07-22 15:29:10 +0000
commit0ff461a0123a7914edae8d3eedc1b779ec402d50 (patch)
tree58a80f7a209e108269156cf8d2e66e6d00ea0614 /eclass/flag-o-matic.eclass
parentfixed license and stable 2.6.3 on x86. (Manifest recommit) (diff)
downloadgentoo-2-0ff461a0123a7914edae8d3eedc1b779ec402d50.tar.gz
gentoo-2-0ff461a0123a7914edae8d3eedc1b779ec402d50.tar.bz2
gentoo-2-0ff461a0123a7914edae8d3eedc1b779ec402d50.zip
update replace-flags to use atom code from filter-flags, related to #42006. Also add ${IUSE} to IUSE for the sake of portage .50 users, which is basically all of them at the moment
Diffstat (limited to 'eclass/flag-o-matic.eclass')
-rw-r--r--eclass/flag-o-matic.eclass43
1 files changed, 29 insertions, 14 deletions
diff --git a/eclass/flag-o-matic.eclass b/eclass/flag-o-matic.eclass
index 547e31c6df8c..0807010be9d0 100644
--- a/eclass/flag-o-matic.eclass
+++ b/eclass/flag-o-matic.eclass
@@ -1,13 +1,15 @@
# Copyright 1999-2004 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo-x86/eclass/flag-o-matic.eclass,v 1.63 2004/07/18 04:59:30 vapier Exp $
+# $Header: /var/cvsroot/gentoo-x86/eclass/flag-o-matic.eclass,v 1.64 2004/07/22 15:29:10 agriffis Exp $
#
# Author Bart Verwilst <verwilst@gentoo.org>
ECLASS=flag-o-matic
INHERITED="$INHERITED $ECLASS"
-IUSE="debug"
+# Please leave ${IUSE} in this until portage .51 is stable, otherwise
+# IUSE gets clobbered.
+IUSE="${IUSE} debug"
#
#### filter-flags <flags> ####
@@ -99,6 +101,10 @@ filter-flags() {
done
for fset in CFLAGS CXXFLAGS; do
+ # Looping over the flags instead of using a global
+ # substitution ensures that we're working with flag atoms.
+ # Otherwise globs like -O* have the potential to wipe out the
+ # list of flags.
for f in ${!fset}; do
for x in "$@"; do
# Note this should work with globs like -O*
@@ -129,24 +135,33 @@ append-flags() {
}
replace-flags() {
- # we do this fancy spacing stuff so as to not filter
- # out part of a flag ... we want flag atoms ! :D
- CFLAGS=" ${CFLAGS} "
- CXXFLAGS=" ${CXXFLAGS} "
- CFLAGS="${CFLAGS// ${1} / ${2} }"
- CXXFLAGS="${CXXFLAGS// ${1} / ${2} }"
- CFLAGS="${CFLAGS:1:${#CFLAGS}-2}"
- CXXFLAGS="${CXXFLAGS:1:${#CXXFLAGS}-2}"
- export CFLAGS CXXFLAGS
+ local f fset
+ declare -a new_CFLAGS new_CXXFLAGS
+
+ for fset in CFLAGS CXXFLAGS; do
+ # Looping over the flags instead of using a global
+ # substitution ensures that we're working with flag atoms.
+ # Otherwise globs like -O* have the potential to wipe out the
+ # list of flags.
+ for f in ${!fset}; do
+ # Note this should work with globs like -O*
+ [[ ${f} == ${1} ]] && f=${2}
+ eval new_${fset}\[\${\#new_${fset}\[@]}]=\${f}
+ done
+ eval export ${fset}=\${new_${fset}\[*]}
+ done
+
return 0
}
replace-cpu-flags() {
local oldcpu newcpu="$1" ; shift
for oldcpu in "$@" ; do
- replace-flags -march=${oldcpu} -march=${newcpu}
- replace-flags -mcpu=${oldcpu} -mcpu=${newcpu}
- replace-flags -mtune=${oldcpu} -mtune=${newcpu}
+ # quote to make sure that no globbing is done (particularly on
+ # ${oldcpu} prior to calling replace-flags
+ replace-flags "-march=${oldcpu}" "-march=${newcpu}"
+ replace-flags "-mcpu=${oldcpu}" "-mcpu=${newcpu}"
+ replace-flags "-mtune=${oldcpu}" "-mtune=${newcpu}"
done
return 0
}