| 1 | # Copyright 1999-2003 Gentoo Technologies, Inc. |
1 | # Copyright 1999-2004 Gentoo Foundation |
| 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.15 2003/04/06 23:35:41 method Exp $ |
3 | # $Header: /var/cvsroot/gentoo-x86/eclass/flag-o-matic.eclass,v 1.71 2004/10/01 10:00:36 robbat2 Exp $ |
| 4 | # |
4 | # |
| 5 | # Author Bart Verwilst <verwilst@gentoo.org> |
5 | # Author Bart Verwilst <verwilst@gentoo.org> |
| 6 | |
6 | |
| 7 | ECLASS=flag-o-matic |
7 | ECLASS=flag-o-matic |
| 8 | INHERITED="$INHERITED $ECLASS" |
8 | INHERITED="$INHERITED $ECLASS" |
| 9 | |
9 | |
|
|
10 | # Please leave ${IUSE} in this until portage .51 is stable, otherwise |
|
|
11 | # IUSE gets clobbered. |
|
|
12 | IUSE="${IUSE} debug" |
|
|
13 | |
| 10 | # |
14 | # |
| 11 | #### filter-flags <flag> #### |
15 | #### filter-flags <flags> #### |
| 12 | # Remove particular flags from C[XX]FLAGS |
16 | # Remove particular flags from C[XX]FLAGS |
|
|
17 | # Matches only complete flags |
| 13 | # |
18 | # |
| 14 | #### append-flags <flag> #### |
19 | #### append-flags <flags> #### |
| 15 | # Add extra flags to your current C[XX]FLAGS |
20 | # Add extra flags to your current C[XX]FLAGS |
| 16 | # |
21 | # |
| 17 | #### replace-flags <orig.flag> <new.flag> ### |
22 | #### replace-flags <orig.flag> <new.flag> ### |
| 18 | # Replace a flag by another one |
23 | # Replace a flag by another one |
| 19 | # |
24 | # |
|
|
25 | #### replace-cpu-flags <old.cpus> <new.cpu> ### |
|
|
26 | # Replace march/mcpu flags that specify <old.cpus> |
|
|
27 | # with flags that specify <new.cpu> |
|
|
28 | # |
| 20 | #### is-flag <flag> #### |
29 | #### is-flag <flag> #### |
| 21 | # Returns "true" if flag is set in C[XX]FLAGS |
30 | # Returns "true" if flag is set in C[XX]FLAGS |
| 22 | # Matches only complete flag |
31 | # Matches only complete a flag |
| 23 | # |
32 | # |
| 24 | #### strip-flags #### |
33 | #### strip-flags #### |
| 25 | # Strip C[XX]FLAGS of everything except known |
34 | # Strip C[XX]FLAGS of everything except known |
| 26 | # good options. |
35 | # good options. |
| 27 | # |
36 | # |
|
|
37 | #### strip-unsupported-flags #### |
|
|
38 | # Strip C[XX]FLAGS of any flags not supported by |
|
|
39 | # installed version of gcc |
|
|
40 | # |
| 28 | #### get-flag <flag> #### |
41 | #### get-flag <flag> #### |
| 29 | # Find and echo the value for a particular flag |
42 | # Find and echo the value for a particular flag |
| 30 | # |
43 | # |
|
|
44 | #### replace-sparc64-flags #### |
|
|
45 | # Sets mcpu to v8 and uses the original value |
|
|
46 | # as mtune if none specified. |
|
|
47 | # |
|
|
48 | #### filter-mfpmath <math types> #### |
|
|
49 | # Remove specified math types from the fpmath specification |
|
|
50 | # If the user has -mfpmath=sse,386, running `filter-mfpmath sse` |
|
|
51 | # will leave the user with -mfpmath=386 |
|
|
52 | # |
|
|
53 | #### append-ldflags #### |
|
|
54 | # Add extra flags to your current LDFLAGS |
|
|
55 | # |
|
|
56 | #### filter-ldflags <flags> #### |
|
|
57 | # Remove particular flags from LDFLAGS |
|
|
58 | # Matches only complete flags |
|
|
59 | # |
|
|
60 | #### etexec-flags #### |
|
|
61 | # hooked function for hardened gcc that appends |
|
|
62 | # -fno-pic to {C,CXX,LD}FLAGS |
|
|
63 | # when a package is filtering -fpic, -fPIC, -fpie, -fPIE |
|
|
64 | # |
|
|
65 | #### fstack-flags #### |
|
|
66 | # hooked function for hardened gcc that appends |
|
|
67 | # -fno-stack-protector to {C,CXX,LD}FLAGS |
|
|
68 | # when a package is filtering -fstack-protector, -fstack-protector-all |
|
|
69 | # notice: modern automatic specs files will also suppress -fstack-protector-all |
|
|
70 | # when only -fno-stack-protector is given |
|
|
71 | # |
| 31 | |
72 | |
| 32 | ALLOWED_FLAGS="-O -mcpu -march -mtune -fstack-protector -pipe -g" |
73 | # C[XX]FLAGS that we allow in strip-flags |
|
|
74 | setup-allowed-flags() { |
|
|
75 | if [ -z "${ALLOWED_FLAGS}" ] ; then |
|
|
76 | export ALLOWED_FLAGS="-O -O1 -O2 -mcpu -march -mtune -fstack-protector -fno-stack-protector -fno-pie -fno-unit-at-a-time -pipe -g" |
|
|
77 | case "${ARCH}" in |
|
|
78 | mips) ALLOWED_FLAGS="${ALLOWED_FLAGS} -mips1 -mips2 -mips3 -mips4 -mips32 -mips64 -mips16 -EL -EB -mabi" ;; |
|
|
79 | amd64) ALLOWED_FLAGS="${ALLOWED_FLAGS} -fPIC -m64" ;; |
|
|
80 | x86) ALLOWED_FLAGS="${ALLOWED_FLAGS} -m32" ;; |
|
|
81 | alpha) ALLOWED_FLAGS="${ALLOWED_FLAGS} -fPIC" ;; |
|
|
82 | ia64) ALLOWED_FLAGS="${ALLOWED_FLAGS} -fPIC" ;; |
|
|
83 | esac |
|
|
84 | fi |
|
|
85 | # allow a bunch of flags that negate features / control ABI |
|
|
86 | ALLOWED_FLAGS="${ALLOWED_FLAGS} -fno-stack-protector -fno-stack-protector-all" |
|
|
87 | case "${ARCH}" in |
|
|
88 | x86|amd64|ia64) ALLOWED_FLAGS="${ALLOWED_FLAGS} -mno-mmx -mno-sse -mno-sse2 -mno-sse3 -mno-3dnow" ;; |
|
|
89 | esac |
|
|
90 | ALLOWED_FLAGS="${ALLOWED_FLAGS} -mregparm -mno-app-regs -mapp-regs -msoft-float -mflat -mno-faster-structs -mfaster-structs -mlittle-endian -mbig-endian -mlive-g0 -mcmodel -mno-stack-bias -mstack-bias" |
| 33 | |
91 | |
|
|
92 | # C[XX]FLAGS that we are think is ok, but needs testing |
|
|
93 | # NOTE: currently -Os have issues with gcc3 and K6* arch's |
|
|
94 | export UNSTABLE_FLAGS="-Os -O3 -freorder-blocks -fprefetch-loop-arrays" |
|
|
95 | return 0 |
|
|
96 | } |
| 34 | |
97 | |
| 35 | filter-flags () { |
98 | filter-flags() { |
|
|
99 | local x f fset |
|
|
100 | declare -a new_CFLAGS new_CXXFLAGS |
| 36 | |
101 | |
| 37 | for x in $1 |
102 | for x in "$@" ; do |
|
|
103 | case "${x}" in |
|
|
104 | -fPIC|-fpic|-fPIE|-fpie|-pie) etexec-flags;; |
|
|
105 | -fstack-protector|-fstack-protector-all) fstack-flags;; |
|
|
106 | esac |
| 38 | do |
107 | done |
| 39 | export CFLAGS="${CFLAGS/${x}}" |
108 | |
| 40 | export CXXFLAGS="${CXXFLAGS/${x}}" |
109 | for fset in CFLAGS CXXFLAGS; do |
|
|
110 | # Looping over the flags instead of using a global |
|
|
111 | # substitution ensures that we're working with flag atoms. |
|
|
112 | # Otherwise globs like -O* have the potential to wipe out the |
|
|
113 | # list of flags. |
|
|
114 | for f in ${!fset}; do |
|
|
115 | for x in "$@"; do |
|
|
116 | # Note this should work with globs like -O* |
|
|
117 | [[ ${f} == ${x} ]] && continue 2 |
|
|
118 | done |
|
|
119 | eval new_${fset}\[\${\#new_${fset}\[@]}]=\${f} |
| 41 | done |
120 | done |
|
|
121 | eval export ${fset}=\${new_${fset}\[*]} |
|
|
122 | done |
| 42 | |
123 | |
|
|
124 | return 0 |
| 43 | } |
125 | } |
| 44 | |
126 | |
|
|
127 | filter-lfs-flags() { |
|
|
128 | filter-flags -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE |
|
|
129 | } |
|
|
130 | |
|
|
131 | append-lfs-flags() { |
|
|
132 | append-flags -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE |
|
|
133 | } |
|
|
134 | |
| 45 | append-flags () { |
135 | append-flags() { |
| 46 | |
|
|
| 47 | CFLAGS="${CFLAGS} $1" |
136 | export CFLAGS="${CFLAGS} $*" |
| 48 | CXXFLAGS="${CXXFLAGS} $1" |
137 | export CXXFLAGS="${CXXFLAGS} $*" |
| 49 | |
138 | [ -n "`is-flag -fno-stack-protector`" -o \ |
|
|
139 | -n "`is-flag -fno-stack-protector-all`" ] && fstack-flags |
|
|
140 | return 0 |
| 50 | } |
141 | } |
| 51 | |
142 | |
| 52 | replace-flags () { |
143 | replace-flags() { |
|
|
144 | local f fset |
|
|
145 | declare -a new_CFLAGS new_CXXFLAGS |
| 53 | |
146 | |
| 54 | CFLAGS="${CFLAGS/${1}/${2} }" |
147 | for fset in CFLAGS CXXFLAGS; do |
| 55 | CXXFLAGS="${CXXFLAGS/${1}/${2} }" |
148 | # Looping over the flags instead of using a global |
|
|
149 | # substitution ensures that we're working with flag atoms. |
|
|
150 | # Otherwise globs like -O* have the potential to wipe out the |
|
|
151 | # list of flags. |
|
|
152 | for f in ${!fset}; do |
|
|
153 | # Note this should work with globs like -O* |
|
|
154 | [[ ${f} == ${1} ]] && f=${2} |
|
|
155 | eval new_${fset}\[\${\#new_${fset}\[@]}]=\${f} |
|
|
156 | done |
|
|
157 | eval export ${fset}=\${new_${fset}\[*]} |
|
|
158 | done |
| 56 | |
159 | |
|
|
160 | return 0 |
|
|
161 | } |
|
|
162 | |
|
|
163 | replace-cpu-flags() { |
|
|
164 | local newcpu="$#" ; newcpu="${!newcpu}" |
|
|
165 | while [ $# -gt 1 ] ; do |
|
|
166 | # quote to make sure that no globbing is done (particularly on |
|
|
167 | # ${oldcpu} prior to calling replace-flags |
|
|
168 | replace-flags "-march=${1}" "-march=${newcpu}" |
|
|
169 | replace-flags "-mcpu=${1}" "-mcpu=${newcpu}" |
|
|
170 | replace-flags "-mtune=${1}" "-mtune=${newcpu}" |
|
|
171 | shift |
|
|
172 | done |
|
|
173 | return 0 |
| 57 | } |
174 | } |
| 58 | |
175 | |
| 59 | is-flag() { |
176 | is-flag() { |
|
|
177 | local x |
| 60 | |
178 | |
| 61 | for x in ${CFLAGS} ${CXXFLAGS} |
179 | for x in ${CFLAGS} ${CXXFLAGS} ; do |
| 62 | do |
180 | # Note this should work with globs like -mcpu=ultrasparc* |
| 63 | if [ "${x}" = "$1" ] |
181 | if [[ ${x} == ${1} ]]; then |
| 64 | then |
|
|
| 65 | echo true |
182 | echo true |
| 66 | break |
183 | return 0 |
| 67 | fi |
184 | fi |
| 68 | done |
185 | done |
|
|
186 | return 1 |
|
|
187 | } |
| 69 | |
188 | |
|
|
189 | filter-mfpmath() { |
|
|
190 | local orig_mfpmath new_math prune_math |
|
|
191 | |
|
|
192 | # save the original -mfpmath flag |
|
|
193 | orig_mfpmath="`get-flag -mfpmath`" |
|
|
194 | # get the value of the current -mfpmath flag |
|
|
195 | new_math=" `get-flag mfpmath | tr , ' '` " |
|
|
196 | # figure out which math values are to be removed |
|
|
197 | prune_math="" |
|
|
198 | for prune_math in "$@" ; do |
|
|
199 | new_math="${new_math/ ${prune_math} / }" |
|
|
200 | done |
|
|
201 | new_math="`echo ${new_math:1:${#new_math}-2} | tr ' ' ,`" |
|
|
202 | |
|
|
203 | if [ -z "${new_math}" ] ; then |
|
|
204 | # if we're removing all user specified math values are |
|
|
205 | # slated for removal, then we just filter the flag |
|
|
206 | filter-flags ${orig_mfpmath} |
|
|
207 | else |
|
|
208 | # if we only want to filter some of the user specified |
|
|
209 | # math values, then we replace the current flag |
|
|
210 | replace-flags ${orig_mfpmath} -mfpmath=${new_math} |
|
|
211 | fi |
|
|
212 | return 0 |
| 70 | } |
213 | } |
| 71 | |
214 | |
| 72 | strip-flags() { |
215 | strip-flags() { |
|
|
216 | local x y flag NEW_CFLAGS NEW_CXXFLAGS |
|
|
217 | |
|
|
218 | setup-allowed-flags |
| 73 | |
219 | |
| 74 | local NEW_CFLAGS="" |
220 | local NEW_CFLAGS="" |
| 75 | local NEW_CXXFLAGS="" |
221 | local NEW_CXXFLAGS="" |
| 76 | |
222 | |
| 77 | set -f |
223 | # Allow unstable C[XX]FLAGS if we are using unstable profile ... |
|
|
224 | if has ~${ARCH} ${ACCEPT_KEYWORDS} ; then |
|
|
225 | use debug && einfo "Enabling the use of some unstable flags" |
|
|
226 | ALLOWED_FLAGS="${ALLOWED_FLAGS} ${UNSTABLE_FLAGS}" |
|
|
227 | fi |
| 78 | |
228 | |
|
|
229 | set -f # disable pathname expansion |
|
|
230 | |
| 79 | for x in ${CFLAGS} |
231 | for x in ${CFLAGS}; do |
| 80 | do |
|
|
| 81 | for y in ${ALLOWED_FLAGS} |
232 | for y in ${ALLOWED_FLAGS}; do |
| 82 | do |
|
|
| 83 | flag=${x%%=*} |
233 | flag=${x%%=*} |
| 84 | if [ "${flag%%${y}}" = "" ] |
234 | if [ "${flag%%${y}}" = "" ] ; then |
| 85 | then |
|
|
| 86 | NEW_CFLAGS="${NEW_CFLAGS} ${x}" |
235 | NEW_CFLAGS="${NEW_CFLAGS} ${x}" |
| 87 | break |
236 | break |
| 88 | fi |
237 | fi |
| 89 | done |
238 | done |
| 90 | done |
239 | done |
| 91 | |
240 | |
| 92 | for x in ${CXXFLAGS} |
241 | for x in ${CXXFLAGS}; do |
| 93 | do |
|
|
| 94 | for y in ${ALLOWED_FLAGS} |
242 | for y in ${ALLOWED_FLAGS}; do |
| 95 | do |
|
|
| 96 | flag=${x%%=*} |
243 | flag=${x%%=*} |
| 97 | if [ "${flag%%${y}}" = "" ] |
244 | if [ "${flag%%${y}}" = "" ] ; then |
| 98 | then |
|
|
| 99 | NEW_CXXFLAGS="${NEW_CXXFLAGS} ${x}" |
245 | NEW_CXXFLAGS="${NEW_CXXFLAGS} ${x}" |
| 100 | break |
246 | break |
| 101 | fi |
247 | fi |
| 102 | done |
248 | done |
| 103 | done |
249 | done |
| 104 | |
250 | |
| 105 | set +f |
251 | # In case we filtered out all optimization flags fallback to -O2 |
|
|
252 | if [ "${CFLAGS/-O}" != "${CFLAGS}" -a "${NEW_CFLAGS/-O}" = "${NEW_CFLAGS}" ]; then |
|
|
253 | NEW_CFLAGS="${NEW_CFLAGS} -O2" |
|
|
254 | fi |
|
|
255 | if [ "${CXXFLAGS/-O}" != "${CXXFLAGS}" -a "${NEW_CXXFLAGS/-O}" = "${NEW_CXXFLAGS}" ]; then |
|
|
256 | NEW_CXXFLAGS="${NEW_CXXFLAGS} -O2" |
|
|
257 | fi |
|
|
258 | |
|
|
259 | set +f # re-enable pathname expansion |
| 106 | |
260 | |
| 107 | export CFLAGS="${NEW_CFLAGS}" |
261 | export CFLAGS="${NEW_CFLAGS}" |
| 108 | export CXXFLAGS="${NEW_CXXFLAGS}" |
262 | export CXXFLAGS="${NEW_CXXFLAGS}" |
|
|
263 | return 0 |
|
|
264 | } |
|
|
265 | |
|
|
266 | test_flag() { |
|
|
267 | local cc=${CC:-gcc} ; cc=${cc%% *} |
|
|
268 | if ${cc} -S -xc "$@" -o /dev/null /dev/null &>/dev/null; then |
|
|
269 | printf "%s\n" "$*" |
|
|
270 | return 0 |
|
|
271 | fi |
|
|
272 | return 1 |
|
|
273 | } |
|
|
274 | |
|
|
275 | test_version_info() { |
|
|
276 | local cc=${CC:-gcc} ; cc=${cc%% *} |
|
|
277 | if [[ $(${cc} --version 2>&1) == *$1* ]]; then |
|
|
278 | return 0 |
|
|
279 | else |
|
|
280 | return 1 |
|
|
281 | fi |
|
|
282 | } |
|
|
283 | |
|
|
284 | strip-unsupported-flags() { |
|
|
285 | local NEW_CFLAGS NEW_CXXFLAGS |
|
|
286 | |
|
|
287 | for x in ${CFLAGS} ; do |
|
|
288 | NEW_CFLAGS="${NEW_CFLAGS} `test_flag ${x}`" |
|
|
289 | done |
|
|
290 | for x in ${CXXFLAGS} ; do |
|
|
291 | NEW_CXXFLAGS="${NEW_CXXFLAGS} `test_flag ${x}`" |
|
|
292 | done |
|
|
293 | |
|
|
294 | export CFLAGS="${NEW_CFLAGS}" |
|
|
295 | export CXXFLAGS="${NEW_CXXFLAGS}" |
| 109 | } |
296 | } |
| 110 | |
297 | |
| 111 | get-flag() { |
298 | get-flag() { |
| 112 | local findflag="$1" |
299 | local f findflag="$1" |
| 113 | |
300 | |
|
|
301 | # this code looks a little flaky but seems to work for |
|
|
302 | # everything we want ... |
|
|
303 | # for example, if CFLAGS="-march=i686": |
|
|
304 | # `get-flag -march` == "-march=i686" |
|
|
305 | # `get-flag march` == "i686" |
| 114 | for f in ${CFLAGS} ${CXXFLAGS} ; do |
306 | for f in ${CFLAGS} ${CXXFLAGS} ; do |
| 115 | if [ "${f/${findflag}}" != "${f}" ] ; then |
307 | if [ "${f/${findflag}}" != "${f}" ] ; then |
| 116 | echo "${f/-${findflag}=}" |
308 | printf "%s\n" "${f/-${findflag}=}" |
| 117 | return |
309 | return 0 |
| 118 | fi |
310 | fi |
| 119 | done |
311 | done |
|
|
312 | return 1 |
| 120 | } |
313 | } |
|
|
314 | |
|
|
315 | has_hardened() { |
|
|
316 | test_version_info Hardened && return 0 |
|
|
317 | # the specs file wont exist unless gcc has GCC_SPECS support |
|
|
318 | [ -f "${GCC_SPECS}" -a "${GCC_SPECS}" != "${GCC_SPECS/hardened/}" ] && \ |
|
|
319 | return 0 |
|
|
320 | return 1 |
|
|
321 | } |
|
|
322 | |
|
|
323 | has_pic() { |
|
|
324 | [ "${CFLAGS/-fPIC}" != "${CFLAGS}" ] && return 0 |
|
|
325 | [ "${CFLAGS/-fpic}" != "${CFLAGS}" ] && return 0 |
|
|
326 | test_version_info pie && return 0 |
|
|
327 | return 1 |
|
|
328 | } |
|
|
329 | |
|
|
330 | has_pie() { |
|
|
331 | [ "${CFLAGS/-fPIE}" != "${CFLAGS}" ] && return 0 |
|
|
332 | [ "${CFLAGS/-fpie}" != "${CFLAGS}" ] && return 0 |
|
|
333 | test_version_info pie && return 0 |
|
|
334 | return 1 |
|
|
335 | } |
|
|
336 | |
|
|
337 | has_ssp() { |
|
|
338 | [ "${CFLAGS/-fstack-protector}" != "${CFLAGS}" ] && return 0 |
|
|
339 | test_version_info ssp && return 0 |
|
|
340 | return 1 |
|
|
341 | } |
|
|
342 | |
|
|
343 | has_m64() { |
|
|
344 | # this doesnt test if the flag is accepted, it tests if the flag |
|
|
345 | # actually -WORKS-. non-multilib gcc will take both -m32 and -m64! |
|
|
346 | # please dont replace this function with test_flag in some future |
|
|
347 | # clean-up! |
|
|
348 | temp=`mktemp` |
|
|
349 | echo "int main() { return(0); }" > ${temp}.c |
|
|
350 | ${CC/ .*/} -m64 -o /dev/null ${temp}.c > /dev/null 2>&1 |
|
|
351 | ret=$? |
|
|
352 | rm -f ${temp}.c |
|
|
353 | [ "$ret" != "1" ] && return 0 |
|
|
354 | return 1 |
|
|
355 | } |
|
|
356 | |
|
|
357 | has_m32() { |
|
|
358 | # this doesnt test if the flag is accepted, it tests if the flag |
|
|
359 | # actually -WORKS-. non-multilib gcc will take both -m32 and -m64! |
|
|
360 | # please dont replace this function with test_flag in some future |
|
|
361 | # clean-up! |
|
|
362 | temp=`mktemp` |
|
|
363 | echo "int main() { return(0); }" > ${temp}.c |
|
|
364 | ${CC/ .*/} -m32 -o /dev/null ${temp}.c > /dev/null 2>&1 |
|
|
365 | ret=$? |
|
|
366 | rm -f ${temp}.c |
|
|
367 | [ "$ret" != "1" ] && return 0 |
|
|
368 | return 1 |
|
|
369 | } |
|
|
370 | |
|
|
371 | replace-sparc64-flags() { |
|
|
372 | local SPARC64_CPUS="ultrasparc v9" |
|
|
373 | |
|
|
374 | if [ "${CFLAGS/mtune}" != "${CFLAGS}" ]; then |
|
|
375 | for x in ${SPARC64_CPUS}; do |
|
|
376 | CFLAGS="${CFLAGS/-mcpu=${x}/-mcpu=v8}" |
|
|
377 | done |
|
|
378 | else |
|
|
379 | for x in ${SPARC64_CPUS}; do |
|
|
380 | CFLAGS="${CFLAGS/-mcpu=${x}/-mcpu=v8 -mtune=${x}}" |
|
|
381 | done |
|
|
382 | fi |
|
|
383 | |
|
|
384 | if [ "${CXXFLAGS/mtune}" != "${CXXFLAGS}" ]; then |
|
|
385 | for x in ${SPARC64_CPUS}; do |
|
|
386 | CXXFLAGS="${CXXFLAGS/-mcpu=${x}/-mcpu=v8}" |
|
|
387 | done |
|
|
388 | else |
|
|
389 | for x in ${SPARC64_CPUS}; do |
|
|
390 | CXXFLAGS="${CXXFLAGS/-mcpu=${x}/-mcpu=v8 -mtune=${x}}" |
|
|
391 | done |
|
|
392 | fi |
|
|
393 | |
|
|
394 | export CFLAGS CXXFLAGS |
|
|
395 | } |
|
|
396 | |
|
|
397 | append-ldflags() { |
|
|
398 | export LDFLAGS="${LDFLAGS} $*" |
|
|
399 | return 0 |
|
|
400 | } |
|
|
401 | |
|
|
402 | filter-ldflags() { |
|
|
403 | local x |
|
|
404 | |
|
|
405 | # we do this fancy spacing stuff so as to not filter |
|
|
406 | # out part of a flag ... we want flag atoms ! :D |
|
|
407 | LDFLAGS=" ${LDFLAGS} " |
|
|
408 | for x in "$@" ; do |
|
|
409 | LDFLAGS="${LDFLAGS// ${x} / }" |
|
|
410 | done |
|
|
411 | LDFLAGS="${LDFLAGS:1:${#LDFLAGS}-2}" |
|
|
412 | export LDFLAGS |
|
|
413 | return 0 |
|
|
414 | } |
|
|
415 | |
|
|
416 | etexec-flags() { |
|
|
417 | # if you're not using a hardened compiler you wont need this |
|
|
418 | # PIC/no-pic kludge in the first place. |
|
|
419 | has_hardened || return 0 |
|
|
420 | # this kludge breaks on amd64, and probably other -fPIC dependant |
|
|
421 | # archs. |
|
|
422 | use amd64 && return 0 |
|
|
423 | |
|
|
424 | if has_pie || has_pic; then |
|
|
425 | [ -z "`is-flag -fno-pic`" ] && |
|
|
426 | export CFLAGS="${CFLAGS} `test_flag -fno-pic`" |
|
|
427 | [ -z "`is-flag -nopie`" ] && |
|
|
428 | export CFLAGS="${CFLAGS} `test_flag -nopie`" |
|
|
429 | fi |
|
|
430 | return 0 |
|
|
431 | } |
|
|
432 | |
|
|
433 | fstack-flags() { |
|
|
434 | if has_ssp; then |
|
|
435 | [ -z "`is-flag -fno-stack-protector`" ] && |
|
|
436 | export CFLAGS="${CFLAGS} `test_flag -fno-stack-protector`" |
|
|
437 | fi |
|
|
438 | return 0 |
|
|
439 | } |