public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
From: "Justin Lecher" <jlec@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] proj/sci:master commit in: eclass/
Date: Wed, 15 Jun 2011 20:50:26 +0000 (UTC)	[thread overview]
Message-ID: <c5e4d2832a36c8b57fb7f0910b5c18500a5a5ff8.jlec@gentoo> (raw)

commit:     c5e4d2832a36c8b57fb7f0910b5c18500a5a5ff8
Author:     Justin Lecher <jlec <AT> gentoo <DOT> org>
AuthorDate: Wed Jun 15 20:49:43 2011 +0000
Commit:     Justin Lecher <jlec <AT> gentoo <DOT> org>
CommitDate: Wed Jun 15 20:49:43 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/sci.git;a=commit;h=c5e4d283

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 eclass.
 # @DESCRIPTION:
 # If you need a fortran compiler, inherit this eclass. This eclass tests for
-# working fortran compilers. Optional, it checks for openmp capability of 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=1.
-# Only phase function exported is pkg_setup.
+# Only phase function exported is pkg_pretend and pkg_setup.
 
 # @ECLASS-VARIABLE: FORTRAN_NEED_OPENMP
 # @DESCRIPTION:
@@ -22,6 +23,16 @@
 #
 # Default is 0
 
+# @ECLASS-VARIABLE: FORTRAN_STANDARD
+# @DESCRIPTION:
+# Set this, if a special dialect needs to be support. Generally not needed.
+#
+# Valid settings are
+#
+# FORTRAN_STANDARD="77 90 95 2003"
+#
+# Defaults to FORTRAN_STANDARD="77" which is sufficient for most cases.
+
 inherit toolchain-funcs
 
 DEPEND="virtual/fortran"
@@ -29,46 +40,47 @@ RDEPEND="${DEPEND}"
 
 # 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=${T}/test-fortran-generic
