blob: d1c1d7d1014f107c6d4f68254102547ba3358044 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
|
# Copyright 1999-2004 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/eclass/fortran.eclass,v 1.20 2008/11/07 00:53:30 dberkholz Exp $
#
# Author: Danny van Dyk <kugelfang@gentoo.org>
#
inherit eutils autotools
DESCRIPTION="Based on the ${ECLASS} eclass"
IUSE="debug"
#DEPEND="virtual/fortran" # Let's aim for this...
# Which Fortran Compiler has been selected ?
export FORTRANC
# These are the options to ./configure / econf that enable the usage
# of a specific Fortran Compiler. If your package uses a different
# option that the one listed here, overwrite it in your ebuild.
g77_CONF="--with-f77"
f2c_CONF="--with-f2c"
# This function prints the necessary options for the currently selected
# Fortran Compiler.
fortran_conf() {
echo $(eval echo \${$(echo -n ${FORTRANC})_CONF})
}
# need_fortran(<profiles>):
# profiles = <profile> ... <profile>
#
# profile:
# * gfortran - GCC Fortran 95
# * g77 - GCC Fortran 77
# * f2c - Fortran 2 C Translator
# * ifc - Intel Fortran Compiler
# * f95 - Sun Studio Fortran Compiler
#
# Checks if at least one of <profiles> is installed.
# Checks also if F77 (the fortran compiler to use) is available
# on the System.
need_fortran() {
if [ -z "$*" ]; then
eerror "Call need_fortran with at least one argument !"
fi
local AVAILABLE
local PROFILE
for PROFILE in $@; do
case ${PROFILE} in
gfortran)
if [ -x "$(type -P gfortran 2> /dev/null)" ]; then
AVAILABLE="${AVAILABLE} gfortran"
fi
;;
g77)
if [ -x "$(type -P g77 2> /dev/null)" ]; then
AVAILABLE="${AVAILABLE} g77"
fi
;;
f2c)
if [ -x "$(type -P f2c 2> /dev/null)" ]; then
AVAILABLE="${AVAILABLE} f2c"
fi
;;
ifc)
case ${ARCH} in
x86|ia64|amd64)
if [ -x "$(type -P ifort 2> /dev/null)" ]; then
AVAILABLE="${AVAILABLE} ifort"
elif [ -x "$(type -P ifc 2> /dev/null)" ]; then
AVAILABLE="${AVAILABLE} ifc"
fi
;;
*)
;;
esac
;;
f95)
case ${ARCH} in
x86|amd64)
if [ -x "$(type -P f95 2> /dev/null)" ]; then
AVAILABLE="${AVAILABLE} f95"
fi
;;
*)
;;
esac
;;
esac
done
AVAILABLE="${AVAILABLE/^[[:space:]]}"
use debug && echo ${AVAILABLE}
if [ -z "${AVAILABLE}" ]; then
eerror "None of the needed Fortran Compilers ($@) is installed."
eerror "To install one of these, choose one of the following steps:"
i=1
for PROFILE in $@; do
case ${PROFILE} in
gfortran)
eerror "[${i}] USE=\"fortran\" emerge =sys-devel/gcc-4*"
;;
g77)
eerror "[${i}] USE=\"fortran\" emerge =sys-devel/gcc-3*"
;;
f2c)
eerror "[${i}] emerge dev-lang/f2c"
;;
ifc)
case ${ARCH} in
x86|ia64)
eerror "[${i}] emerge dev-lang/ifc"
;;
*)
;;
esac
;;
f95)
case ${ARCH} in
x86|amd64)
eerror "[${i}] emerge dev-lang/sunstudio"
;;
*)
;;
esac
;;
esac
i=$((i + 1))
done
die "Install a Fortran Compiler !"
else
einfo "You need one of these Fortran Compilers: $@"
einfo "Installed are: ${AVAILABLE}"
if [ -n "${F77}" -o -n "${FC}" -o -n "${F2C}" ]; then
if [ -n "${F77}" ]; then
FC="${F77}" # F77 overwrites FC
fi
if [ -n "${FC}" -a -n "${F2C}" ]; then
ewarn "Using ${FC} and f2c is impossible. Disabling F2C !"
F2C="" # Disabling f2c
MY_FORTRAN="$(basename ${FC})" # set MY_FORTRAN to filename of
# the Fortran Compiler
else
if [ -n "${F2C}" ]; then
MY_FORTRAN="$(basename ${F2C})"
elif [ -n "${FC}" ]; then
MY_FORTRAN="$(basename ${FC})"
else
MY_FORTRAN="$(basename ${F77})"
fi
fi
fi
# default to gfortran if available, g77 if not
use debug && echo "MY_FORTRAN: \"${MY_FORTRAN}\""
if hasq gfortran ${AVAILABLE}; then
MY_FORTRAN=${MY_FORTRAN:=gfortran}
elif hasq g77 ${AVAILABLE}; then
MY_FORTRAN=${MY_FORTRAN:=g77}
else
# Default to the first valid Fortran compiler
for i in ${AVAILABLE}; do
MY_FORTRAN=$i
break
done
fi
use debug && echo "MY_FORTRAN: \"${MY_FORTRAN}\""
if ! hasq ${MY_FORTRAN} ${AVAILABLE}; then
eerror "Current Fortran Compiler is set to ${MY_FORTRAN}, which is not usable with this package !"
die "Wrong Fortran Compiler !"
fi
case ${MY_FORTRAN} in
gfortran|g77|ifc|ifort|f2c|f95)
FORTRANC="${MY_FORTRAN}"
esac
fi
use debug && echo "FORTRANC: \"${FORTRANC}\""
}
# patch_fortran():
# Apply necessary patches for ${FORTRANC}
patch_fortran() {
if [[ -z "${FORTRANC}" || ! -d "${FILESDIR}" ]]; then
return
fi
local PATCHES=$(find ${FILESDIR} -name "${P}-${FORTRANC}-*")
einfo "Applying patches for selected FORTRAN compiler: ${FORTRANC}"
local PATCH
if [ -n "${PATCHES}" ]; then
for PATCH in ${PATCHES}; do
epatch ${PATCH}
done
eautoreconf
fi
}
# fortran_pkg_setup():
# Set FORTRAN to indicate the list of Fortran Compiler that
# can be used for the ebuild.
# If not set in ebuild, FORTRAN will default to f77
fortran_pkg_setup() {
need_fortran ${FORTRAN:="gfortran g77"}
}
# fortran_src_unpack():
# Run patch_fortran if no new src_unpack() is defined.
fortran_src_unpack() {
unpack ${A}
cd ${S}
patch_fortran
}
EXPORT_FUNCTIONS pkg_setup src_unpack
|