/[gentoo-x86]/sci-libs/mkl/mkl-10.0.5.025.ebuild
Gentoo

Contents of /sci-libs/mkl/mkl-10.0.5.025.ebuild

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.20 - (show annotations) (download)
Tue Mar 31 20:12:53 2015 UTC (5 years, 2 months ago) by ulm
Branch: MAIN
CVS Tags: HEAD
Changes since 1.19: +5 -5 lines
Update dependency after package move of eselect modules to app-eselect.

(Portage version: 2.2.18/cvs/Linux x86_64, signed Manifest commit with key 9433907D693FB5B8!)

1 # Copyright 1999-2015 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3 # $Header: /var/cvsroot/gentoo-x86/sci-libs/mkl/mkl-10.0.5.025.ebuild,v 1.19 2013/07/02 09:00:02 ago Exp $
4
5 inherit eutils fortran-2 multilib toolchain-funcs check-reqs
6
7 PID=1232
8 PB=${PN}
9
10 DESCRIPTION="Intel(R) Math Kernel Library: linear algebra, fft, math functions"
11 HOMEPAGE="http://developer.intel.com/software/products/mkl/"
12 SRC_URI="http://registrationcenter-download.intel.com/irc_nas/${PID}/l_${PN}_p_${PV}.tgz"
13
14 KEYWORDS="-* amd64 ~ia64 x86"
15 SLOT="0"
16 LICENSE="Intel-SDP"
17 IUSE="doc fftw fortran95 int64 mpi"
18 RESTRICT="strip mirror"
19
20 DEPEND="
21 app-eselect/eselect-blas
22 app-eselect/eselect-cblas
23 app-eselect/eselect-lapack"
24 RDEPEND="${DEPEND}
25 doc? ( app-doc/blas-docs app-doc/lapack-docs )
26 mpi? ( virtual/mpi )"
27
28 MKL_DIR=/opt/intel/${PN}/${PV}
29 INTEL_LIC_DIR=/opt/intel/licenses
30
31 QA_EXECSTACK="opt/intel/${PN}/${PV}/*"
32 QA_TEXTRELS="opt/intel/${PN}/${PV}/*"
33
34 get_fcomp() {
35 case $(tc-getFC) in
36 *gfortran* )
37 FCOMP="gfortran" ;;
38 ifort )
39 FCOMP="ifc" ;;
40 * )
41 FCOMP=$(tc-getFC) ;;
42 esac
43 }
44
45 pkg_setup() {
46 fortran-2_pkg_setup
47 # Check the license
48 if [[ -z ${MKL_LICENSE} ]]; then
49 MKL_LICENSE="$(grep -ls MKern ${ROOT}${INTEL_LIC_DIR}/* | tail -n 1)"
50 MKL_LICENSE=${MKL_LICENSE/${ROOT}/}
51 fi
52 if [[ -z ${MKL_LICENSE} ]]; then
53 eerror "Did not find any valid mkl license."
54 eerror "Register at ${HOMEPAGE} to receive a license"
55 eerror "and place it in ${INTEL_LIC_DIR} or run:"
56 eerror "export MKL_LICENSE=/my/license/file emerge mkl"
57 die "license setup failed"
58 fi
59
60 # Check if we have enough free diskspace to install
61 CHECKREQS_DISK_BUILD="1100M"
62 check-reqs_pkg_setup
63
64 # Check and setup fortran
65 if use fortran95; then
66 # blas95 and lapack95 don't compile with gfortran < 4.2
67 [[ $(tc-getFC) =~ (gfortran|g77) ]] && [[ $(gcc-major-version)$(gcc-minor-version) -lt 42 ]] &&
68 die "blas95 and lapack95 don't compile with gfortran < 4.2"
69 fi
70 MKL_FC="gnu"
71 [[ $(tc-getFC) =~ if ]] && MKL_FC="intel"
72
73 # build profiles according to what compiler is installed
74 MKL_CC="gnu"
75 [[ $(tc-getCC) == icc ]] && MKL_CC="intel"
76
77 if has_version sys-cluster/mpich; then
78 MKL_MPI=mpich
79 elif has_version sys-cluster/mpich2; then
80 MKL_MPI=mpich2
81 elif has_version sys-cluster/openmpi; then
82 MKL_MPI=openmpi
83 else
84 MKL_MPI=intelmpi
85 fi
86 get_fcomp
87 }
88
89 src_unpack() {
90
91 unpack ${A}
92 cd l_${PN}_*_${PV}/install
93
94 cp ${MKL_LICENSE} "${WORKDIR}"/
95 MKL_LIC="$(basename ${MKL_LICENSE})"
96
97 # binary blob extractor installs rpm leftovers in /opt/intel
98 addwrite /opt/intel
99 # undocumented features: INSTALLMODE_mkl=NONRPM
100
101 # We need to install mkl non-interactively.
102 # If things change between versions, first do it interactively:
103 # tar xf l_*; ./install.sh --duplicate mkl.ini;
104 # The file will be instman/mkl.ini
105 # Then check it and modify the ebuild-created one below
106 # --norpm is required to be able to install 10.x
107 cat > mkl.ini <<-EOF
108 [MKL]
109 EULA_ACCEPT_REJECT=ACCEPT
110 FLEXLM_LICENSE_LOCATION=${WORKDIR}/${MKL_LIC}
111 INSTALLMODE_mkl=NONRPM
112 INSTALL_DESTINATION=${S}
113 EOF
114 einfo "Extracting ..."
115 ./install \
116 --silent ./mkl.ini \
117 --installpath "${S}" \
118 --log log.txt &> /dev/null
119
120 if [[ -z $(find "${S}" -name libmkl.so) ]]; then
121 eerror "Could not find extracted files"
122 eerror "See ${PWD}/log.txt to see why"
123 die "extracting failed"
124 fi
125 # remove left over
126 rm -f /opt/intel/.*mkl*.log /opt/intel/intel_sdp_products.db
127
128 # remove unused stuff and set up intel names
129 rm -rf "${WORKDIR}"/l_*
130
131 cd "${S}"
132 # allow openmpi to work
133 epatch "${FILESDIR}"/${PN}-10.0.2.018-openmpi.patch
134 # make scalapack tests work for gfortran
135 #epatch "${FILESDIR}"/${PN}-10.0.2.018-tests.patch
136 case ${ARCH} in
137 x86) MKL_ARCH=32
138 MKL_KERN=ia32
139 rm -rf lib*/{em64t,64}
140 ;;
141
142 amd64) MKL_ARCH=em64t
143 MKL_KERN=em64t
144 rm -rf lib*/{32,64}
145 ;;
146
147 ia64) MKL_ARCH=64
148 MKL_KERN=ipf
149 rm -rf lib*/{32,em64t}
150 ;;
151 esac
152 MKL_LIBDIR=${MKL_DIR}/lib/${MKL_ARCH}
153 # fix env scripts
154 sed -i \
155 -e "s:${S}:${MKL_DIR}:g" \
156 tools/environment/*sh || die "sed support file failed"
157 }
158
159 src_compile() {
160 cd "${S}"/interfaces
161 if use fortran95; then
162 einfo "Compiling fortan95 static lib wrappers"
163 local myconf="lib${MKL_ARCH}"
164 [[ $(tc-getFC) =~ gfortran ]] && \
165 myconf="${myconf} FC=gfortran"
166 if use int64; then
167 myconf="${myconf} interface=ilp64"
168 [[ $(tc-getFC) =~ gfortran ]] && \
169 myconf="${myconf} FOPTS=-fdefault-integer-8"
170 fi
171 for x in blas95 lapack95; do
172 pushd ${x}
173 emake ${myconf} || die "emake ${x} failed"
174 popd
175 done
176 fi
177
178 if use fftw; then
179 local fftwdirs="fftw2xc fftw2xf fftw3xc fftw3xf"
180 local myconf="lib${MKL_ARCH} compiler=${MKL_CC}"
181 if use mpi; then
182 fftwdirs="${fftwdirs} fftw2x_cdft"
183 myconf="${myconf} mpi=${MKL_MPI}"
184 fi
185 einfo "Compiling fftw static lib wrappers"
186 for x in ${fftwdirs}; do
187 pushd ${x}
188 emake ${myconf} || die "emake ${x} failed"
189 popd
190 done
191 fi
192 }
193
194 src_test() {
195 cd "${S}"/tests
196 local myconf
197 local testdirs="blas cblas"
198 use int64 && myconf="${myconf} interface=ilp64"
199 # buggy with g77 and gfortran
200 #if use mpi; then
201 # testdirs="${testdirs} scalapack"
202 # myconf="${myconf} mpi=${MKL_MPI}"
203 #fi
204 for x in ${testdirs}; do
205 pushd ${x}
206 einfo "Testing ${x}"
207 emake \
208 compiler=${MKL_FC} \
209 ${myconf} \
210 so${MKL_ARCH} \
211 || die "emake ${x} failed"
212 popd
213 done
214 }
215
216 mkl_make_generic_profile() {
217 cd "${S}"
218 # produce eselect files
219 # don't make them in FILESDIR, it changes every major version
220 cat > eselect.blas <<-EOF
221 ${MKL_LIBDIR}/libmkl_${MKL_KERN}.a /usr/@LIBDIR@/libblas.a
222 ${MKL_LIBDIR}/libmkl.so /usr/@LIBDIR@/libblas.so
223 ${MKL_LIBDIR}/libmkl.so /usr/@LIBDIR@/libblas.so.0
224 EOF
225 cat > eselect.cblas <<-EOF
226 ${MKL_LIBDIR}/libmkl_${MKL_KERN}.a /usr/@LIBDIR@/libcblas.a
227 ${MKL_LIBDIR}/libmkl.so /usr/@LIBDIR@/libcblas.so
228 ${MKL_LIBDIR}/libmkl.so /usr/@LIBDIR@/libcblas.so.0
229 ${MKL_DIR}/include/mkl_cblas.h /usr/include/cblas.h
230 EOF
231 cat > eselect.lapack <<-EOF
232 ${MKL_LIBDIR}/libmkl_lapack.a /usr/@LIBDIR@/liblapack.a
233 ${MKL_LIBDIR}/libmkl_lapack.so /usr/@LIBDIR@/liblapack.so
234 ${MKL_LIBDIR}/libmkl_lapack.so /usr/@LIBDIR@/liblapack.so.0
235 EOF
236 }
237
238 # usage: mkl_add_profile <profile> <interface_lib> <thread_lib> <rtl_lib>
239 mkl_add_profile() {
240 cd "${S}"
241 local prof=${1}
242 for x in blas cblas lapack; do
243 cat > ${x}-${prof}.pc <<-EOF
244 prefix=${MKL_DIR}
245 libdir=${MKL_LIBDIR}
246 includedir=\${prefix}/include
247 Name: ${x}
248 Description: Intel(R) Math Kernel Library implementation of ${x}
249 Version: ${PV}
250 URL: ${HOMEPAGE}
251 EOF
252 done
253 cat >> blas-${prof}.pc <<-EOF
254 Libs: -Wl,--no-as-needed -L\${libdir} ${2} ${3} -lmkl_core ${4} -lpthread
255 EOF
256 cat >> cblas-${prof}.pc <<-EOF
257 Requires: blas
258 Libs: -Wl,--no-as-needed -L\${libdir} ${2} ${3} -lmkl_core ${4} -lpthread
259 Cflags: -I\${includedir}
260 EOF
261 cat >> lapack-${prof}.pc <<-EOF
262 Requires: blas
263 Libs: -Wl,--no-as-needed -L\${libdir} ${2} ${3} -lmkl_core -lmkl_lapack ${4} -lpthread
264 EOF
265 insinto ${MKL_LIBDIR}
266 for x in blas cblas lapack; do
267 doins ${x}-${prof}.pc
268 cp eselect.${x} eselect.${x}.${prof}
269 echo "${MKL_LIBDIR}/${x}-${prof}.pc /usr/@LIBDIR@/pkgconfig/${x}.pc" \
270 >> eselect.${x}.${prof}
271 eselect ${x} add $(get_libdir) eselect.${x}.${prof} ${prof}
272 done
273 }
274
275 mkl_make_profiles() {
276 local clib
277 has_version 'dev-lang/ifc' && clib="intel"
278 built_with_use sys-devel/gcc fortran && clib="${clib} gf"
279 local slib="-lmkl_sequential"
280 local rlib="-liomp5"
281 local pbase=${PN}
282 for c in ${clib}; do
283 local ilib="-lmkl_${c}_lp64"
284 use x86 && ilib="-lmkl_${c}"
285 local tlib="-lmkl_${c/gf/gnu}_thread"
286 local comp="${c/gf/gfortran}"
287 comp="${comp/intel/ifort}"
288 mkl_add_profile ${pbase}-${comp} ${ilib} ${slib}
289 mkl_add_profile ${pbase}-${comp}-threads ${ilib} ${tlib} ${rlib}
290 if use int64; then
291 ilib="-lmkl_${c}_ilp64"
292 mkl_add_profile ${pbase}-${comp}-int64 ${ilib} ${slib}
293 mkl_add_profile ${pbase}-${comp}-threads-int64 ${ilib} ${tlib} ${rlib}
294 fi
295 done
296 }
297
298 src_install() {
299 dodir ${MKL_DIR}
300
301 # install license
302 if [[ ! -f ${INTEL_LIC_DIR}/${MKL_LIC} ]]; then
303 insinto ${INTEL_LIC_DIR}
304 doins "${WORKDIR}"/${MKL_LIC} || die "install license failed"
305 fi
306
307 # install main stuff: cp faster than doins
308 einfo "Installing files..."
309 local cpdirs="benchmarks doc examples include interfaces lib man tests"
310 local doinsdirs="tools"
311 cp -pPR ${cpdirs} "${D}"${MKL_DIR} \
312 || die "installing mkl failed"
313 insinto ${MKL_DIR}
314 doins -r ${doinsdirs} || die "doins ${doinsdirs} failed"
315 dosym mkl_cblas.h ${MKL_DIR}/include/cblas.h
316
317 # install blas/lapack profiles
318 mkl_make_generic_profile
319 mkl_make_profiles
320
321 # install env variables
322 cat > 35mkl <<-EOF
323 MKLROOT=${MKL_DIR}
324 LDPATH=${MKL_LIBDIR}
325 MANPATH=${MKL_DIR}/man
326 EOF
327 doenvd 35mkl || die "doenvd failed"
328 }
329
330 pkg_postinst() {
331 # if blas profile is mkl, set lapack and cblas profiles as mkl
332 local blas_prof=$(eselect blas show | cut -d' ' -f2)
333 local def_prof="mkl-gfortran-threads"
334 has_version 'dev-lang/ifc' && def_prof="mkl-ifort-threads"
335 use int64 && def_prof="${def_prof}-int64"
336 for x in blas cblas lapack; do
337 local cur_prof=$(eselect ${x} show | cut -d' ' -f2)
338 if [[ -z ${cur_prof} || ${cur_prof} == ${def_prof} ]]; then
339 # work around eselect bug #189942
340 local configfile="${ROOT}"/etc/env.d/${x}/$(get_libdir)/config
341 [[ -e ${configfile} ]] && rm -f ${configfile}
342 eselect ${x} set ${def_prof}
343 elog "${x} has been eselected to ${def_prof}"
344 else
345 elog "Current eselected ${x} is ${current_lib}"
346 elog "To use one of mkl profiles, issue (as root):"
347 elog "\t eselect ${x} set <profile>"
348 fi
349 if [[ ${blas_prof} == mkl* && ${cur_prof} != ${blas_prof} ]]; then
350 eselect blas set ${def_prof}
351 elog "${x} is now set to ${def_prof} for consistency"
352 fi
353 done
354 if [[ $(gcc-major-version)$(gcc-minor-version) -lt 42 ]]; then
355 elog "Multi-threading OpenMP for GNU compilers only available"
356 elog "with gcc >= 4.2. Make sure you have a compatible version"
357 elog "and select it with gcc-config before selecting gnu profiles"
358 fi
359 }

  ViewVC Help
Powered by ViewVC 1.1.20