commit:     5b5e9e7d6c21a48ad35d3fc033902201a71a06d4
Author:     gienah <gienah <AT> gentoo <DOT> org>
AuthorDate: Tue Feb 18 14:01:11 2014 +0000
Commit:     Justin Lecher <jlec <AT> gentoo <DOT> org>
CommitDate: Sat Sep 27 11:05:57 2014 +0000
URL:        http://sources.gentoo.org/gitweb/?p=proj/sci.git;a=commit;h=5b5e9e7d

multibuild openblas when USE=int64 is specified.

---
 sci-libs/openblas/ChangeLog            |   3 +
 sci-libs/openblas/openblas-9999.ebuild | 221 +++++++++++++++++++++------------
 2 files changed, 142 insertions(+), 82 deletions(-)

diff --git a/sci-libs/openblas/ChangeLog b/sci-libs/openblas/ChangeLog
index caf34f2..b4f5886 100644
--- a/sci-libs/openblas/ChangeLog
+++ b/sci-libs/openblas/ChangeLog
@@ -2,6 +2,9 @@
 # Copyright 1999-2014 Gentoo Foundation; Distributed under the GPL v2
 # $Header: $
 
+  18 Feb 2014; Mark Wright <gie...@gentoo.org> openblas-9999.ebuild:
+  multibuild openblas when USE=int64 is specified.
+
   06 Jan 2014; Justin Lecher <j...@gentoo.org> openblas-9999.ebuild,
   metadata.xml:
   Switch from git-2 to git-r3

diff --git a/sci-libs/openblas/openblas-9999.ebuild 
b/sci-libs/openblas/openblas-9999.ebuild
index 618c03b..3bd158a 100644
--- a/sci-libs/openblas/openblas-9999.ebuild
+++ b/sci-libs/openblas/openblas-9999.ebuild
@@ -4,7 +4,7 @@
 
 EAPI=5
 
-inherit alternatives-2 eutils fortran-2 git-r3 multilib toolchain-funcs
+inherit alternatives-2 eutils fortran-2 git-r3 multilib multibuild 
toolchain-funcs
 
 DESCRIPTION="Optimized BLAS library based on GotoBLAS2"
 HOMEPAGE="http://xianyi.github.com/OpenBLAS/";
@@ -14,105 +14,162 @@ EGIT_BRANCH="develop"
 
 LICENSE="BSD"
 SLOT="0"
-IUSE="int64 dynamic openmp static-libs threads"
+IUSE="dynamic int64 openmp static-libs threads"
 KEYWORDS=""
 
-src_configure() {
-       # lapack and lapacke are not modified from upstream lapack
-       sed \
-               -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:" \
-               -i 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
-}
+INT64_SUFFIX="int64"
+BASE_PROFNAME="openblas"
 
-src_compile() {
-       # openblas already does multi-jobs
-       MAKEOPTS+=" -j1"
-       openblas_flags=""
-       local openblas_name=openblas
+get_openblas_flags() {
+       local openblas_flags=""
        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"
-
+       if [[ "${MULTIBUILD_ID}" =~ "_${INT64_SUFFIX}" ]]; then
+               openblas_flags+=" INTERFACE64=1 LIBNAMESUFFIX=${INT64_SUFFIX}"
+       fi
        # 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
+       echo "${openblas_flags}"
+}
+
+get_profname() {
+       local profname="${BASE_PROFNAME}"
+       use dynamic && \
+               profname+="-dynamic"
+       if [[ "${MULTIBUILD_ID}" =~ "_${INT64_SUFFIX}" ]]; then
+               profname+="-${INT64_SUFFIX}"
+       fi
+       # 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
+               profname+="-threads"
+       elif use openmp; then
+               profname+="-openmp"
+       fi
+       echo "${profname}"
+}
+
+pkg_setup() {
+       # The file /usr/include/openblas/openblas_config.h is generated during 
the install.
+       # By listing the int64 variant first, the int64 variant 
/usr/include/openblas/openblas_config.h
+       # will be overwritten by the normal variant in the install, which 
removes the
+       # #define OPENBLAS_USE64BITINT for us.  We then specify it in Cflags in 
the
+       # /usr/lib64/pkg-config/openblas-int64-{threads,openmp}.pc file.
+       MULTIBUILD_VARIANTS=()
+       use int64 && \
+               MULTIBUILD_VARIANTS+=( ${BASE_PROFNAME}_${INT64_SUFFIX} )
+       MULTIBUILD_VARIANTS+=( ${BASE_PROFNAME} )
+}
+
+src_prepare() {
+       multibuild_copy_sources
+}
+
+src_configure() {
+       my_configure() {
+               # lapack and lapacke are not modified from upstream lapack
+               sed \
+                       -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:" \
+                       -i Makefile.rule || die
+       }
+       multibuild_foreach_variant run_in_build_dir my_configure
+}
+
+src_compile() {
+       # openblas already does multi-jobs
+       MAKEOPTS+=" -j1"
+       my_src_compile () {
+               local openblas_flags=$(get_openblas_flags)
+               local profname=$(get_profname)
+               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} -l${MULTIBUILD_ID}
+                       Libs.private: -lm
+               EOF
+               if [[ "${MULTIBUILD_ID}" =~ "_${INT64_SUFFIX}" ]]; then
+                       cat <<-EOF >> ${profname}.pc
+                               Cflags: -DOPENBLAS_USE64BITINT 
-I\${includedir}/${PN}
+                               Fflags=-fdefault-integer-8
+                       EOF
+               else
+                       cat <<-EOF >> ${profname}.pc
+                               Cflags: -I\${includedir}/${PN}
+                               Fflags=
+                       EOF
+               fi
+               mv libs/libopenblas* . || die
+       }
+       multibuild_foreach_variant run_in_build_dir my_src_compile
 }
 
 src_test() {
-       emake tests ${openblas_flags}
+       my_src_test () {
+               local openblas_flags=$(get_openblas_flags)
+               emake tests ${openblas_flags}
+       }
+       multibuild_foreach_variant run_in_build_dir my_src_test
 }
 
 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
+       my_src_install () {
+               local openblas_flags=$(get_openblas_flags)
+               local profname=$(get_profname)
+               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
+               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
+               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
+       }
+       multibuild_foreach_variant run_in_build_dir my_src_install
 }

Reply via email to