blob: e0af7128767f48b3a4a0e68abe04a0ba11949494 (
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
|
# Copyright 1999-2011 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: $
EAPI=4
inherit eutils toolchain-funcs alternatives-2 git-2
DESCRIPTION="Optimized BLAS library based on GotoBLAS2"
HOMEPAGE="http://xianyi.github.com/OpenBLAS/"
EGIT_REPO_URI="git://github.com/xianyi/OpenBLAS.git"
LICENSE="BSD"
SLOT="0"
KEYWORDS="~amd64 ~x86"
IUSE="+incblas int64 dynamic openmp static-libs threads"
RDEPEND="virtual/fortran"
DEPEND="${RDEPEND}"
S="${WORKDIR}/${MYPN}"
src_prepare() {
epatch "${FILESDIR}"/${PN}-{sharedlibs,aliasing}.patch
# respect LDFLAGS
sed -i -e '/^LDFLAGS\s*=/d' Makefile.* || die
# respect CFLAGS only if dynamic flag not enabled
if ! use dynamic; then
sed -i \
-e "/^COMMON_OPT/s/-O2/${CFLAGS}/" \
Makefile.rule || die
fi
# fix executable stacks
local i
for i in $(find . -name \*.S); do
cat >> ${i} <<-EOF
#if defined(__ELF__)
.section .note.GNU-stack,"",%progbits
#endif
EOF
done
}
src_configure() {
local use_openmp=$(use openmp && echo 1)
use threads && use openmp && use_openmp="" && \
einfo "openmp and threads enabled: using threads"
sed -i \
-e "s:^#\s*\(NO_LAPACK\)\s*=.*:\1=1:" \
-e "s:^#\s*\(CC\)\s*=.*:\1=$(tc-getCC):" \
-e "s:^#\s*\(FC\)\s*=.*:\1=$(tc-getFC):" \
-e "s:^#\s*\(USE_THREAD\)\s*=.*:\1=$(use threads && echo 1 || echo 0):" \
-e "s:^#\s*\(USE_OPENMP\)\s*=.*:\1=${use_openmp}:" \
-e "s:^#\s*\(DYNAMIC_ARCH\)\s*=.*:\1=$(use dynamic && echo 1):" \
-e "s:^#\s*\(INTERFACE64\)\s*=.*:\1=$(use int64 && echo 1):" \
-e "s:^#\s*\(NO_CBLAS\)\s*=.*:\1=$(use incblas || echo 1):" \
Makefile.rule || die
}
src_compile() {
mkdir solibs
emake libs shared && mv *.so solibs/
use static-libs && emake clean && emake libs NEED_PIC=
}
src_test() {
emake tests
}
src_install() {
local profname=${PN} threads
use int64 && profname=${profname}-int64
if use threads; then
threads="-pthread"
profname=${profname}-threads
elif use openmp; then
profname=${profname}-openmp
fi
dolib.so solibs/lib*.so
use static-libs && dolib.a lib*.a
# create pkg-config file and associated eselect file
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 -lm ${threads}
EOF
insinto /usr/$(get_libdir)/pkgconfig
doins ${profname}.pc
alternatives_for blas ${profname} 0 \
"/usr/$(get_libdir)/pkgconfig/blas.pc" "${profname}.pc"
if use incblas; then
insinto /usr/include/${PN}
doins cblas.h || die
echo >> ${profname}.pc "Cflags: -I\${includedir}/${PN}"
alternatives_for cblas ${profname} 0 \
"/usr/$(get_libdir)/pkgconfig/cblas.pc" "${profname}.pc" \
"/usr/include/cblas.h" "${PN}/cblas.h"
fi
dodoc GotoBLAS_{01Readme,03FAQ,04FAQ,05LargePage,06WeirdPerformance}.txt
}
|