Gentoo Archives: gentoo-commits

From: Justin Lecher <jlec@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/sci:master commit in: eclass/
Date: Sat, 28 Nov 2015 18:59:21
Message-Id: 1448736791.d215df7d2187828382b0668509874cf85f712118.jlec@gentoo
1 commit: d215df7d2187828382b0668509874cf85f712118
2 Author: Justin Lecher <jlec <AT> gentoo <DOT> org>
3 AuthorDate: Sat Nov 28 18:53:11 2015 +0000
4 Commit: Justin Lecher <jlec <AT> gentoo <DOT> org>
5 CommitDate: Sat Nov 28 18:53:11 2015 +0000
6 URL: https://gitweb.gentoo.org/proj/sci.git/commit/?id=d215df7d
7
8 Merged into tree
9
10 Signed-off-by: Justin Lecher <jlec <AT> gentoo.org>
11
12 eclass/fortran-2.eclass | 276 ------------------------------------------------
13 1 file changed, 276 deletions(-)
14
15 diff --git a/eclass/fortran-2.eclass b/eclass/fortran-2.eclass
16 deleted file mode 100644
17 index 5cb6d7d..0000000
18 --- a/eclass/fortran-2.eclass
19 +++ /dev/null
20 @@ -1,276 +0,0 @@
21 -# Copyright 1999-2015 Gentoo Foundation
22 -# Distributed under the terms of the GNU General Public License v2
23 -# $Id$
24 -
25 -# @ECLASS: fortran-2.eclass
26 -# @MAINTAINER:
27 -# jlec@g.o
28 -# sci@g.o
29 -# @AUTHOR:
30 -# Author Justin Lecher <jlec@g.o>
31 -# Test functions provided by Sebastien Fabbro and Kacper Kowalik
32 -# @BLURB: Simplify fortran compiler management
33 -# @DESCRIPTION:
34 -# If you need a fortran compiler, then you should be inheriting this eclass.
35 -# In case you only need optional support, please export FORTRAN_NEEDED before
36 -# inheriting the eclass.
37 -#
38 -# The eclass tests for working fortran compilers
39 -# and exports the variables FC and F77.
40 -# Optionally, it checks for extended capabilities based on
41 -# the variable options selected in the ebuild
42 -# The only phase function exported is fortran-2_pkg_setup.
43 -# @EXAMPLE:
44 -# FORTRAN_NEEDED="lapack fortran"
45 -#
46 -# inherit fortran-2
47 -#
48 -# FORTRAN_NEED_OPENMP=1
49 -
50 -if [[ ! ${_FORTRAN_2_CLASS} ]]; then
51 -
52 -# @ECLASS-VARIABLE: FORTRAN_NEED_OPENMP
53 -# @DESCRIPTION:
54 -# Set to "1" in order to automatically have the eclass abort if the fortran
55 -# compiler lacks openmp support.
56 -: ${FORTRAN_NEED_OPENMP:=0}
57 -
58 -# @ECLASS-VARIABLE: FORTRAN_STANDARD
59 -# @DESCRIPTION:
60 -# Set this, if a special dialect needs to be supported.
61 -# Generally not needed as default is sufficient.
62 -#
63 -# Valid settings are any combination of: 77 90 95 2003
64 -: ${FORTRAN_STANDARD:=77}
65 -
66 -# @ECLASS-VARIABLE: FORTRAN_NEEDED
67 -# @DESCRIPTION:
68 -# If your package has an optional fortran support, set this variable
69 -# to the space separated list of USE triggering the fortran
70 -# dependency.
71 -#
72 -# e.g. FORTRAN_NEEDED=lapack would result in
73 -#
74 -# DEPEND="lapack? ( virtual/fortran )"
75 -#
76 -# If unset, we always depend on virtual/fortran.
77 -: ${FORTRAN_NEEDED:=always}
78 -
79 -inherit eutils toolchain-funcs
80 -
81 -for _f_use in ${FORTRAN_NEEDED}; do
82 - case ${_f_use} in
83 - always)
84 - DEPEND+=" virtual/fortran"
85 - break
86 - ;;
87 - no)
88 - break
89 - ;;
90 - *)
91 - DEPEND+=" ${_f_use}? ( virtual/fortran )"
92 - ;;
93 - esac
94 -done
95 -RDEPEND="${DEPEND}"
96 -
97 -# @FUNCTION: fortran_int64_abi_fflags
98 -# @DESCRIPTION: Return the Fortran compiler flag to enable 64 bit integers for
99 -# array indices
100 -# @CODE
101 -fortran_int64_abi_fflags() {
102 - debug-print-function ${FUNCNAME} "${@}"
103 - _FC=$(tc-getFC)
104 - if [[ ${_FC} == *gfortran* ]]; then
105 - echo "-fdefault-integer-8"
106 - elif [[ ${_FC} == ifort ]]; then
107 - echo "-integer-size 64"
108 - else
109 - die "Compiler flag for 64bit interger for ${_FC} unknown"
110 - fi
111 -}
112 -
113 -# @FUNCTION: _fortran_write_testsuite
114 -# @INTERNAL
115 -# @DESCRIPTION:
116 -# writes fortran test code
117 -_fortran_write_testsuite() {
118 - local filebase=${T}/test-fortran
119 -
120 - # f77 code
121 - cat <<- EOF > "${filebase}.f"
122 - end
123 - EOF
124 -
125 - # f90/95 code
126 - cat <<- EOF > "${filebase}.f90"
127 - end
128 - EOF
129 -
130 - # f2003 code
131 - cat <<- EOF > "${filebase}.f03"
132 - procedure(), pointer :: p
133 - end
134 - EOF
135 -}
136 -
137 -# @FUNCTION: _fortran_compile_test
138 -# @USAGE: <compiler> [dialect]
139 -# @INTERNAL
140 -# @DESCRIPTION:
141 -# Takes fortran compiler as first argument and dialect as second.
142 -# Checks whether the passed fortran compiler speaks the fortran dialect
143 -_fortran_compile_test() {
144 - local filebase=${T}/test-fortran
145 - local fcomp=${1}
146 - local fdia=${2}
147 - local fcode=${filebase}.f${fdia}
148 - local ret
149 -
150 - [[ $# -lt 1 ]] && \
151 - die "_fortran_compile_test() needs at least one argument"
152 -
153 - [[ -f ${fcode} ]] || _fortran_write_testsuite
154 -
155 - ${fcomp} "${fcode}" -o "${fcode}.x" \
156 - >> "${T}"/_fortran_compile_test.log 2>&1
157 - ret=$?
158 -
159 - rm -f "${fcode}.x"
160 - return ${ret}
161 -}
162 -
163 -# @FUNCTION: _fortran-has-openmp
164 -# @RETURN: return code of the compiler
165 -# @INTERNAL
166 -# @DESCRIPTION:
167 -# See if the fortran supports OpenMP.
168 -_fortran-has-openmp() {
169 - local flag
170 - local filebase=${T}/test-fc-openmp
171 - local fcode=${filebase}.f
172 - local ret
173 - local _fc=$(tc-getFC)
174 -
175 - cat <<- EOF > "${fcode}"
176 - call omp_get_num_threads
177 - end
178 - EOF
179 -
180 - for flag in -fopenmp -xopenmp -openmp -mp -omp -qsmp=omp; do
181 - ${_fc} ${flag} "${fcode}" -o "${fcode}.x" \
182 - &>> "${T}"/_fortran_compile_test.log
183 - ret=$?
184 - (( ${ret} )) || break
185 - done
186 -
187 - rm -f "${fcode}.x"
188 - return ${ret}
189 -}
190 -
191 -# @FUNCTION: _fortran_die_msg
192 -# @INTERNAL
193 -# @DESCRIPTION:
194 -# Detailed description how to handle fortran support
195 -_fortran_die_msg() {
196 - echo
197 - eerror "Please install currently selected gcc version with USE=fortran."
198 - eerror "If you intend to use a different compiler then gfortran, please"
199 - eerror "set FC variable accordingly and take care that the necessary"
200 - eerror "fortran dialects are supported."
201 - echo
202 - die "Currently no working fortran compiler is available"
203 -}
204 -
205 -# @FUNCTION: _fortran_test_function
206 -# @INTERNAL
207 -# @DESCRIPTION:
208 -# Internal test function for working fortran compiler.
209 -# It is called in fortran-2_pkg_setup.
210 -_fortran_test_function() {
211 - local dialect
212 -
213 - : ${F77:=$(tc-getFC)}
214 -
215 - : ${FORTRAN_STANDARD:=77}
216 - for dialect in ${FORTRAN_STANDARD}; do
217 - case ${dialect} in
218 - 77) _fortran_compile_test $(tc-getF77) || \
219 - _fortran_die_msg ;;
220 - 90|95) _fortran_compile_test $(tc-getFC) 90 || \
221 - _fortran_die_msg ;;
222 - 2003) _fortran_compile_test $(tc-getFC) 03 || \
223 - _fortran_die_msg ;;
224 - 2008) die "Future" ;;
225 - *) die "${dialect} is not a Fortran dialect." ;;
226 - esac
227 - done
228 -
229 - tc-export F77 FC
230 - einfo "Using following Fortran compiler:"
231 - einfo " F77: ${F77}"
232 - einfo " FC: ${FC}"
233 -
234 - if [[ ${FORTRAN_NEED_OPENMP} == 1 ]]; then
235 - if _fortran-has-openmp; then
236 - einfo "${FC} has OPENMP support"
237 - else
238 - die "Please install current gcc with USE=openmp or set the FC variable to a compiler that supports OpenMP"
239 - fi
240 - fi
241 -}
242 -
243 -# @FUNCTION: _fortran-2_pkg_setup
244 -# @INTERNAL
245 -# @DESCRIPTION:
246 -# _The_ fortran-2_pkg_setup() code
247 -_fortran-2_pkg_setup() {
248 - for _f_use in ${FORTRAN_NEEDED}; do
249 - case ${_f_use} in
250 - always)
251 - _fortran_test_function && break
252 - ;;
253 - no)
254 - einfo "Forcing fortran support off"
255 - break
256 - ;;
257 - *)
258 - if use ${_f_use}; then
259 - _fortran_test_function && break
260 - else
261 - unset FC
262 - unset F77
263 - fi
264 - ;;
265 - esac
266 - done
267 -}
268 -
269 -
270 -# @FUNCTION: fortran-2_pkg_setup
271 -# @DESCRIPTION:
272 -# Setup functionality,
273 -# checks for a valid fortran compiler and optionally for its openmp support.
274 -fortran-2_pkg_setup() {
275 - case ${EAPI:-0} in
276 - 0|1|2|3)
277 - eqawarn "Support for EAPI < 4 will be removed from the"
278 - eqawarn "fortran-2.eclass in until 2013-09-30."
279 - eqawarn "Please migrate your package to a higher EAPI"
280 - eqawarn "or file a bug at https://bugs.gentoo.org"
281 - _fortran-2_pkg_setup ;;
282 - 4|5)
283 - if [[ ${MERGE_TYPE} != binary ]]; then
284 - _fortran-2_pkg_setup
285 - fi
286 - ;;
287 - esac
288 -}
289 -
290 -case ${EAPI:-0} in
291 - 0|1|2|3|4|5) EXPORT_FUNCTIONS pkg_setup ;;
292 - *) die "EAPI=${EAPI} is not supported" ;;
293 -esac
294 -
295 -_FORTRAN_2_ECLASS=1
296 -fi