1 |
On Sun, 28 Oct 2018 19:29:28 +0100 Michał Górny wrote: |
2 |
> On Sun, 2018-10-28 at 01:38 +0300, Andrew Savchenko wrote: |
3 |
> > Hi all! |
4 |
> > |
5 |
> > The only blocker for EAPI 7 update is eutils inheritance, but it |
6 |
> > seems to be not used within the current eclass code, probably a |
7 |
> > remnant from older days. So it is removed. |
8 |
> > |
9 |
> > Looks like no other EAPI 7 specific changes needed. |
10 |
> > |
11 |
> |
12 |
> Please use -U99999 to include more context to the patches. |
13 |
|
14 |
diff --git a/eclass/fortran-2.eclass b/eclass/fortran-2.eclass |
15 |
index 820cbbcb49bd..1baf776e368a 100644 |
16 |
--- a/eclass/fortran-2.eclass |
17 |
+++ b/eclass/fortran-2.eclass |
18 |
@@ -1,285 +1,285 @@ |
19 |
-# Copyright 1999-2017 Gentoo Foundation |
20 |
+# Copyright 1999-2018 Gentoo Authors |
21 |
# Distributed under the terms of the GNU General Public License v2 |
22 |
|
23 |
# @ECLASS: fortran-2.eclass |
24 |
# @MAINTAINER: |
25 |
# jlec@g.o |
26 |
# sci@g.o |
27 |
# @AUTHOR: |
28 |
# Author Justin Lecher <jlec@g.o> |
29 |
# Test functions provided by Sebastien Fabbro and Kacper Kowalik |
30 |
-# @SUPPORTED_EAPIS: 4 5 6 |
31 |
+# @SUPPORTED_EAPIS: 4 5 6 7 |
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 |
-inherit eutils toolchain-funcs |
51 |
+inherit toolchain-funcs |
52 |
|
53 |
case ${EAPI:-0} in |
54 |
- 4|5|6) EXPORT_FUNCTIONS pkg_setup ;; |
55 |
+ 4|5|6|7) EXPORT_FUNCTIONS pkg_setup ;; |
56 |
*) die "EAPI=${EAPI} is not supported" ;; |
57 |
esac |
58 |
|
59 |
if [[ ! ${_FORTRAN_2_CLASS} ]]; then |
60 |
|
61 |
# @ECLASS-VARIABLE: FORTRAN_NEED_OPENMP |
62 |
# @DESCRIPTION: |
63 |
# Set to "1" in order to automatically have the eclass abort if the fortran |
64 |
# compiler lacks openmp support. |
65 |
: ${FORTRAN_NEED_OPENMP:=0} |
66 |
|
67 |
# @ECLASS-VARIABLE: FORTRAN_STANDARD |
68 |
# @DESCRIPTION: |
69 |
# Set this, if a special dialect needs to be supported. |
70 |
# Generally not needed as default is sufficient. |
71 |
# |
72 |
# Valid settings are any combination of: 77 90 95 2003 |
73 |
: ${FORTRAN_STANDARD:=77} |
74 |
|
75 |
# @ECLASS-VARIABLE: FORTRAN_NEEDED |
76 |
# @DESCRIPTION: |
77 |
# If your package has an optional fortran support, set this variable |
78 |
# to the space separated list of USE triggering the fortran |
79 |
# dependency. |
80 |
# |
81 |
# e.g. FORTRAN_NEEDED=lapack would result in |
82 |
# |
83 |
# DEPEND="lapack? ( virtual/fortran )" |
84 |
# |
85 |
# If unset, we always depend on virtual/fortran. |
86 |
: ${FORTRAN_NEEDED:=always} |
87 |
|
88 |
for _f_use in ${FORTRAN_NEEDED}; do |
89 |
case ${_f_use} in |
90 |
always) |
91 |
DEPEND+=" virtual/fortran" |
92 |
RDEPEND+=" virtual/fortran" |
93 |
break |
94 |
;; |
95 |
no) |
96 |
break |
97 |
;; |
98 |
test) |
99 |
DEPEND+=" ${_f_use}? ( virtual/fortran )" |
100 |
;; |
101 |
*) |
102 |
DEPEND+=" ${_f_use}? ( virtual/fortran )" |
103 |
RDEPEND+=" ${_f_use}? ( virtual/fortran )" |
104 |
;; |
105 |
esac |
106 |
done |
107 |
unset _f_use |
108 |
|
109 |
# @FUNCTION: fortran_int64_abi_fflags |
110 |
# @DESCRIPTION: |
111 |
# Return the Fortran compiler flag to enable 64 bit integers for |
112 |
# array indices |
113 |
# @CODE |
114 |
fortran_int64_abi_fflags() { |
115 |
debug-print-function ${FUNCNAME} "${@}" |
116 |
|
117 |
_FC=$(tc-getFC) |
118 |
if [[ ${_FC} == *gfortran* ]]; then |
119 |
echo "-fdefault-integer-8" |
120 |
elif [[ ${_FC} == ifort ]]; then |
121 |
echo "-integer-size 64" |
122 |
else |
123 |
die "Compiler flag for 64bit interger for ${_FC} unknown" |
124 |
fi |
125 |
} |
126 |
|
127 |
# @FUNCTION: _fortran_write_testsuite |
128 |
# @INTERNAL |
129 |
# @DESCRIPTION: |
130 |
# writes fortran test code |
131 |
_fortran_write_testsuite() { |
132 |
debug-print-function ${FUNCNAME} "${@}" |
133 |
|
134 |
local filebase=${T}/test-fortran |
135 |
|
136 |
# f77 code |
137 |
cat <<- EOF > "${filebase}.f" |
138 |
end |
139 |
EOF |
140 |
|
141 |
# f90/95 code |
142 |
cat <<- EOF > "${filebase}.f90" |
143 |
end |
144 |
EOF |
145 |
|
146 |
# f2003 code |
147 |
cat <<- EOF > "${filebase}.f03" |
148 |
procedure(), pointer :: p |
149 |
end |
150 |
EOF |
151 |
} |
152 |
|
153 |
# @FUNCTION: _fortran_compile_test |
154 |
# @USAGE: <compiler> [dialect] |
155 |
# @INTERNAL |
156 |
# @DESCRIPTION: |
157 |
# Takes fortran compiler as first argument and dialect as second. |
158 |
# Checks whether the passed fortran compiler speaks the fortran dialect |
159 |
_fortran_compile_test() { |
160 |
debug-print-function ${FUNCNAME} "${@}" |
161 |
|
162 |
local filebase=${T}/test-fortran |
163 |
local fcomp=${1} |
164 |
local fdia=${2} |
165 |
local fcode=${filebase}.f${fdia} |
166 |
local ret |
167 |
|
168 |
[[ $# -lt 1 ]] && \ |
169 |
die "_fortran_compile_test() needs at least one argument" |
170 |
|
171 |
[[ -f ${fcode} ]] || _fortran_write_testsuite |
172 |
|
173 |
${fcomp} "${fcode}" -o "${fcode}.x" \ |
174 |
>> "${T}"/_fortran_compile_test.log 2>&1 |
175 |
ret=$? |
176 |
|
177 |
rm -f "${fcode}.x" |
178 |
return ${ret} |
179 |
} |
180 |
|
181 |
# @FUNCTION: _fortran-has-openmp |
182 |
# @RETURN: return code of the compiler |
183 |
# @INTERNAL |
184 |
# @DESCRIPTION: |
185 |
# See if the fortran supports OpenMP. |
186 |
_fortran-has-openmp() { |
187 |
debug-print-function ${FUNCNAME} "${@}" |
188 |
|
189 |
local flag |
190 |
local filebase=${T}/test-fc-openmp |
191 |
local fcode=${filebase}.f |
192 |
local ret |
193 |
local _fc=$(tc-getFC) |
194 |
|
195 |
cat <<- EOF > "${fcode}" |
196 |
call omp_get_num_threads |
197 |
end |
198 |
EOF |
199 |
|
200 |
for flag in -fopenmp -xopenmp -openmp -mp -omp -qsmp=omp; do |
201 |
${_fc} ${flag} "${fcode}" -o "${fcode}.x" \ |
202 |
&>> "${T}"/_fortran_compile_test.log |
203 |
ret=$? |
204 |
(( ${ret} )) || break |
205 |
done |
206 |
|
207 |
rm -f "${fcode}.x" |
208 |
return ${ret} |
209 |
} |
210 |
|
211 |
# @FUNCTION: _fortran_die_msg |
212 |
# @INTERNAL |
213 |
# @DESCRIPTION: |
214 |
# Detailed description how to handle fortran support |
215 |
_fortran_die_msg() { |
216 |
debug-print-function ${FUNCNAME} "${@}" |
217 |
|
218 |
echo |
219 |
eerror "Please install currently selected gcc version with USE=fortran." |
220 |
eerror "If you intend to use a different compiler then gfortran, please" |
221 |
eerror "set FC variable accordingly and take care that the necessary" |
222 |
eerror "fortran dialects are supported." |
223 |
echo |
224 |
die "Currently no working fortran compiler is available (see ${T}/_fortran_compile_test.log for information)" |
225 |
} |
226 |
|
227 |
# @FUNCTION: _fortran_test_function |
228 |
# @INTERNAL |
229 |
# @DESCRIPTION: |
230 |
# Internal test function for working fortran compiler. |
231 |
# It is called in fortran-2_pkg_setup. |
232 |
_fortran_test_function() { |
233 |
debug-print-function ${FUNCNAME} "${@}" |
234 |
|
235 |
local dialect |
236 |
|
237 |
: ${F77:=$(tc-getFC)} |
238 |
|
239 |
: ${FORTRAN_STANDARD:=77} |
240 |
for dialect in ${FORTRAN_STANDARD}; do |
241 |
case ${dialect} in |
242 |
77) _fortran_compile_test $(tc-getF77) || \ |
243 |
_fortran_die_msg ;; |
244 |
90|95) _fortran_compile_test $(tc-getFC) 90 || \ |
245 |
_fortran_die_msg ;; |
246 |
2003) _fortran_compile_test $(tc-getFC) 03 || \ |
247 |
_fortran_die_msg ;; |
248 |
2008) die "Future" ;; |
249 |
*) die "${dialect} is not a Fortran dialect." ;; |
250 |
esac |
251 |
done |
252 |
|
253 |
tc-export F77 FC |
254 |
einfo "Using following Fortran compiler:" |
255 |
einfo " F77: ${F77}" |
256 |
einfo " FC: ${FC}" |
257 |
|
258 |
if [[ ${FORTRAN_NEED_OPENMP} == 1 ]]; then |
259 |
if _fortran-has-openmp; then |
260 |
einfo "${FC} has OPENMP support" |
261 |
else |
262 |
die "Please install current gcc with USE=openmp or set the FC variable to a compiler that supports OpenMP" |
263 |
fi |
264 |
fi |
265 |
} |
266 |
|
267 |
# @FUNCTION: _fortran-2_pkg_setup |
268 |
# @INTERNAL |
269 |
# @DESCRIPTION: |
270 |
# _The_ fortran-2_pkg_setup() code |
271 |
_fortran-2_pkg_setup() { |
272 |
for _f_use in ${FORTRAN_NEEDED}; do |
273 |
case ${_f_use} in |
274 |
always) |
275 |
_fortran_test_function && break |
276 |
;; |
277 |
no) |
278 |
einfo "Forcing fortran support off" |
279 |
break |
280 |
;; |
281 |
*) |
282 |
if use ${_f_use}; then |
283 |
_fortran_test_function && break |
284 |
else |
285 |
unset FC |
286 |
unset F77 |
287 |
fi |
288 |
;; |
289 |
esac |
290 |
done |
291 |
} |
292 |
|
293 |
|
294 |
# @FUNCTION: fortran-2_pkg_setup |
295 |
# @DESCRIPTION: |
296 |
# Setup functionality, |
297 |
# checks for a valid fortran compiler and optionally for its openmp support. |
298 |
fortran-2_pkg_setup() { |
299 |
debug-print-function ${FUNCNAME} "${@}" |
300 |
|
301 |
if [[ ${MERGE_TYPE} != binary ]]; then |
302 |
_fortran-2_pkg_setup |
303 |
fi |
304 |
} |
305 |
|
306 |
_FORTRAN_2_ECLASS=1 |
307 |
fi |
308 |
|
309 |
|
310 |
Best regards, |
311 |
Andrew Savchenko |