/[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.70 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.70 2004/09/25 07:37:19 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"
11
12# need access to emktemp()
13inherit eutils toolchain-funcs
13 14
14# 15#
15#### filter-flags <flags> #### 16#### filter-flags <flags> ####
16# Remove particular flags from C[XX]FLAGS 17# Remove particular flags from C[XX]FLAGS
17# Matches only complete flags 18# Matches only complete flags
71# 72#
72 73
73# C[XX]FLAGS that we allow in strip-flags 74# C[XX]FLAGS that we allow in strip-flags
74setup-allowed-flags() { 75setup-allowed-flags() {
75 if [ -z "${ALLOWED_FLAGS}" ] ; then 76 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 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"
77 case "${ARCH}" in 82 case "${ARCH}" in
78 mips) ALLOWED_FLAGS="${ALLOWED_FLAGS} -mips1 -mips2 -mips3 -mips4 -mabi" ;; 83 mips) ALLOWED_FLAGS="${ALLOWED_FLAGS} -mips1 -mips2 -mips3 -mips4 -mips32 -mips64 -mips16 -EL -EB -mabi" ;;
79 amd64) ALLOWED_FLAGS="${ALLOWED_FLAGS} -fPIC -m64" ;; 84 amd64) ALLOWED_FLAGS="${ALLOWED_FLAGS} -fPIC -m64" ;;
80 x86) ALLOWED_FLAGS="${ALLOWED_FLAGS} -m32" ;; 85 x86) ALLOWED_FLAGS="${ALLOWED_FLAGS} -m32" ;;
81 alpha) ALLOWED_FLAGS="${ALLOWED_FLAGS} -fPIC" ;; 86 alpha) ALLOWED_FLAGS="${ALLOWED_FLAGS} -fPIC" ;;
82 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" ;;
83 esac 90 esac
84 fi 91 fi
85 # allow a bunch of flags that negate features / control ABI 92 # allow a bunch of flags that negate features / control ABI
86 ALLOWED_FLAGS="${ALLOWED_FLAGS} -fno-stack-protector -fno-stack-protector-all" 93 ALLOWED_FLAGS="${ALLOWED_FLAGS} -fno-stack-protector -fno-stack-protector-all"
87 case "${ARCH}" in 94 case "${ARCH}" in
262 export CXXFLAGS="${NEW_CXXFLAGS}" 269 export CXXFLAGS="${NEW_CXXFLAGS}"
263 return 0 270 return 0
264} 271}
265 272
266test_flag() { 273test_flag() {
267 local cc=${CC:-gcc} ; cc=${cc%% *} 274 if $(tc-getCC) -S -xc "$@" -o "$(emktemp)" /dev/null &>/dev/null; then
268 if ${cc} -S -xc "$@" -o /dev/null /dev/null &>/dev/null; then
269 printf "%s\n" "$*" 275 printf "%s\n" "$*"
270 return 0 276 return 0
271 fi 277 fi
272 return 1 278 return 1
273} 279}
274 280
275test_version_info() { 281test_version_info() {
276 local cc=${CC:-gcc} ; cc=${cc%% *}
277 if [[ $(${cc} --version 2>&1) == *$1* ]]; then 282 if [[ $($(tc-getCC) --version 2>&1) == *$1* ]]; then
278 return 0 283 return 0
279 else 284 else
280 return 1 285 return 1
281 fi 286 fi
282} 287}
343has_m64() { 348has_m64() {
344 # this doesnt test if the flag is accepted, it tests if the flag 349 # 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! 350 # actually -WORKS-. non-multilib gcc will take both -m32 and -m64!
346 # please dont replace this function with test_flag in some future 351 # please dont replace this function with test_flag in some future
347 # clean-up! 352 # clean-up!
348 temp=`mktemp` 353 local temp="$(emktemp)"
349 echo "int main() { return(0); }" > ${temp}.c 354 echo "int main() { return(0); }" > ${temp}.c
350 ${CC/ .*/} -m64 -o /dev/null ${temp}.c > /dev/null 2>&1 355 MY_CC=$(tc-getCC)
351 ret=$? 356 ${MY_CC/ .*/} -m64 -o "$(emktemp)" ${temp}.c > /dev/null 2>&1
357 local ret=$?
352 rm -f ${temp}.c 358 rm -f ${temp}.c
353 [ "$ret" != "1" ] && return 0 359 [ "$ret" != "1" ] && return 0
354 return 1 360 return 1
355} 361}
356 362
357has_m32() { 363has_m32() {
358 # this doesnt test if the flag is accepted, it tests if the flag 364 # 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! 365 # actually -WORKS-. non-multilib gcc will take both -m32 and -m64!
360 # please dont replace this function with test_flag in some future 366 # please dont replace this function with test_flag in some future
361 # clean-up! 367 # clean-up!
362 temp=`mktemp` 368 local temp="$(emktemp)"
363 echo "int main() { return(0); }" > ${temp}.c 369 echo "int main() { return(0); }" > ${temp}.c
364 ${CC/ .*/} -m32 -o /dev/null ${temp}.c > /dev/null 2>&1 370 MY_CC=$(tc-getCC)
365 ret=$? 371 ${MY_CC/ .*/} -m32 -o "$(emktemp)" ${temp}.c > /dev/null 2>&1
372 local ret=$?
366 rm -f ${temp}.c 373 rm -f ${temp}.c
367 [ "$ret" != "1" ] && return 0 374 [ "$ret" != "1" ] && return 0
368 return 1 375 return 1
369} 376}
370 377
415 422
416etexec-flags() { 423etexec-flags() {
417 # 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
418 # PIC/no-pic kludge in the first place. 425 # PIC/no-pic kludge in the first place.
419 has_hardened || return 0 426 has_hardened || return 0
420 # this kludge breaks on amd64, and probably other -fPIC dependant
421 # archs.
422 use amd64 && return 0 427 use amd64 && return 0
428 use mips && return 0
423 429
424 if has_pie || has_pic; then 430 if has_pie || has_pic; then
425 [ -z "`is-flag -fno-pic`" ] && 431 [ -z "`is-flag -fno-pic`" ] &&
426 export CFLAGS="${CFLAGS} `test_flag -fno-pic`" 432 export CFLAGS="${CFLAGS} `test_flag -fno-pic`"
427 [ -z "`is-flag -nopie`" ] && 433 [ -z "`is-flag -nopie`" ] &&
435 [ -z "`is-flag -fno-stack-protector`" ] && 441 [ -z "`is-flag -fno-stack-protector`" ] &&
436 export CFLAGS="${CFLAGS} `test_flag -fno-stack-protector`" 442 export CFLAGS="${CFLAGS} `test_flag -fno-stack-protector`"
437 fi 443 fi
438 return 0 444 return 0
439} 445}
446
447# This is thanks to great work from Paul de Vrieze <gentoo-user@devrieze.net>,
448# bug #9016. Also thanks to Jukka Salmi <salmi@gmx.net> (bug #13907) for more
449# fixes.
450#
451# Export CFLAGS and CXXFLAGS that are compadible with gcc-2.95.3
452gcc2-flags() {
453 CFLAGS=${CFLAGS//pentium-mmx/i586}
454 CFLAGS=${CFLAGS//pentium[234]/i686}
455 CFLAGS=${CFLAGS//k6-[23]/k6}
456 CFLAGS=${CFLAGS//athlon-tbird/i686}
457 CFLAGS=${CFLAGS//athlon-4/i686}
458 CFLAGS=${CFLAGS//athlon-[xm]p/i686}
459 CFLAGS=${CFLAGS//athlon/i686}
460
461 CXXFLAGS=${CXXFLAGS//pentium-mmx/i586}
462 CXXFLAGS=${CXXFLAGS//pentium[234]/i686}
463 CXXFLAGS=${CXXFLAGS//k6-[23]/k6}
464 CXXFLAGS=${CXXFLAGS//athlon-tbird/i686}
465 CXXFLAGS=${CXXFLAGS//athlon-4/i686}
466 CXXFLAGS=${CXXFLAGS//athlon-[xm]p/i686}
467 CXXFLAGS=${CXXFLAGS//athlon/i686}
468
469 if [ "$ARCH" = alpha ]; then
470 CHOST=${CHOST/#alphaev6[78]/alphaev6}
471 CFLAGS=${CFLAGS//ev6[78]/ev6}
472 CXXFLAGS=${CXXFLAGS//ev6[78]/ev6}
473 fi
474
475 export CFLAGS CXXFLAGS
476}

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

  ViewVC Help
Powered by ViewVC 1.1.20