-	local fcomp=${1}
+# FUNCTION: _write_testsuite
+# DESCRIPTION: writes fortran test code
+_write_testsuite() {
+	local filebase=${T}/test-fortran
 
-	[[ -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=$?
 
-	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
 }
 
 # 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=${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=${T}/test-fortran
 	local fcomp=${1}
+	local fdia=${2}
 
-	[[ -z ${fcomp} ]] && die "_speaks_fortran_2003 needs one argument"
+	[[ -z ${fcomp} ]] && die "_compile_test() needs at least one arg"
 
-	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=$?
 
-	rm -f "${base}"*
+	rm -f "${filebase}-f${fdia}"
 	return ${ret}
 }
 
@@ -79,46 +91,35 @@ _speaks_fortran_2003() {
 # See if the fortran supports OpenMP.
 _fortran-has-openmp() {
 	local flag
-	local base=${T}/test-fc-openmp
+	local filebase=${T}/test-fc-openmp
 
-	cat <<- EOF > "${base}.f"
+	cat <<- EOF > "${filebase}.f"
 	       call omp_get_num_threads
 	       end
 	EOF
 
 	for flag in -fopenmp -xopenmp -openmp -mp -omp -qsmp=omp; do
-		$(tc-getFC "$@") ${flag} "${base}.f" -o "${base}" >&/dev/null
+		$(tc-getFC "$@") ${flag} "${filebase}.f" -o "${filebase}" >&/dev/null
 		local ret=$?
 		(( ${ret} )) || break
 	done
 
-	rm -f "${base}"*
+	rm -f "${filebase}"*
 	return ${ret}
 }
 
-# @FUNCTION: get_fcomp
-# @DESCRIPTION:
-# Returns the canonical name or the native compiler of the current fortran 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=$($(tc-getFC) -show | awk '{print $1}')
-			echo $(FC=${_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=fortran."
+	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"
 }
 
 # @FUNCTION: fortran-2_pkg_pretend
@@ -127,30 +128,44 @@ get_fcomp() {
 fortran-2_pkg_pretend() {
 	local dialect
 
-	_speaks_fortran_generic $(tc-getFC) || \
-		_speaks_fortran_generic $(tc-getF77) || \
-		die "Please emerge the current gcc with USE=fortran or export FC defining a working fortran compiler"
-
-	[[ -n ${FORTRAN_STANDARD} ]] || FORTRAN_STANDARD="77"
+	[[ -n ${F77} ]] || F77=$(tc-getFC)
 
+	: ${FORTRAN_STANDARD:=77}
 	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
 
 	if [[ ${FORTRAN_NEED_OPENMP} == 1 ]]; then
 		_fortran-has-openmp || \
-			die "Please emerge current gcc with USE=openmp or export FC with compiler that supports OpenMP"
+			die "Please install current gcc with USE=openmp or set the FC variable 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=4.
+#
+# 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=${EAPI} by the fortran-2.eclass"
+		ewarn "will be end at 01-Sep-2011"
+		ewarn "Please migrate your package to EAPI=4"
+		fortran-2_pkg_pretend
 	fi
+	[[ -n ${F77} ]] || export F77=$(tc-getFC)
+	[[ -n ${FC} ]] || export FC=$(tc-getFC)
 }
 
 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=${EAPI} is not supported" ;;
 esac



             reply	other threads:[~2011-06-15 20:50 UTC|newest]

Thread overview: 169+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-06-15 20:50 Justin Lecher [this message]
  -- strict thread matches above, loose matches on Subject: below --
2021-01-30 15:24 [gentoo-commits] proj/sci:master commit in: eclass/ Andrew Ammerlaan
2021-01-30 10:04 Andrew Ammerlaan
2021-01-19 17:02 Andrew Ammerlaan
2020-12-19 21:38 Aisha Tammy
2020-12-19 21:36 Aisha Tammy
2020-10-01  1:43 Aisha Tammy
2018-10-28  6:21 Justin Lecher
2018-08-31  3:04 Matthias Maier
2018-04-03 16:44 Matthias Maier
2018-04-03 16:44 Matthias Maier
2018-04-02 11:20 Justin Lecher
2018-01-27 20:29 [gentoo-commits] proj/sci:jlec/scilab " Justin Lecher
2018-01-27 20:28 ` [gentoo-commits] proj/sci:master " Justin Lecher
2017-12-25 20:33 Justin Lecher
2017-08-29 13:52 Benda XU
2017-08-25  6:10 Benda XU
2017-08-23  3:15 Benda XU
2017-06-06  4:12 Benda XU
2017-04-30  7:47 Justin Lecher
2017-03-07  7:45 Marius Brehler
2017-02-24 14:14 Marius Brehler
2017-02-24 13:59 Marius Brehler
2016-12-10 10:51 Justin Lecher
2016-08-29 20:45 Justin Bronder
2016-07-31 21:13 Justin Lecher
2016-02-22 13:25 Justin Lecher
2016-02-19 10:12 Justin Lecher
2016-02-15  8:19 Justin Lecher
2016-02-15  8:19 Justin Lecher
2016-02-10 18:27 Justin Lecher
2016-02-10 18:27 Justin Lecher
2016-02-10 18:27 Justin Lecher
2016-02-10 18:27 Justin Lecher
2015-12-27 16:19 Justin Lecher
2015-12-27 16:19 Justin Lecher
2015-12-27 16:19 Justin Lecher
2015-12-14  7:53 Justin Lecher
2015-12-04  7:01 Justin Lecher
2015-12-03 10:03 Justin Lecher
2015-11-29 10:17 Justin Lecher
2015-11-29 10:17 Justin Lecher
2015-11-29 10:17 Justin Lecher
2015-11-29 10:17 Justin Lecher
2015-11-29 10:17 Justin Lecher
2015-11-28 18:59 Justin Lecher
2015-08-20 23:29 Christoph Junghans
2015-05-24  8:14 Justin Lecher
2015-03-28 18:29 Justin Lecher
2015-03-28 16:41 Justin Lecher
2015-02-21 10:01 Justin Lecher
2015-02-18  9:06 Justin Lecher
2015-02-05  8:01 Justin Lecher
2015-01-26  7:19 Justin Lecher
2015-01-10 13:35 Justin Lecher
2014-12-02 15:36 Justin Lecher
2014-12-02 15:36 Justin Lecher
2014-12-02 15:36 Justin Lecher
2014-09-15 12:01 Justin Lecher
2014-05-26  7:07 Justin Lecher
2014-05-23  9:14 Justin Lecher
2014-01-22 10:11 Reinis Danne
2014-01-22 10:09 Reinis Danne
2014-01-22 10:09 Reinis Danne
2014-01-22 10:09 Reinis Danne
2014-01-22 10:09 Reinis Danne
2014-01-22 10:09 Reinis Danne
2014-01-22 10:09 Reinis Danne
2014-01-22 10:09 Reinis Danne
2014-01-22 10:09 Reinis Danne
2014-01-22 10:09 Reinis Danne
2014-01-22 10:09 Reinis Danne
2014-01-22 10:09 Reinis Danne
2014-01-22 10:09 Reinis Danne
2014-01-22 10:09 Reinis Danne
2014-01-21 19:38 Reinis Danne
2014-01-04 18:11 Justin Lecher
2013-11-26  5:28 Sebastien Fabbro
2013-11-26  5:28 Sebastien Fabbro
2013-07-24  9:17 Justin Lecher
2013-07-24  9:17 Justin Lecher
2013-07-22 13:14 Justin Lecher
2013-07-19 18:27 Alexey Shvetsov
2013-07-09  1:17 Justin Bronder
2013-07-02  2:15 Justin Bronder
2013-07-02  0:09 Justin Bronder
2013-02-14 16:32 Denis Dupeyron
2013-02-14 16:32 Denis Dupeyron
2013-01-24 19:47 Sebastien Fabbro
2013-01-15 15:27 Justin Lecher
2013-01-11 20:45 Justin Bronder
2012-11-30  3:31 Christoph Junghans
2012-11-29 21:05 Justin Lecher
2012-11-29 21:05 Justin Lecher
2012-11-29  7:03 Justin Lecher
2012-11-29  7:03 Justin Lecher
2012-11-29  7:03 Justin Lecher
2012-11-29  7:03 Justin Lecher
2012-11-28  7:22 Justin Lecher
2012-11-28  5:29 Christoph Junghans
2012-11-27 19:33 Justin Lecher
2012-11-27 19:33 Justin Lecher
2012-11-27 19:33 Justin Lecher
2012-11-27 19:33 Justin Lecher
2012-11-27 19:33 Justin Lecher
2012-11-27 19:33 Justin Lecher
2012-11-27 19:33 Justin Lecher
2012-11-27 19:33 Justin Lecher
2012-11-27 19:33 Justin Lecher
2012-11-27 19:33 Justin Lecher
2012-11-27 19:33 Justin Lecher
2012-11-26 22:02 Justin Lecher
2012-11-26 22:02 Justin Lecher
2012-11-26 22:02 Justin Lecher
2012-11-26 22:02 Justin Lecher
2012-11-26 22:02 Justin Lecher
2012-11-02 19:54 Justin Lecher
2012-11-02 19:46 Justin Lecher
2012-11-02 19:43 Justin Lecher
2012-10-04 14:39 Christoph Junghans
2012-09-20 12:45 Justin Lecher
2012-08-30  8:38 Justin Lecher
2012-08-09  5:15 Christoph Junghans
2012-07-27 22:10 Sebastien Fabbro
2012-04-27 11:42 Justin Lecher
2012-04-27 11:42 Justin Lecher
2012-02-16 22:35 Sebastien Fabbro
2012-01-31 18:15 Sebastien Fabbro
2011-10-25 17:16 Justin Lecher
2011-10-23 21:53 Justin Lecher
2011-10-23 21:53 Justin Lecher
2011-10-05  7:54 Justin Lecher
2011-08-03 23:55 Andrea Arteaga
2011-07-18  9:09 Andreas Hüttel
2011-07-17 19:55 Andreas Hüttel
2011-07-17 18:26 Andreas Hüttel
2011-07-17 18:02 Andreas Hüttel
2011-07-17 17:53 Andreas Hüttel
2011-07-17 17:03 Andreas Hüttel
2011-07-17 17:03 Andreas Hüttel
2011-06-30 16:57 Alexey Shvetsov
2011-06-30 16:47 Alexey Shvetsov
2011-06-30 16:45 Alexey Shvetsov
2011-06-21 11:54 Justin Lecher
2011-06-20  5:20 Justin Lecher
2011-06-20  5:20 Justin Lecher
2011-06-15 21:30 Justin Lecher
2011-06-15  6:32 Justin Lecher
2011-06-13 10:27 Justin Lecher
2011-06-13  8:29 Kacper Kowalik
2011-06-13  8:20 Justin Lecher
2011-06-12 15:09 Kacper Kowalik
2011-06-12 14:52 Kacper Kowalik
2011-06-12 14:39 Justin Lecher
2011-06-12 13:41 Justin Lecher
2011-06-12 12:16 Justin Lecher
2011-06-12 11:57 Kacper Kowalik
2011-06-12 11:24 Kacper Kowalik
2011-06-12 10:53 Justin Lecher
2011-05-19  5:56 Justin Lecher
2011-04-04 11:18 Justin Lecher
2011-03-22  6:58 Justin Lecher
2011-03-20 16:28 Justin Lecher
2011-03-15 10:24 Justin Lecher
2011-03-15  7:25 Justin Lecher
2011-03-15  7:16 Justin Lecher
2011-03-14  9:25 Justin Lecher
2011-03-10 19:00 Justin Lecher
2011-03-10 19:00 Justin Lecher
2011-03-10 19:00 Justin Lecher

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=c5e4d2832a36c8b57fb7f0910b5c18500a5a5ff8.jlec@gentoo \
    --to=jlec@gentoo.org \
    --cc=gentoo-commits@lists.gentoo.org \
    --cc=gentoo-dev@lists.gentoo.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox