/[gentoo-x86]/eclass/fortran-2.eclass
Gentoo

Diff of /eclass/fortran-2.eclass

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 1.7 Revision 1.12
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/fortran-2.eclass,v 1.7 2012/10/07 12:06:54 jlec Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/fortran-2.eclass,v 1.12 2012/10/16 18:31:48 jlec Exp $
4 4
5# @ECLASS: fortran-2.eclass 5# @ECLASS: fortran-2.eclass
6# @MAINTAINER: 6# @MAINTAINER:
7# jlec@gentoo.org 7# jlec@gentoo.org
8# sci@gentoo.org 8# sci@gentoo.org
9# @AUTHOR: 9# @AUTHOR:
10# Author Justin Lecher <jlec@gentoo.org> 10# Author Justin Lecher <jlec@gentoo.org>
11# Test functions provided by Sebastien Fabbro and Kacper Kowalik 11# Test functions provided by Sebastien Fabbro and Kacper Kowalik
12# @BLURB: Simplify fortran compiler management 12# @BLURB: Simplify fortran compiler management
13# @DESCRIPTION: 13# @DESCRIPTION:
14# If you need a fortran compiler, then you should be inheriting this eclass and 14# If you need a fortran compiler, then you should be inheriting this eclass.
15# adding virtual/fortran to your dependencies. 15# In case you only need optional support, please export FORTRAN_NEEDED before
16# inheriting the eclass.
17#
16# The eclass tests for working fortran compilers 18# The eclass tests for working fortran compilers
17# and exports the variables FC and F77. 19# and exports the variables FC and F77.
18# Optionally, it checks for extended capabilities based on 20# Optionally, it checks for extended capabilities based on
19# the variable options selected in the ebuild 21# the variable options selected in the ebuild
20# The only phase function exported is fortran-2_pkg_setup. 22# The only phase function exported is fortran-2_pkg_setup.
23#
24# Example:
25#
26# FORTRAN_NEEDED="lapack fortran"
27#
28# inherit fortran-2
29#
30# FORTRAN_NEED_OPENMP=1
21 31
22# @ECLASS-VARIABLE: FORTRAN_NEED_OPENMP 32# @ECLASS-VARIABLE: FORTRAN_NEED_OPENMP
23# @DESCRIPTION: 33# @DESCRIPTION:
24# Set to "1" in order to automatically have the eclass abort if the fortran 34# Set to "1" in order to automatically have the eclass abort if the fortran
25# compiler lacks openmp support. 35# compiler lacks openmp support.
31# Generally not needed as default is sufficient. 41# Generally not needed as default is sufficient.
32# 42#
33# Valid settings are any combination of: 77 90 95 2003 43# Valid settings are any combination of: 77 90 95 2003
34: ${FORTRAN_STANDARD:=77} 44: ${FORTRAN_STANDARD:=77}
35 45
46# @ECLASS-VARIABLE: FORTRAN_NEEDED
47# @DESCRIPTION:
48# If your package has an optional fortran support, set this variable
49# to the space seperated list of USE triggering the fortran
50# dependence.
51#
52# e.g. FORTRAN_NEEDED=lapack would result in
53#
54# DEPEND="lapack? ( virtual/fortran )"
55#
56# If unset, we always depend on virtual/fortran.
57: ${FORTRAN_NEEDED:=always}
58
36inherit toolchain-funcs 59inherit eutils toolchain-funcs
60
61for _f_use in ${FORTRAN_NEEDED}; do
62 case ${_f_use} in
63 always)
64 DEPEND+=" virtual/fortran"
65 break
66 ;;
67 no)
68 break
69 ;;
70 *)
71 DEPEND+=" ${_f_use}? ( virtual/fortran )"
72 ;;
73 esac
74done
75RDEPEND="${DEPEND}"
37 76
38# @FUNCTION: _write_testsuite 77# @FUNCTION: _write_testsuite
39# @INTERNAL 78# @INTERNAL
40# @DESCRIPTION: 79# @DESCRIPTION:
41# writes fortran test code 80# writes fortran test code
124 163
125# @FUNCTION: fortran-2_pkg_setup 164# @FUNCTION: fortran-2_pkg_setup
126# @DESCRIPTION: 165# @DESCRIPTION:
127# Setup functionallity, checks for a valid fortran compiler and optionally for its openmp support. 166# Setup functionallity, checks for a valid fortran compiler and optionally for its openmp support.
128fortran-2_pkg_setup() { 167fortran-2_pkg_setup() {
168for _f_use in ${FORTRAN_NEEDED}; do
169 case ${_f_use} in
170 always)
171 _fortran_test_function && break
172 ;;
173 no)
174 einfo "Forcing fortran support off"
175 break
176 ;;
177 *)
178 use ${_f_use} && _fortran_test_function && break
179 ;;
180 esac
181done
182}
183
184# @FUNCTION: _fortran_test_function
185# @INTERNAL
186# @DESCRIPTION:
187# Internal testfunction for working fortran compiler. It is called in fortran-2_pkg_setup
188_fortran_test_function() {
129 local dialect 189 local dialect
130 190
131 : ${F77:=$(tc-getFC)} 191 : ${F77:=$(tc-getFC)}
132 192
133 : ${FORTRAN_STANDARD:=77} 193 : ${FORTRAN_STANDARD:=77}
139 2008) die "Future" ;; 199 2008) die "Future" ;;
140 *) die "${dialect} is not a Fortran dialect." ;; 200 *) die "${dialect} is not a Fortran dialect." ;;
141 esac 201 esac
142 done 202 done
143 203
144 if [[ ${FORTRAN_NEED_OPENMP} == 1 ]]; then
145 _fortran-has-openmp || \
146 die "Please install current gcc with USE=openmp or set the FC variable to a compiler that supports OpenMP"
147 fi
148 tc-export F77 FC 204 tc-export F77 FC
149 einfo "Using following Fortran compiler" 205 einfo "Using following Fortran compiler:"
150 einfo " F77: ${F77}" 206 einfo " F77: ${F77}"
151 einfo " FC: ${FC}" 207 einfo " FC: ${FC}"
208
209 if [[ ${FORTRAN_NEED_OPENMP} == 1 ]]; then
210 if _fortran-has-openmp; then
211 einfo "${FC} has OPENMP support"
212 else
213 die "Please install current gcc with USE=openmp or set the FC variable to a compiler that supports OpenMP"
214 fi
215 fi
152} 216}
153 217
154case ${EAPI:-0} in 218case ${EAPI:-0} in
155 0|1|2|3|4|5) EXPORT_FUNCTIONS pkg_setup ;; 219 0|1|2|3|4|5) EXPORT_FUNCTIONS pkg_setup ;;
156 *) die "EAPI=${EAPI} is not supported" ;; 220 *) die "EAPI=${EAPI} is not supported" ;;

Legend:
Removed from v.1.7  
changed lines
  Added in v.1.12

  ViewVC Help
Powered by ViewVC 1.1.20