/[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.9 Revision 1.15
1# Copyright 1999-2002 Gentoo Technologies, Inc. 1# Copyright 1999-2003 Gentoo Technologies, Inc.
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.15 2003/04/06 23:35:41 method Exp $
4#
3# Author Bart Verwilst <verwilst@gentoo.org> 5# Author Bart Verwilst <verwilst@gentoo.org>
4# $Header: /var/cvsroot/gentoo-x86/eclass/flag-o-matic.eclass,v 1.9 2002/10/20 06:43:10 seemant Exp $
5 6
6ECLASS=flag-o-matic 7ECLASS=flag-o-matic
7INHERITED="$INHERITED $ECLASS" 8INHERITED="$INHERITED $ECLASS"
8 9
9# 10#
22# 23#
23#### strip-flags #### 24#### strip-flags ####
24# Strip C[XX]FLAGS of everything except known 25# Strip C[XX]FLAGS of everything except known
25# good options. 26# good options.
26# 27#
28#### get-flag <flag> ####
29# Find and echo the value for a particular flag
30#
31
32ALLOWED_FLAGS="-O -mcpu -march -mtune -fstack-protector -pipe -g"
33
27 34
28filter-flags () { 35filter-flags () {
29 36
30 for x in $1 37 for x in $1
31 do 38 do
65strip-flags() { 72strip-flags() {
66 73
67 local NEW_CFLAGS="" 74 local NEW_CFLAGS=""
68 local NEW_CXXFLAGS="" 75 local NEW_CXXFLAGS=""
69 76
70 local ALLOWED_FLAGS="-O -mcpu -march -pipe"
71
72 set -f 77 set -f
73 78
74 for x in ${CFLAGS} 79 for x in ${CFLAGS}
75 do 80 do
76 for y in ${ALLOWED_FLAGS} 81 for y in ${ALLOWED_FLAGS}
77 do 82 do
83 flag=${x%%=*}
78 if [ "${x/${y}}" != "${x}" ] 84 if [ "${flag%%${y}}" = "" ]
79 then 85 then
80 if [ -z "${NEW_CFLAGS}" ]
81 then
82 NEW_CFLAGS="${x}"
83 else
84 NEW_CFLAGS="${NEW_CFLAGS} ${x}" 86 NEW_CFLAGS="${NEW_CFLAGS} ${x}"
85 fi 87 break
86 fi 88 fi
87 done 89 done
88 done 90 done
89 91
90 for x in ${CXXFLAGS} 92 for x in ${CXXFLAGS}
91 do 93 do
92 for y in ${ALLOWED_FLAGS} 94 for y in ${ALLOWED_FLAGS}
93 do 95 do
96 flag=${x%%=*}
94 if [ "${x/${y}}" != "${x}" ] 97 if [ "${flag%%${y}}" = "" ]
95 then 98 then
96 if [ -z "${NEW_CXXFLAGS}" ]
97 then
98 NEW_CXXFLAGS="${x}"
99 else
100 NEW_CXXFLAGS="${NEW_CXXFLAGS} ${x}" 99 NEW_CXXFLAGS="${NEW_CXXFLAGS} ${x}"
101 fi 100 break
102 fi 101 fi
103 done 102 done
104 done 103 done
105 104
106 set +f 105 set +f
107 106
108 export CFLAGS="${NEW_CFLAGS}" 107 export CFLAGS="${NEW_CFLAGS}"
109 export CXXFLAGS="${NEW_CXXFLAGS}" 108 export CXXFLAGS="${NEW_CXXFLAGS}"
110} 109}
111 110
111get-flag() {
112 local findflag="$1"
113
114 for f in ${CFLAGS} ${CXXFLAGS} ; do
115 if [ "${f/${findflag}}" != "${f}" ] ; then
116 echo "${f/-${findflag}=}"
117 return
118 fi
119 done
120}

Legend:
Removed from v.1.9  
changed lines
  Added in v.1.15

  ViewVC Help
Powered by ViewVC 1.1.20