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/, sci-libs/openblas/files/
Date: Sat, 29 Apr 2017 09:50:48
Message-Id: 1493297186.bb7078923091f3a7e8acddde6a84b3acafd28c5b.jlec@gentoo
1 commit: bb7078923091f3a7e8acddde6a84b3acafd28c5b
2 Author: François Bissey <francois.bissey <AT> canterbury <DOT> ac <DOT> nz>
3 AuthorDate: Thu Apr 27 12:46:26 2017 +0000
4 Commit: Justin Lecher <jlec <AT> gentoo <DOT> org>
5 CommitDate: Thu Apr 27 12:46:26 2017 +0000
6 URL: https://gitweb.gentoo.org/proj/sci.git/commit/?id=bb707892
7
8 sci-libs/openblas: Bump openblas to 0.2.19 (#779)
9
10 * sci-libs/openblas: Bump openblas to latest
11
12 Package-Manager: portage-2.3.3
13
14 * sci-libs/openblas: add a few upstreamed patches
15
16 Package-Manager: portage-2.3.3
17
18 sci-libs/openblas/files/openblas-0.2.19-MAKE.patch | 29 +++
19 .../files/openblas-0.2.19-utest_ldflags.patch | 13 ++
20 sci-libs/openblas/openblas-0.2.19.ebuild | 199 +++++++++++++++++++++
21 3 files changed, 241 insertions(+)
22
23 diff --git a/sci-libs/openblas/files/openblas-0.2.19-MAKE.patch b/sci-libs/openblas/files/openblas-0.2.19-MAKE.patch
24 new file mode 100644
25 index 000000000..c77dd0f93
26 --- /dev/null
27 +++ b/sci-libs/openblas/files/openblas-0.2.19-MAKE.patch
28 @@ -0,0 +1,29 @@
29 +diff --git a/Makefile b/Makefile
30 +index 2ae0047..2071e10 100644
31 +--- a/Makefile
32 ++++ b/Makefile
33 +@@ -278,13 +278,13 @@ lapack-timing : large.tgz timing.tgz
34 + ifndef NOFORTRAN
35 + (cd $(NETLIB_LAPACK_DIR); $(TAR) zxf ../timing.tgz TIMING)
36 + (cd $(NETLIB_LAPACK_DIR)/TIMING; $(TAR) zxf ../../large.tgz )
37 +- make -C $(NETLIB_LAPACK_DIR)/TIMING
38 ++ $(MAKE) -C $(NETLIB_LAPACK_DIR)/TIMING
39 + endif
40 +
41 +
42 + lapack-test :
43 + (cd $(NETLIB_LAPACK_DIR)/TESTING && rm -f x* *.out)
44 +- make -j 1 -C $(NETLIB_LAPACK_DIR)/TESTING xeigtstc xeigtstd xeigtsts xeigtstz xlintstc xlintstd xlintstds xlintstrfd xlintstrfz xlintsts xlintstz xlintstzc xlintstrfs xlintstrfc
45 ++ $(MAKE) -j 1 -C $(NETLIB_LAPACK_DIR)/TESTING xeigtstc xeigtstd xeigtsts xeigtstz xlintstc xlintstd xlintstds xlintstrfd xlintstrfz xlintsts xlintstz xlintstzc xlintstrfs xlintstrfc
46 + ifneq ($(CROSS), 1)
47 + ( cd $(NETLIB_LAPACK_DIR)/INSTALL; ./testlsame; ./testslamch; ./testdlamch; \
48 + ./testsecond; ./testdsecnd; ./testieee; ./testversion )
49 +@@ -299,7 +299,7 @@ lapack-runtest:
50 +
51 + blas-test:
52 + (cd $(NETLIB_LAPACK_DIR)/BLAS && rm -f x* *.out)
53 +- make -j 1 -C $(NETLIB_LAPACK_DIR) blas_testing
54 ++ $(MAKE) -j 1 -C $(NETLIB_LAPACK_DIR) blas_testing
55 + (cd $(NETLIB_LAPACK_DIR)/BLAS && cat *.out)
56 +
57 +
58
59 diff --git a/sci-libs/openblas/files/openblas-0.2.19-utest_ldflags.patch b/sci-libs/openblas/files/openblas-0.2.19-utest_ldflags.patch
60 new file mode 100644
61 index 000000000..2ffd5babe
62 --- /dev/null
63 +++ b/sci-libs/openblas/files/openblas-0.2.19-utest_ldflags.patch
64 @@ -0,0 +1,13 @@
65 +diff --git a/utest/Makefile b/utest/Makefile
66 +index 3ccc0a0..ce809e3 100644
67 +--- a/utest/Makefile
68 ++++ b/utest/Makefile
69 +@@ -18,7 +18,7 @@ endif
70 + all : run_test
71 +
72 + $(UTESTBIN): $(OBJS)
73 +- $(CC) $(CFLAGS) -o $@ $^ ../$(LIBNAME) $(EXTRALIB) $(FEXTRALIB)
74 ++ $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ ../$(LIBNAME) $(EXTRALIB) $(FEXTRALIB)
75 +
76 + run_test: $(UTESTBIN)
77 + ifndef CROSS
78
79 diff --git a/sci-libs/openblas/openblas-0.2.19.ebuild b/sci-libs/openblas/openblas-0.2.19.ebuild
80 new file mode 100644
81 index 000000000..3ff5f8502
82 --- /dev/null
83 +++ b/sci-libs/openblas/openblas-0.2.19.ebuild
84 @@ -0,0 +1,199 @@
85 +# Copyright 1999-2017 Gentoo Foundation
86 +# Distributed under the terms of the GNU General Public License v2
87 +
88 +EAPI=6
89 +
90 +NUMERIC_MODULE_NAME="openblas"
91 +
92 +inherit alternatives-2 eutils multilib numeric numeric-int64-multibuild
93 +
94 +DESCRIPTION="Optimized BLAS library based on GotoBLAS2"
95 +HOMEPAGE="http://xianyi.github.com/OpenBLAS/"
96 +SRC_URI="http://github.com/xianyi/OpenBLAS/tarball/v${PV} -> ${P}.tar.gz
97 + http://sagetrac.lipn.univ-paris13.fr/sage/${PN}-0.2.19-clang-3.9.patch"
98 +
99 +LICENSE="BSD"
100 +SLOT="0"
101 +KEYWORDS="~amd64 ~x86 ~amd64-linux ~x86-linux ~x86-macos ~ppc64 ~x64-macos"
102 +IUSE="dynamic openmp static-libs threads"
103 +
104 +RDEPEND=""
105 +DEPEND="${RDEPEND}
106 + virtual/pkgconfig"
107 +
108 +MULTILIB_WRAPPED_HEADERS=(
109 + /usr/include/openblas/cblas.h
110 + /usr/include/openblas/f77blas.h
111 + /usr/include/openblas/openblas_config.h
112 +)
113 +
114 +PATCHES=(
115 + "${DISTDIR}"/${PN}-0.2.19-clang-3.9.patch
116 + "${FILESDIR}"/${PN}-0.2.19-MAKE.patch
117 + "${FILESDIR}"/${PN}-0.2.19-utest_ldflags.patch
118 + )
119 +
120 +get_openblas_flags() {
121 + local openblas_flags=()
122 + use dynamic && \
123 + openblas_flags+=( DYNAMIC_ARCH=1 TARGET=GENERIC NUM_THREADS=64 NO_AFFINITY=1 )
124 + $(numeric-int64_is_int64_build) && \
125 + openblas_flags+=( INTERFACE64=1 )
126 + # choose posix threads over openmp when the two are set
127 + # yet to see the need of having the two profiles simultaneously
128 + if use threads; then
129 + openblas_flags+=( USE_THREAD=1 USE_OPENMP=0 )
130 + elif use openmp; then
131 + openblas_flags+=( USE_OPENMP=1 )
132 + fi
133 + local profname=$(numeric-int64_get_module_name)
134 + local libname="${profname//-/_}"
135 + local underscoresuffix="${libname#${PN}}"
136 + if [[ "${underscoresuffix}" != "_" ]]; then
137 + local libnamesuffix="${underscoresuffix#_}"
138 + openblas_flags+=( LIBNAMESUFFIX=${libnamesuffix} )
139 + fi
140 +
141 + [[ "${ABI}" == "x86" ]] && openblas_flags+=( BINARY=32 )
142 +
143 + echo "${openblas_flags[@]}"
144 +}
145 +
146 +get_openblas_abi_cflags() {
147 + local openblas_abi_cflags=()
148 + if [[ "${ABI}" == "x86" ]]; then
149 + openblas_abi_cflags=( -DARCH_X86=1 -DOPENBLAS___32BIT__=1 )
150 + elif [[ "${ABI}" == "amd64" ]]; then
151 + openblas_abi_cflags=( -DARCH_X86_64=1 -DOPENBLAS___64BIT__=1 )
152 + elif [[ "${ABI}" == "ppc64" ]]; then
153 + openblas_abi_cflags=( -DARCH_POWER=1 -DOPENBLAS___64BIT__=1 )
154 + else
155 + die "unsupported abi: ${ABI}"
156 + fi
157 + $(numeric-int64_is_int64_build) && \
158 + openblas_abi_cflags+=( -DOPENBLAS_USE64BITINT )
159 + use openmp && openblas_abi_cflags+=( -fopenmp )
160 + echo "${openblas_abi_cflags[@]}"
161 +}
162 +
163 +src_unpack() {
164 + default
165 + find "${WORKDIR}" -maxdepth 1 -type d -name \*OpenBLAS\* && \
166 + mv "${WORKDIR}"/*OpenBLAS* "${S}" || die
167 +}
168 +
169 +src_prepare() {
170 + default
171 +
172 + # lapack and lapacke are not modified from upstream lapack
173 + sed \
174 + -e "s:^#\s*\(NO_LAPACK\)\s*=.*:\1=1:" \
175 + -e "s:^#\s*\(NO_LAPACKE\)\s*=.*:\1=1:" \
176 + -i Makefile.rule || die
177 + numeric-int64-multibuild_copy_sources
178 +}
179 +
180 +src_configure() {
181 + blas_configure() {
182 + local openblas_abi_cflags="$(get_openblas_abi_cflags)"
183 + local internal_openblas_abi_cflags="${openblas_abi_cflags//OPENBLAS_}"
184 + sed \
185 + -e "s:^#\s*\(CC\)\s*=.*:\1=$(tc-getCC) $(get_abi_CFLAGS):" \
186 + -e "s:^#\s*\(FC\)\s*=.*:\1=$(tc-getFC) $(get_abi_CFLAGS):" \
187 + -e "s:^#\s*\(COMMON_OPT\)\s*=.*:\1=${CFLAGS} ${internal_openblas_abi_cflags}:" \
188 + -i Makefile.rule || die
189 + }
190 + numeric-int64-multibuild_foreach_all_abi_variants run_in_build_dir blas_configure
191 +}
192 +
193 +src_compile() {
194 + # openblas already does multi-jobs
195 + MAKEOPTS+=" -j1"
196 + my_src_compile () {
197 + local openblas_flags=$(get_openblas_flags)
198 + # cflags already defined twice
199 + unset CFLAGS || die
200 + emake clean && emake libs shared ${openblas_flags}
201 + mkdir -p libs && mv libopenblas* libs/ ||??die
202 + # avoid pic when compiling static libraries, so re-compiling
203 + if use static-libs; then
204 + emake clean
205 + emake libs ${openblas_flags} NO_SHARED=1 NEED_PIC=
206 + mv libopenblas* libs/ ||??die
207 + fi
208 + rm -f config.h config_last.h || die
209 + # Note: prints this spurious warning: make: Nothing to be done for 'config.h'.
210 + emake config.h
211 + cp config.h config_last.h || die
212 +
213 + mv libs/libopenblas* . || die
214 + }
215 + numeric-int64-multibuild_foreach_all_abi_variants run_in_build_dir my_src_compile
216 +}
217 +
218 +src_test() {
219 + my_src_test () {
220 + local openblas_flags=$(get_openblas_flags)
221 + emake tests ${openblas_flags}
222 + }
223 + numeric-int64-multibuild_foreach_all_abi_variants run_in_build_dir my_src_test
224 +}
225 +
226 +src_install() {
227 + my_src_install() {
228 + local openblas_flags=$(get_openblas_flags)
229 + local profname=$(numeric-int64_get_module_name)
230 + local pcfile
231 + # The file /usr/include/openblas/openblas_config.h is generated during the install.
232 + # The sed on config_last.h removes the #define's OPENBLAS_USE64BITINT
233 + # OPENBLASS__32BIT__ OPENBLASS__64BIT__ OPENBLAS__ARCH_X86 OPENBLAS__ARCH_X86_64
234 + # from /usr/include/openblas/openblas_config.h. We then specify it in Cflags in
235 + # the /usr/lib64/pkg-config/openblas-int64-{threads,openmp}.pc file.
236 + sed -e '/#define USE64BITINT/d' \
237 + -e '/#define ARCH_X86/d' \
238 + -e '/#define __\(32\|64\)BIT__/d' \
239 + -i config_last.h \
240 + || die "Could not ensure there is no definition of USE64BITINT in config_last.h"
241 + emake install \
242 + PREFIX="${ED}"usr ${openblas_flags} \
243 + OPENBLAS_INCLUDE_DIR="${ED}"usr/include/${PN} \
244 + OPENBLAS_LIBRARY_DIR="${ED}"usr/$(get_libdir)
245 + if ! use static-libs; then
246 + rm "${ED}"usr/$(get_libdir)/lib*.a || die
247 + fi
248 +
249 + local openblas_abi_cflags=$(get_openblas_abi_cflags)
250 + local openblas_abi_fflags=$(numeric-int64_get_fortran_int64_abi_fflags)
251 + local libname="${profname//-/_}"
252 +
253 + create_pkgconfig \
254 + --name "${profname}" \
255 + --libs "-L\${libdir} -l${libname}" \
256 + --libs-private "-lm" \
257 + --cflags "-I\${includedir}/${PN} ${openblas_abi_cflags}" \
258 + ${profname}
259 +
260 + if [[ ${CHOST} == *-darwin* ]] ; then
261 + cd "${ED}"/usr/$(get_libdir) ||??die
262 + local d
263 + for d in *.dylib; do
264 + ebegin "Correcting install_name of ${d}"
265 + install_name_tool -id "${EPREFIX}/usr/$(get_libdir)/${d}" "${d}" || die
266 + eend $?
267 + done
268 + fi
269 + if [[ ${#MULTIBUILD_VARIANTS[@]} -gt 1 ]]; then
270 + multilib_prepare_wrappers
271 + multilib_check_headers
272 + fi
273 + }
274 + numeric-int64-multibuild_foreach_all_abi_variants run_in_build_dir my_src_install
275 +
276 + printf "/usr/include/cblas.h ${PN}/cblas.h" > "${T}"/alternative-cblas-generic.sh ||??die
277 + numeric-int64-multibuild_install_alternative blas ${NUMERIC_MODULE_NAME}
278 + numeric-int64-multibuild_install_alternative cblas ${NUMERIC_MODULE_NAME}
279 +
280 + multilib_install_wrappers
281 +
282 + dodoc GotoBLAS_{01Readme,03FAQ,04FAQ,05LargePage,06WeirdPerformance}.txt *md Changelog.txt
283 +}