/[gentoo-x86]/eclass/flag-o-matic.eclass
Gentoo

Diff of /eclass/flag-o-matic.eclass

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

Revision 1.63 Revision 1.64
1# Copyright 1999-2004 Gentoo Foundation 1# Copyright 1999-2004 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/flag-o-matic.eclass,v 1.63 2004/07/18 04:59:30 vapier Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/flag-o-matic.eclass,v 1.64 2004/07/22 15:29:10 agriffis Exp $
4# 4#
5# Author Bart Verwilst <verwilst@gentoo.org> 5# Author Bart Verwilst <verwilst@gentoo.org>
6 6
7ECLASS=flag-o-matic 7ECLASS=flag-o-matic
8INHERITED="$INHERITED $ECLASS" 8INHERITED="$INHERITED $ECLASS"
9 9
10# Please leave ${IUSE} in this until portage .51 is stable, otherwise
11# IUSE gets clobbered.
10IUSE="debug" 12IUSE="${IUSE} debug"
11 13
12# 14#
13#### filter-flags <flags> #### 15#### filter-flags <flags> ####
14# Remove particular flags from C[XX]FLAGS 16# Remove particular flags from C[XX]FLAGS
15# Matches only complete flags 17# Matches only complete flags
97 -fstack-protector|-fstack-protector-all) fstack-flags;; 99 -fstack-protector|-fstack-protector-all) fstack-flags;;
98 esac 100 esac
99 done 101 done
100 102
101 for fset in CFLAGS CXXFLAGS; do 103 for fset in CFLAGS CXXFLAGS; do
104 # Looping over the flags instead of using a global
105 # substitution ensures that we're working with flag atoms.
106 # Otherwise globs like -O* have the potential to wipe out the
107 # list of flags.
102 for f in ${!fset}; do 108 for f in ${!fset}; do
103 for x in "$@"; do 109 for x in "$@"; do
104 # Note this should work with globs like -O* 110 # Note this should work with globs like -O*
105 [[ ${f} == ${x} ]] && continue 2 111 [[ ${f} == ${x} ]] && continue 2
106 done 112 done
127 -n "`is-flag -fno-stack-protector-all`" ] && fstack-flags 133 -n "`is-flag -fno-stack-protector-all`" ] && fstack-flags
128 return 0 134 return 0
129} 135}
130 136
131replace-flags() { 137replace-flags() {
132 # we do this fancy spacing stuff so as to not filter 138 local f fset
133 # out part of a flag ... we want flag atoms ! :D 139 declare -a new_CFLAGS new_CXXFLAGS
134 CFLAGS=" ${CFLAGS} " 140
135 CXXFLAGS=" ${CXXFLAGS} " 141 for fset in CFLAGS CXXFLAGS; do
136 CFLAGS="${CFLAGS// ${1} / ${2} }" 142 # Looping over the flags instead of using a global
137 CXXFLAGS="${CXXFLAGS// ${1} / ${2} }" 143 # substitution ensures that we're working with flag atoms.
138 CFLAGS="${CFLAGS:1:${#CFLAGS}-2}" 144 # Otherwise globs like -O* have the potential to wipe out the
139 CXXFLAGS="${CXXFLAGS:1:${#CXXFLAGS}-2}" 145 # list of flags.
140 export CFLAGS CXXFLAGS 146 for f in ${!fset}; do
147 # Note this should work with globs like -O*
148 [[ ${f} == ${1} ]] && f=${2}
149 eval new_${fset}\[\${\#new_${fset}\[@]}]=\${f}
150 done
151 eval export ${fset}=\${new_${fset}\[*]}
152 done
153
141 return 0 154 return 0
142} 155}
143 156
144replace-cpu-flags() { 157replace-cpu-flags() {
145 local oldcpu newcpu="$1" ; shift 158 local oldcpu newcpu="$1" ; shift
146 for oldcpu in "$@" ; do 159 for oldcpu in "$@" ; do
160 # quote to make sure that no globbing is done (particularly on
161 # ${oldcpu} prior to calling replace-flags
147 replace-flags -march=${oldcpu} -march=${newcpu} 162 replace-flags "-march=${oldcpu}" "-march=${newcpu}"
148 replace-flags -mcpu=${oldcpu} -mcpu=${newcpu} 163 replace-flags "-mcpu=${oldcpu}" "-mcpu=${newcpu}"
149 replace-flags -mtune=${oldcpu} -mtune=${newcpu} 164 replace-flags "-mtune=${oldcpu}" "-mtune=${newcpu}"
150 done 165 done
151 return 0 166 return 0
152} 167}
153 168
154is-flag() { 169is-flag() {

Legend:
Removed from v.1.63  
changed lines
  Added in v.1.64

  ViewVC Help
Powered by ViewVC 1.1.20