/[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.73 Revision 1.79
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.73 2004/10/13 14:11:52 vapier Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/flag-o-matic.eclass,v 1.79 2004/12/25 18:45:56 chriswhite 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"
9 9
10# Please leave ${IUSE} in this until portage .51 is stable, otherwise
11# IUSE gets clobbered.
12IUSE="${IUSE} debug" 10IUSE="debug"
13 11
14# need access to emktemp() 12# need access to emktemp()
15inherit eutils 13inherit eutils toolchain-funcs
16 14
17# 15#
18#### filter-flags <flags> #### 16#### filter-flags <flags> ####
19# Remove particular flags from C[XX]FLAGS 17# Remove particular flags from C[XX]FLAGS
20# Matches only complete flags 18# Matches only complete flags
74# 72#
75 73
76# C[XX]FLAGS that we allow in strip-flags 74# C[XX]FLAGS that we allow in strip-flags
77setup-allowed-flags() { 75setup-allowed-flags() {
78 if [ -z "${ALLOWED_FLAGS}" ] ; then 76 if [ -z "${ALLOWED_FLAGS}" ] ; then
79 export ALLOWED_FLAGS="-O -O1 -O2 -mcpu -march -mtune -fstack-protector -fno-stack-protector -fno-pie -fno-unit-at-a-time -pipe -g" 77 export ALLOWED_FLAGS="-pipe"
78 export ALLOWED_FLAGS="${ALLOWED_FLAGS} -O -O0 -O1 -O2 -mcpu -march -mtune"
79 export ALLOWED_FLAGS="${ALLOWED_FLAGS} -fstack-protector -fno-stack-protector"
80 export ALLOWED_FLAGS="${ALLOWED_FLAGS} -fno-pie -fno-unit-at-a-time"
81 export ALLOWED_FLAGS="${ALLOWED_FLAGS} -g -g0 -g1 -g2 -g3 -ggdb -ggdb0 -ggdb1 -ggdb2 -ggdb3"
80 case "${ARCH}" in 82 case "${ARCH}" in
81 mips) ALLOWED_FLAGS="${ALLOWED_FLAGS} -mips1 -mips2 -mips3 -mips4 -mips32 -mips64 -mips16 -EL -EB -mabi" ;; 83 mips) ALLOWED_FLAGS="${ALLOWED_FLAGS} -mips1 -mips2 -mips3 -mips4 -mips32 -mips64 -mips16 -EL -EB -mabi" ;;
82 amd64) ALLOWED_FLAGS="${ALLOWED_FLAGS} -fPIC -m64" ;; 84 amd64) ALLOWED_FLAGS="${ALLOWED_FLAGS} -fPIC -m64" ;;
83 x86) ALLOWED_FLAGS="${ALLOWED_FLAGS} -m32" ;; 85 x86) ALLOWED_FLAGS="${ALLOWED_FLAGS} -m32" ;;
84 alpha) ALLOWED_FLAGS="${ALLOWED_FLAGS} -fPIC" ;; 86 alpha) ALLOWED_FLAGS="${ALLOWED_FLAGS} -fPIC" ;;
85 ia64) ALLOWED_FLAGS="${ALLOWED_FLAGS} -fPIC" ;; 87 ia64) ALLOWED_FLAGS="${ALLOWED_FLAGS} -fPIC" ;;
88 sparc) ALLOWED_FLAGS="${ALLOWED_FLAGS} -m32 -m64" ;;
89 ppc) ALLOWED_FLAGS="${ALLOWED_FLAGS} -mabi" ;;
86 esac 90 esac
87 fi 91 fi
88 # allow a bunch of flags that negate features / control ABI 92 # allow a bunch of flags that negate features / control ABI
89 ALLOWED_FLAGS="${ALLOWED_FLAGS} -fno-stack-protector -fno-stack-protector-all" 93 ALLOWED_FLAGS="${ALLOWED_FLAGS} -fno-stack-protector -fno-stack-protector-all"
90 case "${ARCH}" in 94 case "${ARCH}" in
265 export CXXFLAGS="${NEW_CXXFLAGS}" 269 export CXXFLAGS="${NEW_CXXFLAGS}"
266 return 0 270 return 0
267} 271}
268 272
269test_flag() { 273test_flag() {
270 local cc=${CC:-gcc} ; cc=${cc%% *}
271 if ${cc} -S -xc "$@" -o "$(emktemp)" /dev/null &>/dev/null; then 274 if $(tc-getCC) -S -xc "$@" -o "$(emktemp)" /dev/null &>/dev/null; then
272 printf "%s\n" "$*" 275 printf "%s\n" "$*"
273 return 0 276 return 0
274 fi 277 fi
275 return 1 278 return 1
276} 279}
277 280
278test_version_info() { 281test_version_info() {
279 local cc=${CC:-gcc} ; cc=${cc%% *}
280 if [[ $(${cc} --version 2>&1) == *$1* ]]; then 282 if [[ $($(tc-getCC) --version 2>&1) == *$1* ]]; then
281 return 0 283 return 0
282 else 284 else
283 return 1 285 return 1
284 fi 286 fi
285} 287}
348 # actually -WORKS-. non-multilib gcc will take both -m32 and -m64! 350 # actually -WORKS-. non-multilib gcc will take both -m32 and -m64!
349 # please dont replace this function with test_flag in some future 351 # please dont replace this function with test_flag in some future
350 # clean-up! 352 # clean-up!
351 local temp="$(emktemp)" 353 local temp="$(emktemp)"
352 echo "int main() { return(0); }" > ${temp}.c 354 echo "int main() { return(0); }" > ${temp}.c
355 MY_CC=$(tc-getCC)
353 ${CC/ .*/} -m64 -o "$(emktemp)" ${temp}.c > /dev/null 2>&1 356 ${MY_CC/ .*/} -m64 -o "$(emktemp)" ${temp}.c > /dev/null 2>&1
354 local ret=$? 357 local ret=$?
355 rm -f ${temp}.c 358 rm -f ${temp}.c
356 [ "$ret" != "1" ] && return 0 359 [ "$ret" != "1" ] && return 0
357 return 1 360 return 1
358} 361}
362 # actually -WORKS-. non-multilib gcc will take both -m32 and -m64! 365 # actually -WORKS-. non-multilib gcc will take both -m32 and -m64!
363 # please dont replace this function with test_flag in some future 366 # please dont replace this function with test_flag in some future
364 # clean-up! 367 # clean-up!
365 local temp="$(emktemp)" 368 local temp="$(emktemp)"
366 echo "int main() { return(0); }" > ${temp}.c 369 echo "int main() { return(0); }" > ${temp}.c
370 MY_CC=$(tc-getCC)
367 ${CC/ .*/} -m32 -o "$(emktemp)" ${temp}.c > /dev/null 2>&1 371 ${MY_CC/ .*/} -m32 -o "$(emktemp)" ${temp}.c > /dev/null 2>&1
368 local ret=$? 372 local ret=$?
369 rm -f ${temp}.c 373 rm -f ${temp}.c
370 [ "$ret" != "1" ] && return 0 374 [ "$ret" != "1" ] && return 0
371 return 1 375 return 1
372} 376}
418 422
419etexec-flags() { 423etexec-flags() {
420 # if you're not using a hardened compiler you wont need this 424 # if you're not using a hardened compiler you wont need this
421 # PIC/no-pic kludge in the first place. 425 # PIC/no-pic kludge in the first place.
422 has_hardened || return 0 426 has_hardened || return 0
423 # this kludge breaks on amd64, and probably other -fPIC dependant
424 # archs.
425 use amd64 && return 0 427 use amd64 && return 0
428 use mips && return 0
426 429
427 if has_pie || has_pic; then 430 if has_pie || has_pic; then
428 [ -z "`is-flag -fno-pic`" ] && 431 [ -z "`is-flag -fno-pic`" ] &&
429 export CFLAGS="${CFLAGS} `test_flag -fno-pic`" 432 export CFLAGS="${CFLAGS} `test_flag -fno-pic`"
430 [ -z "`is-flag -nopie`" ] && 433 [ -z "`is-flag -nopie`" ] &&

Legend:
Removed from v.1.73  
changed lines
  Added in v.1.79

  ViewVC Help
Powered by ViewVC 1.1.20