blob: 349df81c85c90b67b77d25c93cb0d99266f0a430 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
|
# Copyright 1999-2003 Gentoo Technologies, Inc.
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/eclass/flag-o-matic.eclass,v 1.20 2003/06/25 03:27:43 vapier Exp $
#
# Author Bart Verwilst <verwilst@gentoo.org>
ECLASS=flag-o-matic
INHERITED="$INHERITED $ECLASS"
#
#### filter-flags <flags> ####
# Remove particular flags from C[XX]FLAGS
# Matches only complete flags
#
#### append-flags <flags> ####
# Add extra flags to your current C[XX]FLAGS
#
#### replace-flags <orig.flag> <new.flag> ###
# Replace a flag by another one
#
#### is-flag <flag> ####
# Returns "true" if flag is set in C[XX]FLAGS
# Matches only complete a flag
#
#### strip-flags ####
# Strip C[XX]FLAGS of everything except known
# good options.
#
#### get-flag <flag> ####
# Find and echo the value for a particular flag
#
#### replace-sparc64-flags ####
# Sets mcpu to v8 and uses the original value
# as mtune if none specified.
#
# C[XX]FLAGS that we allow in strip-flags
ALLOWED_FLAGS="-O -O1 -O2 -mcpu -march -mtune -fstack-protector -pipe -g"
# C[XX]FLAGS that we are think is ok, but needs testing
# NOTE: currently -Os have issues with gcc3 and K6* arch's
UNSTABLE_FLAGS="-Os -O3 -freorder-blocks -fprefetch-loop-arrays"
filter-flags() {
# we do this fancy spacing stuff so as to not filter
# out part of a flag ... we want flag atoms ! :D
export CFLAGS=" ${CFLAGS} "
export CXXFLAGS=" ${CXXFLAGS} "
for x in $@ ; do
export CFLAGS="${CFLAGS/ ${x} / }"
export CXXFLAGS="${CXXFLAGS/ ${x} / }"
done
export CFLAGS="${CFLAGS:1:${#CFLAGS}-2}"
export CXXFLAGS="${CXXFLAGS:1:${#CXXFLAGS}-2}"
}
append-flags() {
CFLAGS="${CFLAGS} $@"
CXXFLAGS="${CXXFLAGS} $@"
}
replace-flags() {
CFLAGS="${CFLAGS/${1}/${2} }"
CXXFLAGS="${CXXFLAGS/${1}/${2} }"
}
is-flag() {
for x in ${CFLAGS} ${CXXFLAGS} ; do
if [ "${x}" == "$1" ] ; then
echo true
return 0
fi
done
return 1
}
strip-flags() {
local NEW_CFLAGS=""
local NEW_CXXFLAGS=""
# Allow unstable C[XX]FLAGS if we are using unstable profile ...
if [ `has ~${ARCH} ${ACCEPT_KEYWORDS}` ] ; then
[ `use debug` ] && einfo "Enabling the use of some unstable flags"
ALLOWED_FLAGS="${ALLOWED_FLAGS} ${UNSTABLE_FLAGS}"
fi
set -f
for x in ${CFLAGS}
do
for y in ${ALLOWED_FLAGS}
do
flag=${x%%=*}
if [ "${flag%%${y}}" = "" ]
then
NEW_CFLAGS="${NEW_CFLAGS} ${x}"
break
fi
done
done
for x in ${CXXFLAGS}
do
for y in ${ALLOWED_FLAGS}
do
flag=${x%%=*}
if [ "${flag%%${y}}" = "" ]
then
NEW_CXXFLAGS="${NEW_CXXFLAGS} ${x}"
break
fi
done
done
set +f
[ `use debug` ] \
&& einfo "CFLAGS=\"${NEW_CFLAGS}\"" \
&& einfo "CXXFLAGS=\"${NEW_CXXFLAGS}\""
export CFLAGS="${NEW_CFLAGS}"
export CXXFLAGS="${NEW_CXXFLAGS}"
}
get-flag() {
local findflag="$1"
for f in ${CFLAGS} ${CXXFLAGS} ; do
if [ "${f/${findflag}}" != "${f}" ] ; then
echo "${f/-${findflag}=}"
return
fi
done
}
replace-sparc64-flags() {
local SPARC64_CPUS="ultrasparc v9"
if [ "${CFLAGS/mtune}" != "${CFLAGS}" ]
then
for x in ${SPARC64_CPUS}
do
CFLAGS="${CFLAGS/-mcpu=${x}/-mcpu=v8}"
done
else
for x in ${SPARC64_CPUS}
do
CFLAGS="${CFLAGS/-mcpu=${x}/-mcpu=v8 -mtune=${x}}"
done
fi
if [ "${CXXFLAGS/mtune}" != "${CXXFLAGS}" ]
then
for x in ${SPARC64_CPUS}
do
CXXFLAGS="${CXXFLAGS/-mcpu=${x}/-mcpu=v8}"
done
else
for x in ${SPARC64_CPUS}
do
CXXFLAGS="${CXXFLAGS/-mcpu=${x}/-mcpu=v8 -mtune=${x}}"
done
fi
}
|