/[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.58 Revision 1.62
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.58 2004/06/10 15:28:56 agriffis 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
7ECLASS=flag-o-matic 7ECLASS=flag-o-matic
8INHERITED="$INHERITED $ECLASS" 8INHERITED="$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
89filter-flags() { 89filter-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
110 return 0 111 return 0
111} 112}
112 113
113filter-lfs-flags() { 114filter-lfs-flags() {
114 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
133 CXXFLAGS=" ${CXXFLAGS} " 134 CXXFLAGS=" ${CXXFLAGS} "
134 CFLAGS="${CFLAGS// ${1} / ${2} }" 135 CFLAGS="${CFLAGS// ${1} / ${2} }"
135 CXXFLAGS="${CXXFLAGS// ${1} / ${2} }" 136 CXXFLAGS="${CXXFLAGS// ${1} / ${2} }"
136 CFLAGS="${CFLAGS:1:${#CFLAGS}-2}" 137 CFLAGS="${CFLAGS:1:${#CFLAGS}-2}"
137 CXXFLAGS="${CXXFLAGS:1:${#CXXFLAGS}-2}" 138 CXXFLAGS="${CXXFLAGS:1:${#CXXFLAGS}-2}"
139 export CFLAGS CXXFLAGS
138 return 0 140 return 0
139} 141}
140 142
141replace-cpu-flags() { 143replace-cpu-flags() {
142 local oldcpu newcpu="$1" ; shift 144 local oldcpu newcpu="$1" ; shift
229 if [ "${CXXFLAGS/-O}" != "${CXXFLAGS}" -a "${NEW_CXXFLAGS/-O}" = "${NEW_CXXFLAGS}" ]; then 231 if [ "${CXXFLAGS/-O}" != "${CXXFLAGS}" -a "${NEW_CXXFLAGS/-O}" = "${NEW_CXXFLAGS}" ]; then
230 NEW_CXXFLAGS="${NEW_CXXFLAGS} -O2" 232 NEW_CXXFLAGS="${NEW_CXXFLAGS} -O2"
231 fi 233 fi
232 234
233 set +f # re-enable pathname expansion 235 set +f # re-enable pathname expansion
234
235 useq debug \
236 && einfo "CFLAGS=\"${NEW_CFLAGS}\"" \
237 && einfo "CXXFLAGS=\"${NEW_CXXFLAGS}\""
238 236
239 export CFLAGS="${NEW_CFLAGS}" 237 export CFLAGS="${NEW_CFLAGS}"
240 export CXXFLAGS="${NEW_CXXFLAGS}" 238 export CXXFLAGS="${NEW_CXXFLAGS}"
241 return 0 239 return 0
242} 240}
314 test_version_info ssp && return 0 312 test_version_info ssp && return 0
315 return 1 313 return 1
316} 314}
317 315
318has_m64() { 316has_m64() {
319 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
320 return $? 327 return 1
321} 328}
322 329
323has_m32() { 330has_m32() {
324 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
325 return $? 341 return 1
326} 342}
327 343
328replace-sparc64-flags() { 344replace-sparc64-flags() {
329 local SPARC64_CPUS="ultrasparc v9" 345 local SPARC64_CPUS="ultrasparc v9"
330 346
345 else 361 else
346 for x in ${SPARC64_CPUS}; do 362 for x in ${SPARC64_CPUS}; do
347 CXXFLAGS="${CXXFLAGS/-mcpu=${x}/-mcpu=v8 -mtune=${x}}" 363 CXXFLAGS="${CXXFLAGS/-mcpu=${x}/-mcpu=v8 -mtune=${x}}"
348 done 364 done
349 fi 365 fi
366
367 export CFLAGS CXXFLAGS
350} 368}
351 369
352append-ldflags() { 370append-ldflags() {
353 LDFLAGS="${LDFLAGS} $*" 371 export LDFLAGS="${LDFLAGS} $*"
354 return 0 372 return 0
355} 373}
356 374
357filter-ldflags() { 375filter-ldflags() {
358 local x 376 local x
362 LDFLAGS=" ${LDFLAGS} " 380 LDFLAGS=" ${LDFLAGS} "
363 for x in "$@" ; do 381 for x in "$@" ; do
364 LDFLAGS="${LDFLAGS// ${x} / }" 382 LDFLAGS="${LDFLAGS// ${x} / }"
365 done 383 done
366 LDFLAGS="${LDFLAGS:1:${#LDFLAGS}-2}" 384 LDFLAGS="${LDFLAGS:1:${#LDFLAGS}-2}"
385 export LDFLAGS
367 return 0 386 return 0
368} 387}
369 388
370etexec-flags() { 389etexec-flags() {
371 # if you're not using a hardened compiler you wont need this 390 # if you're not using a hardened compiler you wont need this

Legend:
Removed from v.1.58  
changed lines
  Added in v.1.62

  ViewVC Help
Powered by ViewVC 1.1.20