/[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.11 Revision 1.17
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.17 2003/04/27 20:57:46 azarah 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.11 2002/12/22 12:11:56 cretin Exp $
5 6
6ECLASS=flag-o-matic 7ECLASS=flag-o-matic
7INHERITED="$INHERITED $ECLASS" 8INHERITED="$INHERITED $ECLASS"
8 9
9# 10#
25# good options. 26# good options.
26# 27#
27#### get-flag <flag> #### 28#### get-flag <flag> ####
28# Find and echo the value for a particular flag 29# Find and echo the value for a particular flag
29# 30#
31#### replace-sparc64-flags ####
32# Sets mcpu to v8 and uses the original value
33# as mtune if none specified.
34#
35
36
37# C[XX]FLAGS that we allow in strip-flags
38ALLOWED_FLAGS="-O -O1 -O2 -mcpu -march -mtune -fstack-protector -pipe -g"
39
40# C[XX]FLAGS that we are think is ok, but needs testing
41# NOTE: currently -Os have issues with gcc3 and K6* arch's
42UNSTABLE_FLAGS="-Os -O3 -freorder-blocks -fprefetch-loop-arrays"
30 43
31filter-flags () { 44filter-flags () {
32 45
33 for x in $1 46 for x in $1
34 do 47 do
68strip-flags() { 81strip-flags() {
69 82
70 local NEW_CFLAGS="" 83 local NEW_CFLAGS=""
71 local NEW_CXXFLAGS="" 84 local NEW_CXXFLAGS=""
72 85
73 local ALLOWED_FLAGS="-O -mcpu -march -pipe -g" 86 # Allow unstable C[XX]FLAGS if we are using unstable profile ...
87 if [ "${ACCEPT_KEYWORDS/~/}" != "${ACCEPT_KEYWORDS}" -a \
88 "${ACCEPT_KEYWORDS/-~/}" = "${ACCEPT_KEYWORDS}" ]
89 then
90 if use debug &> /dev/null
91 then
92 einfo "Enabling the use of some unstable flags"
93 fi
94
95 ALLOWED_FLAGS="${ALLOWED_FLAGS} ${UNSTABLE_FLAGS}"
96 fi
74 97
75 set -f 98 set -f
76 99
77 for x in ${CFLAGS} 100 for x in ${CFLAGS}
78 do 101 do
79 for y in ${ALLOWED_FLAGS} 102 for y in ${ALLOWED_FLAGS}
80 do 103 do
104 flag=${x%%=*}
81 if [ "${x/${y}}" != "${x}" ] 105 if [ "${flag%%${y}}" = "" ]
82 then 106 then
83 if [ -z "${NEW_CFLAGS}" ]
84 then
85 NEW_CFLAGS="${x}"
86 else
87 NEW_CFLAGS="${NEW_CFLAGS} ${x}" 107 NEW_CFLAGS="${NEW_CFLAGS} ${x}"
88 fi 108 break
89 fi 109 fi
90 done 110 done
91 done 111 done
92 112
93 for x in ${CXXFLAGS} 113 for x in ${CXXFLAGS}
94 do 114 do
95 for y in ${ALLOWED_FLAGS} 115 for y in ${ALLOWED_FLAGS}
96 do 116 do
117 flag=${x%%=*}
97 if [ "${x/${y}}" != "${x}" ] 118 if [ "${flag%%${y}}" = "" ]
98 then 119 then
99 if [ -z "${NEW_CXXFLAGS}" ]
100 then
101 NEW_CXXFLAGS="${x}"
102 else
103 NEW_CXXFLAGS="${NEW_CXXFLAGS} ${x}" 120 NEW_CXXFLAGS="${NEW_CXXFLAGS} ${x}"
104 fi 121 break
105 fi 122 fi
106 done 123 done
107 done 124 done
108 125
109 set +f 126 set +f
110 127
128 use debug &>/dev/null && einfo "CFLAGS=\"${NEW_CFLAGS}\""
129 use debug &>/dev/null && einfo "CXXFLAGS=\"${NEW_CXXFLAGS}\""
130
111 export CFLAGS="${NEW_CFLAGS}" 131 export CFLAGS="${NEW_CFLAGS}"
112 export CXXFLAGS="${NEW_CXXFLAGS}" 132 export CXXFLAGS="${NEW_CXXFLAGS}"
113} 133}
114 134
115get-flag() { 135get-flag() {
120 echo "${f/-${findflag}=}" 140 echo "${f/-${findflag}=}"
121 return 141 return
122 fi 142 fi
123 done 143 done
124} 144}
145
146replace-sparc64-flags () {
147
148 local SPARC64_CPUS="ultrasparc v9"
149
150 if [ "${CFLAGS/mtune}" != "${CFLAGS}" ]
151 then
152 for x in ${SPARC64_CPUS}
153 do
154 CFLAGS="${CFLAGS/-mcpu=${x}/-mcpu=v8}"
155 done
156 else
157 for x in ${SPARC64_CPUS}
158 do
159 CFLAGS="${CFLAGS/-mcpu=${x}/-mcpu=v8 -mtune=${x}}"
160 done
161 fi
162
163 if [ "${CXXFLAGS/mtune}" != "${CXXFLAGS}" ]
164 then
165 for x in ${SPARC64_CPUS}
166 do
167 CXXFLAGS="${CXXFLAGS/-mcpu=${x}/-mcpu=v8}"
168 done
169 else
170 for x in ${SPARC64_CPUS}
171 do
172 CXXFLAGS="${CXXFLAGS/-mcpu=${x}/-mcpu=v8 -mtune=${x}}"
173 done
174 fi
175
176}

Legend:
Removed from v.1.11  
changed lines
  Added in v.1.17

  ViewVC Help
Powered by ViewVC 1.1.20