| 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.80 2005/01/20 18:29:13 eradicator 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 | |
| 7 | ECLASS=flag-o-matic |
7 | ECLASS=flag-o-matic |
| 8 | INHERITED="$INHERITED $ECLASS" |
8 | INHERITED="$INHERITED $ECLASS" |
| … | |
… | |
| 323 | [ -f "${GCC_SPECS}" -a "${GCC_SPECS}" != "${GCC_SPECS/hardened/}" ] && \ |
323 | [ -f "${GCC_SPECS}" -a "${GCC_SPECS}" != "${GCC_SPECS/hardened/}" ] && \ |
| 324 | return 0 |
324 | return 0 |
| 325 | return 1 |
325 | return 1 |
| 326 | } |
326 | } |
| 327 | |
327 | |
|
|
328 | # indicate whether PIC is set |
| 328 | has_pic() { |
329 | has_pic() { |
| 329 | [ "${CFLAGS/-fPIC}" != "${CFLAGS}" ] && return 0 |
330 | [ "${CFLAGS/-fPIC}" != "${CFLAGS}" ] && return 0 |
| 330 | [ "${CFLAGS/-fpic}" != "${CFLAGS}" ] && return 0 |
331 | [ "${CFLAGS/-fpic}" != "${CFLAGS}" ] && return 0 |
|
|
332 | [ "$(echo | $(tc-getCC) ${CFLAGS} -E -dM - | grep __PIC__)" ] && return 0 |
| 331 | test_version_info pie && return 0 |
333 | test_version_info pie && return 0 |
| 332 | return 1 |
334 | return 1 |
| 333 | } |
335 | } |
| 334 | |
336 | |
|
|
337 | # indicate whether PIE is set |
| 335 | has_pie() { |
338 | has_pie() { |
| 336 | [ "${CFLAGS/-fPIE}" != "${CFLAGS}" ] && return 0 |
339 | [ "${CFLAGS/-fPIE}" != "${CFLAGS}" ] && return 0 |
| 337 | [ "${CFLAGS/-fpie}" != "${CFLAGS}" ] && return 0 |
340 | [ "${CFLAGS/-fpie}" != "${CFLAGS}" ] && return 0 |
| 338 | 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 |
| 339 | return 1 |
344 | return 1 |
| 340 | } |
345 | } |
| 341 | |
346 | |
|
|
347 | # indicate whether code for SSP is being generated |
| 342 | has_ssp() { |
348 | has_ssp() { |
|
|
349 | # note; this matches both -fstack-protector and -fstack-protector-all |
| 343 | [ "${CFLAGS/-fstack-protector}" != "${CFLAGS}" ] && return 0 |
350 | [ "${CFLAGS/-fstack-protector}" != "${CFLAGS}" ] && return 0 |
| 344 | test_version_info ssp && return 0 |
351 | [ "$(echo | $(tc-getCC) ${CFLAGS} -E -dM - | grep __SSP__)" ] && return 0 |
| 345 | return 1 |
352 | return 1 |
| 346 | } |
353 | } |
| 347 | |
354 | |
| 348 | has_m64() { |
355 | has_m64() { |
| 349 | # 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 |