/[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.16 - (show annotations) (download)
Sat Apr 19 18:20:56 2003 UTC (11 years, 7 months ago) by joker
Branch: MAIN
Changes since 1.15: +38 -1 lines
Added the function replace-sparc64-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.15 2003/04/06 23:35:41 method 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 ALLOWED_FLAGS="-O -mcpu -march -mtune -fstack-protector -pipe -g"
38
39
40 filter-flags () {
41
42 for x in $1
43 do
44 export CFLAGS="${CFLAGS/${x}}"
45 export CXXFLAGS="${CXXFLAGS/${x}}"
46 done
47
48 }
49
50 append-flags () {
51
52 CFLAGS="${CFLAGS} $1"
53 CXXFLAGS="${CXXFLAGS} $1"
54
55 }
56
57 replace-flags () {
58
59 CFLAGS="${CFLAGS/${1}/${2} }"
60 CXXFLAGS="${CXXFLAGS/${1}/${2} }"
61
62 }
63
64 is-flag() {
65
66 for x in ${CFLAGS} ${CXXFLAGS}
67 do
68 if [ "${x}" = "$1" ]
69 then
70 echo true
71 break
72 fi
73 done
74
75 }
76
77 strip-flags() {
78
79 local NEW_CFLAGS=""
80 local NEW_CXXFLAGS=""
81
82 set -f
83
84 for x in ${CFLAGS}
85 do
86 for y in ${ALLOWED_FLAGS}
87 do
88 flag=${x%%=*}
89 if [ "${flag%%${y}}" = "" ]
90 then
91 NEW_CFLAGS="${NEW_CFLAGS} ${x}"
92 break
93 fi
94 done
95 done
96
97 for x in ${CXXFLAGS}
98 do
99 for y in ${ALLOWED_FLAGS}
100 do
101 flag=${x%%=*}
102 if [ "${flag%%${y}}" = "" ]
103 then
104 NEW_CXXFLAGS="${NEW_CXXFLAGS} ${x}"
105 break
106 fi
107 done
108 done
109
110 set +f
111
112 export CFLAGS="${NEW_CFLAGS}"
113 export CXXFLAGS="${NEW_CXXFLAGS}"
114 }
115
116 get-flag() {
117 local findflag="$1"
118
119 for f in ${CFLAGS} ${CXXFLAGS} ; do
120 if [ "${f/${findflag}}" != "${f}" ] ; then
121 echo "${f/-${findflag}=}"
122 return
123 fi
124 done
125 }
126
127 replace-sparc64-flags () {
128
129 local SPARC64_CPUS="ultrasparc v9"
130
131 if [ "${CFLAGS/mtune}" != "${CFLAGS}" ]
132 then
133 for x in ${SPARC64_CPUS}
134 do
135 CFLAGS="${CFLAGS/-mcpu=${x}/-mcpu=v8}"
136 done
137 else
138 for x in ${SPARC64_CPUS}
139 do
140 CFLAGS="${CFLAGS/-mcpu=${x}/-mcpu=v8 -mtune=${x}}"
141 done
142 fi
143
144 if [ "${CXXFLAGS/mtune}" != "${CXXFLAGS}" ]
145 then
146 for x in ${SPARC64_CPUS}
147 do
148 CXXFLAGS="${CXXFLAGS/-mcpu=${x}/-mcpu=v8}"
149 done
150 else
151 for x in ${SPARC64_CPUS}
152 do
153 CXXFLAGS="${CXXFLAGS/-mcpu=${x}/-mcpu=v8 -mtune=${x}}"
154 done
155 fi
156
157 }

  ViewVC Help
Powered by ViewVC 1.1.20