/[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.100 Revision 1.104
1# Copyright 1999-2005 Gentoo Foundation 1# Copyright 1999-2005 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.100 2005/12/09 22:25:24 azarah Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/flag-o-matic.eclass,v 1.104 2006/01/14 10:52:12 kevquinn Exp $
4 4
5 5
6# need access to emktemp() 6# need access to emktemp()
7inherit eutils toolchain-funcs multilib 7inherit eutils toolchain-funcs multilib
8 8
320 320
321 shift 321 shift
322 322
323 [[ -z ${comp} ]] && \ 323 [[ -z ${comp} ]] && \
324 return 1 324 return 1
325 325
326 for x in "$@" ; do 326 for x in "$@" ; do
327 test-flag-${comp} "${x}" && flags="${flags} ${x}" 327 test-flag-${comp} "${x}" && flags="${flags} ${x}"
328 done 328 done
329 329
330 echo "${flags}" 330 echo "${flags}"
341 341
342# Short-hand that should hopefully work for both C and C++ compiler, but 342# Short-hand that should hopefully work for both C and C++ compiler, but
343# its really only present due to the append-flags() abomination. 343# its really only present due to the append-flags() abomination.
344test-flags() { test-flags-CC "$@"; } 344test-flags() { test-flags-CC "$@"; }
345 345
346# Depriciated, use test-flags() 346# Deprecated, use test-flags()
347test_flag() { 347test_flag() {
348 addwrite "/dev/stderr"
349 ewarn "test_flag: deprecated, please use test-flags()!" >/dev/stderr 348 ewarn "test_flag: deprecated, please use test-flags()!" >&2
350 349
351 test-flags-CC "$@" 350 test-flags-CC "$@"
352} 351}
353 352
354test_version_info() { 353test_version_info() {
390 return 1 389 return 1
391} 390}
392 391
393# DEPRECATED - use gcc-specs-relro or gcc-specs-now from toolchain-funcs 392# DEPRECATED - use gcc-specs-relro or gcc-specs-now from toolchain-funcs
394has_hardened() { 393has_hardened() {
395 addwrite "/dev/stderr"
396 ewarn "has_hardened: deprecated, please use gcc-specs-{relro,now}()!" \ 394 ewarn "has_hardened: deprecated, please use gcc-specs-{relro,now}()!" >&2
397 >/dev/stderr 395
398
399 test_version_info Hardened && return 0 396 test_version_info Hardened && return 0
400 # The specs file wont exist unless gcc has GCC_SPECS support 397 # The specs file wont exist unless gcc has GCC_SPECS support
401 [[ -f ${GCC_SPECS} && ${GCC_SPECS} != ${GCC_SPECS/hardened/} ]] 398 [[ -f ${GCC_SPECS} && ${GCC_SPECS} != ${GCC_SPECS/hardened/} ]]
402} 399}
403 400
404# DEPRECATED - use gcc-specs-pie from toolchain-funcs 401# DEPRECATED - use gcc-specs-pie from toolchain-funcs
405# indicate whether PIC is set 402# indicate whether PIC is set
406has_pic() { 403has_pic() {
407 addwrite "/dev/stderr"
408 ewarn "has_pic: deprecated, please use gcc-specs-pie()!" >/dev/stderr 404 ewarn "has_pic: deprecated, please use gcc-specs-pie()!" >&2
409 405
410 [[ ${CFLAGS/-fPIC} != ${CFLAGS} || \ 406 [[ ${CFLAGS/-fPIC} != ${CFLAGS} || \
411 ${CFLAGS/-fpic} != ${CFLAGS} || \ 407 ${CFLAGS/-fpic} != ${CFLAGS} || \
412 -n $(echo | $(tc-getCC) ${CFLAGS} -E -dM - | grep __PIC__) ]] 408 -n $(echo | $(tc-getCC) ${CFLAGS} -E -dM - | grep __PIC__) ]]
413} 409}
414 410
415# DEPRECATED - use gcc-specs-pie from toolchain-funcs 411# DEPRECATED - use gcc-specs-pie from toolchain-funcs
416# indicate whether PIE is set 412# indicate whether PIE is set
417has_pie() { 413has_pie() {
418 addwrite "/dev/stderr"
419 ewarn "has_pie: deprecated, please use gcc-specs-pie()!" >/dev/stderr 414 ewarn "has_pie: deprecated, please use gcc-specs-pie()!" >&2
420 415
421 [[ ${CFLAGS/-fPIE} != ${CFLAGS} || \ 416 [[ ${CFLAGS/-fPIE} != ${CFLAGS} || \
422 ${CFLAGS/-fpie} != ${CFLAGS} || \ 417 ${CFLAGS/-fpie} != ${CFLAGS} || \
423 -n $(echo | $(tc-getCC) ${CFLAGS} -E -dM - | grep __PIE__) || \ 418 -n $(echo | $(tc-getCC) ${CFLAGS} -E -dM - | grep __PIE__) || \
424 -n $(echo | $(tc-getCC) ${CFLAGS} -E -dM - | grep __PIC__) ]] 419 -n $(echo | $(tc-getCC) ${CFLAGS} -E -dM - | grep __PIC__) ]]
425 # test PIC while waiting for specs to be updated to generate __PIE__ 420 # test PIC while waiting for specs to be updated to generate __PIE__
426} 421}
427 422
428# DEPRECATED - use gcc-specs-ssp from toolchain-funcs 423# DEPRECATED - use gcc-specs-ssp from toolchain-funcs
429# indicate whether code for SSP is being generated for all functions 424# indicate whether code for SSP is being generated for all functions
430has_ssp_all() { 425has_ssp_all() {
431 addwrite "/dev/stderr"
432 ewarn "has_ssp_all: deprecated, please use gcc-specs-ssp()!" >/dev/stderr 426 ewarn "has_ssp_all: deprecated, please use gcc-specs-ssp()!" >&2
433 427
434 # note; this matches only -fstack-protector-all 428 # note; this matches only -fstack-protector-all
435 [[ ${CFLAGS/-fstack-protector-all} != ${CFLAGS} || \ 429 [[ ${CFLAGS/-fstack-protector-all} != ${CFLAGS} || \
436 -n $(echo | $(tc-getCC) ${CFLAGS} -E -dM - | grep __SSP_ALL__) ]] || \ 430 -n $(echo | $(tc-getCC) ${CFLAGS} -E -dM - | grep __SSP_ALL__) ]] || \
437 gcc-specs-ssp 431 gcc-specs-ssp
438} 432}
439 433
440# DEPRECATED - use gcc-specs-ssp from toolchain-funcs 434# DEPRECATED - use gcc-specs-ssp from toolchain-funcs
441# indicate whether code for SSP is being generated 435# indicate whether code for SSP is being generated
442has_ssp() { 436has_ssp() {
443 addwrite "/dev/stderr"
444 ewarn "has_ssp: deprecated, please use gcc-specs-ssp()!" >/dev/stderr 437 ewarn "has_ssp: deprecated, please use gcc-specs-ssp()!" >&2
445 438
446 # note; this matches both -fstack-protector and -fstack-protector-all 439 # note; this matches both -fstack-protector and -fstack-protector-all
447 [[ ${CFLAGS/-fstack-protector} != ${CFLAGS} || \ 440 [[ ${CFLAGS/-fstack-protector} != ${CFLAGS} || \
448 -n $(echo | $(tc-getCC) ${CFLAGS} -E -dM - | grep __SSP__) ]] || \ 441 -n $(echo | $(tc-getCC) ${CFLAGS} -E -dM - | grep __SSP__) ]] || \
449 gcc-specs-ssp 442 gcc-specs-ssp
450} 443}
452has_m64() { 445has_m64() {
453 # this doesnt test if the flag is accepted, it tests if the flag 446 # this doesnt test if the flag is accepted, it tests if the flag
454 # actually -WORKS-. non-multilib gcc will take both -m32 and -m64! 447 # actually -WORKS-. non-multilib gcc will take both -m32 and -m64!
455 # please dont replace this function with test_flag in some future 448 # please dont replace this function with test_flag in some future
456 # clean-up! 449 # clean-up!
457 450
458 local temp="$(emktemp)" 451 local temp="$(emktemp)"
459 echo "int main() { return(0); }" > "${temp}".c 452 echo "int main() { return(0); }" > "${temp}".c
460 MY_CC=$(tc-getCC) 453 MY_CC=$(tc-getCC)
461 ${MY_CC/ .*/} -m64 -o "$(emktemp)" "${temp}".c > /dev/null 2>&1 454 ${MY_CC/ .*/} -m64 -o "$(emktemp)" "${temp}".c > /dev/null 2>&1
462 local ret=$? 455 local ret=$?
526 [[ -z ${LDFLAGS// } ]] \ 519 [[ -z ${LDFLAGS// } ]] \
527 && LDFLAGS="" \ 520 && LDFLAGS="" \
528 || LDFLAGS=${LDFLAGS:1:${#LDFLAGS}-2} 521 || LDFLAGS=${LDFLAGS:1:${#LDFLAGS}-2}
529 export LDFLAGS 522 export LDFLAGS
530 return 0 523 return 0
524}
525
526# Turn C style ldflags (-Wl,-foo) into straight ldflags
527raw-ldflags() {
528 local x input="$@"
529 [[ -z ${input} ]] && input=${LDFLAGS}
530 set --
531 for x in ${input} ; do
532 x=${x#-Wl,}
533 set -- "$@" ${x//,/ }
534 done
535 echo "$@"
531} 536}
532 537
533fstack-flags() { 538fstack-flags() {
534 if gcc-specs-ssp; then 539 if gcc-specs-ssp; then
535 [ -z "`is-flag -fno-stack-protector`" ] && 540 [ -z "`is-flag -fno-stack-protector`" ] &&

Legend:
Removed from v.1.100  
changed lines
  Added in v.1.104

  ViewVC Help
Powered by ViewVC 1.1.20