/[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 - (hide annotations) (download)
Sun Apr 27 20:57:46 2003 UTC (11 years, 4 months ago) by azarah
Branch: MAIN
Changes since 1.16: +21 -2 lines
support for UNSTABLE_FLAGS

1 vapier 1.12 # Copyright 1999-2003 Gentoo Technologies, Inc.
2 verwilst 1.1 # Distributed under the terms of the GNU General Public License v2
3 azarah 1.17 # $Header: /home/cvsroot/gentoo-x86/eclass/flag-o-matic.eclass,v 1.16 2003/04/19 18:20:56 joker Exp $
4 vapier 1.12 #
5 verwilst 1.1 # Author Bart Verwilst <verwilst@gentoo.org>
6 azarah 1.8
7 verwilst 1.1 ECLASS=flag-o-matic
8 danarmak 1.6 INHERITED="$INHERITED $ECLASS"
9 azarah 1.8
10 verwilst 1.2 #
11 verwilst 1.3 #### filter-flags <flag> ####
12     # Remove particular flags from C[XX]FLAGS
13 verwilst 1.2 #
14 verwilst 1.3 #### append-flags <flag> ####
15     # Add extra flags to your current C[XX]FLAGS
16     #
17 verwilst 1.4 #### replace-flags <orig.flag> <new.flag> ###
18 verwilst 1.3 # Replace a flag by another one
19     #
20 danarmak 1.7 #### is-flag <flag> ####
21     # Returns "true" if flag is set in C[XX]FLAGS
22     # Matches only complete flag
23     #
24 azarah 1.8 #### strip-flags ####
25     # Strip C[XX]FLAGS of everything except known
26     # good options.
27     #
28 vapier 1.10 #### get-flag <flag> ####
29     # Find and echo the value for a particular flag
30     #
31 joker 1.16 #### replace-sparc64-flags ####
32     # Sets mcpu to v8 and uses the original value
33     # as mtune if none specified.
34     #
35    
36 verwilst 1.3
37 azarah 1.17 # C[XX]FLAGS that we allow in strip-flags
38     ALLOWED_FLAGS="-O -O1 -O2 -mcpu -march -mtune -fstack-protector -pipe -g"
39 verwilst 1.13
40 azarah 1.17 # 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 verwilst 1.13
44 verwilst 1.1 filter-flags () {
45    
46 azarah 1.8 for x in $1
47     do
48     export CFLAGS="${CFLAGS/${x}}"
49     export CXXFLAGS="${CXXFLAGS/${x}}"
50 verwilst 1.1 done
51 verwilst 1.2
52     }
53    
54     append-flags () {
55    
56 azarah 1.8 CFLAGS="${CFLAGS} $1"
57     CXXFLAGS="${CXXFLAGS} $1"
58 verwilst 1.1
59     }
60    
61 verwilst 1.4 replace-flags () {
62 verwilst 1.1
63 seemant 1.9 CFLAGS="${CFLAGS/${1}/${2} }"
64     CXXFLAGS="${CXXFLAGS/${1}/${2} }"
65 danarmak 1.7
66     }
67    
68     is-flag() {
69    
70 azarah 1.8 for x in ${CFLAGS} ${CXXFLAGS}
71     do
72     if [ "${x}" = "$1" ]
73     then
74     echo true
75     break
76 danarmak 1.7 fi
77     done
78 verwilst 1.1
79     }
80 azarah 1.8
81     strip-flags() {
82    
83     local NEW_CFLAGS=""
84     local NEW_CXXFLAGS=""
85    
86 azarah 1.17 # 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 azarah 1.8 set -f
99    
100     for x in ${CFLAGS}
101     do
102     for y in ${ALLOWED_FLAGS}
103     do
104 lostlogic 1.14 flag=${x%%=*}
105     if [ "${flag%%${y}}" = "" ]
106 azarah 1.8 then
107 lostlogic 1.14 NEW_CFLAGS="${NEW_CFLAGS} ${x}"
108     break
109 azarah 1.8 fi
110     done
111     done
112    
113     for x in ${CXXFLAGS}
114     do
115     for y in ${ALLOWED_FLAGS}
116     do
117 lostlogic 1.14 flag=${x%%=*}
118     if [ "${flag%%${y}}" = "" ]
119 azarah 1.8 then
120 lostlogic 1.14 NEW_CXXFLAGS="${NEW_CXXFLAGS} ${x}"
121     break
122 azarah 1.8 fi
123     done
124     done
125    
126     set +f
127    
128 azarah 1.17 use debug &>/dev/null && einfo "CFLAGS=\"${NEW_CFLAGS}\""
129     use debug &>/dev/null && einfo "CXXFLAGS=\"${NEW_CXXFLAGS}\""
130    
131 azarah 1.8 export CFLAGS="${NEW_CFLAGS}"
132     export CXXFLAGS="${NEW_CXXFLAGS}"
133     }
134    
135 vapier 1.10 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 joker 1.16 }
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 vapier 1.10 }

  ViewVC Help
Powered by ViewVC 1.1.20