From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from pigeon.gentoo.org ([208.92.234.80] helo=lists.gentoo.org) by finch.gentoo.org with esmtp (Exim 4.60) (envelope-from ) id 1QWx2v-0005Ff-Ew for garchives@archives.gentoo.org; Wed, 15 Jun 2011 20:50:42 +0000 Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id C51741C0AA; Wed, 15 Jun 2011 20:50:32 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) by pigeon.gentoo.org (Postfix) with ESMTP id 85DED1C0AA for ; Wed, 15 Jun 2011 20:50:32 +0000 (UTC) Received: from pelican.gentoo.org (unknown [66.219.59.40]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id B40CE1B4024 for ; Wed, 15 Jun 2011 20:50:31 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by pelican.gentoo.org (Postfix) with ESMTP id 0B8498003E for ; Wed, 15 Jun 2011 20:50:26 +0000 (UTC) From: "Justin Lecher" To: gentoo-commits@lists.gentoo.org Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Justin Lecher" Message-ID: Subject: [gentoo-commits] proj/sci:master commit in: eclass/ X-VCS-Repository: proj/sci X-VCS-Files: eclass/fortran-2.eclass X-VCS-Directories: eclass/ X-VCS-Committer: jlec X-VCS-Committer-Name: Justin Lecher X-VCS-Revision: c5e4d2832a36c8b57fb7f0910b5c18500a5a5ff8 Date: Wed, 15 Jun 2011 20:50:26 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: quoted-printable X-Archives-Salt: X-Archives-Hash: 615f95d04484d7330e01013dfca7a49f commit: c5e4d2832a36c8b57fb7f0910b5c18500a5a5ff8 Author: Justin Lecher gentoo org> AuthorDate: Wed Jun 15 20:49:43 2011 +0000 Commit: Justin Lecher gentoo org> CommitDate: Wed Jun 15 20:49:43 2011 +0000 URL: http://git.overlays.gentoo.org/gitweb/?p=3Dproj/sci.git;a=3Dc= ommit;h=3Dc5e4d283 fortran-2.eclass nearly finished for review. --- eclass/fortran-2.eclass | 149 ++++++++++++++++++++++++++---------------= ------ 1 files changed, 82 insertions(+), 67 deletions(-) diff --git a/eclass/fortran-2.eclass b/eclass/fortran-2.eclass index 5ebf8ca..b758051 100644 --- a/eclass/fortran-2.eclass +++ b/eclass/fortran-2.eclass @@ -12,9 +12,10 @@ # @BLURB: Packages, which need a fortran compiler should inherit this ec= lass. # @DESCRIPTION: # If you need a fortran compiler, inherit this eclass. This eclass tests= for -# working fortran compilers. Optional, it checks for openmp capability o= f the +# working fortran compilers and exports the variables FC and F77. +# Optional, it checks for openmp capability of the # current fortran compiler through FORTRAN_NEED_OPENMP=3D1. -# Only phase function exported is pkg_setup. +# Only phase function exported is pkg_pretend and pkg_setup. =20 # @ECLASS-VARIABLE: FORTRAN_NEED_OPENMP # @DESCRIPTION: @@ -22,6 +23,16 @@ # # Default is 0 =20 +# @ECLASS-VARIABLE: FORTRAN_STANDARD +# @DESCRIPTION: +# Set this, if a special dialect needs to be support. Generally not need= ed. +# +# Valid settings are +# +# FORTRAN_STANDARD=3D"77 90 95 2003" +# +# Defaults to FORTRAN_STANDARD=3D"77" which is sufficient for most cases= . + inherit toolchain-funcs =20 DEPEND=3D"virtual/fortran" @@ -29,46 +40,47 @@ RDEPEND=3D"${DEPEND}" =20 # internal function # -# FUNCTION: _speaks_fortran_generic -# DESCRIPTION: -# Takes fortran compiler as argument. -# Checks whether the passed fortran compiler is working -_speaks_fortran_generic() { - local base=3D${T}/test-fortran-generic - local fcomp=3D${1} +# FUNCTION: _write_testsuite +# DESCRIPTION: writes fortran test code +_write_testsuite() { + local filebase=3D${T}/test-fortran =20 - [[ -z ${fcomp} ]] && die "_speaks_fortran_generic needs one argument" - - cat <<- EOF > "${base}.f" + # f77 code + cat <<- EOF > "${filebase}.f" end EOF - ${fcomp} "${base}.f" -o "${base}" >&/dev/null - local ret=3D$? =20 - rm -f "${base}"* - return ${ret} + # f90/95 code + cat <<- EOF > "${filebase}.f90" + end + EOF + + # f2003 code + cat <<- EOF > "${filebase}.f03" + procedure(), pointer :: p + end + EOF } =20 # internal function # -# FUNCTION: _speaks_fortran_2003 +# FUNCTION: _compile_test # DESCRIPTION: -# Takes fortran compiler as argument. -# Checks whether the passed fortran compiler is working -_speaks_fortran_2003() { - local base=3D${T}/test-fortran-2003 +# Takes fortran compiler as first argument and dialect as second. +# Checks whether the passed fortran compiler speaks the fortran dialect +_compile_test() { + local filebase=3D${T}/test-fortran local fcomp=3D${1} + local fdia=3D${2} =20 - [[ -z ${fcomp} ]] && die "_speaks_fortran_2003 needs one argument" + [[ -z ${fcomp} ]] && die "_compile_test() needs at least one arg" =20 - cat <<- EOF > "${base}.f" - procedure(), pointer :: p - end - EOF - ${fcomp} "${base}.f" -o "${base}" >&/dev/null + [[ -f "${filebase}.f${fdia}" ]] || _write_testsuite + + ${fcomp} "${filebase}.f${fdia}" -o "${filebase}-f${fdia}" >&/dev/null local ret=3D$? =20 - rm -f "${base}"* + rm -f "${filebase}-f${fdia}" return ${ret} } =20 @@ -79,46 +91,35 @@ _speaks_fortran_2003() { # See if the fortran supports OpenMP. _fortran-has-openmp() { local flag - local base=3D${T}/test-fc-openmp + local filebase=3D${T}/test-fc-openmp =20 - cat <<- EOF > "${base}.f" + cat <<- EOF > "${filebase}.f" call omp_get_num_threads end EOF =20 for flag in -fopenmp -xopenmp -openmp -mp -omp -qsmp=3Domp; do - $(tc-getFC "$@") ${flag} "${base}.f" -o "${base}" >&/dev/null + $(tc-getFC "$@") ${flag} "${filebase}.f" -o "${filebase}" >&/dev/null local ret=3D$? (( ${ret} )) || break done =20 - rm -f "${base}"* + rm -f "${filebase}"* return ${ret} } =20 -# @FUNCTION: get_fcomp -# @DESCRIPTION: -# Returns the canonical name or the native compiler of the current fortr= an compiler -# -# e.g. +# internal # -# x86_64-linux-gnu-gfortran -> gfortran -get_fcomp() { - case $(tc-getFC) in - *gfortran* ) - echo "gfortran" ;; - *g77* ) - echo "g77" ;; - ifort ) - echo "ifc" ;; - pathf*) - echo "pathcc" ;; - mpi*) - local _fcomp=3D$($(tc-getFC) -show | awk '{print $1}') - echo $(FC=3D${_fcomp} get_fcomp) ;; - * ) - echo $(tc-getFC) ;; - esac +# FUNCTION: _die_msg +# DESCRIPTION: Detailed description how to handle fortran support +_die_msg() { + echo + eerror "Please install currently selected gcc version with USE=3Dfortra= n." + eerror "If you intend to use a different compiler then gfortran, please= " + eerror "set FC variable accordingly and take care that the neccessary" + eerror "fortran dialects are support." + echo + die "Currently no working fortran compiler is available" } =20 # @FUNCTION: fortran-2_pkg_pretend @@ -127,30 +128,44 @@ get_fcomp() { fortran-2_pkg_pretend() { local dialect =20 - _speaks_fortran_generic $(tc-getFC) || \ - _speaks_fortran_generic $(tc-getF77) || \ - die "Please emerge the current gcc with USE=3Dfortran or export FC def= ining a working fortran compiler" - - [[ -n ${FORTRAN_STANDARD} ]] || FORTRAN_STANDARD=3D"77" + [[ -n ${F77} ]] || F77=3D$(tc-getFC) =20 + : ${FORTRAN_STANDARD:=3D77} for dialect in ${FORTRAN_STANDARD}; do case ${dialect} in - 77|90|95) _speaks_fortran_generic $(tc-getFC) || \ - die "Your fortran compiler does not speak the Fortran ${dialect}" ;; - 2003) _speaks_fortran_${dialect} $(tc-getFC) || \ - die "Your fortran compiler does not speak the Fortran ${dialect}" ;; - 2008) die "Future";; - *) die "This dialect is not a fortran ";; + 77) _compile_test $(tc-getF77) || _die_msg ;; + 90|95) _compile_test $(tc-getFC) 90 || _die_msg ;; + 2003) _compile_test $(tc-getFC) 03 || _die_msg ;; + 2008) die "Future" ;; + *) die "${dialect} is not a Fortran dialect." ;; esac done =20 if [[ ${FORTRAN_NEED_OPENMP} =3D=3D 1 ]]; then _fortran-has-openmp || \ - die "Please emerge current gcc with USE=3Dopenmp or export FC with co= mpiler that supports OpenMP" + die "Please install current gcc with USE=3Dopenmp or set the FC varia= ble to a compiler that supports OpenMP" + fi +} + +# @FUNCTION: fortran-2_pkg_setup +# @DESCRIPTION: +# In EAPI < 4 it calls the compiler check. This behaviour is deprecated +# and will be removed at 01-Sep-2011. Please migrate to EAPI=3D4. +# +# Exports the FC and F77 variable according to the compiler checks. +fortran-2_pkg_setup() { + if has ${EAPI:-0} 0 1 2 3; then + ewarn "The support for EAPI=3D${EAPI} by the fortran-2.eclass" + ewarn "will be end at 01-Sep-2011" + ewarn "Please migrate your package to EAPI=3D4" + fortran-2_pkg_pretend fi + [[ -n ${F77} ]] || export F77=3D$(tc-getFC) + [[ -n ${FC} ]] || export FC=3D$(tc-getFC) } =20 case "${EAPI:-0}" in - 4) EXPORT_FUNCTIONS pkg_pretend;; + 1|2|3) EXPORT_FUNCTIONS pkg_setup ;; + 4) EXPORT_FUNCTIONS pkg_pretend pkg_setup ;; *) die "EAPI=3D${EAPI} is not supported" ;; esac