| 1 | # Copyright 1999-2012 Gentoo Foundation |
1 | # Copyright 1999-2012 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.182 2012/11/18 08:27:00 vapier Exp $ |
3 | # $Header: /var/cvsroot/gentoo-x86/eclass/flag-o-matic.eclass,v 1.183 2012/11/18 08:29:17 vapier Exp $ |
| 4 | |
4 | |
| 5 | # @ECLASS: flag-o-matic.eclass |
5 | # @ECLASS: flag-o-matic.eclass |
| 6 | # @MAINTAINER: |
6 | # @MAINTAINER: |
| 7 | # toolchain@gentoo.org |
7 | # toolchain@gentoo.org |
| 8 | # @BLURB: common functions to manipulate and query toolchain flags |
8 | # @BLURB: common functions to manipulate and query toolchain flags |
| … | |
… | |
| 420 | # Returns shell true if <flag> is supported by the Fortran 90 compiler, else returns shell false. |
420 | # Returns shell true if <flag> is supported by the Fortran 90 compiler, else returns shell false. |
| 421 | test-flag-FC() { test-flag-PROG "FC" f95 "$1"; } |
421 | test-flag-FC() { test-flag-PROG "FC" f95 "$1"; } |
| 422 | |
422 | |
| 423 | test-flags-PROG() { |
423 | test-flags-PROG() { |
| 424 | local comp=$1 |
424 | local comp=$1 |
| 425 | local flags |
425 | local flags=() |
| 426 | local x |
426 | local x |
| 427 | |
427 | |
| 428 | shift |
428 | shift |
| 429 | |
429 | |
| 430 | [[ -z ${comp} ]] && return 1 |
430 | [[ -z ${comp} ]] && return 1 |
| 431 | |
431 | |
| 432 | for x in "$@" ; do |
432 | for x ; do |
| 433 | test-flag-${comp} "${x}" && flags="${flags}${flags:+ }${x}" |
433 | test-flag-${comp} "${x}" && flags+=( "${x}" ) |
| 434 | done |
434 | done |
| 435 | |
435 | |
| 436 | echo "${flags}" |
436 | echo "${flags[*]}" |
| 437 | |
437 | |
| 438 | # Just bail if we dont have any flags |
438 | # Just bail if we dont have any flags |
| 439 | [[ -n ${flags} ]] |
439 | [[ ${#flags[@]} -gt 0 ]] |
| 440 | } |
440 | } |
| 441 | |
441 | |
| 442 | # @FUNCTION: test-flags-CC |
442 | # @FUNCTION: test-flags-CC |
| 443 | # @USAGE: <flags> |
443 | # @USAGE: <flags> |
| 444 | # @DESCRIPTION: |
444 | # @DESCRIPTION: |