Gentoo Archives: gentoo-commits

From: Justin Lecher <jlec@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/sci:master commit in: sci-libs/openblas/
Date: Mon, 30 Nov 2015 10:58:16
Message-Id: 1448877184.b732e197ccd3fac26ad8fe3d74864688471b9128.jlec@gentoo
1 commit: b732e197ccd3fac26ad8fe3d74864688471b9128
2 Author: Justin Lecher <jlec <AT> gentoo <DOT> org>
3 AuthorDate: Mon Nov 30 09:53:04 2015 +0000
4 Commit: Justin Lecher <jlec <AT> gentoo <DOT> org>
5 CommitDate: Mon Nov 30 09:53:04 2015 +0000
6 URL: https://gitweb.gentoo.org/proj/sci.git/commit/?id=b732e197
7
8 sci-libs/openblas: Version Bump
9
10 Package-Manager: portage-2.2.25
11 Signed-off-by: Justin Lecher <jlec <AT> gentoo.org>
12
13 sci-libs/openblas/openblas-0.2.15.ebuild | 193 +++++++++++++++++++++++++++++++
14 1 file changed, 193 insertions(+)
15
16 diff --git a/sci-libs/openblas/openblas-0.2.15.ebuild b/sci-libs/openblas/openblas-0.2.15.ebuild
17 new file mode 100644
18 index 0000000..3a92aef
19 --- /dev/null
20 +++ b/sci-libs/openblas/openblas-0.2.15.ebuild
21 @@ -0,0 +1,193 @@
22 +# Copyright 1999-2015 Gentoo Foundation
23 +# Distributed under the terms of the GNU General Public License v2
24 +# $Id$
25 +
26 +EAPI=5
27 +
28 +NUMERIC_MODULE_NAME="openblas"
29 +
30 +inherit alternatives-2 numeric numeric-int64-multibuild
31 +
32 +DESCRIPTION="Optimized BLAS library based on GotoBLAS2"
33 +HOMEPAGE="http://xianyi.github.com/OpenBLAS/"
34 +SRC_URI="
35 + http://github.com/xianyi/OpenBLAS/tarball/v${PV} -> ${P}.tar.gz
36 + http://dev.gentoo.org/~gienah/distfiles/${PN}-0.2.11-gentoo.patch"
37 +
38 +LICENSE="BSD"
39 +SLOT="0"
40 +KEYWORDS="~amd64 ~x86 ~amd64-linux ~x86-linux ~x86-macos ~ppc-macos ~x64-macos"
41 +IUSE="dynamic openmp static-libs threads"
42 +
43 +RDEPEND=""
44 +DEPEND="${RDEPEND}
45 + virtual/pkgconfig"
46 +
47 +MULTILIB_WRAPPED_HEADERS=(
48 + /usr/include/openblas/cblas.h
49 + /usr/include/openblas/f77blas.h
50 + /usr/include/openblas/openblas_config.h
51 +)
52 +
53 +get_openblas_flags() {
54 + local openblas_flags=()
55 + use dynamic && \
56 + openblas_flags+=( DYNAMIC_ARCH=1 TARGET=GENERIC NUM_THREADS=64 NO_AFFINITY=1 )
57 + $(numeric-int64_is_int64_build) && \
58 + openblas_flags+=( INTERFACE64=1 )
59 + # choose posix threads over openmp when the two are set
60 + # yet to see the need of having the two profiles simultaneously
61 + if use threads; then
62 + openblas_flags+=( USE_THREAD=1 USE_OPENMP=0 )
63 + elif use openmp; then
64 + openblas_flags+=( USE_OPENMP=1 )
65 + fi
66 + local profname=$(numeric-int64_get_module_name)
67 + local libname="${profname//-/_}"
68 + local underscoresuffix="${libname#${PN}}"
69 + if [[ "${underscoresuffix}" != "_" ]]; then
70 + local libnamesuffix="${underscoresuffix#_}"
71 + openblas_flags+=( LIBNAMESUFFIX=${libnamesuffix} )
72 + fi
73 + echo "${openblas_flags[@]}"
74 +}
75 +
76 +get_openblas_abi_cflags() {
77 + local openblas_abi_cflags=()
78 + if [[ "${ABI}" == "x86" ]]; then
79 + openblas_abi_cflags=( -DOPENBLAS_ARCH_X86=1 -DOPENBLAS___32BIT__=1 )
80 + else
81 + openblas_abi_cflags=( -DOPENBLAS_ARCH_X86_64=1 -DOPENBLAS___64BIT__=1 )
82 + fi
83 + $(numeric-int64_is_int64_build) && \
84 + openblas_abi_cflags+=( -DOPENBLAS_USE64BITINT )
85 + echo "${openblas_abi_cflags[@]}"
86 +}
87 +
88 +src_unpack() {
89 + default
90 + find "${WORKDIR}" -maxdepth 1 -type d -name \*OpenBLAS\* && \
91 + mv "${WORKDIR}"/*OpenBLAS* "${S}" || die
92 +}
93 +
94 +src_prepare() {
95 + epatch "${DISTDIR}/${PN}-0.2.11-gentoo.patch"
96 +
97 + # lapack and lapacke are not modified from upstream lapack
98 + sed \
99 + -e "s:^#\s*\(NO_LAPACK\)\s*=.*:\1=1:" \
100 + -e "s:^#\s*\(NO_LAPACKE\)\s*=.*:\1=1:" \
101 + -i Makefile.rule || die
102 + numeric-int64-multibuild_copy_sources
103 +}
104 +
105 +src_configure() {
106 + blas_configure() {
107 + local openblas_abi_cflags="$(get_openblas_abi_cflags)"
108 + local internal_openblas_abi_cflags="${openblas_abi_cflags//OPENBLAS_}"
109 + sed \
110 + -e "s:^#\s*\(CC\)\s*=.*:\1=$(tc-getCC) $(get_abi_CFLAGS):" \
111 + -e "s:^#\s*\(FC\)\s*=.*:\1=$(tc-getFC) $(get_abi_CFLAGS):" \
112 + -e "s:^#\s*\(COMMON_OPT\)\s*=.*:\1=${CFLAGS} ${internal_openblas_abi_cflags}:" \
113 + -i Makefile.rule || die
114 + }
115 + numeric-int64-multibuild_foreach_all_abi_variants run_in_build_dir blas_configure
116 +}
117 +
118 +src_compile() {
119 + # openblas already does multi-jobs
120 + MAKEOPTS+=" -j1"
121 + my_src_compile () {
122 + local openblas_flags=$(get_openblas_flags)
123 + # cflags already defined twice
124 + unset CFLAGS || die
125 + emake clean && emake libs shared ${openblas_flags}
126 + mkdir -p libs && mv libopenblas* libs/ || die
127 + # avoid pic when compiling static libraries, so re-compiling
128 + if use static-libs; then
129 + emake clean
130 + emake libs ${openblas_flags} NO_SHARED=1 NEED_PIC=
131 + mv libopenblas* libs/ || die
132 + fi
133 + # Fix Bug 524612 - [science overlay] sci-libs/openblas-0.2.11 - Assembler messages:
134 + # ../kernel/x86_64/gemm_kernel_8x4_barcelona.S:451: Error: missing ')'
135 + # The problem is applying this patch in src_prepare() causes build failures on
136 + # assembler code as the assembler does not understand sizeof(float). So
137 + # delay applying the patch until after building the libraries.
138 + epatch "${FILESDIR}/${PN}-0.2.11-openblas_config_header_same_between_ABIs.patch"
139 + rm -f config.h config_last.h || die
140 + # Note: prints this spurious warning: make: Nothing to be done for 'config.h'.
141 + emake config.h
142 + cp config.h config_last.h || die
143 +
144 + mv libs/libopenblas* . || die
145 + }
146 + numeric-int64-multibuild_foreach_all_abi_variants run_in_build_dir my_src_compile
147 +}
148 +
149 +src_test() {
150 + my_src_test () {
151 + local openblas_flags=$(get_openblas_flags)
152 + emake tests ${openblas_flags}
153 + }
154 + numeric-int64-multibuild_foreach_all_abi_variants run_in_build_dir my_src_test
155 +}
156 +
157 +src_install() {
158 + my_src_install() {
159 + local openblas_flags=$(get_openblas_flags)
160 + local profname=$(numeric-int64_get_module_name)
161 + local pcfile
162 + # The file /usr/include/openblas/openblas_config.h is generated during the install.
163 + # The sed on config_last.h removes the #define's OPENBLAS_USE64BITINT
164 + # OPENBLASS__32BIT__ OPENBLASS__64BIT__ OPENBLAS__ARCH_X86 OPENBLAS__ARCH_X86_64
165 + # from /usr/include/openblas/openblas_config.h. We then specify it in Cflags in
166 + # the /usr/lib64/pkg-config/openblas-int64-{threads,openmp}.pc file.
167 + sed -e '/#define USE64BITINT/d' \
168 + -e '/#define ARCH_X86/d' \
169 + -e '/#define __\(32\|64\)BIT__/d' \
170 + -i config_last.h \
171 + || die "Could not ensure there is no definition of USE64BITINT in config_last.h"
172 + emake install \
173 + PREFIX="${ED}"usr ${openblas_flags} \
174 + OPENBLAS_INCLUDE_DIR="${ED}"usr/include/${PN} \
175 + OPENBLAS_LIBRARY_DIR="${ED}"usr/$(get_libdir)
176 + if ! use static-libs; then
177 + rm "${ED}"usr/$(get_libdir)/lib*.a || die
178 + fi
179 +
180 + local openblas_abi_cflags=$(get_openblas_abi_cflags)
181 + local openblas_abi_fflags=$(numeric-int64_get_fortran_int64_abi_fflags)
182 + local libname="${profname//-/_}"
183 +
184 + create_pkgconfig \
185 + --name "${profname}" \
186 + --libs "-L\${libdir} -l${libname}" \
187 + --libs-private "-lm" \
188 + --cflags "-I\${includedir}/${PN} ${openblas_abi_cflags}" \
189 + ${profname}
190 +
191 + if [[ ${CHOST} == *-darwin* ]] ; then
192 + cd "${ED}"/usr/$(get_libdir) || die
193 + local d
194 + for d in *.dylib; do
195 + ebegin "Correcting install_name of ${d}"
196 + install_name_tool -id "${EPREFIX}/usr/$(get_libdir)/${d}" "${d}" || die
197 + eend $?
198 + done
199 + fi
200 + if [[ ${#MULTIBUILD_VARIANTS[@]} -gt 1 ]]; then
201 + multilib_prepare_wrappers
202 + multilib_check_headers
203 + fi
204 + }
205 + numeric-int64-multibuild_foreach_all_abi_variants run_in_build_dir my_src_install
206 +
207 + printf "/usr/include/cblas.h ${PN}/cblas.h" > "${T}"/alternative-cblas-generic.sh || die
208 + numeric-int64-multibuild_install_alternative blas ${NUMERIC_MODULE_NAME}
209 + numeric-int64-multibuild_install_alternative cblas ${NUMERIC_MODULE_NAME}
210 +
211 + multilib_install_wrappers
212 +
213 + dodoc GotoBLAS_{01Readme,03FAQ,04FAQ,05LargePage,06WeirdPerformance}.txt *md Changelog.txt
214 +}