diff options
author | Justin Lecher <jlec@gentoo.org> | 2012-10-16 18:31:48 +0000 |
---|---|---|
committer | Justin Lecher <jlec@gentoo.org> | 2012-10-16 18:31:48 +0000 |
commit | 5a66c0f56c104e492c7551af0e3ea3c9c65ab3eb (patch) | |
tree | 20d7da067ed217d7091d24da5f73121e54d72153 /eclass/fortran-2.eclass | |
parent | sci-libs/fftw: Use versionator.eclass, #438536 (diff) | |
download | gentoo-2-5a66c0f56c104e492c7551af0e3ea3c9c65ab3eb.tar.gz gentoo-2-5a66c0f56c104e492c7551af0e3ea3c9c65ab3eb.tar.bz2 gentoo-2-5a66c0f56c104e492c7551af0e3ea3c9c65ab3eb.zip |
Add enhanced DEP support in fortran-2.eclass to easy the usage. Only inherit fortran-2 is need for general use. For a USE dependency on fortran the new FORTRAN_NEEDED=USE variable was introduced
Diffstat (limited to 'eclass/fortran-2.eclass')
-rw-r--r-- | eclass/fortran-2.eclass | 88 |
1 files changed, 72 insertions, 16 deletions
diff --git a/eclass/fortran-2.eclass b/eclass/fortran-2.eclass index 05f00440a75f..059dbff0510f 100644 --- a/eclass/fortran-2.eclass +++ b/eclass/fortran-2.eclass @@ -1,6 +1,6 @@ # Copyright 1999-2012 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 -# $Header: /var/cvsroot/gentoo-x86/eclass/fortran-2.eclass,v 1.11 2012/10/07 14:53:43 jlec Exp $ +# $Header: /var/cvsroot/gentoo-x86/eclass/fortran-2.eclass,v 1.12 2012/10/16 18:31:48 jlec Exp $ # @ECLASS: fortran-2.eclass # @MAINTAINER: @@ -11,13 +11,23 @@ # Test functions provided by Sebastien Fabbro and Kacper Kowalik # @BLURB: Simplify fortran compiler management # @DESCRIPTION: -# If you need a fortran compiler, then you should be inheriting this eclass and -# adding virtual/fortran to your dependencies. +# If you need a fortran compiler, then you should be inheriting this eclass. +# In case you only need optional support, please export FORTRAN_NEEDED before +# inheriting the eclass. +# # The eclass tests for working fortran compilers # and exports the variables FC and F77. # Optionally, it checks for extended capabilities based on # the variable options selected in the ebuild # The only phase function exported is fortran-2_pkg_setup. +# +# Example: +# +# FORTRAN_NEEDED="lapack fortran" +# +# inherit fortran-2 +# +# FORTRAN_NEED_OPENMP=1 # @ECLASS-VARIABLE: FORTRAN_NEED_OPENMP # @DESCRIPTION: @@ -33,8 +43,37 @@ # Valid settings are any combination of: 77 90 95 2003 : ${FORTRAN_STANDARD:=77} +# @ECLASS-VARIABLE: FORTRAN_NEEDED +# @DESCRIPTION: +# If your package has an optional fortran support, set this variable +# to the space seperated list of USE triggering the fortran +# dependence. +# +# e.g. FORTRAN_NEEDED=lapack would result in +# +# DEPEND="lapack? ( virtual/fortran )" +# +# If unset, we always depend on virtual/fortran. +: ${FORTRAN_NEEDED:=always} + inherit eutils toolchain-funcs +for _f_use in ${FORTRAN_NEEDED}; do + case ${_f_use} in + always) + DEPEND+=" virtual/fortran" + break + ;; + no) + break + ;; + *) + DEPEND+=" ${_f_use}? ( virtual/fortran )" + ;; + esac +done +RDEPEND="${DEPEND}" + # @FUNCTION: _write_testsuite # @INTERNAL # @DESCRIPTION: @@ -126,6 +165,27 @@ _die_msg() { # @DESCRIPTION: # Setup functionallity, checks for a valid fortran compiler and optionally for its openmp support. fortran-2_pkg_setup() { +for _f_use in ${FORTRAN_NEEDED}; do + case ${_f_use} in + always) + _fortran_test_function && break + ;; + no) + einfo "Forcing fortran support off" + break + ;; + *) + use ${_f_use} && _fortran_test_function && break + ;; + esac +done +} + +# @FUNCTION: _fortran_test_function +# @INTERNAL +# @DESCRIPTION: +# Internal testfunction for working fortran compiler. It is called in fortran-2_pkg_setup +_fortran_test_function() { local dialect : ${F77:=$(tc-getFC)} @@ -141,25 +201,21 @@ fortran-2_pkg_setup() { esac done - if [[ ${FORTRAN_NEED_OPENMP} == 1 ]]; then - _fortran-has-openmp || \ - die "Please install current gcc with USE=openmp or set the FC variable to a compiler that supports OpenMP" - fi tc-export F77 FC - einfo "Using following Fortran compiler" + einfo "Using following Fortran compiler:" einfo " F77: ${F77}" einfo " FC: ${FC}" + + if [[ ${FORTRAN_NEED_OPENMP} == 1 ]]; then + if _fortran-has-openmp; then + einfo "${FC} has OPENMP support" + else + die "Please install current gcc with USE=openmp or set the FC variable to a compiler that supports OpenMP" + fi + fi } case ${EAPI:-0} in 0|1|2|3|4|5) EXPORT_FUNCTIONS pkg_setup ;; *) die "EAPI=${EAPI} is not supported" ;; esac - -#if in_iuse fortran; then -# DEPEND="fortran? ( virtual/fortran )" -#else -# DEPEND="virtual/fortran" -#fi - -#RDEPEND="${DEPEND}" |