/[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.3 Revision 1.16
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.16 2003/04/19 18:20:56 joker Exp $
4#
3# Author Bart Verwilst <verwilst@gentoo.org> 5# Author Bart Verwilst <verwilst@gentoo.org>
4# /space/gentoo/cvsroot/gentoo-x86/eclass/flag-o-matic.eclass 6
5ECLASS=flag-o-matic 7ECLASS=flag-o-matic
8INHERITED="$INHERITED $ECLASS"
6 9
7# 10#
8#### filter-flags <flag> #### 11#### filter-flags <flag> ####
9# Remove particular flags from C[XX]FLAGS 12# Remove particular flags from C[XX]FLAGS
10# 13#
11#### append-flags <flag> #### 14#### append-flags <flag> ####
12# Add extra flags to your current C[XX]FLAGS 15# Add extra flags to your current C[XX]FLAGS
13# 16#
14#### change-flags <orig.flag> <new.flag> ### 17#### replace-flags <orig.flag> <new.flag> ###
15# Replace a flag by another one 18# Replace a flag by another one
16# 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
37ALLOWED_FLAGS="-O -mcpu -march -mtune -fstack-protector -pipe -g"
17 38
18 39
19filter-flags () { 40filter-flags () {
20 41
21 for x in $1; do 42 for x in $1
43 do
22 CFLAGS="${CFLAGS/$x}" 44 export CFLAGS="${CFLAGS/${x}}"
23 CXXFLAGS="${CXXFLAGS/$x}" 45 export CXXFLAGS="${CXXFLAGS/${x}}"
24 done 46 done
25 47
26} 48}
27 49
28append-flags () { 50append-flags () {
29 51
30
31 CFLAGS="$CFLAGS $1" 52 CFLAGS="${CFLAGS} $1"
32 CXXFLAGS="$CXXFLAGS $1" 53 CXXFLAGS="${CXXFLAGS} $1"
33 54
34} 55}
35 56
36change-flags () { 57replace-flags () {
37 58
38 CFLAGS="${CFLAGS/${1}/${2}" 59 CFLAGS="${CFLAGS/${1}/${2} }"
39 CXXFLAGS="${CXXFLAGS/${1}/${2}" 60 CXXFLAGS="${CXXFLAGS/${1}/${2} }"
40 61
41} 62}
63
64is-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
77strip-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
116get-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
127replace-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}

Legend:
Removed from v.1.3  
changed lines
  Added in v.1.16

  ViewVC Help
Powered by ViewVC 1.1.20