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 <gentoo-commits+bounces-353588-garchives=archives.gentoo.org@lists.gentoo.org>)
	id 1QViIk-0001p0-UA
	for garchives@archives.gentoo.org; Sun, 12 Jun 2011 10:54:03 +0000
Received: from pigeon.gentoo.org (localhost [127.0.0.1])
	by pigeon.gentoo.org (Postfix) with SMTP id 2B7051C08E;
	Sun, 12 Jun 2011 10:53:33 +0000 (UTC)
Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183])
	by pigeon.gentoo.org (Postfix) with ESMTP id F27301C08E
	for <gentoo-commits@lists.gentoo.org>; Sun, 12 Jun 2011 10:53: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 8C5821B403D
	for <gentoo-commits@lists.gentoo.org>; Sun, 12 Jun 2011 10:53:32 +0000 (UTC)
Received: from localhost.localdomain (localhost [127.0.0.1])
	by pelican.gentoo.org (Postfix) with ESMTP id E4E958003F
	for <gentoo-commits@lists.gentoo.org>; Sun, 12 Jun 2011 10:53:31 +0000 (UTC)
From: "Justin Lecher" <jlec@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Content-type: text/plain; charset=UTF-8
Reply-To: gentoo-dev@lists.gentoo.org, "Justin Lecher" <jlec@gentoo.org>
Message-ID: <fd2fefc00aa08026238d3f9db27051cadfdd362c.jlec@gentoo>
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: fd2fefc00aa08026238d3f9db27051cadfdd362c
Date: Sun, 12 Jun 2011 10:53:31 +0000 (UTC)
Precedence: bulk
List-Post: <mailto:gentoo-commits@lists.gentoo.org>
List-Help: <mailto:gentoo-commits+help@lists.gentoo.org>
List-Unsubscribe: <mailto:gentoo-commits+unsubscribe@lists.gentoo.org>
List-Subscribe: <mailto:gentoo-commits+subscribe@lists.gentoo.org>
List-Id: Gentoo Linux mail <gentoo-commits.gentoo.org>
X-BeenThere: gentoo-commits@lists.gentoo.org
Content-Transfer-Encoding: quoted-printable
X-Archives-Salt: 
X-Archives-Hash: cf5792fb58cc41f514ff190528d93830

commit:     fd2fefc00aa08026238d3f9db27051cadfdd362c
Author:     Justin Lecher <jlec <AT> gentoo <DOT> org>
AuthorDate: Sun Jun 12 10:52:53 2011 +0000
Commit:     Justin Lecher <jlec <AT> gentoo <DOT> org>
CommitDate: Sun Jun 12 10:52:53 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=3Dproj/sci.git;a=3Dc=
ommit;h=3Dfd2fefc0

fortran-2.eclass added

---
 eclass/fortran-2.eclass |   63 +++++++++++++++++++++++++++++++++++++++++=
++++++
 1 files changed, 63 insertions(+), 0 deletions(-)

diff --git a/eclass/fortran-2.eclass b/eclass/fortran-2.eclass
new file mode 100644
index 0000000..6528724
--- /dev/null
+++ b/eclass/fortran-2.eclass
@@ -0,0 +1,63 @@
+# Copyright 1999-2011 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Header: $
+
+# Author Justin Lecher <jlec@gentoo.org>
+
+# @ECLASS: fortran-2.eclass
+# @MAINTAINER:
+# sci@gentoo.org
+# jlec@gentoo.org
+# @BLURB: Packages, which need a frortran compiler should inherit this e=
class.
+# @DESCRIPTION:
+# If you need a fortran compiler, inherit this eclass. This eclass tests=
 for
+# working fortran compilers. Optional, check for openmp capability of th=
e
+# current fortran compiler through FCOPENMP=3D1. Only function exported
+# is pkg_setup.
+
+# @ECLASS-VARIABLE: FCOPENMP
+# @DESCRIPTION:
+# If FCOPNMP=3D1, FC is tested for openmp capabilities
+#
+# Default is 0
+
+inherit toolchain-funcs
+
+DEPEND=3D"virtual/fortran"
+RDEPEND=3D"${DEPEND}"
+
+_tc-has-fortran() {
+	local base=3D"${T}/test-tc-fortran"
+	cat <<-EOF > "${base}.f"
+	      end
+	EOF
+	$(tc-getFC "$@") "${base}.f" -o "${base}" >&/dev/null
+	local ret=3D$?
+	rm -f "${base}"*
+	return ${ret}
+}
+
+# See if the toolchain gfortran only supports OpenMP.
+_gfortran-has-openmp() {
+	[[ $(tc-getFC) !=3D *gfortran* ]] && return 0
+	local base=3D"${T}/test-fc-openmp"
+	# leave extra leading space to make sure it works on fortran 77 as well
+	cat <<- EOF > "${base}.f"
+	call omp_get_num_threads
+	end
+	EOF
+	$(tc-getFC "$@") -fopenmp "${base}.f" -o "${base}" >&/dev/null
+	local ret=3D$?
+	rm -f "${base}"*
+	return ${ret}
+}
+
+fortran-2_pkg_setup() {
+	_tc-has-fortran || \
+		 die "Please emerge the current gcc with USE=3Dfortran or export FC de=
fining a working fortran compiler"
+	if [[ ${FCOPENMP} =3D=3D 1 ]]; then
+		_gfortran-has-openmp || die "Please emerge current gcc with USE=3Dopen=
mp"
+	fi
+}
+
+EXPORT_FUNCTIONS pkg_setup