/[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.82 Revision 1.83
1# Copyright 1999-2004 Gentoo Foundation 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.82 2005/02/07 17:50:24 solar Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/flag-o-matic.eclass,v 1.83 2005/02/19 07:11:31 mr_bones_ Exp $
4# 4#
5# Author Bart Verwilst <verwilst@gentoo.org> 5# Author Bart Verwilst <verwilst@gentoo.org>
6 6
7ECLASS=flag-o-matic 7ECLASS=flag-o-matic
8INHERITED="$INHERITED $ECLASS" 8INHERITED="$INHERITED $ECLASS"
96 export UNSTABLE_FLAGS="-Os -O3 -freorder-blocks -fprefetch-loop-arrays" 96 export UNSTABLE_FLAGS="-Os -O3 -freorder-blocks -fprefetch-loop-arrays"
97 return 0 97 return 0
98} 98}
99 99
100filter-flags() { 100filter-flags() {
101 local x f fset 101 local x f fset
102 declare -a new_CFLAGS new_CXXFLAGS 102 declare -a new_CFLAGS new_CXXFLAGS
103 103
104 for x in "$@" ; do 104 for x in "$@" ; do
105 case "${x}" in 105 case "${x}" in
106 -fPIC|-fpic|-fPIE|-fpie|-pie) 106 -fPIC|-fpic|-fPIE|-fpie|-pie)
144 -n "`is-flag -fno-stack-protector-all`" ] && fstack-flags 144 -n "`is-flag -fno-stack-protector-all`" ] && fstack-flags
145 return 0 145 return 0
146} 146}
147 147
148replace-flags() { 148replace-flags() {
149 local f fset 149 local f fset
150 declare -a new_CFLAGS new_CXXFLAGS 150 declare -a new_CFLAGS new_CXXFLAGS
151 151
152 for fset in CFLAGS CXXFLAGS; do 152 for fset in CFLAGS CXXFLAGS; do
153 # Looping over the flags instead of using a global 153 # Looping over the flags instead of using a global
154 # substitution ensures that we're working with flag atoms. 154 # substitution ensures that we're working with flag atoms.
331 test_version_info pie && return 0 331 test_version_info pie && return 0
332 return 1 332 return 1
333} 333}
334 334
335# indicate whether PIE is set 335# indicate whether PIE is set
336has_pie() { 336has_pie() {
337 [ "${CFLAGS/-fPIE}" != "${CFLAGS}" ] && return 0 337 [ "${CFLAGS/-fPIE}" != "${CFLAGS}" ] && return 0
338 [ "${CFLAGS/-fpie}" != "${CFLAGS}" ] && return 0 338 [ "${CFLAGS/-fpie}" != "${CFLAGS}" ] && return 0
339 [ "$(echo | $(tc-getCC) ${CFLAGS} -E -dM - | grep __PIE__)" ] && return 0 339 [ "$(echo | $(tc-getCC) ${CFLAGS} -E -dM - | grep __PIE__)" ] && return 0
340 # test PIC while waiting for specs to be updated to generate __PIE__ 340 # test PIC while waiting for specs to be updated to generate __PIE__
341 [ "$(echo | $(tc-getCC) ${CFLAGS} -E -dM - | grep __PIC__)" ] && return 0 341 [ "$(echo | $(tc-getCC) ${CFLAGS} -E -dM - | grep __PIC__)" ] && return 0
342 return 1 342 return 1
343} 343}
344 344
345# indicate whether code for SSP is being generated 345# indicate whether code for SSP is being generated
346has_ssp() { 346has_ssp() {
347 # note; this matches both -fstack-protector and -fstack-protector-all 347 # note; this matches both -fstack-protector and -fstack-protector-all
348 [ "${CFLAGS/-fstack-protector}" != "${CFLAGS}" ] && return 0 348 [ "${CFLAGS/-fstack-protector}" != "${CFLAGS}" ] && return 0
349 [ "$(echo | $(tc-getCC) ${CFLAGS} -E -dM - | grep __SSP__)" ] && return 0 349 [ "$(echo | $(tc-getCC) ${CFLAGS} -E -dM - | grep __SSP__)" ] && return 0
384} 384}
385 385
386replace-sparc64-flags() { 386replace-sparc64-flags() {
387 local SPARC64_CPUS="ultrasparc v9" 387 local SPARC64_CPUS="ultrasparc v9"
388 388
389 if [ "${CFLAGS/mtune}" != "${CFLAGS}" ]; then 389 if [ "${CFLAGS/mtune}" != "${CFLAGS}" ]; then
390 for x in ${SPARC64_CPUS}; do 390 for x in ${SPARC64_CPUS}; do
391 CFLAGS="${CFLAGS/-mcpu=${x}/-mcpu=v8}" 391 CFLAGS="${CFLAGS/-mcpu=${x}/-mcpu=v8}"
392 done 392 done
393 else 393 else
394 for x in ${SPARC64_CPUS}; do 394 for x in ${SPARC64_CPUS}; do
395 CFLAGS="${CFLAGS/-mcpu=${x}/-mcpu=v8 -mtune=${x}}" 395 CFLAGS="${CFLAGS/-mcpu=${x}/-mcpu=v8 -mtune=${x}}"
396 done 396 done
397 fi 397 fi
398 398
399 if [ "${CXXFLAGS/mtune}" != "${CXXFLAGS}" ]; then 399 if [ "${CXXFLAGS/mtune}" != "${CXXFLAGS}" ]; then
400 for x in ${SPARC64_CPUS}; do 400 for x in ${SPARC64_CPUS}; do
401 CXXFLAGS="${CXXFLAGS/-mcpu=${x}/-mcpu=v8}" 401 CXXFLAGS="${CXXFLAGS/-mcpu=${x}/-mcpu=v8}"
402 done 402 done
403 else 403 else
404 for x in ${SPARC64_CPUS}; do 404 for x in ${SPARC64_CPUS}; do
428 return 0 428 return 0
429} 429}
430 430
431fstack-flags() { 431fstack-flags() {
432 if has_ssp; then 432 if has_ssp; then
433 [ -z "`is-flag -fno-stack-protector`" ] && 433 [ -z "`is-flag -fno-stack-protector`" ] &&
434 export CFLAGS="${CFLAGS} `test_flag -fno-stack-protector`" 434 export CFLAGS="${CFLAGS} `test_flag -fno-stack-protector`"
435 fi 435 fi
436 return 0 436 return 0
437} 437}
438 438

Legend:
Removed from v.1.82  
changed lines
  Added in v.1.83

  ViewVC Help
Powered by ViewVC 1.1.20