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, 06 Oct 2014 05:56:42
Message-Id: 1411815957.5b5e9e7d6c21a48ad35d3fc033902201a71a06d4.jlec@gentoo
1 commit: 5b5e9e7d6c21a48ad35d3fc033902201a71a06d4
2 Author: gienah <gienah <AT> gentoo <DOT> org>
3 AuthorDate: Tue Feb 18 14:01:11 2014 +0000
4 Commit: Justin Lecher <jlec <AT> gentoo <DOT> org>
5 CommitDate: Sat Sep 27 11:05:57 2014 +0000
6 URL: http://sources.gentoo.org/gitweb/?p=proj/sci.git;a=commit;h=5b5e9e7d
7
8 multibuild openblas when USE=int64 is specified.
9
10 ---
11 sci-libs/openblas/ChangeLog | 3 +
12 sci-libs/openblas/openblas-9999.ebuild | 221 +++++++++++++++++++++------------
13 2 files changed, 142 insertions(+), 82 deletions(-)
14
15 diff --git a/sci-libs/openblas/ChangeLog b/sci-libs/openblas/ChangeLog
16 index caf34f2..b4f5886 100644
17 --- a/sci-libs/openblas/ChangeLog
18 +++ b/sci-libs/openblas/ChangeLog
19 @@ -2,6 +2,9 @@
20 # Copyright 1999-2014 Gentoo Foundation; Distributed under the GPL v2
21 # $Header: $
22
23 + 18 Feb 2014; Mark Wright <gienah@g.o> openblas-9999.ebuild:
24 + multibuild openblas when USE=int64 is specified.
25 +
26 06 Jan 2014; Justin Lecher <jlec@g.o> openblas-9999.ebuild,
27 metadata.xml:
28 Switch from git-2 to git-r3
29
30 diff --git a/sci-libs/openblas/openblas-9999.ebuild b/sci-libs/openblas/openblas-9999.ebuild
31 index 618c03b..3bd158a 100644
32 --- a/sci-libs/openblas/openblas-9999.ebuild
33 +++ b/sci-libs/openblas/openblas-9999.ebuild
34 @@ -4,7 +4,7 @@
35
36 EAPI=5
37
38 -inherit alternatives-2 eutils fortran-2 git-r3 multilib toolchain-funcs
39 +inherit alternatives-2 eutils fortran-2 git-r3 multilib multibuild toolchain-funcs
40
41 DESCRIPTION="Optimized BLAS library based on GotoBLAS2"
42 HOMEPAGE="http://xianyi.github.com/OpenBLAS/"
43 @@ -14,105 +14,162 @@ EGIT_BRANCH="develop"
44
45 LICENSE="BSD"
46 SLOT="0"
47 -IUSE="int64 dynamic openmp static-libs threads"
48 +IUSE="dynamic int64 openmp static-libs threads"
49 KEYWORDS=""
50
51 -src_configure() {
52 - # lapack and lapacke are not modified from upstream lapack
53 - sed \
54 - -e "s:^#\s*\(CC\)\s*=.*:\1=$(tc-getCC):" \
55 - -e "s:^#\s*\(FC\)\s*=.*:\1=$(tc-getFC):" \
56 - -e "s:^#\s*\(COMMON_OPT\)\s*=.*:\1=${CFLAGS}:" \
57 - -e "s:^#\s*\(NO_LAPACK\)\s*=.*:\1=1:" \
58 - -e "s:^#\s*\(NO_LAPACKE\)\s*=.*:\1=1:" \
59 - -i Makefile.rule || die
60 -}
61 -
62 -openblas_compile() {
63 - local profname=$1
64 - einfo "Compiling profile ${profname}"
65 - # cflags already defined twice
66 - unset CFLAGS
67 - emake clean
68 - emake libs shared ${openblas_flags}
69 - mkdir -p libs && mv libopenblas* libs/
70 - # avoid pic when compiling static libraries, so re-compiling
71 - if use static-libs; then
72 - emake clean
73 - emake libs ${openblas_flags} NO_SHARED=1 NEED_PIC=
74 - mv libopenblas* libs/
75 - fi
76 - cat <<-EOF > ${profname}.pc
77 - prefix=${EPREFIX}/usr
78 - libdir=\${prefix}/$(get_libdir)
79 - includedir=\${prefix}/include
80 - Name: ${PN}
81 - Description: ${DESCRIPTION}
82 - Version: ${PV}
83 - URL: ${HOMEPAGE}
84 - Libs: -L\${libdir} -lopenblas
85 - Libs.private: -lm
86 - Cflags: -I\${includedir}/${PN}
87 - EOF
88 -}
89 +INT64_SUFFIX="int64"
90 +BASE_PROFNAME="openblas"
91
92 -src_compile() {
93 - # openblas already does multi-jobs
94 - MAKEOPTS+=" -j1"
95 - openblas_flags=""
96 - local openblas_name=openblas
97 +get_openblas_flags() {
98 + local openblas_flags=""
99 use dynamic && \
100 - openblas_name+="-dynamic" && \
101 openblas_flags+=" DYNAMIC_ARCH=1 TARGET=GENERIC NUM_THREADS=64 NO_AFFINITY=1"
102 - use int64 && \
103 - openblas_name+="-int64" && \
104 - openblas_flags+=" INTERFACE64=1"
105 -
106 + if [[ "${MULTIBUILD_ID}" =~ "_${INT64_SUFFIX}" ]]; then
107 + openblas_flags+=" INTERFACE64=1 LIBNAMESUFFIX=${INT64_SUFFIX}"
108 + fi
109 # choose posix threads over openmp when the two are set
110 # yet to see the need of having the two profiles simultaneously
111 if use threads; then
112 - openblas_name+="-threads"
113 openblas_flags+=" USE_THREAD=1 USE_OPENMP=0"
114 elif use openmp; then
115 - openblas_name+="-openmp"
116 openblas_flags+=" USE_THREAD=0 USE_OPENMP=1"
117 fi
118 - openblas_compile ${openblas_name}
119 - mv libs/libopenblas* . || die
120 + echo "${openblas_flags}"
121 +}
122 +
123 +get_profname() {
124 + local profname="${BASE_PROFNAME}"
125 + use dynamic && \
126 + profname+="-dynamic"
127 + if [[ "${MULTIBUILD_ID}" =~ "_${INT64_SUFFIX}" ]]; then
128 + profname+="-${INT64_SUFFIX}"
129 + fi
130 + # choose posix threads over openmp when the two are set
131 + # yet to see the need of having the two profiles simultaneously
132 + if use threads; then
133 + profname+="-threads"
134 + elif use openmp; then
135 + profname+="-openmp"
136 + fi
137 + echo "${profname}"
138 +}
139 +
140 +pkg_setup() {
141 + # The file /usr/include/openblas/openblas_config.h is generated during the install.
142 + # By listing the int64 variant first, the int64 variant /usr/include/openblas/openblas_config.h
143 + # will be overwritten by the normal variant in the install, which removes the
144 + # #define OPENBLAS_USE64BITINT for us. We then specify it in Cflags in the
145 + # /usr/lib64/pkg-config/openblas-int64-{threads,openmp}.pc file.
146 + MULTIBUILD_VARIANTS=()
147 + use int64 && \
148 + MULTIBUILD_VARIANTS+=( ${BASE_PROFNAME}_${INT64_SUFFIX} )
149 + MULTIBUILD_VARIANTS+=( ${BASE_PROFNAME} )
150 +}
151 +
152 +src_prepare() {
153 + multibuild_copy_sources
154 +}
155 +
156 +src_configure() {
157 + my_configure() {
158 + # lapack and lapacke are not modified from upstream lapack
159 + sed \
160 + -e "s:^#\s*\(CC\)\s*=.*:\1=$(tc-getCC):" \
161 + -e "s:^#\s*\(FC\)\s*=.*:\1=$(tc-getFC):" \
162 + -e "s:^#\s*\(COMMON_OPT\)\s*=.*:\1=${CFLAGS}:" \
163 + -e "s:^#\s*\(NO_LAPACK\)\s*=.*:\1=1:" \
164 + -e "s:^#\s*\(NO_LAPACKE\)\s*=.*:\1=1:" \
165 + -i Makefile.rule || die
166 + }
167 + multibuild_foreach_variant run_in_build_dir my_configure
168 +}
169 +
170 +src_compile() {
171 + # openblas already does multi-jobs
172 + MAKEOPTS+=" -j1"
173 + my_src_compile () {
174 + local openblas_flags=$(get_openblas_flags)
175 + local profname=$(get_profname)
176 + einfo "Compiling profile ${profname}"
177 + # cflags already defined twice
178 + unset CFLAGS
179 + emake clean
180 + emake libs shared ${openblas_flags}
181 + mkdir -p libs && mv libopenblas* libs/
182 + # avoid pic when compiling static libraries, so re-compiling
183 + if use static-libs; then
184 + emake clean
185 + emake libs ${openblas_flags} NO_SHARED=1 NEED_PIC=
186 + mv libopenblas* libs/
187 + fi
188 + cat <<-EOF > ${profname}.pc
189 + prefix=${EPREFIX}/usr
190 + libdir=\${prefix}/$(get_libdir)
191 + includedir=\${prefix}/include
192 + Name: ${PN}
193 + Description: ${DESCRIPTION}
194 + Version: ${PV}
195 + URL: ${HOMEPAGE}
196 + Libs: -L\${libdir} -l${MULTIBUILD_ID}
197 + Libs.private: -lm
198 + EOF
199 + if [[ "${MULTIBUILD_ID}" =~ "_${INT64_SUFFIX}" ]]; then
200 + cat <<-EOF >> ${profname}.pc
201 + Cflags: -DOPENBLAS_USE64BITINT -I\${includedir}/${PN}
202 + Fflags=-fdefault-integer-8
203 + EOF
204 + else
205 + cat <<-EOF >> ${profname}.pc
206 + Cflags: -I\${includedir}/${PN}
207 + Fflags=
208 + EOF
209 + fi
210 + mv libs/libopenblas* . || die
211 + }
212 + multibuild_foreach_variant run_in_build_dir my_src_compile
213 }
214
215 src_test() {
216 - emake tests ${openblas_flags}
217 + my_src_test () {
218 + local openblas_flags=$(get_openblas_flags)
219 + emake tests ${openblas_flags}
220 + }
221 + multibuild_foreach_variant run_in_build_dir my_src_test
222 }
223
224 src_install() {
225 - local pcfile
226 - for pcfile in *.pc; do
227 - local profname=${pcfile%.pc}
228 - emake install \
229 - PREFIX="${ED}"usr ${openblas_flags} \
230 - OPENBLAS_INCLUDE_DIR="${ED}"usr/include/${PN} \
231 - OPENBLAS_LIBRARY_DIR="${ED}"usr/$(get_libdir)
232 - use static-libs || rm "${ED}"usr/$(get_libdir)/lib*.a
233 - alternatives_for blas ${profname} 0 \
234 - /usr/$(get_libdir)/pkgconfig/blas.pc ${pcfile}
235 - alternatives_for cblas ${profname} 0 \
236 - /usr/$(get_libdir)/pkgconfig/cblas.pc ${pcfile} \
237 - /usr/include/cblas.h ${PN}/cblas.h
238 - insinto /usr/$(get_libdir)/pkgconfig
239 - doins ${pcfile}
240 - done
241 + my_src_install () {
242 + local openblas_flags=$(get_openblas_flags)
243 + local profname=$(get_profname)
244 + local pcfile
245 + for pcfile in *.pc; do
246 + local profname=${pcfile%.pc}
247 + emake install \
248 + PREFIX="${ED}"usr ${openblas_flags} \
249 + OPENBLAS_INCLUDE_DIR="${ED}"usr/include/${PN} \
250 + OPENBLAS_LIBRARY_DIR="${ED}"usr/$(get_libdir)
251 + use static-libs || rm "${ED}"usr/$(get_libdir)/lib*.a
252 + alternatives_for blas ${profname} 0 \
253 + /usr/$(get_libdir)/pkgconfig/blas.pc ${pcfile}
254 + alternatives_for cblas ${profname} 0 \
255 + /usr/$(get_libdir)/pkgconfig/cblas.pc ${pcfile} \
256 + /usr/include/cblas.h ${PN}/cblas.h
257 + insinto /usr/$(get_libdir)/pkgconfig
258 + doins ${pcfile}
259 + done
260
261 - dodoc GotoBLAS_{01Readme,03FAQ,04FAQ,05LargePage,06WeirdPerformance}.txt
262 - dodoc *md Changelog.txt
263 + dodoc GotoBLAS_{01Readme,03FAQ,04FAQ,05LargePage,06WeirdPerformance}.txt
264 + dodoc *md Changelog.txt
265
266 - if [[ ${CHOST} == *-darwin* ]] ; then
267 - cd "${ED}"/usr/$(get_libdir)
268 - local d
269 - for d in *.dylib ; do
270 - ebegin "Correcting install_name of ${d}"
271 - install_name_tool -id "${EPREFIX}/usr/$(get_libdir)/${d}" "${d}"
272 - eend $?
273 - done
274 - fi
275 + if [[ ${CHOST} == *-darwin* ]] ; then
276 + cd "${ED}"/usr/$(get_libdir)
277 + local d
278 + for d in *.dylib ; do
279 + ebegin "Correcting install_name of ${d}"
280 + install_name_tool -id "${EPREFIX}/usr/$(get_libdir)/${d}" "${d}"
281 + eend $?
282 + done
283 + fi
284 + }
285 + multibuild_foreach_variant run_in_build_dir my_src_install
286 }