diff options
author | Martin Schlemmer <azarah@gentoo.org> | 2002-10-13 01:01:58 +0000 |
---|---|---|
committer | Martin Schlemmer <azarah@gentoo.org> | 2002-10-13 01:01:58 +0000 |
commit | 888e90d00c3347d928942c9ef780d663192e5f90 (patch) | |
tree | e982b340a1fd8bb0b16fbae6684f2f2e75365355 /eclass | |
parent | corrected URI (diff) | |
download | gentoo-2-888e90d00c3347d928942c9ef780d663192e5f90.tar.gz gentoo-2-888e90d00c3347d928942c9ef780d663192e5f90.tar.bz2 gentoo-2-888e90d00c3347d928942c9ef780d663192e5f90.zip |
add strip-flags() to flag-o-matic.eclass
Diffstat (limited to 'eclass')
-rw-r--r-- | eclass/flag-o-matic.eclass | 78 |
1 files changed, 67 insertions, 11 deletions
diff --git a/eclass/flag-o-matic.eclass b/eclass/flag-o-matic.eclass index 14ff1af8b423..5a4e5def3e28 100644 --- a/eclass/flag-o-matic.eclass +++ b/eclass/flag-o-matic.eclass @@ -1,9 +1,11 @@ # Copyright 1999-2002 Gentoo Technologies, Inc. # Distributed under the terms of the GNU General Public License v2 # Author Bart Verwilst <verwilst@gentoo.org> -# /space/gentoo/cvsroot/gentoo-x86/eclass/flag-o-matic.eclass +# $Header: /var/cvsroot/gentoo-x86/eclass/flag-o-matic.eclass,v 1.8 2002/10/13 01:01:58 azarah Exp $ + ECLASS=flag-o-matic INHERITED="$INHERITED $ECLASS" + # #### filter-flags <flag> #### # Remove particular flags from C[XX]FLAGS @@ -18,21 +20,25 @@ INHERITED="$INHERITED $ECLASS" # Returns "true" if flag is set in C[XX]FLAGS # Matches only complete flag # +#### strip-flags #### +# Strip C[XX]FLAGS of everything except known +# good options. +# filter-flags () { - for x in $1; do - CFLAGS="${CFLAGS/$x}" - CXXFLAGS="${CXXFLAGS/$x}" + for x in $1 + do + export CFLAGS="${CFLAGS/${x}}" + export CXXFLAGS="${CXXFLAGS/${x}}" done } append-flags () { - - CFLAGS="$CFLAGS $1" - CXXFLAGS="$CXXFLAGS $1" + CFLAGS="${CFLAGS} $1" + CXXFLAGS="${CXXFLAGS} $1" } @@ -45,11 +51,61 @@ replace-flags () { is-flag() { - for x in $CFLAGS $CXXFLAGS; do - if [ "$x" == "$1" ]; then - echo true - break + for x in ${CFLAGS} ${CXXFLAGS} + do + if [ "${x}" = "$1" ] + then + echo true + break fi done } + +strip-flags() { + + local NEW_CFLAGS="" + local NEW_CXXFLAGS="" + + local ALLOWED_FLAGS="-O -mcpu -march -pipe" + + set -f + + for x in ${CFLAGS} + do + for y in ${ALLOWED_FLAGS} + do + if [ "${x/${y}}" != "${x}" ] + then + if [ -z "${NEW_CFLAGS}" ] + then + NEW_CFLAGS="${x}" + else + NEW_CFLAGS="${NEW_CFLAGS} ${x}" + fi + fi + done + done + + for x in ${CXXFLAGS} + do + for y in ${ALLOWED_FLAGS} + do + if [ "${x/${y}}" != "${x}" ] + then + if [ -z "${NEW_CXXFLAGS}" ] + then + NEW_CXXFLAGS="${x}" + else + NEW_CXXFLAGS="${NEW_CXXFLAGS} ${x}" + fi + fi + done + done + + set +f + + export CFLAGS="${NEW_CFLAGS}" + export CXXFLAGS="${NEW_CXXFLAGS}" +} + |