| 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.103 2006/01/10 01:14:30 vapier 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() |
| 7 | inherit eutils toolchain-funcs multilib |
7 | inherit eutils toolchain-funcs multilib |
| 8 | |
8 | |
| … | |
… | |
| 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. |
| 344 | test-flags() { test-flags-CC "$@"; } |
344 | test-flags() { test-flags-CC "$@"; } |
| 345 | |
345 | |
| 346 | # Depriciated, use test-flags() |
346 | # Deprecated, use test-flags() |
| 347 | test_flag() { |
347 | test_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 | |
| 354 | test_version_info() { |
353 | test_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 |
| 394 | has_hardened() { |
393 | has_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 |
|
|
| 398 | |
395 | |
| 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 |
| 406 | has_pic() { |
403 | has_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 |
| 417 | has_pie() { |
413 | has_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__) ]] |
| … | |
… | |
| 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 |
| 430 | has_ssp_all() { |
425 | has_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 |
| 442 | has_ssp() { |
436 | has_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 |