summaryrefslogtreecommitdiff
path: root/eclass
diff options
context:
space:
mode:
authorMike Frysinger <vapier@gentoo.org>2004-02-21 07:19:29 +0000
committerMike Frysinger <vapier@gentoo.org>2004-02-21 07:19:29 +0000
commitf855aa0c25e28474e65fc5361ef8cba98e9ccfc5 (patch)
tree2c2e966f38a0dec1b1751a6f91c99ce068aed2f0 /eclass
parentmove ALLOWED_FLAGS/UNSTABLE_FLAGS out of global scope since only one or two f... (diff)
downloadgentoo-2-f855aa0c25e28474e65fc5361ef8cba98e9ccfc5.tar.gz
gentoo-2-f855aa0c25e28474e65fc5361ef8cba98e9ccfc5.tar.bz2
gentoo-2-f855aa0c25e28474e65fc5361ef8cba98e9ccfc5.zip
add replace-cpu-flags to help tone down march/mcpu flags
make sure filter-flags/replace-flags catch multiple copies of a flag (for example, if user has -msse -msse -msse and we try to `filter-flags -msse`, we would catch only the first one before)
Diffstat (limited to 'eclass')
-rw-r--r--eclass/flag-o-matic.eclass24
1 files changed, 19 insertions, 5 deletions
diff --git a/eclass/flag-o-matic.eclass b/eclass/flag-o-matic.eclass
index b38bef2f7788..df3ed286e586 100644
--- a/eclass/flag-o-matic.eclass
+++ b/eclass/flag-o-matic.eclass
@@ -1,6 +1,6 @@
# Copyright 1999-2003 Gentoo Technologies, Inc.
# Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo-x86/eclass/flag-o-matic.eclass,v 1.36 2004/02/21 07:07:56 vapier Exp $
+# $Header: /var/cvsroot/gentoo-x86/eclass/flag-o-matic.eclass,v 1.37 2004/02/21 07:19:29 vapier Exp $
#
# Author Bart Verwilst <verwilst@gentoo.org>
@@ -18,6 +18,10 @@ INHERITED="$INHERITED $ECLASS"
#### replace-flags <orig.flag> <new.flag> ###
# Replace a flag by another one
#
+#### replace-cpu-flags <new.cpu> <old.cpus> ###
+# Replace march/mcpu flags that specify <old.cpus>
+# with flags that specify <new.cpu>
+#
#### is-flag <flag> ####
# Returns "true" if flag is set in C[XX]FLAGS
# Matches only complete a flag
@@ -86,8 +90,8 @@ filter-flags() {
CFLAGS=" ${CFLAGS} "
CXXFLAGS=" ${CXXFLAGS} "
for x in "$@" ; do
- CFLAGS="${CFLAGS/ ${x} / }"
- CXXFLAGS="${CXXFLAGS/ ${x} / }"
+ CFLAGS="${CFLAGS// ${x} / }"
+ CXXFLAGS="${CXXFLAGS// ${x} / }"
done
CFLAGS="${CFLAGS:1:${#CFLAGS}-2}"
CXXFLAGS="${CXXFLAGS:1:${#CXXFLAGS}-2}"
@@ -106,13 +110,23 @@ replace-flags() {
# 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} / ${2} }"
+ CXXFLAGS="${CXXFLAGS// ${1} / ${2} }"
CFLAGS="${CFLAGS:1:${#CFLAGS}-2}"
CXXFLAGS="${CXXFLAGS:1:${#CXXFLAGS}-2}"
return 0
}
+replace-cpu-flags() {
+ local newcpu="$1" ; shift
+ local oldcpu=""
+ for oldcpu in "$@" ; do
+ replace-flags -march=${oldcpu} -march=${newcpu}
+ replace-flags -mcpu=${oldcpu} -mcpu=${newcpu}
+ done
+ return 0
+}
+
is-flag() {
for x in ${CFLAGS} ${CXXFLAGS} ; do
if [ "${x}" == "$1" ] ; then