| 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.75 2004/10/28 01:38:31 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 | |
| 7 | ECLASS=flag-o-matic |
7 | ECLASS=flag-o-matic |
| 8 | INHERITED="$INHERITED $ECLASS" |
8 | INHERITED="$INHERITED $ECLASS" |
| … | |
… | |
| 72 | # |
72 | # |
| 73 | |
73 | |
| 74 | # C[XX]FLAGS that we allow in strip-flags |
74 | # C[XX]FLAGS that we allow in strip-flags |
| 75 | setup-allowed-flags() { |
75 | setup-allowed-flags() { |
| 76 | if [ -z "${ALLOWED_FLAGS}" ] ; then |
76 | if [ -z "${ALLOWED_FLAGS}" ] ; then |
| 77 | 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" |
| 78 | case "${ARCH}" in |
82 | case "${ARCH}" in |
| 79 | 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" ;; |
| 80 | amd64) ALLOWED_FLAGS="${ALLOWED_FLAGS} -fPIC -m64" ;; |
84 | amd64) ALLOWED_FLAGS="${ALLOWED_FLAGS} -fPIC -m64" ;; |
| 81 | x86) ALLOWED_FLAGS="${ALLOWED_FLAGS} -m32" ;; |
85 | x86) ALLOWED_FLAGS="${ALLOWED_FLAGS} -m32" ;; |
| 82 | alpha) ALLOWED_FLAGS="${ALLOWED_FLAGS} -fPIC" ;; |
86 | alpha) ALLOWED_FLAGS="${ALLOWED_FLAGS} -fPIC" ;; |
| 83 | 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" ;; |
| 84 | esac |
90 | esac |
| 85 | fi |
91 | fi |
| 86 | # allow a bunch of flags that negate features / control ABI |
92 | # allow a bunch of flags that negate features / control ABI |
| 87 | ALLOWED_FLAGS="${ALLOWED_FLAGS} -fno-stack-protector -fno-stack-protector-all" |
93 | ALLOWED_FLAGS="${ALLOWED_FLAGS} -fno-stack-protector -fno-stack-protector-all" |
| 88 | case "${ARCH}" in |
94 | case "${ARCH}" in |
| … | |
… | |
| 416 | |
422 | |
| 417 | etexec-flags() { |
423 | etexec-flags() { |
| 418 | # 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 |
| 419 | # PIC/no-pic kludge in the first place. |
425 | # PIC/no-pic kludge in the first place. |
| 420 | has_hardened || return 0 |
426 | has_hardened || return 0 |
| 421 | # this kludge breaks on amd64, and probably other -fPIC dependant |
|
|
| 422 | # archs. |
|
|
| 423 | use amd64 && return 0 |
427 | use amd64 && return 0 |
|
|
428 | use mips && return 0 |
| 424 | |
429 | |
| 425 | if has_pie || has_pic; then |
430 | if has_pie || has_pic; then |
| 426 | [ -z "`is-flag -fno-pic`" ] && |
431 | [ -z "`is-flag -fno-pic`" ] && |
| 427 | export CFLAGS="${CFLAGS} `test_flag -fno-pic`" |
432 | export CFLAGS="${CFLAGS} `test_flag -fno-pic`" |
| 428 | [ -z "`is-flag -nopie`" ] && |
433 | [ -z "`is-flag -nopie`" ] && |