blob: 96ca05b80738b8f88671ce240a6101ec1026d1de (
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
|
# Copyright 1999-2014 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: $
EAPI=5
inherit eutils toolchain-funcs alternatives-2 multilib fortran-2
DESCRIPTION="Optimized BLAS library based on GotoBLAS2"
HOMEPAGE="http://xianyi.github.com/OpenBLAS/"
SRC_URI="http://github.com/xianyi/OpenBLAS/tarball/v${PV} -> ${P}.tar.gz"
KEYWORDS="~amd64 ~x86 ~amd64-linux ~x86-linux ~x86-macos ~ppc-macos ~x64-macos"
LICENSE="BSD"
SLOT="0"
IUSE="int64 dynamic openmp static-libs threads"
RDEPEND=""
DEPEND="${RDEPEND}"
src_unpack() {
default
find "${WORKDIR}" -maxdepth 1 -type d -name \*OpenBLAS\* && \
mv "${WORKDIR}"/*OpenBLAS* "${S}"
}
src_configure() {
# lapack and lapacke are not modified from upstream lapack
sed -i \
-e "s:^#\s*\(CC\)\s*=.*:\1=$(tc-getCC):" \
-e "s:^#\s*\(FC\)\s*=.*:\1=$(tc-getFC):" \
-e "s:^#\s*\(COMMON_OPT\)\s*=.*:\1=${CFLAGS}:" \
-e "s:^#\s*\(NO_LAPACK\)\s*=.*:\1=1:" \
-e "s:^#\s*\(NO_LAPACKE\)\s*=.*:\1=1:" \
Makefile.rule || die
}
openblas_compile() {
local profname=$1
einfo "Compiling profile ${profname}"
# cflags already defined twice
unset CFLAGS
emake clean
emake libs shared ${openblas_flags}
mkdir -p libs && mv libopenblas* libs/
# avoid pic when compiling static libraries, so re-compiling
if use static-libs; then
emake clean
emake libs ${openblas_flags} NO_SHARED=1 NEED_PIC=
mv libopenblas* libs/
fi
cat <<-EOF > ${profname}.pc
prefix=${EPREFIX}/usr
libdir=\${prefix}/$(get_libdir)
includedir=\${prefix}/include
Name: ${PN}
Description: ${DESCRIPTION}
Version: ${PV}
URL: ${HOMEPAGE}
Libs: -L\${libdir} -lopenblas
Libs.private: -lm
Cflags: -I\${includedir}/${PN}
EOF
}
src_compile() {
# openblas already does multi-jobs
MAKEOPTS+=" -j1"
openblas_flags=""
local openblas_name=openblas
use dynamic && \
openblas_name+="-dynamic" && \
openblas_flags+=" DYNAMIC_ARCH=1 TARGET=GENERIC NUM_THREADS=64 NO_AFFINITY=1"
use int64 && \
openblas_name+="-int64" && \
openblas_flags+=" INTERFACE64=1"
# choose posix threads over openmp when the two are set
# yet to see the need of having the two profiles simultaneously
if use threads; then
openblas_name+="-threads"
openblas_flags+=" USE_THREAD=1 USE_OPENMP=0"
elif use openmp; then
openblas_name+="-openmp"
openblas_flags+=" USE_THREAD=0 USE_OPENMP=1"
fi
openblas_compile ${openblas_name}
mv libs/libopenblas* . || die
}
src_test() {
emake tests ${openblas_flags}
}
src_install() {
local pcfile
for pcfile in *.pc; do
local profname=${pcfile%.pc}
emake install \
PREFIX="${ED}"usr ${openblas_flags} \
OPENBLAS_INCLUDE_DIR="${ED}"usr/include/${PN} \
OPENBLAS_LIBRARY_DIR="${ED}"usr/$(get_libdir)
use static-libs || rm "${ED}"usr/$(get_libdir)/lib*.a
alternatives_for blas ${profname} 0 \
/usr/$(get_libdir)/pkgconfig/blas.pc ${pcfile}
alternatives_for cblas ${profname} 0 \
/usr/$(get_libdir)/pkgconfig/cblas.pc ${pcfile} \
/usr/include/cblas.h ${PN}/cblas.h
insinto /usr/$(get_libdir)/pkgconfig
doins ${pcfile}
done
dodoc GotoBLAS_{01Readme,03FAQ,04FAQ,05LargePage,06WeirdPerformance}.txt
dodoc *md Changelog.txt
if [[ ${CHOST} == *-darwin* ]] ; then
cd "${ED}"/usr/$(get_libdir)
local d
for d in *.dylib ; do
ebegin "Correcting install_name of ${d}"
install_name_tool -id "${EPREFIX}/usr/$(get_libdir)/${d}" "${d}"
eend $?
done
fi
}
|