| 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.59 2004/06/25 00:18:04 vapier Exp $ |
3 | # $Header: /var/cvsroot/gentoo-x86/eclass/flag-o-matic.eclass,v 1.62 2004/07/15 04:59:44 lv 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" |
| … | |
… | |
| 85 | export UNSTABLE_FLAGS="-Os -O3 -freorder-blocks -fprefetch-loop-arrays" |
85 | export UNSTABLE_FLAGS="-Os -O3 -freorder-blocks -fprefetch-loop-arrays" |
| 86 | return 0 |
86 | return 0 |
| 87 | } |
87 | } |
| 88 | |
88 | |
| 89 | filter-flags() { |
89 | filter-flags() { |
| 90 | local x |
90 | local x f fset |
|
|
91 | declare -a new_CFLAGS new_CXXFLAGS |
| 91 | |
92 | |
| 92 | for x in "$@" ; do |
93 | for x in "$@" ; do |
| 93 | case "${x}" in |
94 | case "${x}" in |
| 94 | -fPIC|-fpic|-fPIE|-fpie|-pie) etexec-flags;; |
95 | -fPIC|-fpic|-fPIE|-fpie|-pie) etexec-flags;; |
| 95 | -fstack-protector|-fstack-protector-all) fstack-flags;; |
96 | -fstack-protector|-fstack-protector-all) fstack-flags;; |
| 96 | *) ;; |
|
|
| 97 | esac |
97 | esac |
| 98 | done |
98 | done |
| 99 | |
99 | |
| 100 | # we do this fancy spacing stuff so as to not filter |
100 | for fset in CFLAGS CXXFLAGS; do |
| 101 | # out part of a flag ... we want flag atoms ! :D |
101 | for f in ${!fset}; do |
| 102 | CFLAGS=" ${CFLAGS} " |
|
|
| 103 | CXXFLAGS=" ${CXXFLAGS} " |
|
|
| 104 | for x in "$@" ; do |
102 | for x in "$@"; do |
| 105 | CFLAGS="${CFLAGS// ${x} / }" |
103 | # Note this should work with globs like -O* |
| 106 | CXXFLAGS="${CXXFLAGS// ${x} / }" |
104 | [[ ${f} == ${x} ]] && continue 2 |
|
|
105 | done |
|
|
106 | eval new_${fset}\[\${\#new_${fset}\[@]}]=\${f} |
| 107 | done |
107 | done |
| 108 | CFLAGS="${CFLAGS:1:${#CFLAGS}-2}" |
108 | eval export ${fset}=\${new_${fset}\[*]} |
| 109 | CXXFLAGS="${CXXFLAGS:1:${#CXXFLAGS}-2}" |
109 | done |
| 110 | export CFLAGS CXXFLAGS |
110 | |
| 111 | return 0 |
111 | return 0 |
| 112 | } |
112 | } |
| 113 | |
113 | |
| 114 | filter-lfs-flags() { |
114 | filter-lfs-flags() { |
| 115 | filter-flags -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE |
115 | filter-flags -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE |
| … | |
… | |
| 312 | test_version_info ssp && return 0 |
312 | test_version_info ssp && return 0 |
| 313 | return 1 |
313 | return 1 |
| 314 | } |
314 | } |
| 315 | |
315 | |
| 316 | has_m64() { |
316 | has_m64() { |
| 317 | test_flag -m64 |
317 | # this doesnt test if the flag is accepted, it tests if the flag |
|
|
318 | # actually -WORKS-. non-multilib gcc will take both -m32 and -m64! |
|
|
319 | # please dont replace this function with test_flag in some future |
|
|
320 | # clean-up! |
|
|
321 | temp=`mktemp` |
|
|
322 | echo "int main() { return(0); }" > ${temp}.c |
|
|
323 | ${CC/ .*/} -m64 -o /dev/null ${temp}.c > /dev/null 2>&1 |
|
|
324 | ret=$? |
|
|
325 | rm -f ${temp}.c |
|
|
326 | [ "$ret" != "1" ] && return 0 |
| 318 | return $? |
327 | return 1 |
| 319 | } |
328 | } |
| 320 | |
329 | |
| 321 | has_m32() { |
330 | has_m32() { |
| 322 | test_flag -m32 |
331 | # this doesnt test if the flag is accepted, it tests if the flag |
|
|
332 | # actually -WORKS-. non-multilib gcc will take both -m32 and -m64! |
|
|
333 | # please dont replace this function with test_flag in some future |
|
|
334 | # clean-up! |
|
|
335 | temp=`mktemp` |
|
|
336 | echo "int main() { return(0); }" > ${temp}.c |
|
|
337 | ${CC/ .*/} -m32 -o /dev/null ${temp}.c > /dev/null 2>&1 |
|
|
338 | ret=$? |
|
|
339 | rm -f ${temp}.c |
|
|
340 | [ "$ret" != "1" ] && return 0 |
| 323 | return $? |
341 | return 1 |
| 324 | } |
342 | } |
| 325 | |
343 | |
| 326 | replace-sparc64-flags() { |
344 | replace-sparc64-flags() { |
| 327 | local SPARC64_CPUS="ultrasparc v9" |
345 | local SPARC64_CPUS="ultrasparc v9" |
| 328 | |
346 | |