/[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.15 Revision 1.16
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.15 2012/11/28 12:11:51 jlec Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/fortran-2.eclass,v 1.16 2012/11/28 13:03:30 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
70 ;; 70 ;;
71 esac 71 esac
72done 72done
73RDEPEND="${DEPEND}" 73RDEPEND="${DEPEND}"
74 74
75# @FUNCTION: _write_testsuite 75# @FUNCTION: _fortran_write_testsuite
76# @INTERNAL 76# @INTERNAL
77# @DESCRIPTION: 77# @DESCRIPTION:
78# writes fortran test code 78# writes fortran test code
79_write_testsuite() { 79_fortran_write_testsuite() {
80 local filebase=${T}/test-fortran 80 local filebase=${T}/test-fortran
81 81
82 # f77 code 82 # f77 code
83 cat <<- EOF > "${filebase}.f" 83 cat <<- EOF > "${filebase}.f"
84 end 84 end
94 procedure(), pointer :: p 94 procedure(), pointer :: p
95 end 95 end
96 EOF 96 EOF
97} 97}
98 98
99# @FUNCTION: _compile_test 99# @FUNCTION: _fortran_compile_test
100# @USAGE: <compiler> [dialect]
100# @INTERNAL 101# @INTERNAL
101# @DESCRIPTION: 102# @DESCRIPTION:
102# Takes fortran compiler as first argument and dialect as second. 103# Takes fortran compiler as first argument and dialect as second.
103# Checks whether the passed fortran compiler speaks the fortran dialect 104# Checks whether the passed fortran compiler speaks the fortran dialect
104_compile_test() { 105_fortran_compile_test() {
105 local filebase=${T}/test-fortran 106 local filebase=${T}/test-fortran
106 local fcomp=${1} 107 local fcomp=${1}
107 local fdia=${2} 108 local fdia=${2}
108 local fcode=${filebase}.f${fdia} 109 local fcode=${filebase}.f${fdia}
109 local ret 110 local ret
110 111
111 [[ $# -eq 0 ]] && die "_compile_test() needs at least one argument" 112 [[ $# -lt 1 ]] && die "_fortran_compile_test() needs at least one arguments"
112 113
113 [[ -f ${fcode} ]] || _write_testsuite 114 [[ -f ${fcode} ]] || _fortran_write_testsuite
114 115
115 ${fcomp} "${fcode}" -o "${fcode}.x" >&/dev/null 116 ${fcomp} "${fcode}" -o "${fcode}.x" &>> "${T}"/_fortran_compile_test.log
116 ret=$? 117 ret=$?
117 118
118 rm -f "${fcode}.x" 119 rm -f "${fcode}.x"
119 return ${ret} 120 return ${ret}
120} 121}
121 122
122# @FUNCTION: _fortran-has-openmp 123# @FUNCTION: _fortran-has-openmp
124# @RETURN: compilers return value
123# @INTERNAL 125# @INTERNAL
124# @DESCRIPTION: 126# @DESCRIPTION:
125# See if the fortran supports OpenMP. 127# See if the fortran supports OpenMP.
126_fortran-has-openmp() { 128_fortran-has-openmp() {
127 local flag 129 local flag
134 call omp_get_num_threads 136 call omp_get_num_threads
135 end 137 end
136 EOF 138 EOF
137 139
138 for flag in -fopenmp -xopenmp -openmp -mp -omp -qsmp=omp; do 140 for flag in -fopenmp -xopenmp -openmp -mp -omp -qsmp=omp; do
139 ${_fc} ${flag} "${fcode}" -o "${fcode}.x" >&/dev/null 141 ${_fc} ${flag} "${fcode}" -o "${fcode}.x" &>> "${T}"/_fortran_compile_test.log
140 ret=$? 142 ret=$?
141 (( ${ret} )) || break 143 (( ${ret} )) || break
142 done 144 done
143 145
144 rm -f "${fcode}.x" 146 rm -f "${fcode}.x"
145 return ${ret} 147 return ${ret}
146} 148}
147 149
148# @FUNCTION: _die_msg 150# @FUNCTION: _fortran_die_msg
149# @INTERNAL 151# @INTERNAL
150# @DESCRIPTION: 152# @DESCRIPTION:
151# Detailed description how to handle fortran support 153# Detailed description how to handle fortran support
152_die_msg() { 154_fortran_die_msg() {
153 echo 155 echo
154 eerror "Please install currently selected gcc version with USE=fortran." 156 eerror "Please install currently selected gcc version with USE=fortran."
155 eerror "If you intend to use a different compiler then gfortran, please" 157 eerror "If you intend to use a different compiler then gfortran, please"
156 eerror "set FC variable accordingly and take care that the neccessary" 158 eerror "set FC variable accordingly and take care that the neccessary"
157 eerror "fortran dialects are support." 159 eerror "fortran dialects are support."
158 echo 160 echo
159 die "Currently no working fortran compiler is available" 161 die "Currently no working fortran compiler is available"
160} 162}
161 163
162# @FUNCTION: fortran-2_pkg_setup
163# @DESCRIPTION:
164# Setup functionallity, checks for a valid fortran compiler and optionally for its openmp support.
165fortran-2_pkg_setup() {
166for _f_use in ${FORTRAN_NEEDED}; do
167 case ${_f_use} in
168 always)
169 _fortran_test_function && break
170 ;;
171 no)
172 einfo "Forcing fortran support off"
173 break
174 ;;
175 *)
176 if use ${_f_use}; then
177 _fortran_test_function && break
178 else
179 unset FC
180 unset F77
181 fi
182 ;;
183 esac
184done
185}
186
187# @FUNCTION: _fortran_test_function 164# @FUNCTION: _fortran_test_function
188# @INTERNAL 165# @INTERNAL
189# @DESCRIPTION: 166# @DESCRIPTION:
190# Internal testfunction for working fortran compiler. It is called in fortran-2_pkg_setup 167# Internal testfunction for working fortran compiler. It is called in fortran-2_pkg_setup
191_fortran_test_function() { 168_fortran_test_function() {
194 : ${F77:=$(tc-getFC)} 171 : ${F77:=$(tc-getFC)}
195 172
196 : ${FORTRAN_STANDARD:=77} 173 : ${FORTRAN_STANDARD:=77}
197 for dialect in ${FORTRAN_STANDARD}; do 174 for dialect in ${FORTRAN_STANDARD}; do
198 case ${dialect} in 175 case ${dialect} in
199 77) _compile_test $(tc-getF77) || _die_msg ;; 176 77) _fortran_compile_test $(tc-getF77) || _fortran_die_msg ;;
200 90|95) _compile_test $(tc-getFC) 90 || _die_msg ;; 177 90|95) _fortran_compile_test $(tc-getFC) 90 || _fortran_die_msg ;;
201 2003) _compile_test $(tc-getFC) 03 || _die_msg ;; 178 2003) _fortran_compile_test $(tc-getFC) 03 || _fortran_die_msg ;;
202 2008) die "Future" ;; 179 2008) die "Future" ;;
203 *) die "${dialect} is not a Fortran dialect." ;; 180 *) die "${dialect} is not a Fortran dialect." ;;
204 esac 181 esac
205 done 182 done
206 183
216 die "Please install current gcc with USE=openmp or set the FC variable to a compiler that supports OpenMP" 193 die "Please install current gcc with USE=openmp or set the FC variable to a compiler that supports OpenMP"
217 fi 194 fi
218 fi 195 fi
219} 196}
220 197
198# @FUNCTION: fortran-2_pkg_setup
199# @DESCRIPTION:
200# Setup functionallity, checks for a valid fortran compiler and optionally for its openmp support.
201fortran-2_pkg_setup() {
202 for _f_use in ${FORTRAN_NEEDED}; do
203 case ${_f_use} in
204 always)
205 _fortran_test_function && break
206 ;;
207 no)
208 einfo "Forcing fortran support off"
209 break
210 ;;
211 *)
212 if use ${_f_use}; then
213 _fortran_test_function && break
214 else
215 unset FC
216 unset F77
217 fi
218 ;;
219 esac
220 done
221}
222
221case ${EAPI:-0} in 223case ${EAPI:-0} in
222 0|1|2|3|4|5) EXPORT_FUNCTIONS pkg_setup ;; 224 0|1|2|3|4|5) EXPORT_FUNCTIONS pkg_setup ;;
223 *) die "EAPI=${EAPI} is not supported" ;; 225 *) die "EAPI=${EAPI} is not supported" ;;
224esac 226esac

Legend:
Removed from v.1.15  
changed lines
  Added in v.1.16

  ViewVC Help
Powered by ViewVC 1.1.20