/[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 - (hide annotations) (download)
Sat Apr 19 18:20:56 2003 UTC (11 years, 3 months ago) by joker
Branch: MAIN
Changes since 1.15: +38 -1 lines
Added the function replace-sparc64-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 joker 1.16 # $Header: /home/cvsroot/gentoo-x86/eclass/flag-o-matic.eclass,v 1.15 2003/04/06 23:35:41 method 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 method 1.15 ALLOWED_FLAGS="-O -mcpu -march -mtune -fstack-protector -pipe -g"
38 verwilst 1.13
39    
40 verwilst 1.1 filter-flags () {
41    
42 azarah 1.8 for x in $1
43     do
44     export CFLAGS="${CFLAGS/${x}}"
45     export CXXFLAGS="${CXXFLAGS/${x}}"
46 verwilst 1.1 done
47 verwilst 1.2
48     }
49    
50     append-flags () {
51    
52 azarah 1.8 CFLAGS="${CFLAGS} $1"
53     CXXFLAGS="${CXXFLAGS} $1"
54 verwilst 1.1
55     }
56    
57 verwilst 1.4 replace-flags () {
58 verwilst 1.1
59 seemant 1.9 CFLAGS="${CFLAGS/${1}/${2} }"
60     CXXFLAGS="${CXXFLAGS/${1}/${2} }"
61 danarmak 1.7
62     }
63    
64     is-flag() {
65    
66 azarah 1.8 for x in ${CFLAGS} ${CXXFLAGS}
67     do
68     if [ "${x}" = "$1" ]
69     then
70     echo true
71     break
72 danarmak 1.7 fi
73     done
74 verwilst 1.1
75     }
76 azarah 1.8
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 lostlogic 1.14 flag=${x%%=*}
89     if [ "${flag%%${y}}" = "" ]
90 azarah 1.8 then
91 lostlogic 1.14 NEW_CFLAGS="${NEW_CFLAGS} ${x}"
92     break
93 azarah 1.8 fi
94     done
95     done
96    
97     for x in ${CXXFLAGS}
98     do
99     for y in ${ALLOWED_FLAGS}
100     do
101 lostlogic 1.14 flag=${x%%=*}
102     if [ "${flag%%${y}}" = "" ]
103 azarah 1.8 then
104 lostlogic 1.14 NEW_CXXFLAGS="${NEW_CXXFLAGS} ${x}"
105     break
106 azarah 1.8 fi
107     done
108     done
109    
110     set +f
111    
112     export CFLAGS="${NEW_CFLAGS}"
113     export CXXFLAGS="${NEW_CXXFLAGS}"
114     }
115    
116 vapier 1.10 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 joker 1.16 }
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 vapier 1.10 }

  ViewVC Help
Powered by ViewVC 1.1.20