/[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.77 Revision 1.81
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.77 2004/11/13 07:07:08 solar Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/flag-o-matic.eclass,v 1.81 2005/01/29 03:09:45 solar 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
10IUSE="debug" 10IUSE="debug"
11 11
12# need access to emktemp() 12# need access to emktemp()
13inherit eutils toolchain-funcs 13inherit eutils toolchain-funcs multilib
14 14
15# 15#
16#### filter-flags <flags> #### 16#### filter-flags <flags> ####
17# Remove particular flags from C[XX]FLAGS 17# Remove particular flags from C[XX]FLAGS
18# Matches only complete flags 18# Matches only complete flags
83 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" ;;
84 amd64) ALLOWED_FLAGS="${ALLOWED_FLAGS} -fPIC -m64" ;; 84 amd64) ALLOWED_FLAGS="${ALLOWED_FLAGS} -fPIC -m64" ;;
85 x86) ALLOWED_FLAGS="${ALLOWED_FLAGS} -m32" ;; 85 x86) ALLOWED_FLAGS="${ALLOWED_FLAGS} -m32" ;;
86 alpha) ALLOWED_FLAGS="${ALLOWED_FLAGS} -fPIC" ;; 86 alpha) ALLOWED_FLAGS="${ALLOWED_FLAGS} -fPIC" ;;
87 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" ;;
88 esac 90 esac
89 fi 91 fi
90 # allow a bunch of flags that negate features / control ABI 92 # allow a bunch of flags that negate features / control ABI
91 ALLOWED_FLAGS="${ALLOWED_FLAGS} -fno-stack-protector -fno-stack-protector-all" 93 ALLOWED_FLAGS="${ALLOWED_FLAGS} -fno-stack-protector -fno-stack-protector-all"
92 case "${ARCH}" in 94 case "${ARCH}" in
321 [ -f "${GCC_SPECS}" -a "${GCC_SPECS}" != "${GCC_SPECS/hardened/}" ] && \ 323 [ -f "${GCC_SPECS}" -a "${GCC_SPECS}" != "${GCC_SPECS/hardened/}" ] && \
322 return 0 324 return 0
323 return 1 325 return 1
324} 326}
325 327
328# indicate whether PIC is set
326has_pic() { 329has_pic() {
327 [ "${CFLAGS/-fPIC}" != "${CFLAGS}" ] && return 0 330 [ "${CFLAGS/-fPIC}" != "${CFLAGS}" ] && return 0
328 [ "${CFLAGS/-fpic}" != "${CFLAGS}" ] && return 0 331 [ "${CFLAGS/-fpic}" != "${CFLAGS}" ] && return 0
332 [ "$(echo | $(tc-getCC) ${CFLAGS} -E -dM - | grep __PIC__)" ] && return 0
329 test_version_info pie && return 0 333 test_version_info pie && return 0
330 return 1 334 return 1
331} 335}
332 336
337# indicate whether PIE is set
333has_pie() { 338has_pie() {
334 [ "${CFLAGS/-fPIE}" != "${CFLAGS}" ] && return 0 339 [ "${CFLAGS/-fPIE}" != "${CFLAGS}" ] && return 0
335 [ "${CFLAGS/-fpie}" != "${CFLAGS}" ] && return 0 340 [ "${CFLAGS/-fpie}" != "${CFLAGS}" ] && return 0
336 test_version_info pie && return 0 341 [ "$(echo | $(tc-getCC) ${CFLAGS} -E -dM - | grep __PIE__)" ] && return 0
342 # test PIC while waiting for specs to be updated to generate __PIE__
343 [ "$(echo | $(tc-getCC) ${CFLAGS} -E -dM - | grep __PIC__)" ] && return 0
337 return 1 344 return 1
338} 345}
339 346
347# indicate whether code for SSP is being generated
340has_ssp() { 348has_ssp() {
349 # note; this matches both -fstack-protector and -fstack-protector-all
341 [ "${CFLAGS/-fstack-protector}" != "${CFLAGS}" ] && return 0 350 [ "${CFLAGS/-fstack-protector}" != "${CFLAGS}" ] && return 0
342 test_version_info ssp && return 0 351 [ "$(echo | $(tc-getCC) ${CFLAGS} -E -dM - | grep __SSP__)" ] && return 0
343 return 1 352 return 1
344} 353}
345 354
346has_m64() { 355has_m64() {
347 # this doesnt test if the flag is accepted, it tests if the flag 356 # this doesnt test if the flag is accepted, it tests if the flag
361has_m32() { 370has_m32() {
362 # this doesnt test if the flag is accepted, it tests if the flag 371 # this doesnt test if the flag is accepted, it tests if the flag
363 # actually -WORKS-. non-multilib gcc will take both -m32 and -m64! 372 # actually -WORKS-. non-multilib gcc will take both -m32 and -m64!
364 # please dont replace this function with test_flag in some future 373 # please dont replace this function with test_flag in some future
365 # clean-up! 374 # clean-up!
375
376 [ "$(tc-arch)" = "amd64" ] && has_multilib_profile && return 0
377
366 local temp="$(emktemp)" 378 local temp="$(emktemp)"
367 echo "int main() { return(0); }" > ${temp}.c 379 echo "int main() { return(0); }" > ${temp}.c
368 MY_CC=$(tc-getCC) 380 MY_CC=$(tc-getCC)
369 ${MY_CC/ .*/} -m32 -o "$(emktemp)" ${temp}.c > /dev/null 2>&1 381 ${MY_CC/ .*/} -m32 -o "$(emktemp)" ${temp}.c > /dev/null 2>&1
370 local ret=$? 382 local ret=$?

Legend:
Removed from v.1.77  
changed lines
  Added in v.1.81

  ViewVC Help
Powered by ViewVC 1.1.20