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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.17 - (show annotations) (download)
Sun Apr 27 20:57:46 2003 UTC (11 years, 7 months ago) by azarah
Branch: MAIN
Changes since 1.16: +21 -2 lines
support for UNSTABLE_FLAGS

1 # Copyright 1999-2003 Gentoo Technologies, Inc.
2 # Distributed under the terms of the GNU General Public License v2
3 # $Header: /home/cvsroot/gentoo-x86/eclass/flag-o-matic.eclass,v 1.16 2003/04/19 18:20:56 joker Exp $
4 #
5 # Author Bart Verwilst <verwilst@gentoo.org>
6
7 ECLASS=flag-o-matic
8 INHERITED="$INHERITED $ECLASS"
9
10 #
11 #### filter-flags <flag> ####
12 # Remove particular flags from C[XX]FLAGS
13 #
14 #### append-flags <flag> ####
15 # Add extra flags to your current C[XX]FLAGS
16 #
17 #### replace-flags <orig.flag> <new.flag> ###
18 # Replace a flag by another one
19 #
20 #### is-flag <flag> ####
21 # Returns "true" if flag is set in C[XX]FLAGS
22 # Matches only complete flag
23 #
24 #### strip-flags ####
25 # Strip C[XX]FLAGS of everything except known
26 # good options.
27 #
28 #### get-flag <flag> ####
29 # Find and echo the value for a particular flag
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
38 ALLOWED_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
42 UNSTABLE_FLAGS="-Os -O3 -freorder-blocks -fprefetch-loop-arrays"
43
44 filter-flags () {
45
46 for x in $1
47 do
48 export CFLAGS="${CFLAGS/${x}}"
49 export CXXFLAGS="${CXXFLAGS/${x}}"
50 done
51
52 }
53
54 append-flags () {
55
56 CFLAGS="${CFLAGS} $1"
57 CXXFLAGS="${CXXFLAGS} $1"
58
59 }
60
61 replace-flags () {
62
63 CFLAGS="${CFLAGS/${1}/${2} }"
64 CXXFLAGS="${CXXFLAGS/${1}/${2} }"
65
66 }
67
68 is-flag() {
69
70 for x in ${CFLAGS} ${CXXFLAGS}
71 do
72 if [ "${x}" = "$1" ]
73 then
74 echo true
75 break
76 fi
77 done
78
79 }
80
81 strip-flags() {
82
83 local NEW_CFLAGS=""
84 local NEW_CXXFLAGS=""
85
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
97
98 set -f
99
100 for x in ${CFLAGS}
101 do
102 for y in ${ALLOWED_FLAGS}
103 do
104 flag=${x%%=*}
105 if [ "${flag%%${y}}" = "" ]
106 then
107 NEW_CFLAGS="${NEW_CFLAGS} ${x}"
108 break
109 fi
110 done
111 done
112
113 for x in ${CXXFLAGS}
114 do
115 for y in ${ALLOWED_FLAGS}
116 do
117 flag=${x%%=*}
118 if [ "${flag%%${y}}" = "" ]
119 then
120 NEW_CXXFLAGS="${NEW_CXXFLAGS} ${x}"
121 break
122 fi
123 done
124 done
125
126 set +f
127
128 use debug &>/dev/null && einfo "CFLAGS=\"${NEW_CFLAGS}\""
129 use debug &>/dev/null && einfo "CXXFLAGS=\"${NEW_CXXFLAGS}\""
130
131 export CFLAGS="${NEW_CFLAGS}"
132 export CXXFLAGS="${NEW_CXXFLAGS}"
133 }
134
135 get-flag() {
136 local findflag="$1"
137
138 for f in ${CFLAGS} ${CXXFLAGS} ; do
139 if [ "${f/${findflag}}" != "${f}" ] ; then
140 echo "${f/-${findflag}=}"
141 return
142 fi
143 done
144 }
145
146 replace-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 }

  ViewVC Help
Powered by ViewVC 1.1.20