| 1 | # Copyright 1999-2011 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.3 2011/06/21 14:05:30 jlec Exp $ |
3 | # $Header: /var/cvsroot/gentoo-x86/eclass/fortran-2.eclass,v 1.7 2012/10/07 12:06:54 jlec Exp $ |
| 4 | |
|
|
| 5 | # Author Justin Lecher <jlec@gentoo.org> |
|
|
| 6 | # Test functions provided by Sebastien Fabbro and Kacper Kowalik |
|
|
| 7 | |
4 | |
| 8 | # @ECLASS: fortran-2.eclass |
5 | # @ECLASS: fortran-2.eclass |
| 9 | # @MAINTAINER: |
6 | # @MAINTAINER: |
| 10 | # jlec@gentoo.org |
7 | # jlec@gentoo.org |
| 11 | # sci@gentoo.org |
8 | # sci@gentoo.org |
|
|
9 | # @AUTHOR: |
|
|
10 | # Author Justin Lecher <jlec@gentoo.org> |
|
|
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. |
14 | # If you need a fortran compiler, then you should be inheriting this eclass and |
|
|
15 | # adding virtual/fortran to your dependencies. |
| 15 | # The eclass tests for working fortran compilers |
16 | # The eclass tests for working fortran compilers |
| 16 | # and exports the variables FC and F77. |
17 | # and exports the variables FC and F77. |
| 17 | # Optionally, it checks for extended capabilities based on |
18 | # Optionally, it checks for extended capabilities based on |
| 18 | # the variable options selected in the ebuild |
19 | # the variable options selected in the ebuild |
| 19 | # The only phase function exported is fortran-2_pkg_setup. |
20 | # The only phase function exported is fortran-2_pkg_setup. |
| … | |
… | |
| 33 | : ${FORTRAN_STANDARD:=77} |
34 | : ${FORTRAN_STANDARD:=77} |
| 34 | |
35 | |
| 35 | inherit toolchain-funcs |
36 | inherit toolchain-funcs |
| 36 | |
37 | |
| 37 | # @FUNCTION: _write_testsuite |
38 | # @FUNCTION: _write_testsuite |
| 38 | # @DESCRIPTION: writes fortran test code |
|
|
| 39 | # @INTERNAL |
39 | # @INTERNAL |
|
|
40 | # @DESCRIPTION: |
|
|
41 | # writes fortran test code |
| 40 | _write_testsuite() { |
42 | _write_testsuite() { |
| 41 | local filebase=${T}/test-fortran |
43 | local filebase=${T}/test-fortran |
| 42 | |
44 | |
| 43 | # f77 code |
45 | # f77 code |
| 44 | cat <<- EOF > "${filebase}.f" |
46 | cat <<- EOF > "${filebase}.f" |
| … | |
… | |
| 56 | end |
58 | end |
| 57 | EOF |
59 | EOF |
| 58 | } |
60 | } |
| 59 | |
61 | |
| 60 | # @FUNCTION: _compile_test |
62 | # @FUNCTION: _compile_test |
|
|
63 | # @INTERNAL |
| 61 | # @DESCRIPTION: |
64 | # @DESCRIPTION: |
| 62 | # Takes fortran compiler as first argument and dialect as second. |
65 | # Takes fortran compiler as first argument and dialect as second. |
| 63 | # Checks whether the passed fortran compiler speaks the fortran dialect |
66 | # Checks whether the passed fortran compiler speaks the fortran dialect |
| 64 | # @INTERNAL |
|
|
| 65 | _compile_test() { |
67 | _compile_test() { |
| 66 | local filebase=${T}/test-fortran |
68 | local filebase=${T}/test-fortran |
| 67 | local fcomp=${1} |
69 | local fcomp=${1} |
| 68 | local fdia=${2} |
70 | local fdia=${2} |
| 69 | local fcode=${filebase}.f${fdia} |
71 | local fcode=${filebase}.f${fdia} |
| … | |
… | |
| 79 | rm -f "${fcode}.x" |
81 | rm -f "${fcode}.x" |
| 80 | return ${ret} |
82 | return ${ret} |
| 81 | } |
83 | } |
| 82 | |
84 | |
| 83 | # @FUNCTION: _fortran-has-openmp |
85 | # @FUNCTION: _fortran-has-openmp |
|
|
86 | # @INTERNAL |
| 84 | # @DESCRIPTION: |
87 | # @DESCRIPTION: |
| 85 | # See if the fortran supports OpenMP. |
88 | # See if the fortran supports OpenMP. |
| 86 | # @INTERNAL |
|
|
| 87 | _fortran-has-openmp() { |
89 | _fortran-has-openmp() { |
| 88 | local flag |
90 | local flag |
| 89 | local filebase=${T}/test-fc-openmp |
91 | local filebase=${T}/test-fc-openmp |
| 90 | local fcode=${filebase}.f |
92 | local fcode=${filebase}.f |
| 91 | local ret |
93 | local ret |
| … | |
… | |
| 105 | rm -f "${fcode}.x" |
107 | rm -f "${fcode}.x" |
| 106 | return ${ret} |
108 | return ${ret} |
| 107 | } |
109 | } |
| 108 | |
110 | |
| 109 | # @FUNCTION: _die_msg |
111 | # @FUNCTION: _die_msg |
| 110 | # @DESCRIPTION: Detailed description how to handle fortran support |
|
|
| 111 | # @INTERNAL |
112 | # @INTERNAL |
|
|
113 | # @DESCRIPTION: |
|
|
114 | # Detailed description how to handle fortran support |
| 112 | _die_msg() { |
115 | _die_msg() { |
| 113 | echo |
116 | echo |
| 114 | eerror "Please install currently selected gcc version with USE=fortran." |
117 | eerror "Please install currently selected gcc version with USE=fortran." |
| 115 | eerror "If you intend to use a different compiler then gfortran, please" |
118 | eerror "If you intend to use a different compiler then gfortran, please" |
| 116 | eerror "set FC variable accordingly and take care that the neccessary" |
119 | eerror "set FC variable accordingly and take care that the neccessary" |
| … | |
… | |
| 141 | if [[ ${FORTRAN_NEED_OPENMP} == 1 ]]; then |
144 | if [[ ${FORTRAN_NEED_OPENMP} == 1 ]]; then |
| 142 | _fortran-has-openmp || \ |
145 | _fortran-has-openmp || \ |
| 143 | die "Please install current gcc with USE=openmp or set the FC variable to a compiler that supports OpenMP" |
146 | die "Please install current gcc with USE=openmp or set the FC variable to a compiler that supports OpenMP" |
| 144 | fi |
147 | fi |
| 145 | tc-export F77 FC |
148 | tc-export F77 FC |
|
|
149 | einfo "Using following Fortran compiler" |
|
|
150 | einfo " F77: ${F77}" |
|
|
151 | einfo " FC: ${FC}" |
| 146 | } |
152 | } |
| 147 | |
153 | |
| 148 | case ${EAPI:-0} in |
154 | case ${EAPI:-0} in |
| 149 | 0|1|2|3|4) EXPORT_FUNCTIONS pkg_setup ;; |
155 | 0|1|2|3|4|5) EXPORT_FUNCTIONS pkg_setup ;; |
| 150 | *) die "EAPI=${EAPI} is not supported" ;; |
156 | *) die "EAPI=${EAPI} is not supported" ;; |
| 151 | esac |
157 | esac |