commit:     bc36b5406f2bb289a3920ef13d50853a567bc83d
Author:     Justin Lecher <jlec <AT> gentoo <DOT> org>
AuthorDate: Sat Sep 19 07:14:19 2015 +0000
Commit:     Justin Lecher <jlec <AT> gentoo <DOT> org>
CommitDate: Sat Nov 28 17:25:09 2015 +0000
URL:        https://gitweb.gentoo.org/proj/sci.git/commit/?id=bc36b540

Large fix of numeric code

fortran-int64.eclass code has been splitted into
numeric-int64-multibuild.eclass, fortran-2.eclass and
numeric.eclass.

Gentoo:
https://bugs.gentoo.org/show_bug.cgi?id=563292
https://bugs.gentoo.org/show_bug.cgi?id=551764
https://bugs.gentoo.org/show_bug.cgi?id=555302

Github:
resolves gentoo-science/sci#438
resolves gentoo-science/sci#443
resolves gentoo-science/sci#447
resolves gentoo-science/sci#450
resolves gentoo-science/sci#467
resolves gentoo-science/sci#492
resolves gentoo-science/sci#507
resolves gentoo-science/sci#508
resolves gentoo-science/sci#522

Signed-off-by: Justin Lecher <jlec <AT> gentoo.org>

 eclass/alternatives-2.eclass                       |  10 +-
 eclass/fortran-2.eclass                            | 276 ++++++++++++++
 eclass/fortran-int64.eclass                        | 300 ----------------
 eclass/numeric-int64-multibuild.eclass             | 397 +++++++++++++++++++++
 eclass/numeric.eclass                              |  35 +-
 .../blas-reference-20131116-r1.ebuild              | 118 ------
 .../blas-reference-20131116-r2.ebuild              | 107 ++++++
 .../blas-reference/blas-reference-20131116.ebuild  |  78 ----
 .../blas-reference/blas-reference-99999999.ebuild  |  76 ++--
 sci-libs/blas-reference/metadata.xml               |   4 +-
 .../cblas-reference-20110218-r1.ebuild             |  98 +++--
 .../cblas-reference-20110218.ebuild                | 116 ------
 sci-libs/gotoblas2/gotoblas2-1.13.ebuild           | 139 ++++----
 .../lapack-reference/lapack-reference-3.4.2.ebuild | 139 --------
 .../lapack-reference/lapack-reference-3.5.0.ebuild |  81 ++---
 .../lapack-reference/lapack-reference-9999.ebuild  |  86 ++---
 sci-libs/openblas/openblas-0.2.11.ebuild           | 227 ------------
 sci-libs/openblas/openblas-0.2.12.ebuild           | 227 ------------
 sci-libs/openblas/openblas-0.2.14.ebuild           | 190 ++++------
 sci-libs/openblas/openblas-0.2.8.ebuild            | 126 -------
 sci-libs/openblas/openblas-9999.ebuild             | 190 ++++------
 sci-libs/xblas/xblas-1.0.248-r1.ebuild             |  78 ++--
 sci-libs/xblas/xblas-1.0.248.ebuild                |  93 -----
 virtual/blas/blas-2.1-r1.ebuild                    |  38 --
 virtual/blas/blas-2.1-r2.ebuild                    |  41 ---
 virtual/blas/blas-2.1-r3.ebuild                    |  11 +-
 virtual/blas/metadata.xml                          |   6 +-
 virtual/cblas/cblas-2.0-r1.ebuild                  |  28 --
 virtual/cblas/cblas-2.0-r2.ebuild                  |  31 --
 virtual/cblas/cblas-2.0-r3.ebuild                  |  14 +-
 virtual/cblas/cblas-2.0.ebuild                     |  24 --
 virtual/lapack/lapack-3.4-r1.ebuild                |  35 --
 virtual/lapack/lapack-3.5-r1.ebuild                |  33 --
 virtual/lapack/lapack-3.5-r2.ebuild                |   6 +-
 34 files changed, 1239 insertions(+), 2219 deletions(-)

diff --git a/eclass/alternatives-2.eclass b/eclass/alternatives-2.eclass
index 749cda8..19e8306 100644
--- a/eclass/alternatives-2.eclass
+++ b/eclass/alternatives-2.eclass
@@ -102,7 +102,7 @@ alternatives-2_pkg_postinst() {
                fi
 
                # Set alternative provider if there is no valid provider 
selected
-               eselect "${alt}" update "${provider}"
+               eselect alternatives update "${alt}"
 
                cleanup_old_alternatives_module ${alt}
        done
@@ -122,9 +122,10 @@ alternatives-2_pkg_prerm() {
 
        # If we are uninstalling, update alternatives to valid provider
        [[ -n ${REPLACED_BY_VERSION} ]] || ignore="--ignore"
-
+set -x
        for alt in ${ALTERNATIVES_CREATED[@]}; do
-               eselect "${alt}" update ${ignore} "${provider}"
+               eselect alternatives update "${alt}"
+               ret=$?
 
                case ${ret} in
                        0) : ;;
@@ -134,10 +135,11 @@ alternatives-2_pkg_prerm() {
                                eselect alternatives delete "${alt}" || eerror 
"Failed to remove ${alt}"
                                ;;
                        *)
-                               eerror "eselect ${alt} update ${provider} 
returned ${ret}"
+                               eerror "eselect alternatives update returned 
\"${ret}\""
                                ;;
                esac
        done
+set +x
 }
 
 EXPORT_FUNCTIONS pkg_postinst pkg_prerm

diff --git a/eclass/fortran-2.eclass b/eclass/fortran-2.eclass
new file mode 100644
index 0000000..5cb6d7d
--- /dev/null
+++ b/eclass/fortran-2.eclass
@@ -0,0 +1,276 @@
+# Copyright 1999-2015 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Id$
+
+# @ECLASS: fortran-2.eclass
+# @MAINTAINER:
+# [email protected]
+# [email protected]
+# @AUTHOR:
+# Author Justin Lecher <[email protected]>
+# Test functions provided by Sebastien Fabbro and Kacper Kowalik
+# @BLURB: Simplify fortran compiler management
+# @DESCRIPTION:
+# If you need a fortran compiler, then you should be inheriting this eclass.
+# In case you only need optional support, please export FORTRAN_NEEDED before
+# inheriting the eclass.
+#
+# The eclass tests for working fortran compilers
+# and exports the variables FC and F77.
+# Optionally, it checks for extended capabilities based on
+# the variable options selected in the ebuild
+# The only phase function exported is fortran-2_pkg_setup.
+# @EXAMPLE:
+# FORTRAN_NEEDED="lapack fortran"
+#
+# inherit fortran-2
+#
+# FORTRAN_NEED_OPENMP=1
+
+if [[ ! ${_FORTRAN_2_CLASS} ]]; then
+
+# @ECLASS-VARIABLE: FORTRAN_NEED_OPENMP
+# @DESCRIPTION:
+# Set to "1" in order to automatically have the eclass abort if the fortran
+# compiler lacks openmp support.
+: ${FORTRAN_NEED_OPENMP:=0}
+
+# @ECLASS-VARIABLE: FORTRAN_STANDARD
+# @DESCRIPTION:
+# Set this, if a special dialect needs to be supported.
+# Generally not needed as default is sufficient.
+#
+# Valid settings are any combination of: 77 90 95 2003
+: ${FORTRAN_STANDARD:=77}
+
+# @ECLASS-VARIABLE: FORTRAN_NEEDED
+# @DESCRIPTION:
+# If your package has an optional fortran support, set this variable
+# to the space separated list of USE triggering the fortran
+# dependency.
+#
+# e.g. FORTRAN_NEEDED=lapack would result in
+#
+# DEPEND="lapack? ( virtual/fortran )"
+#
+# If unset, we always depend on virtual/fortran.
+: ${FORTRAN_NEEDED:=always}
+
+inherit eutils toolchain-funcs
+
+for _f_use in ${FORTRAN_NEEDED}; do
+       case ${_f_use} in
+               always)
+                       DEPEND+=" virtual/fortran"
+                       break
+                       ;;
+               no)
+                       break
+                       ;;
+               *)
+                       DEPEND+=" ${_f_use}? ( virtual/fortran )"
+                       ;;
+       esac
+done
+RDEPEND="${DEPEND}"
+
+# @FUNCTION: fortran_int64_abi_fflags
+# @DESCRIPTION: Return the Fortran compiler flag to enable 64 bit integers for
+# array indices
+# @CODE
+fortran_int64_abi_fflags() {
+       debug-print-function ${FUNCNAME} "${@}"
+       _FC=$(tc-getFC)
+       if [[ ${_FC} == *gfortran* ]]; then
+               echo "-fdefault-integer-8"
+       elif [[ ${_FC} == ifort ]]; then
+               echo "-integer-size 64"
+       else
+               die "Compiler flag for 64bit interger for ${_FC} unknown"
+       fi
+}
+
+# @FUNCTION: _fortran_write_testsuite
+# @INTERNAL
+# @DESCRIPTION:
+# writes fortran test code
+_fortran_write_testsuite() {
+       local filebase=${T}/test-fortran
+
+       # f77 code
+       cat <<- EOF > "${filebase}.f"
+              end
+       EOF
+
+       # f90/95 code
+       cat <<- EOF > "${filebase}.f90"
+       end
+       EOF
+
+       # f2003 code
+       cat <<- EOF > "${filebase}.f03"
+              procedure(), pointer :: p
+              end
+       EOF
+}
+
+# @FUNCTION: _fortran_compile_test
+# @USAGE: <compiler> [dialect]
+# @INTERNAL
+# @DESCRIPTION:
+# Takes fortran compiler as first argument and dialect as second.
+# Checks whether the passed fortran compiler speaks the fortran dialect
+_fortran_compile_test() {
+       local filebase=${T}/test-fortran
+       local fcomp=${1}
+       local fdia=${2}
+       local fcode=${filebase}.f${fdia}
+       local ret
+
+       [[ $# -lt 1 ]] && \
+               die "_fortran_compile_test() needs at least one argument"
+
+       [[ -f ${fcode} ]] || _fortran_write_testsuite
+
+       ${fcomp} "${fcode}" -o "${fcode}.x" \
+               >> "${T}"/_fortran_compile_test.log 2>&1
+       ret=$?
+
+       rm -f "${fcode}.x"
+       return ${ret}
+}
+
+# @FUNCTION: _fortran-has-openmp
+# @RETURN: return code of the compiler
+# @INTERNAL
+# @DESCRIPTION:
+# See if the fortran supports OpenMP.
+_fortran-has-openmp() {
+       local flag
+       local filebase=${T}/test-fc-openmp
+       local fcode=${filebase}.f
+       local ret
+       local _fc=$(tc-getFC)
+
+       cat <<- EOF > "${fcode}"
+              call omp_get_num_threads
+              end
+       EOF
+
+       for flag in -fopenmp -xopenmp -openmp -mp -omp -qsmp=omp; do
+               ${_fc} ${flag} "${fcode}" -o "${fcode}.x" \
+                       &>> "${T}"/_fortran_compile_test.log
+               ret=$?
+               (( ${ret} )) || break
+       done
+
+       rm -f "${fcode}.x"
+       return ${ret}
+}
+
+# @FUNCTION: _fortran_die_msg
+# @INTERNAL
+# @DESCRIPTION:
+# Detailed description how to handle fortran support
+_fortran_die_msg() {
+       echo
+       eerror "Please install currently selected gcc version with USE=fortran."
+       eerror "If you intend to use a different compiler then gfortran, please"
+       eerror "set FC variable accordingly and take care that the necessary"
+       eerror "fortran dialects are supported."
+       echo
+       die "Currently no working fortran compiler is available"
+}
+
+# @FUNCTION: _fortran_test_function
+# @INTERNAL
+# @DESCRIPTION:
+# Internal test function for working fortran compiler.
+# It is called in fortran-2_pkg_setup.
+_fortran_test_function() {
+       local dialect
+
+       : ${F77:=$(tc-getFC)}
+
+       : ${FORTRAN_STANDARD:=77}
+       for dialect in ${FORTRAN_STANDARD}; do
+               case ${dialect} in
+                       77) _fortran_compile_test $(tc-getF77) || \
+                               _fortran_die_msg ;;
+                       90|95) _fortran_compile_test $(tc-getFC) 90 || \
+                               _fortran_die_msg ;;
+                       2003) _fortran_compile_test $(tc-getFC) 03 || \
+                               _fortran_die_msg ;;
+                       2008) die "Future" ;;
+                       *) die "${dialect} is not a Fortran dialect." ;;
+               esac
+       done
+
+       tc-export F77 FC
+       einfo "Using following Fortran compiler:"
+       einfo "  F77: ${F77}"
+       einfo "  FC:  ${FC}"
+
+       if [[ ${FORTRAN_NEED_OPENMP} == 1 ]]; then
+               if _fortran-has-openmp; then
+                       einfo "${FC} has OPENMP support"
+               else
+                       die "Please install current gcc with USE=openmp or set 
the FC variable to a compiler that supports OpenMP"
+               fi
+       fi
+}
+
+# @FUNCTION: _fortran-2_pkg_setup
+# @INTERNAL
+# @DESCRIPTION:
+# _The_ fortran-2_pkg_setup() code
+_fortran-2_pkg_setup() {
+       for _f_use in ${FORTRAN_NEEDED}; do
+       case ${_f_use} in
+               always)
+                       _fortran_test_function && break
+                       ;;
+               no)
+                       einfo "Forcing fortran support off"
+                       break
+                       ;;
+               *)
+                       if use ${_f_use}; then
+                               _fortran_test_function && break
+                       else
+                               unset FC
+                               unset F77
+                       fi
+                       ;;
+               esac
+       done
+}
+
+
+# @FUNCTION: fortran-2_pkg_setup
+# @DESCRIPTION:
+# Setup functionality,
+# checks for a valid fortran compiler and optionally for its openmp support.
+fortran-2_pkg_setup() {
+       case ${EAPI:-0} in
+               0|1|2|3)
+                       eqawarn "Support for EAPI < 4 will be removed from the"
+                       eqawarn "fortran-2.eclass in until 2013-09-30."
+                       eqawarn "Please migrate your package to a higher EAPI"
+                       eqawarn "or file a bug at https://bugs.gentoo.org";
+                       _fortran-2_pkg_setup ;;
+               4|5)
+                       if [[ ${MERGE_TYPE} != binary ]]; then
+                               _fortran-2_pkg_setup
+                       fi
+                       ;;
+       esac
+}
+
+case ${EAPI:-0} in
+       0|1|2|3|4|5) EXPORT_FUNCTIONS pkg_setup ;;
+       *) die "EAPI=${EAPI} is not supported" ;;
+esac
+
+_FORTRAN_2_ECLASS=1
+fi

diff --git a/eclass/fortran-int64.eclass b/eclass/fortran-int64.eclass
deleted file mode 100644
index 09980c8..0000000
--- a/eclass/fortran-int64.eclass
+++ /dev/null
@@ -1,300 +0,0 @@
-# Copyright 1999-2014 Gentoo Foundation
-# Distributed under the terms of the GNU General Public License v2
-# $Id$
-
-# @ECLASS: fortran-int64.eclass
-# @MAINTAINER:
-# sci team <[email protected]>
-# @AUTHOR:
-# Author: Mark Wright <[email protected]>
-# @BLURB: flags and utility functions for building Fortran multilib int64
-# multibuild packages
-# @DESCRIPTION:
-# The fortran-int64.eclass exports USE flags and utility functions
-# necessary to build packages for multilib int64 multibuild in a clean
-# and uniform manner.
-
-if [[ ! ${_FORTRAN_INT64_ECLASS} ]]; then
-
-# EAPI=4 is required for meaningful MULTILIB_USEDEP.
-case ${EAPI:-0} in
-       4|5) ;;
-       *) die "EAPI=${EAPI} is not supported" ;;
-esac
-
-inherit multilib-build toolchain-funcs
-
-# @ECLASS-VARIABLE: EBASE_PROFNAME
-# @DESCRIPTION: The base pkg-config module name of the package being built.
-# EBASE_PROFNAME is used by the fortran-int64_get_profname function to
-# determine the pkg-config module name based on whether the package
-# has dynamic, threads or openmp USE flags and if so, if the user has
-# turned them or, and if the current multibuild is a int64 build or not.
-# @CODE
-# EBASE_PROFNAME="openblas"
-# inherit ... fortran-int64
-# @CODE
-: ${EBASE_PROFNAME:=blas}
-
-# @ECLASS-VARIABLE: ESTATIC_MULTIBUILD
-# @DEFAULT_UNSET
-# @DESCRIPTION:
-# If this is set, then do separate static multibuilds.
-# @CODE
-# ESTATIC_MULTIBUILD=1
-# inherit ... fortran-int64
-# @CODE
-
-INT64_SUFFIX="int64"
-STATIC_SUFFIX="static"
-
-# @FUNCTION: fortran-int64_is_int64_build
-# @DESCRIPTION:
-# Returns shell true if the current multibuild is a int64 build,
-# else returns shell false.
-# @CODE
-#      $(fortran-int64_is_int64_build) && \
-#              openblas_abi_cflags+=" -DOPENBLAS_USE64BITINT"
-# @CODE
-fortran-int64_is_int64_build() {
-       debug-print-function ${FUNCNAME} "${@}"
-       if [[ "${MULTIBUILD_ID}" =~ "_${INT64_SUFFIX}" ]]; then
-               return 0
-       else
-               return 1
-       fi
-}
-
-# @FUNCTION: fortran-int64_is_static_build
-# @DESCRIPTION:
-# Returns shell true if ESTATIC_MULTIBUILD is true and the current multibuild
-# is a static build, else returns shell false.
-# @CODE
-#      if $(fortran-int64_is_static_build); then
-#              ...
-# @CODE
-fortran-int64_is_static_build() {
-       debug-print-function ${FUNCNAME} "${@}"
-       if [[ "${MULTIBUILD_ID}" =~ "_${STATIC_SUFFIX}" ]]; then
-               return 0
-       else
-               return 1
-       fi
-}
-
-# @FUNCTION: fortran-int64_get_profname
-# @USAGE: [<profname>]
-# @DESCRIPTION: Return the pkgbuild profile name, without the .pc extension,
-# for the current fortran int64 build.  If the current build is not an int64
-# build, and the ebuild does not have dynamic, threads or openmp USE flags or
-# they are disabled, then the profname is ${EBASE_PROFNAME} or <profname> if
-# <profname> is specified.
-#
-# Takes an optional <profname> parameter.  If no <profname> is specified, uses
-# ${EBASE_PROFNAME} as the base to calculate the profname for the current
-# build.
-fortran-int64_get_profname() {
-       debug-print-function ${FUNCNAME} "${@}"
-       local profname="${1:-${EBASE_PROFNAME}}"
-       if has dynamic ${IUSE} && use dynamic; then
-               profname+="-dynamic"
-       fi
-       if $(fortran-int64_is_int64_build); 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 has threads ${IUSE} && use threads; then
-               profname+="-threads"
-       elif has openmp ${IUSE} && use openmp; then
-               profname+="-openmp"
-       fi
-       echo "${profname}"
-}
-
-# @FUNCTION: fortran-int64_get_blas_provider
-# @DESCRIPTION: Returns the eselect blas provider for the current build.
-# Which is blas-int64 if called from an int64 build, or blas otherwise.
-# @CODE
-#      local profname=$(fortran-int64_get_profname)
-#      local provider=$(fortran-int64_get_blas_provider)
-#      alternatives_for ${provider} $(fortran-int64_get_profname "reference") 
0 \
-#              /usr/$(get_libdir)/pkgconfig/${provider}.pc ${profname}.pc
-# @CODE
-fortran-int64_get_blas_provider() {
-       debug-print-function ${FUNCNAME} "${@}"
-       local provider_name="blas"
-       if $(fortran-int64_is_int64_build); then
-               provider_name+="-${INT64_SUFFIX}"
-       fi
-       echo "${provider_name}"
-}
-
-# @FUNCTION: fortran-int64_get_cblas_provider
-# @DESCRIPTION: Returns the eselect cblas provider for the current build.
-# Which is cblas-int64 if called from an int64 build, or cblas otherwise.
-# @CODE
-#      local profname=$(fortran-int64_get_profname)
-#      local provider=$(fortran-int64_get_cblas_provider)
-#      alternatives_for ${provider} $(fortran-int64_get_profname "reference") 
0 \
-#              /usr/$(get_libdir)/pkgconfig/${provider}.pc ${profname}.pc
-# @CODE
-fortran-int64_get_cblas_provider() {
-       debug-print-function ${FUNCNAME} "${@}"
-       local provider_name="cblas"
-       if $(fortran-int64_is_int64_build); then
-               provider_name+="-${INT64_SUFFIX}"
-       fi
-       echo "${provider_name}"
-}
-
-# @FUNCTION: fortran-int64_get_lapack_provider
-# @DESCRIPTION: Returns the eselect lapack provider for the current build.
-# Which is lapack-int64 if called from an int64 build, or lapack otherwise.
-# @CODE
-#      local profname=$(fortran-int64_get_profname)
-#      local provider=$(fortran-int64_get_lapack_provider)
-#      alternatives_for ${provider} $(fortran-int64_get_profname "reference") 
0 \
-#              /usr/$(get_libdir)/pkgconfig/${provider}.pc ${profname}.pc
-# @CODE
-fortran-int64_get_lapack_provider() {
-       debug-print-function ${FUNCNAME} "${@}"
-       local provider_name="lapack"
-       if $(fortran-int64_is_int64_build); then
-               provider_name+="-${INT64_SUFFIX}"
-       fi
-       echo "${provider_name}"
-}
-
-# @FUNCTION: fortran-int64_get_blas_profname
-# @DESCRIPTION: Returns the pkg-config file name, without the .pc extension,
-# for the currently selected blas-int64 module if we are performing an int64
-# build, or the currently selected blas module otherwise.
-# @CODE
-#      cat <<-EOF > ${profname}.pc
-#              ...
-#              Requires: $(fortran-int64_get_blas_profname)
-#              ...
-# @CODE
-fortran-int64_get_blas_profname() {
-       debug-print-function ${FUNCNAME} "${@}"
-       local blas_provider=$(fortran-int64_get_blas_provider)
-       local blas_symlinks=( $(eselect "${blas_provider}" files) )
-       local blas_prof_symlink="$(readlink -f "${blas_symlinks[0]}")"
-       local blas_prof_file="${blas_prof_symlink##*/}"
-       echo "${blas_prof_file%.pc}"
-}
-
-# @FUNCTION: fortran-int64_get_xblas_profname
-# @DESCRIPTION: Returns the xblas pkg-config file name, without the .pc 
extension,
-# for the current build.  Which is xblas-int64 if we are performing an int64
-# build, or xblas otherwise.
-# @CODE
-#      cat <<-EOF > ${profname}.pc
-#              ...
-#              Requires: $(fortran-int64_get_xblas_profname)
-#              ...
-# @CODE
-fortran-int64_get_xblas_profname() {
-       debug-print-function ${FUNCNAME} "${@}"
-       local xblas_provider="xblas"
-       if $(fortran-int64_is_int64_build); then
-               xblas_provider+="-${INT64_SUFFIX}"
-       fi
-       echo "${xblas_provider}"
-}
-
-# @FUNCTION: fortran-int64_get_fortran_int64_abi_fflags
-# @DESCRIPTION: Return the Fortran compiler flag to enable 64 bit integers for
-# array indices if we are performing an int64 build, or the empty string
-# otherwise.
-# @CODE
-# src_configure() {
-#      local MULTIBUILD_VARIANTS=( $(fortran-int64_multilib_get_enabled_abis) )
-#      my_configure() {
-#              export FCFLAGS="${FCFLAGS} $(get_abi_CFLAGS) 
$(fortran-int64_get_fortran_int64_abi_fflags)"
-#              econf $(use_enable fortran)
-#      }
-#      multibuild_foreach_variant run_in_build_dir 
fortran-int64_multilib_multibuild_wrapper my_configure
-# }
-# @CODE
-fortran-int64_get_fortran_int64_abi_fflags() {
-       debug-print-function ${FUNCNAME} "${@}"
-       local openblas_abi_fflags=""
-       if $(fortran-int64_is_int64_build); then
-               openblas_abi_fflags+="-fdefault-integer-8"
-       fi
-       echo "${openblas_abi_fflags}"
-}
-
-# @FUNCTION: fortran-int64_multilib_get_enabled_abis
-# @DESCRIPTION: Returns the array of multilib int64 and optionally static
-# build combinations.  Each ebuild function that requires multibuild
-# functionalits needs to set the MULTIBUILD_VARIANTS variable to the
-# array returned by this function.
-# @CODE
-# src_prepare() {
-#      local MULTIBUILD_VARIANTS=( $(fortran-int64_multilib_get_enabled_abis) )
-#      multibuild_copy_sources
-# }
-# @CODE
-fortran-int64_multilib_get_enabled_abis() {
-       debug-print-function ${FUNCNAME} "${@}"
-       local MULTILIB_VARIANTS=( $(multilib_get_enabled_abis) )
-       local MULTILIB_INT64_VARIANTS=()
-       local i
-       for i in "${MULTILIB_VARIANTS[@]}"; do
-               if use int64 && [[ "${i}" =~ 64$ ]]; then
-                       MULTILIB_INT64_VARIANTS+=( "${i}_${INT64_SUFFIX}" )
-               fi
-               MULTILIB_INT64_VARIANTS+=( "${i}" )
-       done
-       local MULTIBUILD_VARIANTS=()
-       if [[ -n ${ESTATIC_MULTIBUILD} ]]; then
-               local j
-               for j in "${MULTILIB_INT64_VARIANTS[@]}"; do
-                       use static-libs && MULTIBUILD_VARIANTS+=( 
"${j}_${STATIC_SUFFIX}" )
-                       MULTIBUILD_VARIANTS+=( "${j}" )
-               done
-       else
-               MULTIBUILD_VARIANTS="${MULTILIB_INT64_VARIANTS[@]}"
-       fi
-       echo "${MULTIBUILD_VARIANTS[@]}"
-}
-
-# @FUNCTION: fortran-int64_ensure_blas
-# @DESCRIPTION: Check the blas pkg-config files are available for the currently
-# selected blas module, and for the currently select blas-int64 module if the
-# int64 USE flag is enabled.
-# @CODE
-# src_prepare() {
-#      fortran-int64_ensure_blas
-#      ...
-# @CODE
-fortran-int64_ensure_blas() {
-       local MULTILIB_INT64_VARIANTS=( 
$(fortran-int64_multilib_get_enabled_abis) )
-       local MULTIBUILD_ID
-       for MULTIBUILD_ID in "${MULTILIB_INT64_VARIANTS[@]}"; do
-               local blas_profname=$(fortran-int64_get_blas_profname)
-               $(tc-getPKG_CONFIG) --exists "${blas_profname}" \
-                       || die "${PN} requires the pkgbuild module 
${blas_profname}"
-       done
-}
-
-# @FUNCTION: fortran-int64_multilib_multibuild_wrapper
-# @USAGE: <argv>...
-# @DESCRIPTION:
-# Initialize the environment for ABI selected for multibuild.
-# @CODE
-#      multibuild_foreach_variant run_in_build_dir 
fortran-int64_multilib_multibuild_wrapper my_src_install
-# @CODE
-fortran-int64_multilib_multibuild_wrapper() {
-       debug-print-function ${FUNCNAME} "${@}"
-       local v="${MULTIBUILD_VARIANT/_${INT64_SUFFIX}/}"
-       local ABI="${v/_${STATIC_SUFFIX}/}"
-       multilib_toolchain_setup "${ABI}"
-       "${@}"
-}
-
-_FORTRAN_INT64_ECLASS=1
-fi

diff --git a/eclass/numeric-int64-multibuild.eclass 
b/eclass/numeric-int64-multibuild.eclass
new file mode 100644
index 0000000..a55db31
--- /dev/null
+++ b/eclass/numeric-int64-multibuild.eclass
@@ -0,0 +1,397 @@
+# Copyright 1999-2015 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Id$
+
+# @ECLASS: numeric-int64-multilib.eclass
+# @MAINTAINER:
+# sci team <[email protected]>
+# @AUTHOR:
+# Author: Mark Wright <[email protected]>
+# Author: Justin Lecher <[email protected]>
+# @BLURB: Build functions for Fortran multilib int64 multibuild packages
+# @DESCRIPTION:
+# The numeric-int64-multilib.eclass exports USE flags and utility functions
+# necessary to build packages for multilib int64 multibuild in a clean
+# and uniform manner.
+
+if [[ ! ${_NUMERIC_INT64_MULTILIB_ECLASS} ]]; then
+
+# EAPI=5 is required for meaningful MULTILIB_USEDEP.
+case ${EAPI:-0} in
+       5)
+               inherit multilib
+               ;;
+       *) die "EAPI=${EAPI} is not supported" ;;
+esac
+
+inherit alternatives-2 eutils fortran-2 multilib-build numeric toolchain-funcs
+
+IUSE="int64"
+
+# @ECLASS-VARIABLE: NUMERIC_INT32_SUFFIX
+# @INTERNAL
+# @DESCRIPTION:
+# MULTIBUILD_ID suffix for int32 build
+NUMERIC_INT32_SUFFIX="int32"
+
+# @ECLASS-VARIABLE: NUMERIC_INT64_SUFFIX
+# @INTERNAL
+# @DESCRIPTION:
+# MULTIBUILD_ID suffix for int64 build
+NUMERIC_INT64_SUFFIX="int64"
+
+# @ECLASS-VARIABLE: NUMERIC_STATIC_SUFFIX
+# @INTERNAL
+# @DESCRIPTION:
+# MULTIBUILD_ID suffix for static build
+NUMERIC_STATIC_SUFFIX="static"
+
+# @FUNCTION: numeric-int64_is_int64_build
+# @DESCRIPTION:
+# Returns shell true if the current multibuild is a int64 build,
+# else returns shell false.
+#
+# Example:
+#
+# @CODE
+#      $(numeric-int64_is_int64_build) && \
+#              openblas_abi_cflags+=" -DOPENBLAS_USE64BITINT"
+# @CODE
+numeric-int64_is_int64_build() {
+       debug-print-function ${FUNCNAME} "${@}"
+       if [[ "${MULTIBUILD_ID}" =~ "${NUMERIC_INT64_SUFFIX}" ]]; then
+               return 0
+       else
+               return 1
+       fi
+}
+
+# @FUNCTION: numeric-int64_is_static_build
+# @DESCRIPTION:
+# Returns shell true if current multibuild is a static build,
+# else returns shell false.
+#
+# Example:
+#
+# @CODE
+#      if $(numeric-int64_is_static_build); then
+#              dolib.a lib*a
+#      fi
+# @CODE
+numeric-int64_is_static_build() {
+       debug-print-function ${FUNCNAME} "${@}"
+       if [[ "${MULTIBUILD_ID}" =~ "${NUMERIC_STATIC_SUFFIX}" ]]; then
+               return 0
+       else
+               return 1
+       fi
+}
+
+# @FUNCTION: numeric-int64_get_module_name
+# @USAGE: [<module_name>]
+# @DESCRIPTION:
+# Return the numeric module name, without the .pc extension,
+# for the current fortran int64 build.  If the current build is not an int64
+# build, and the ebuild does not have dynamic, threads or openmp USE flags or
+# they are disabled, then the module_name is ${NUMERIC_MODULE_NAME} or
+# <module_name> if <module_name> is specified.
+#
+# Takes an optional <module_name> parameter.  If no <module_name> is specified,
+# uses ${NUMERIC_MODULE_NAME} as the base to calculate the module_name for the
+# current build.
+#
+# Example:
+#
+# @CODE
+#      NUMERIC_MODULE_NAME=blas
+#      profname=$(numeric-int64_get_module_name)
+#
+#      int32 build:
+#      -> profname == blas
+#
+#      int64 build:
+#      -> profname == blas-int64
+# @CODE
+numeric-int64_get_module_name() {
+       debug-print-function ${FUNCNAME} "${@}"
+       local module_name="${1:-${NUMERIC_MODULE_NAME}}"
+       if has dynamic ${IUSE} && use dynamic; then
+               module_name+="-dynamic"
+       fi
+       if $(numeric-int64_is_int64_build); then
+               module_name+="-${NUMERIC_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_if_iuse threads; then
+               module_name+="-threads"
+       elif use_if_iuse openmp; then
+               module_name+="-openmp"
+       fi
+       echo "${module_name}"
+}
+
+# @FUNCTION: _numeric-int64_get_numeric_alternative
+# @INTERNAL
+_numeric-int64_get_numeric_alternative() {
+       debug-print-function ${FUNCNAME} "${@}"
+       local alternative_name="${1}"
+       if $(numeric-int64_is_int64_build); then
+               alternative_name+="-${NUMERIC_INT64_SUFFIX}"
+       fi
+       echo "${alternative_name}"
+}
+
+# @FUNCTION: numeric-int64_get_blas_alternative
+# @DESCRIPTION:
+# Returns the eselect blas alternative for the current
+# int build type. Which is blas-int64 if called from an int64 build,
+# or blas otherwise.
+numeric-int64_get_blas_alternative() {
+       debug-print-function ${FUNCNAME} "${@}"
+       _numeric-int64_get_numeric_alternative blas
+}
+
+# @FUNCTION: numeric-int64_get_cblas_alternative
+# @DESCRIPTION:
+# Returns the eselect cblas alternative for the current
+# int build type. Which is cblas-int64 if called from an int64 build,
+# or cblas otherwise.
+numeric-int64_get_cblas_alternative() {
+       debug-print-function ${FUNCNAME} "${@}"
+       _numeric-int64_get_numeric_alternative cblas
+}
+
+# @FUNCTION: numeric-int64_get_xblas_alternative
+# @DESCRIPTION:
+# Returns the eselect xblas alternative for the current
+# int build type. Which is xblas-int64 if called from an int64 build,
+# or xblas otherwise.
+numeric-int64_get_xblas_alternative() {
+       debug-print-function ${FUNCNAME} "${@}"
+       _numeric-int64_get_numeric_alternative xblas
+}
+
+# @FUNCTION: numeric-int64_get_lapack_alternative
+# @DESCRIPTION:
+# Returns the eselect lapack alternative for the current
+# int build type. Which is lapack-int64 if called from an int64 build,
+# or lapack otherwise.
+numeric-int64_get_lapack_alternative() {
+       debug-print-function ${FUNCNAME} "${@}"
+       _numeric-int64_get_numeric_alternative lapack
+}
+
+# @FUNCTION: numeric-int64_get_blas_module_name
+# @DESCRIPTION:
+# Returns the pkg-config file name, without the .pc extension,
+# for the currently selected blas-int64 module if we are performing an int64
+# build, or the currently selected blas module otherwise.
+numeric-int64_get_blas_module_name() {
+       debug-print-function ${FUNCNAME} "${@}"
+       local blas_alternative=$(numeric-int64_get_blas_alternative)
+       local blas_symlinks=( $(eselect "${blas_alternative}" files) )
+       local blas_prof_symlink="$(readlink -f ${blas_symlinks[0]})"
+       local blas_prof_file="${blas_prof_symlink##*/}"
+       echo "${blas_prof_file%.pc}"
+}
+
+# @FUNCTION: numeric-int64_get_xblas_module_name
+# @DESCRIPTION:
+# Returns the xblas pkg-config file name,
+# without the .pc extension, for the current build. Which is xblas-int64 if
+# we are performing an int64 build, or xblas otherwise.
+numeric-int64_get_xblas_module_name() {
+       debug-print-function ${FUNCNAME} "${@}"
+       local xblas_provider="xblas"
+       if $(numeric-int64_is_int64_build); then
+               xblas_provider+="-${INT64_SUFFIX}"
+       fi
+       echo "${xblas_provider}"
+}
+
+# @FUNCTION: numeric-int64_get_fortran_int64_abi_fflags
+# @DESCRIPTION:
+# Return the Fortran compiler flag to enable 64 bit integers for
+# array indices if we are performing an int64 build, or the empty string
+# otherwise.
+#
+# Example:
+#
+# @CODE
+# src_configure() {
+#      my_configure() {
+#              export FCFLAGS="${FCFLAGS} $(get_abi_CFLAGS) 
$(numeric-int64_get_fortran_int64_abi_fflags)"
+#              econf $(use_enable fortran)
+#      }
+#      numeric-int64-multibuild_foreach_all_abi_variants run_in_build_dir 
my_configure
+# }
+# @CODE
+numeric-int64_get_fortran_int64_abi_fflags() {
+       debug-print-function ${FUNCNAME} "${@}"
+       $(numeric-int64_is_int64_build) && echo "$(fortran_int64_abi_fflags)"
+}
+
+# @FUNCTION: numeric-int64_get_multibuild_int_variants
+# @DESCRIPTION:
+# Returns the array of int64 and int32
+# multibuild combinations.
+numeric-int64_get_multibuild_int_variants() {
+       debug-print-function ${FUNCNAME} "${@}"
+       local MULTIBUILD_VARIANTS=( int32 ) variant
+
+       use_if_iuse int64 && MULTIBUILD_VARIANTS+=( int64 )
+
+       echo "${MULTIBUILD_VARIANTS[@]}"
+}
+
+# @FUNCTION: numeric-int64_get_multibuild_variants
+# @DESCRIPTION:
+# Returns the array of int64, int32 and static
+# multibuild combinations.
+numeric-int64_get_multibuild_variants() {
+       debug-print-function ${FUNCNAME} "${@}"
+       local MULTIBUILD_VARIANTS=$(numeric-int64_get_multibuild_int_variants)
+       if use_if_iuse static-libs; then
+               for variant in ${MULTIBUILD_VARIANTS[@]}; do
+                       MULTIBUILD_VARIANTS+=( static_${variant} )
+               done
+       fi
+       echo "${MULTIBUILD_VARIANTS[@]}"
+}
+
+# @FUNCTION: numeric-int64_get_all_abi_variants
+# @DESCRIPTION:
+# Returns the array of int64, int32 and static build combinations
+# combined with all multilib ABI variants.
+numeric-int64_get_all_abi_variants() {
+       debug-print-function ${FUNCNAME} "${@}"
+       local abi ret=() variant
+
+       for abi in $(multilib_get_enabled_abis); do
+               for variant in $(numeric-int64_get_multibuild_variants); do
+                       if [[ ${variant} =~ int64 ]]; then
+                               [[ ${abi} =~ amd64 ]] && ret+=( 
${abi}_${variant} )
+                       else
+                               ret+=( ${abi}_${variant} )
+                       fi
+               done
+       done
+       echo "${ret[@]}"
+}
+
+# @FUNCTION: numeric-int64_ensure_blas_int_support
+# @DESCRIPTION:
+# Check the blas supports the necessary int types in the currently
+# selected blas module.
+#
+# Example:
+#
+# @CODE
+# src_prepare() {
+#      numeric-int64_ensure_blas_int_support
+#      ...
+# @CODE
+numeric-int64_ensure_blas_int_support() {
+       local MULTILIB_INT64_VARIANTS=( 
$(numeric-int64_get_multibuild_variants) )
+       local MULTIBUILD_ID
+       for MULTIBUILD_ID in "${MULTILIB_INT64_VARIANTS[@]}"; do
+               local blas_module_name=$(numeric-int64_get_blas_module_name)
+               $(tc-getPKG_CONFIG) --exists "${blas_module_name}" \
+                       || die "${PN} requires the pkgbuild module 
${blas_module_name}"
+       done
+}
+
+# @FUNCTION: numeric-int64-multibuild_install_alternative
+# @USAGE: <alternative name> <provider name> [extra files sources] [extra 
files dest]
+# @DESCRIPTION:
+# Install alternatives pc file and extra files for all providers for all 
multilib ABIs.
+numeric-int64-multibuild_install_alternative() {
+       debug-print-function ${FUNCNAME} "${@}"
+       [[ $# -lt 2 ]] && die "${FUNCNAME} needs at least two arguments"
+       pc_file()  {
+               debug-print-function ${FUNCNAME} "${@}"
+               numeric-int64_is_static_build && return
+               local alternative=$(_numeric-int64_get_numeric_alternative "$1")
+               local module_name=$(numeric-int64_get_module_name)
+               printf \
+                       "/usr/$(get_libdir)/pkgconfig/${alternative}.pc 
${module_name}.pc " \
+                       >> "${T}"/alternative-${alternative}.sh || die
+       }
+       pc_install() {
+               debug-print-function ${FUNCNAME} "${@}"
+               numeric-int64_is_static_build && return
+               local alternative=$(_numeric-int64_get_numeric_alternative "$1")
+               local module_name=$(numeric-int64_get_module_name $2)
+               shift 2
+               alternatives_for \
+                       ${alternative} ${module_name} 0 \
+                       $(cat "${T}"/alternative-${alternative}.sh) ${@}
+       }
+       numeric-int64-multibuild_foreach_all_abi_variants pc_file ${@}
+       numeric-int64-multibuild_foreach_int_abi pc_install ${@}
+}
+
+# @FUNCTION: numeric-int64-multibuild_multilib_wrapper
+# @USAGE: <argv>...
+# @DESCRIPTION:
+# Initialize the environment for ABI selected for multibuild.
+#
+# Example:
+#
+# @CODE
+#      multibuild_foreach_variant run_in_build_dir \
+#              numeric-int64-multibuild_multilib_wrapper my_src_install
+# @CODE
+numeric-int64-multibuild_multilib_wrapper() {
+       debug-print-function ${FUNCNAME} "${@}"
+       local v="${MULTIBUILD_VARIANT/_${NUMERIC_INT32_SUFFIX}/}"
+       local v="${v/_${NUMERIC_INT64_SUFFIX}/}"
+       local ABI="${v/_${NUMERIC_STATIC_SUFFIX}/}"
+       multilib_toolchain_setup "${ABI}"
+       "${@}" || die
+}
+
+# @FUNCTION: numeric-int64-multibuild_foreach_int_abi
+# @USAGE: <argv> ...
+# @DESCRIPTION:
+# Run command for each enabled numeric variant (e.g. int32, int64)
+numeric-int64-multibuild_foreach_int_abi() {
+       debug-print-function ${FUNCNAME} "${@}"
+       local MULTIBUILD_VARIANTS=( 
$(numeric-int64_get_multibuild_int_variants) )
+       multibuild_foreach_variant numeric-int64-multibuild_multilib_wrapper 
"${@}"
+}
+
+# @FUNCTION: numeric-int64-multibuild_foreach_variant
+# @USAGE: <argv> ...
+# @DESCRIPTION:
+# Run command for each enabled numeric abi and static-libs (e.g. int32, int64, 
static)
+numeric-int64-multibuild_foreach_variant() {
+       debug-print-function ${FUNCNAME} "${@}"
+       local MULTIBUILD_VARIANTS=( $(numeric-int64_get_multibuild_variants) )
+       multibuild_foreach_variant numeric-int64-multibuild_multilib_wrapper 
"${@}"
+}
+
+# @FUNCTION: numeric-int64-multibuild_foreach_all_abi_variants
+# @USAGE: <argv> ...
+# @DESCRIPTION:
+# Run command for each enabled numeric variant (e.g. int32, int64, static) 
_AND_
+# enabled multilib ABI
+numeric-int64-multibuild_foreach_all_abi_variants() {
+       debug-print-function ${FUNCNAME} "${@}"
+       local MULTIBUILD_VARIANTS=( $(numeric-int64_get_all_abi_variants) )
+       multibuild_foreach_variant numeric-int64-multibuild_multilib_wrapper 
"${@}"
+}
+
+# @FUNCTION: numeric-int64-multibuild_copy_sources
+# @DESCRIPTION:
+# Thin wrapper around multibuild_copy_sources()
+numeric-int64-multibuild_copy_sources() {
+
+       debug-print-function ${FUNCNAME} "${@}"
+       local MULTIBUILD_VARIANTS=( $(numeric-int64_get_all_abi_variants) )
+       multibuild_copy_sources
+}
+
+_NUMERIC_INT64_MULTILIB_ECLASS=1
+fi

diff --git a/eclass/numeric.eclass b/eclass/numeric.eclass
index b3f92be..adee3c5 100644
--- a/eclass/numeric.eclass
+++ b/eclass/numeric.eclass
@@ -10,22 +10,43 @@
 # Various functions which make the maintenance  numerical algebra packages
 # easier.
 
+case ${EAPI:-0} in
+       0|1|2|3|4|5) ;;
+       *) die "EAPI=${EAPI} is not supported" ;;
+esac
+
+if [[ ! ${_NUMERIC_ECLASS} ]]; then
+
 inherit multilib
 
+# @VARIABLE: NUMERIC_MODULE_NAME
+# @DESCRIPTION:
+# The base pkg-config module name of the package being built.
+# NUMERIC_MODULE_NAME is used by the numeric-int64_get_module_name to
+# determine the pkg-config module name based on whether the package
+# has dynamic, threads or openmp USE flags and if so, if the user has
+# turned them or, and if the current multibuild is a int64 build or not.
+#
+# @CODE
+# NUMERIC_MODULE_NAME="openblas"
+# inherit ... numeric-int64-multibuild
+# @CODE
+: ${NUMERIC_MODULE_NAME:=blas}
+
 # @FUNCTION: create_pkgconfig
 # @USAGE: [ additional arguments ]
 # @DESCRIPTION:
-# Creates and installs .pc file. The function should only be executed in
+# Creates and installs pkg-config file. The function should only be executed in
 # src_install(). For further information about optional arguments please 
consult
 # http://people.freedesktop.org/~dbn/pkg-config-guide.html
 #
 # @CODE
 # Optional arguments are:
 #
-#   -p | --prefix       Offset for current package   (${EPREFIX}/usr)
-#   -e | --exec-prefix  Offset for current package   (${prefix})
-#   -L | --libdir       Libdir to use                (${prefix}/$(get_libdir))
-#   -I | --includedir   Includedir to use                  (${prefix}/include)
+#   -p | --prefix       Offset for current package               
(${EPREFIX}/usr)
+#   -e | --exec-prefix  Offset for current package               (${prefix})
+#   -L | --libdir       Libdir to use                            
(${prefix}/$(get_libdir))
+#   -I | --includedir   Includedir to use                        
(${prefix}/include)
 #   -n | --name         A human-readable name                    (PN}
 #   -d | --description  A brief description                      (DESCRIPTION)
 #   -V | --version      Version of the package                   (PV)
@@ -38,6 +59,7 @@ inherit multilib
 #   --libs-private      Like --libs, but not exposed             (unset)
 # @CODE
 create_pkgconfig() {
+       debug-print-function ${FUNCNAME} "${@}"
        local pcfilename pcrequires pcrequirespriv pcconflicts pclibs 
pclibspriv pccflags
        local pcprefix="${EPREFIX}/usr"
        local pcexecprefix="${pcprefix}"
@@ -112,3 +134,6 @@ create_pkgconfig() {
        insinto /usr/$(get_libdir)/pkgconfig
        doins "${T}"/${pcfilename}.pc
 }
+
+_NUMERIC_ECLASS=1
+fi

diff --git a/sci-libs/blas-reference/blas-reference-20131116-r1.ebuild 
b/sci-libs/blas-reference/blas-reference-20131116-r1.ebuild
deleted file mode 100644
index 4b9d2ea..0000000
--- a/sci-libs/blas-reference/blas-reference-20131116-r1.ebuild
+++ /dev/null
@@ -1,118 +0,0 @@
-# Copyright 1999-2014 Gentoo Foundation
-# Distributed under the terms of the GNU General Public License v2
-# $Id$
-
-EAPI=5
-
-EBASE_PROFNAME="refblas"
-ESTATIC_MULTIBUILD="true"
-inherit fortran-2 cmake-utils alternatives-2 multibuild multilib-build 
toolchain-funcs fortran-int64
-
-LPN=lapack
-LPV=3.5.0
-
-if [[ ${PV} == "99999999" ]] ; then
-       ESVN_REPO_URI="https://icl.cs.utk.edu/svn/lapack-dev/${LPN}/trunk";
-       inherit subversion
-       KEYWORDS=""
-else
-       SRC_URI="http://www.netlib.org/${LPN}/${LPN}-${LPV}.tgz";
-       KEYWORDS="~amd64 ~x86 ~amd64-linux ~x86-linux"
-fi
-
-DESCRIPTION="Reference implementation of BLAS"
-HOMEPAGE="http://www.netlib.org/lapack/";
-
-LICENSE="BSD"
-SLOT="0"
-IUSE="int64 static-libs test"
-
-RDEPEND=""
-DEPEND="${RDEPEND}
-       virtual/pkgconfig"
-PDEPEND=">=virtual/blas-2.1-r3[int64?]"
-
-S="${WORKDIR}/${LPN}-${LPV}"
-
-src_prepare() {
-       # rename library to avoid collision with other blas implementations
-       # ${LIBNAME} and ${PROFNAME} are not defined here, they are in single
-       # quotes in the following seds.  They are later set by defining cmake
-       # variables with -DPROFNAME etc in src_configure
-       sed -i \
-               -e 's:\([^xc]\)blas:\1${LIBNAME}:g' \
-               CMakeLists.txt \
-               BLAS/SRC/CMakeLists.txt || die
-       sed -i \
-               -e '/Name: /s:blas:${PROFNAME}:' \
-               -e 's:-lblas:-l${LIBNAME}:g' \
-                BLAS/blas.pc.in || die
-       sed -i \
-               -e 's:blas):${LIBNAME}):' \
-               BLAS/TESTING/CMakeLists.txt || die
-       sed -i \
-               -e 's:BINARY_DIR}/blas:BINARY_DIR}/${PROFNAME}:' \
-               BLAS/CMakeLists.txt || die
-}
-
-src_configure() {
-       local MULTIBUILD_VARIANTS=( $(fortran-int64_multilib_get_enabled_abis) )
-       blas_configure() {
-               local profname=$(fortran-int64_get_profname)
-               local libname="${profname//-/_}"
-               local mycmakeargs=(
-                       -Wno-dev
-                       -DPROFNAME="${profname}"
-                       -DLIBNAME="${libname}"
-                       -DUSE_OPTIMIZED_BLAS=OFF
-                       $(cmake-utils_use_build test TESTING)
-                       -DCMAKE_Fortran_FLAGS="$($(tc-getPKG_CONFIG) --cflags 
${blas_profname}) $(get_abi_CFLAGS) 
$(fortran-int64_get_fortran_int64_abi_fflags) ${FCFLAGS}"
-                       
-DLAPACK_PKGCONFIG_FFLAGS="$(fortran-int64_get_fortran_int64_abi_fflags)"
-               )
-               if $(fortran-int64_is_static_build); then
-                       mycmakeargs+=(
-                               -DBUILD_SHARED_LIBS=OFF
-                               -DBUILD_STATIC_LIBS=ON
-                       )
-               else
-                       mycmakeargs+=(
-                               -DBUILD_SHARED_LIBS=ON
-                               -DBUILD_STATIC_LIBS=OFF
-                       )
-               fi
-               cmake-utils_src_configure
-       }
-       multibuild_foreach_variant fortran-int64_multilib_multibuild_wrapper 
blas_configure
-}
-
-src_compile() {
-       local MULTIBUILD_VARIANTS=( $(fortran-int64_multilib_get_enabled_abis) )
-       multibuild_foreach_variant fortran-int64_multilib_multibuild_wrapper 
cmake-utils_src_compile -C BLAS
-}
-
-src_test() {
-       local MULTIBUILD_VARIANTS=( $(fortran-int64_multilib_get_enabled_abis) )
-       blas_test() {
-               _check_build_dir
-               pushd "${BUILD_DIR}/BLAS" > /dev/null
-               local ctestargs
-               [[ -n ${TEST_VERBOSE} ]] && ctestargs="--extra-verbose 
--output-on-failure"
-               ctest ${ctestargs} || die
-               popd > /dev/null
-       }
-       multibuild_foreach_variant fortran-int64_multilib_multibuild_wrapper 
blas_test
-}
-
-src_install() {
-       local MULTIBUILD_VARIANTS=( $(fortran-int64_multilib_get_enabled_abis) )
-       my_src_install()  {
-               cmake-utils_src_install -C BLAS
-               if ! $(fortran-int64_is_static_build); then
-                       local profname=$(fortran-int64_get_profname)
-                       local provider=$(fortran-int64_get_blas_provider)
-                       alternatives_for ${provider} 
$(fortran-int64_get_profname "reference") 0 \
-                               /usr/$(get_libdir)/pkgconfig/${provider}.pc 
${profname}.pc
-               fi
-       }
-       multibuild_foreach_variant fortran-int64_multilib_multibuild_wrapper 
my_src_install
-}

diff --git a/sci-libs/blas-reference/blas-reference-20131116-r2.ebuild 
b/sci-libs/blas-reference/blas-reference-20131116-r2.ebuild
new file mode 100644
index 0000000..3b4d976
--- /dev/null
+++ b/sci-libs/blas-reference/blas-reference-20131116-r2.ebuild
@@ -0,0 +1,107 @@
+# Copyright 1999-2015 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Id$
+
+EAPI=5
+
+PYTHON_COMPAT=( python2_7 )
+
+NUMERIC_MODULE_NAME="refblas"
+
+inherit alternatives-2 cmake-utils fortran-2 numeric-int64-multibuild 
python-any-r1 toolchain-funcs
+
+LPN=lapack
+LPV=3.5.0
+
+DESCRIPTION="Reference implementation of BLAS"
+HOMEPAGE="http://www.netlib.org/lapack/";
+SRC_URI="http://www.netlib.org/${LPN}/${LPN}-${LPV}.tgz";
+
+LICENSE="BSD"
+SLOT="0"
+KEYWORDS="~amd64 ~x86 ~amd64-linux ~x86-linux"
+IUSE="static-libs test"
+
+REQUIRED_USE="test? ( ${PYTHON_REQUIRED_USE} )"
+
+RDEPEND=""
+DEPEND="${RDEPEND}
+       test? ( ${PYTHON_DEPS} )
+       virtual/pkgconfig"
+
+S="${WORKDIR}/${LPN}-${LPV}"
+
+src_prepare() {
+       # rename library to avoid collision with other blas implementations
+       # ${LIBNAME} and ${PROFNAME} are not defined here, they are in single
+       # quotes in the following seds.  They are later set by defining cmake
+       # variables with -DPROFNAME etc in src_configure
+       sed -i \
+               -e 's:\([^xc]\)blas:\1${LIBNAME}:g' \
+               CMakeLists.txt \
+               BLAS/SRC/CMakeLists.txt || die
+       sed -i \
+               -e '/Name: /s:blas:${PROFNAME}:' \
+               -e 's:-lblas:-l${LIBNAME}:g' \
+                BLAS/blas.pc.in || die
+       sed -i \
+               -e 's:blas):${LIBNAME}):' \
+               BLAS/TESTING/CMakeLists.txt || die
+       sed -i \
+               -e 's:BINARY_DIR}/blas:BINARY_DIR}/${PROFNAME}:' \
+               BLAS/CMakeLists.txt || die
+}
+
+src_configure() {
+       blas_configure() {
+               local FCFLAGS="${FCFLAGS}"
+               append-fflags $($(tc-getPKG_CONFIG) --cflags ${blas_profname})
+               append-fflags $(get_abi_CFLAGS)
+               append-fflags $(numeric-int64_get_fortran_int64_abi_fflags)
+
+               local profname=$(numeric-int64_get_module_name)
+               local libname="${profname//-/_}"
+
+               local mycmakeargs=(
+                       -Wno-dev
+                       -DPROFNAME="${profname}"
+                       -DLIBNAME="${libname}"
+                       -DUSE_OPTIMIZED_BLAS=OFF
+                       -DCMAKE_Fortran_FLAGS="${FCFLAGS}"
+                       
-DLAPACK_PKGCONFIG_FFLAGS="$(numeric-int64_get_fortran_int64_abi_fflags)"
+                       $(cmake-utils_use_build test TESTING)
+               )
+               if $(numeric-int64_is_static_build); then
+                       mycmakeargs+=(
+                               -DBUILD_SHARED_LIBS=OFF
+                               -DBUILD_STATIC_LIBS=ON
+                       )
+               else
+                       mycmakeargs+=(
+                               -DBUILD_SHARED_LIBS=ON
+                               -DBUILD_STATIC_LIBS=OFF
+                       )
+               fi
+               cmake-utils_src_configure
+       }
+       numeric-int64-multibuild_foreach_all_abi_variants blas_configure
+}
+
+src_compile() {
+       local each target_dirs=( BLAS )
+       use test && target_dirs+=( TESTING )
+       for each in ${target_dirs[@]}; do
+               numeric-int64-multibuild_foreach_all_abi_variants \
+                       cmake-utils_src_compile -C ${each}
+       done
+
+}
+
+src_test() {
+       numeric-int64-multibuild_foreach_all_abi_variants cmake-utils_src_test
+}
+
+src_install() {
+       numeric-int64-multibuild_foreach_all_abi_variants 
cmake-utils_src_install -C BLAS
+       numeric-int64-multibuild_install_alternative blas reference
+}

diff --git a/sci-libs/blas-reference/blas-reference-20131116.ebuild 
b/sci-libs/blas-reference/blas-reference-20131116.ebuild
deleted file mode 100644
index 94337c9..0000000
--- a/sci-libs/blas-reference/blas-reference-20131116.ebuild
+++ /dev/null
@@ -1,78 +0,0 @@
-# Copyright 1999-2014 Gentoo Foundation
-# Distributed under the terms of the GNU General Public License v2
-# $Id$
-
-EAPI=5
-
-inherit fortran-2 cmake-utils alternatives-2
-
-LPN=lapack
-LPV=3.5.0
-
-if [[ ${PV} == "99999999" ]] ; then
-       ESVN_REPO_URI="https://icl.cs.utk.edu/svn/lapack-dev/${LPN}/trunk";
-       inherit subversion
-       KEYWORDS=""
-else
-       SRC_URI="http://www.netlib.org/${LPN}/${LPN}-${LPV}.tgz";
-       KEYWORDS="~amd64 ~x86 ~amd64-linux ~x86-linux"
-fi
-
-DESCRIPTION="Reference implementation of BLAS"
-HOMEPAGE="http://www.netlib.org/lapack/";
-
-LICENSE="BSD"
-SLOT="0"
-IUSE="static-libs test"
-
-S="${WORKDIR}/${LPN}-${LPV}"
-
-src_prepare() {
-       # rename library to avoid collision with other blas implementations
-       sed -i \
-               -e 's:blas:refblas:g' \
-               CMakeLists.txt BLAS/blas.pc.in \
-               BLAS/{SRC,TESTING}/CMakeLists.txt || die
-       sed -i \
-               -e 's:BINARY_DIR}/blas:BINARY_DIR}/refblas:' \
-               BLAS/CMakeLists.txt || die
-       use static-libs && mkdir "${WORKDIR}/${PN}_static"
-}
-
-src_configure() {
-       blas_configure() {
-               local mycmakeargs=(
-                       -DUSE_OPTIMIZED_BLAS=OFF
-                       $(cmake-utils_use_build test TESTING)
-                       $@
-               )
-               cmake-utils_src_configure
-       }
-
-       blas_configure -DBUILD_SHARED_LIBS=ON -DBUILD_STATIC_LIBS=OFF
-       use static-libs && \
-               CMAKE_BUILD_DIR="${WORKDIR}/${PN}_static" blas_configure \
-               -DBUILD_SHARED_LIBS=OFF -DBUILD_STATIC_LIBS=ON
-}
-
-src_compile() {
-       cmake-utils_src_compile -C BLAS
-       use static-libs && CMAKE_BUILD_DIR="${WORKDIR}/${PN}_static" \
-               cmake-utils_src_compile -C BLAS
-}
-
-src_test() {
-       pushd "${CMAKE_BUILD_DIR}/BLAS" > /dev/null
-       local ctestargs
-       [[ -n ${TEST_VERBOSE} ]] && ctestargs="--extra-verbose 
--output-on-failure"
-       ctest ${ctestargs} || die
-       popd > /dev/null
-}
-
-src_install() {
-       cmake-utils_src_install -C BLAS
-       use static-libs && CMAKE_BUILD_DIR="${WORKDIR}/${PN}_static" \
-                       cmake-utils_src_install -C BLAS
-       alternatives_for blas reference 0 \
-               /usr/$(get_libdir)/pkgconfig/blas.pc refblas.pc
-}

diff --git a/sci-libs/blas-reference/blas-reference-99999999.ebuild 
b/sci-libs/blas-reference/blas-reference-99999999.ebuild
index 4b9d2ea..b079855 100644
--- a/sci-libs/blas-reference/blas-reference-99999999.ebuild
+++ b/sci-libs/blas-reference/blas-reference-99999999.ebuild
@@ -1,34 +1,32 @@
-# Copyright 1999-2014 Gentoo Foundation
+# Copyright 1999-2015 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 # $Id$
 
 EAPI=5
 
-EBASE_PROFNAME="refblas"
-ESTATIC_MULTIBUILD="true"
-inherit fortran-2 cmake-utils alternatives-2 multibuild multilib-build 
toolchain-funcs fortran-int64
+PYTHON_COMPAT=( python2_7 )
+
+NUMERIC_MODULE_NAME="refblas"
+
+inherit alternatives-2 cmake-utils fortran-2 numeric-int64-multibuild 
python-any-r1 toolchain-funcs subversion
 
 LPN=lapack
 LPV=3.5.0
 
-if [[ ${PV} == "99999999" ]] ; then
-       ESVN_REPO_URI="https://icl.cs.utk.edu/svn/lapack-dev/${LPN}/trunk";
-       inherit subversion
-       KEYWORDS=""
-else
-       SRC_URI="http://www.netlib.org/${LPN}/${LPN}-${LPV}.tgz";
-       KEYWORDS="~amd64 ~x86 ~amd64-linux ~x86-linux"
-fi
-
 DESCRIPTION="Reference implementation of BLAS"
 HOMEPAGE="http://www.netlib.org/lapack/";
+ESVN_REPO_URI="https://icl.cs.utk.edu/svn/lapack-dev/${LPN}/trunk";
 
 LICENSE="BSD"
 SLOT="0"
-IUSE="int64 static-libs test"
+KEYWORDS=""
+IUSE="static-libs test"
+
+REQUIRED_USE="test? ( ${PYTHON_REQUIRED_USE} )"
 
 RDEPEND=""
 DEPEND="${RDEPEND}
+       test? ( ${PYTHON_DEPS} )
        virtual/pkgconfig"
 PDEPEND=">=virtual/blas-2.1-r3[int64?]"
 
@@ -56,20 +54,25 @@ src_prepare() {
 }
 
 src_configure() {
-       local MULTIBUILD_VARIANTS=( $(fortran-int64_multilib_get_enabled_abis) )
        blas_configure() {
-               local profname=$(fortran-int64_get_profname)
+               local FCFLAGS="${FCFLAGS}"
+               append-fflags $($(tc-getPKG_CONFIG) --cflags ${blas_profname})
+               append-fflags $(get_abi_CFLAGS)
+               append-fflags $(numeric-int64_get_fortran_int64_abi_fflags)
+
+               local profname=$(numeric-int64_get_module_name)
                local libname="${profname//-/_}"
+
                local mycmakeargs=(
                        -Wno-dev
                        -DPROFNAME="${profname}"
                        -DLIBNAME="${libname}"
                        -DUSE_OPTIMIZED_BLAS=OFF
+                       -DCMAKE_Fortran_FLAGS="${FCFLAGS}"
+                       
-DLAPACK_PKGCONFIG_FFLAGS="$(numeric-int64_get_fortran_int64_abi_fflags)"
                        $(cmake-utils_use_build test TESTING)
-                       -DCMAKE_Fortran_FLAGS="$($(tc-getPKG_CONFIG) --cflags 
${blas_profname}) $(get_abi_CFLAGS) 
$(fortran-int64_get_fortran_int64_abi_fflags) ${FCFLAGS}"
-                       
-DLAPACK_PKGCONFIG_FFLAGS="$(fortran-int64_get_fortran_int64_abi_fflags)"
                )
-               if $(fortran-int64_is_static_build); then
+               if $(numeric-int64_is_static_build); then
                        mycmakeargs+=(
                                -DBUILD_SHARED_LIBS=OFF
                                -DBUILD_STATIC_LIBS=ON
@@ -82,37 +85,24 @@ src_configure() {
                fi
                cmake-utils_src_configure
        }
-       multibuild_foreach_variant fortran-int64_multilib_multibuild_wrapper 
blas_configure
+       numeric-int64-multibuild_foreach_all_abi_variants blas_configure
 }
 
 src_compile() {
-       local MULTIBUILD_VARIANTS=( $(fortran-int64_multilib_get_enabled_abis) )
-       multibuild_foreach_variant fortran-int64_multilib_multibuild_wrapper 
cmake-utils_src_compile -C BLAS
+       local each target_dirs=( BLAS )
+       use test && target_dirs+=( TESTING )
+       for each in ${target_dirs[@]}; do
+               numeric-int64-multibuild_foreach_all_abi_variants \
+                       cmake-utils_src_compile -C ${each}
+       done
+
 }
 
 src_test() {
-       local MULTIBUILD_VARIANTS=( $(fortran-int64_multilib_get_enabled_abis) )
-       blas_test() {
-               _check_build_dir
-               pushd "${BUILD_DIR}/BLAS" > /dev/null
-               local ctestargs
-               [[ -n ${TEST_VERBOSE} ]] && ctestargs="--extra-verbose 
--output-on-failure"
-               ctest ${ctestargs} || die
-               popd > /dev/null
-       }
-       multibuild_foreach_variant fortran-int64_multilib_multibuild_wrapper 
blas_test
+       numeric-int64-multibuild_foreach_all_abi_variants cmake-utils_src_test
 }
 
 src_install() {
-       local MULTIBUILD_VARIANTS=( $(fortran-int64_multilib_get_enabled_abis) )
-       my_src_install()  {
-               cmake-utils_src_install -C BLAS
-               if ! $(fortran-int64_is_static_build); then
-                       local profname=$(fortran-int64_get_profname)
-                       local provider=$(fortran-int64_get_blas_provider)
-                       alternatives_for ${provider} 
$(fortran-int64_get_profname "reference") 0 \
-                               /usr/$(get_libdir)/pkgconfig/${provider}.pc 
${profname}.pc
-               fi
-       }
-       multibuild_foreach_variant fortran-int64_multilib_multibuild_wrapper 
my_src_install
+       numeric-int64-multibuild_foreach_all_abi_variants 
cmake-utils_src_install -C BLAS
+       numeric-int64-multibuild_install_alternative blas reference
 }

diff --git a/sci-libs/blas-reference/metadata.xml 
b/sci-libs/blas-reference/metadata.xml
index 346d64c..f5000eb 100644
--- a/sci-libs/blas-reference/metadata.xml
+++ b/sci-libs/blas-reference/metadata.xml
@@ -1,8 +1,8 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <!DOCTYPE pkgmetadata SYSTEM "http://www.gentoo.org/dtd/metadata.dtd";>
 <pkgmetadata>
-<herd>sci</herd>
-<longdescription lang="en">
+  <herd>sci</herd>
+  <longdescription lang="en">
   The BLAS (Basic Linear Algebra Subprograms) are high quality "building
   block" routines for performing basic vector and matrix operations. Level 1
   BLAS do vector-vector operations, Level 2 BLAS do matrix-vector operations,

diff --git a/sci-libs/cblas-reference/cblas-reference-20110218-r1.ebuild 
b/sci-libs/cblas-reference/cblas-reference-20110218-r1.ebuild
index 9e7e1f3..e875937 100644
--- a/sci-libs/cblas-reference/cblas-reference-20110218-r1.ebuild
+++ b/sci-libs/cblas-reference/cblas-reference-20110218-r1.ebuild
@@ -4,8 +4,9 @@
 
 EAPI=5
 
-EBASE_PROFNAME="refcblas"
-inherit eutils alternatives-2 flag-o-matic toolchain-funcs versionator 
multilib fortran-2 multilib-build fortran-int64
+NUMERIC_MODULE_NAME="refcblas"
+
+inherit alternatives-2 flag-o-matic fortran-2 multilib numeric 
numeric-int64-multibuild toolchain-funcs versionator
 
 MYPN="${PN/-reference/}"
 
@@ -15,13 +16,12 @@ SRC_URI="http://www.netlib.org/blas/blast-forum/${MYPN}.tgz 
-> ${P}.tgz"
 
 SLOT="0"
 LICENSE="public-domain"
-IUSE="int64 static-libs"
 KEYWORDS="~alpha ~amd64 ~hppa ~ppc ~ppc64 ~s390 ~sparc ~x86 ~x86-fbsd 
~amd64-linux ~x86-linux ~x64-macos ~x86-macos"
+IUSE="static-libs"
 
 RDEPEND="virtual/blas"
 DEPEND="${RDEPEND}
        virtual/pkgconfig"
-PDEPEND=">=virtual/cblas-2.0-r2[int64?]"
 
 S="${WORKDIR}/CBLAS"
 
@@ -31,7 +31,7 @@ MULTILIB_WRAPPED_HEADERS=(
 
 static_to_shared() {
        local libstatic=$1
-       shift
+       shift || die
        local libname=$(basename ${libstatic%.a})
        local soname=${libname}$(get_libname $(get_version_component_range 1-2))
        local libdir=$(dirname ${libstatic})
@@ -55,22 +55,20 @@ static_to_shared() {
 }
 
 src_prepare() {
-       local MULTIBUILD_VARIANTS=( $(fortran-int64_multilib_get_enabled_abis) )
-       fortran-int64_ensure_blas
+       numeric-int64_ensure_blas_int_support
        find . -name Makefile -exec sed -i \
                -e 's:make:$(MAKE):g' '{}' \; || die
-       multibuild_copy_sources
+       numeric-int64-multibuild_copy_sources
 }
 
 src_configure() {
-       local MULTIBUILD_VARIANTS=( $(fortran-int64_multilib_get_enabled_abis) )
-       my_configure() {
-               local profname=$(fortran-int64_get_profname)
+       cblas_configure() {
+               local profname=$(numeric-int64_get_module_name)
                local libname="${profname//-/_}"
                append-cflags -DADD_
                cat > Makefile.in <<-EOF
-                       BLLIB=$($(tc-getPKG_CONFIG) --libs 
$(fortran-int64_get_blas_provider))
-                       FC=$(tc-getFC) $(get_abi_CFLAGS) 
$(fortran-int64_get_fortran_int64_abi_fflags)
+                       BLLIB=$($(tc-getPKG_CONFIG) --libs 
$(numeric-int64_get_blas_alternative))
+                       FC=$(tc-getFC) $(get_abi_CFLAGS) 
$(numeric-int64_get_fortran_int64_abi_fflags)
                        CC=$(tc-getCC)
                        CBLIB=../lib/lib${libname}.a
                        LOADER=\$(FC)
@@ -79,79 +77,69 @@ src_configure() {
                        RANLIB=$(tc-getRANLIB)
                EOF
        }
-       multibuild_foreach_variant run_in_build_dir 
fortran-int64_multilib_multibuild_wrapper my_configure
+       numeric-int64-multibuild_foreach_all_abi_variants run_in_build_dir 
cblas_configure
 }
 
 src_compile() {
-       local MULTIBUILD_VARIANTS=( $(fortran-int64_multilib_get_enabled_abis) )
-       my_src_compile() {
-               local profname=$(fortran-int64_get_profname)
+       cblas_src_compile() {
+               local profname=$(numeric-int64_get_module_name)
                local libname="${profname//-/_}"
                emake \
                        FFLAGS="${FFLAGS} -fPIC" \
                        CFLAGS="${CFLAGS} -fPIC" \
                        alllib
-               static_to_shared lib/lib${libname}.a $($(tc-getPKG_CONFIG) 
--libs $(fortran-int64_get_blas_profname))
+               static_to_shared lib/lib${libname}.a $($(tc-getPKG_CONFIG) 
--libs $(numeric-int64_get_blas_alternative))
                if use static-libs; then
                        emake clean
                        emake alllib
                fi
        }
-       multibuild_foreach_variant run_in_build_dir 
fortran-int64_multilib_multibuild_wrapper my_src_compile
+       numeric-int64-multibuild_foreach_all_abi_variants run_in_build_dir 
cblas_src_compile
 }
 
 src_test() {
-       local MULTIBUILD_VARIANTS=( $(fortran-int64_multilib_get_enabled_abis) )
-       my_src_test () {
-               local profname=$(fortran-int64_get_profname)
+       cblas_src_test () {
+               local profname=$(numeric-int64_get_module_name)
                local libname="${profname//-/_}"
                cd testing || die
-               default
-               emake run
+               emake && emake run
        }
-       multibuild_foreach_variant run_in_build_dir 
fortran-int64_multilib_multibuild_wrapper my_src_test
+       numeric-int64-multibuild_foreach_all_abi_variants run_in_build_dir 
cblas_src_test
 }
 
 src_install() {
-       local MULTIBUILD_VARIANTS=( $(fortran-int64_multilib_get_enabled_abis) )
-       my_src_install() {
-               local profname=$(fortran-int64_get_profname)
+       cblas_src_install() {
+               local profname=$(numeric-int64_get_module_name)
                local libname="${profname//-/_}"
-               local provider=$(fortran-int64_get_cblas_provider)
                # On linux dynamic libraries are of the form .so.${someversion}
                # On  OS X dynamic libraries are of the form 
${someversion}.dylib
-               dolib.so lib/lib${libname}*$(get_libname)*
-               use static-libs && dolib.a lib/lib${libname}.a
-               insinto /usr/include/cblas
-               doins include/cblas.h
-               cat <<-EOF > ${profname}.pc
-                       prefix=${EPREFIX}/usr
-                       libdir=\${prefix}/$(get_libdir)
-                       includedir=\${prefix}/include
-                       Name: ${profname}
-                       Description: ${DESCRIPTION}
-                       Version: ${PV}
-                       URL: ${HOMEPAGE}
-                       Libs: -L\${libdir} -l${libname}
-                       Private: -lm
-                       Cflags: -I\${includedir}/cblas
-                       Requires: $(fortran-int64_get_blas_profname)
-                       Fflags=$(fortran-int64_get_fortran_int64_abi_fflags)
-               EOF
-               insinto /usr/$(get_libdir)/pkgconfig
-               doins ${profname}.pc
-               alternatives_for ${provider} $(fortran-int64_get_profname 
"reference") 0 \
-                       /usr/$(get_libdir)/pkgconfig/${provider}.pc 
${profname}.pc \
-                       /usr/include/cblas.h cblas/cblas.h
+               if numeric-int64_is_static_build; then
+                       dolib.a lib/lib${libname}.a
+               else
+                       dolib.so lib/lib${libname}*$(get_libname)*
+                       insinto /usr/include/cblas
+                       doins include/cblas.h
+                       create_pkgconfig \
+                               --name "${profname}" \
+                               --libs "-L\${libdir} -l${libname}" \
+                               --libs-private "-lm" \
+                               --cflags "-I\${includedir}/cblas 
$(numeric-int64_get_fortran_int64_abi_fflags)" \
+                               --requires 
$(numeric-int64_get_blas_alternative) \
+                               ${profname}
+               fi
+
                if [[ ${#MULTIBUILD_VARIANTS[@]} -gt 1 ]]; then
                        multilib_prepare_wrappers
                        multilib_check_headers
                fi
        }
-       multibuild_foreach_variant run_in_build_dir 
fortran-int64_multilib_multibuild_wrapper my_src_install
+       numeric-int64-multibuild_foreach_all_abi_variants run_in_build_dir 
cblas_src_install
+
+       numeric-int64-multibuild_install_alternative cblas reference 
/usr/include/cblas.h cblas/cblas.h
+
        multilib_install_wrappers
 
        dodoc README
-       insinto /usr/share/doc/${PF}
-       doins examples/*.c
+       docinto examples
+       dodoc examples/*.c
 }

diff --git a/sci-libs/cblas-reference/cblas-reference-20110218.ebuild 
b/sci-libs/cblas-reference/cblas-reference-20110218.ebuild
deleted file mode 100644
index c2c9b6f..0000000
--- a/sci-libs/cblas-reference/cblas-reference-20110218.ebuild
+++ /dev/null
@@ -1,116 +0,0 @@
-# Copyright 1999-2014 Gentoo Foundation
-# Distributed under the terms of the GNU General Public License v2
-# $Id$
-
-EAPI=5
-
-inherit eutils alternatives-2 flag-o-matic toolchain-funcs versionator 
multilib fortran-2
-
-MYPN="${PN/-reference/}"
-
-DESCRIPTION="C wrapper interface to the F77 reference BLAS implementation"
-HOMEPAGE="http://www.netlib.org/blas/";
-SRC_URI="http://www.netlib.org/blas/blast-forum/${MYPN}.tgz -> ${P}.tgz"
-
-SLOT="0"
-LICENSE="public-domain"
-IUSE="static-libs"
-KEYWORDS="~alpha ~amd64 ~hppa ~ppc ~ppc64 ~s390 ~sparc ~x86 ~x86-fbsd 
~amd64-linux ~x86-linux ~x64-macos ~x86-macos"
-
-RDEPEND="virtual/blas"
-DEPEND="${RDEPEND}
-       virtual/pkgconfig"
-
-S="${WORKDIR}/CBLAS"
-
-LIBNAME=refcblas
-
-static_to_shared() {
-       local libstatic=$1
-       shift
-       local libname=$(basename ${libstatic%.a})
-       local soname=${libname}$(get_libname $(get_version_component_range 1-2))
-       local libdir=$(dirname ${libstatic})
-
-       einfo "Making ${soname} from ${libstatic}"
-       if [[ ${CHOST} == *-darwin* ]] ; then
-               ${LINK:-$(tc-getCC)} ${LDFLAGS}  \
-                       -dynamiclib -install_name 
"${EPREFIX}"/usr/lib/${soname} \
-                       -Wl,-all_load -Wl,${libstatic} \
-                       "$@" -o ${libdir}/${soname} || die "${soname} failed"
-       else
-               ${LINK:-$(tc-getCC)} ${LDFLAGS}  \
-                       -shared -Wl,-soname=${soname} \
-                       -Wl,--whole-archive ${libstatic} -Wl,--no-whole-archive 
\
-                       "$@" -o ${libdir}/${soname} || die "${soname} failed"
-               if [[ $(get_version_component_count) -gt 1 ]]; then
-                       ln -s ${soname} ${libdir}/${libname}$(get_libname 
$(get_major_version)) || die
-               fi
-       fi
-       ln -s ${soname} ${libdir}/${libname}$(get_libname) || die
-}
-
-src_prepare() {
-       find . -name Makefile -exec sed -i \
-               -e 's:make:$(MAKE):g' '{}' \; || die
-       append-cflags -DADD_
-       cat > Makefile.in <<-EOF
-               BLLIB=$($(tc-getPKG_CONFIG) --libs blas)
-               FC=$(tc-getFC)
-               CC=$(tc-getCC)
-               CBLIB=../lib/lib${LIBNAME}.a
-               LOADER=\$(FC)
-               ARCH=$(tc-getAR)
-               ARCHFLAGS=cr
-               RANLIB=$(tc-getRANLIB)
-       EOF
-}
-
-src_compile() {
-       emake \
-               FFLAGS="${FFLAGS} -fPIC" \
-               CFLAGS="${CFLAGS} -fPIC" \
-               CBLIB=../lib/lib${LIBNAME}.a \
-               alllib
-       static_to_shared lib/lib${LIBNAME}.a $($(tc-getPKG_CONFIG) --libs blas)
-       if use static-libs; then
-               emake clean
-               emake alllib
-       fi
-}
-
-src_test() {
-       cd testing || die
-       default
-       emake run
-}
-
-src_install() {
-       # On linux dynamic libraries are of the form .so.${someversion}
-       # On  OS X dynamic libraries are of the form ${someversion}.dylib
-       dolib.so lib/lib${LIBNAME}*$(get_libname)*
-       use static-libs && dolib.a lib/lib${LIBNAME}.a
-       insinto /usr/include/cblas
-       doins include/cblas.h
-       cat <<-EOF > ${LIBNAME}.pc
-               prefix=${EPREFIX}/usr
-               libdir=\${prefix}/$(get_libdir)
-               includedir=\${prefix}/include
-               Name: ${LIBNAME}
-               Description: ${DESCRIPTION}
-               Version: ${PV}
-               URL: ${HOMEPAGE}
-               Libs: -L\${libdir} -l${LIBNAME}
-               Private: -lm
-               Cflags: -I\${includedir}/cblas
-               Requires: blas
-       EOF
-       insinto /usr/$(get_libdir)/pkgconfig
-       doins ${LIBNAME}.pc
-       dodoc README
-       insinto /usr/share/doc/${PF}
-       doins examples/*.c
-       alternatives_for cblas reference 0 \
-               /usr/$(get_libdir)/pkgconfig/cblas.pc ${LIBNAME}.pc \
-               /usr/include/cblas.h cblas/cblas.h
-}

diff --git a/sci-libs/gotoblas2/gotoblas2-1.13.ebuild 
b/sci-libs/gotoblas2/gotoblas2-1.13.ebuild
index e95dfbf..997a220 100644
--- a/sci-libs/gotoblas2/gotoblas2-1.13.ebuild
+++ b/sci-libs/gotoblas2/gotoblas2-1.13.ebuild
@@ -4,7 +4,9 @@
 
 EAPI=5
 
-inherit eutils toolchain-funcs alternatives-2 multilib
+NUMERIC_MODULE_NAME=goto2
+
+inherit eutils numeric-int64-multibuild fortran-2 multilib toolchain-funcs
 
 MYPN="GotoBLAS2"
 MYP="${MYPN}-${PV}_bsd"
@@ -17,11 +19,9 @@ SRC_URI="http://dev.gentoo.org/~bicatali/${MYP}.tar.gz";
 LICENSE="BSD"
 SLOT="0"
 KEYWORDS="~amd64 ~x86 ~x86-macos ~ppc-macos ~x64-macos"
+IUSE="+incblas +openmp static-libs threads"
 
-IUSE="+incblas int64 dynamic openmp static-libs threads"
-
-RDEPEND="virtual/fortran"
-DEPEND="${RDEPEND}"
+REQUIRED_USE="|| ( openmp threads )"
 
 S="${WORKDIR}/${MYPN}"
 
@@ -29,11 +29,9 @@ src_prepare() {
        epatch "${FILESDIR}"/${P}-{dynamic,sharedlibs,fcheck,aliasing}.patch
        # respect LDFLAGS
        sed -i -e '/^LDFLAGS\s*=/d' Makefile.* || die
-       if ! use dynamic; then
-               sed -i \
-                       -e "/^COMMON_OPT/s/-O2/${CFLAGS}/" \
-                       Makefile.rule || die
-       fi
+       sed -i \
+               -e "/^COMMON_OPT/s/-O2/${CFLAGS}/" \
+               Makefile.rule || die
        # fix executable stacks
        local i
        for i in $(find . -name \*.S); do
@@ -43,80 +41,89 @@ src_prepare() {
                        #endif
                EOF
        done
+       numeric-int64-multibuild_copy_sources
 }
 
 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
+       myconfigure() {
+               sed \
+                       -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=$(usex threads 1 
0):" \
+                       -e "s:^#\s*\(USE_OPENMP\)\s*=.*:\1=$(usex openmp 1 
""):" \
+                       -e "s:^#\s*\(DYNAMIC_ARCH\)\s*=.*:\1=1:" \
+                       -e 
"s:^#\s*\(INTERFACE64\)\s*=.*:\1=$(numeric-int64_is_int64_build && echo 1 || 
echo ""):" \
+                       -e "s:^#\s*\(NO_CBLAS\)\s*=.*:\1=$(usex incblas 1 ""):" 
\
+                       -i Makefile.rule || die
+               if numeric-int64_is_int64_build; then
+                       sed \
+                               -e 's:libgoto2:libgoto2_int64:g' \
+                               -i Makefile* || die
+               fi
+       }
+       numeric-int64-multibuild_foreach_all_abi_variants run_in_build_dir 
myconfigure
 }
 
 src_compile() {
-       mkdir solibs
-       emake libs shared && mv *$(get_libname) solibs/
-       use static-libs && emake clean && emake libs NEED_PIC=
+       mycompile() {
+               if numeric-int64_is_static_build; then
+                       use static-libs && emake clean && emake libs NEED_PIC=
+               else
+                       mkdir solibs || die
+                       emake libs shared && mv *$(get_libname) solibs/ || die
+               fi
+       }
+       numeric-int64-multibuild_foreach_all_abi_variants run_in_build_dir 
mycompile
 }
 
 src_test() {
-       emake tests
+       numeric-int64-multibuild_foreach_all_abi_variants run_in_build_dir 
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*$(get_libname)
-       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: ${MYPN}
-               Description: ${DESCRIPTION}
-               Version: ${PV}
-               URL: ${HOMEPAGE}
-               Libs: -L\${libdir} -lgoto2 -lm ${threads}
-       EOF
-
-       alternatives_for blas ${profname} 0 \
-               "/usr/$(get_libdir)/pkgconfig/blas.pc" "${profname}.pc"
-
-       if use incblas; then
-               insinto /usr/include/${PN}
-               doins cblas.h
-               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
+       myinstall() {
+               local profname=$(numeric-int64_get_module_name)
+               local libname=libgoto2
+               local libs="-L\${libdir} -lm"
+               if numeric-int64_is_int64_build; then
+                       libs+=" -lgoto2_int64"
+               else
+                       libs+=" -lgoto2"
+               fi
+               use threads && libs+=" -pthread"
+
+               numeric-int64_is_static_build && libname=libgoto2_int64
+
+               if numeric-int64_is_static_build; then
+                       dolib.a lib*.a
+               else
+                       dolib.so solibs/lib*$(get_libname)
+
+                       create_pkgconfig \
+                               --name "${MYPN}" \
+                               --libs "${libs}" \
+                               --cflags "-I\${includedir}/${PN}" \
+                               ${profname}
+               fi
+
+               if use incblas; then
+                       insinto /usr/include/${PN}
+                       doins cblas.h
+               fi
+       }
+       numeric-int64-multibuild_foreach_all_abi_variants run_in_build_dir 
myinstall
+
+       numeric-int64-multibuild_install_alternative blas 
${NUMERIC_MODULE_NAME} /usr/include/cblas.h ${PN}/cblas.h
 
-       insinto /usr/$(get_libdir)/pkgconfig
-       doins ${profname}.pc
        dodoc 01Readme.txt 03FAQ.txt 05LargePage 06WeirdPerformance
 
        if [[ ${CHOST} == *-darwin* ]] ; then
-               cd "${ED}"/usr/$(get_libdir)
+               cd "${ED}"/usr/$(get_libdir) || die
+               local d
                for d in *.dylib ; do
                        ebegin "correcting install_name of ${d}"
-                       install_name_tool -id 
"${EPREFIX}/usr/$(get_libdir)/${d}" "${d}"
+                       install_name_tool -id 
"${EPREFIX}/usr/$(get_libdir)/${d}" "${d}" || die
                        eend $?
                done
        fi

diff --git a/sci-libs/lapack-reference/lapack-reference-3.4.2.ebuild 
b/sci-libs/lapack-reference/lapack-reference-3.4.2.ebuild
deleted file mode 100644
index e81c5a2..0000000
--- a/sci-libs/lapack-reference/lapack-reference-3.4.2.ebuild
+++ /dev/null
@@ -1,139 +0,0 @@
-# Copyright 1999-2014 Gentoo Foundation
-# Distributed under the terms of the GNU General Public License v2
-# $Id$
-
-EAPI=5
-EBASE_PROFNAME="reflapack"
-ESTATIC_MULTIBUILD=1
-inherit fortran-2 cmake-utils multibuild alternatives-2 multilib-build 
toolchain-funcs fortran-int64
-
-if [[ ${PV} == "9999" ]] ; then
-       # The master ESVN_REPO_URI is difficult to access, the git mirror is 
easier
-       # ESVN_REPO_URI="https://icl.cs.utk.edu/svn/lapack-dev/lapack/trunk";
-       # MY_PN=lapack
-       # inherit subversion
-       EGIT_REPO_URI="https://github.com/nschloe/lapack.git";
-       MY_PN=lapack-reference
-       MYP=${MY_PN}-${PV}
-       inherit git-r3
-       KEYWORDS=""
-else
-       MY_PN=lapack
-       MYP=${MY_PN}-${PV}
-       SRC_URI="http://www.netlib.org/lapack/${MYP}.tgz";
-       KEYWORDS="~amd64 ~x86 ~amd64-linux ~x86-linux"
-fi
-
-DESCRIPTION="Reference implementation of LAPACK"
-HOMEPAGE="http://www.netlib.org/lapack/";
-
-LICENSE="BSD"
-SLOT="0"
-
-IUSE="int64 static-libs test xblas"
-
-RDEPEND="
-       >=virtual/blas-2.1-r3[int64?]
-       xblas? ( sci-libs/xblas[fortran,int64?] )"
-DEPEND="${RDEPEND}
-       virtual/pkgconfig"
-PDEPEND="
-       >=virtual/lapack-3.5-r2[int64?]"
-
-S="${WORKDIR}/${MYP}"
-
-src_prepare() {
-       fortran-int64_ensure_blas
-
-       # rename library to avoid collision with other lapack implementations
-       # ${PROFNAME}, ${LIBNAME} and ${BLAS_REQUIRES} are not defined here, 
they
-       # are in single quotes in the following seds.  They are set later by
-       # defining a cmake variables with -DPROFNAME etc in src_configure.
-       sed -i \
-               -e 's:BINARY_DIR}/lapack.pc:BINARY_DIR}/${PROFNAME}.pc:' \
-               -e '/ALL_TARGETS/s:lapack):${LIBNAME}):' \
-               -e '/LAPACK_LIBRARIES/s:lapack:${LIBNAME}:g' \
-               CMakeLists.txt || die
-       sed -i \
-               -e 's:(lapack:(${LIBNAME}:g' \
-               SRC/CMakeLists.txt || die
-       sed -i \
-               -e '/Name: /s:lapack:${PROFNAME}:' \
-               -e 's:-llapack:-l${LIBNAME}:g' \
-               -e '/Requires: 
/s:blas:${BLAS_REQUIRES}\nFflags=${LAPACK_PKGCONFIG_FFLAGS}:' \
-               lapack.pc.in || die
-       # some string does not get passed properly
-       sed -i \
-               -e '/lapack_testing.py/d' \
-               CTestCustom.cmake.in || die
-       # separate ebuild to tmglib
-       sed -i \
-               -e '/lapack_install_library(tmglib)/d' \
-               TESTING/MATGEN/CMakeLists.txt || die
-}
-
-src_configure() {
-       local MULTIBUILD_VARIANTS=( $(fortran-int64_multilib_get_enabled_abis) )
-       my_src_configure() {
-               local profname=$(fortran-int64_get_profname)
-               local libname="${profname//-/_}"
-               local blas_profname=$(fortran-int64_get_blas_profname)
-               local xblas_profname=$(fortran-int64_get_xblas_profname)
-               local xblas_libname="${xblas_profname//-/_}"
-               local blas_requires="${blas_profname}"
-               use xblas && \
-                       blas_requires+=" ${xblas_profname}"
-               local mycmakeargs=(
-                       -DPROFNAME="${profname}"
-                       -DBLAS_REQUIRES="${blas_requires}"
-                       -DLIBNAME="${libname}"
-                       -DUSE_OPTIMIZED_BLAS=ON
-                       -DBLAS_LIBRARIES="$($(tc-getPKG_CONFIG) --libs 
${blas_profname})"
-                       $(cmake-utils_use_build test TESTING)
-                       $(cmake-utils_use_use xblas XBLAS)
-                       -DCMAKE_C_FLAGS="$($(tc-getPKG_CONFIG) --cflags 
${blas_profname}) ${CFLAGS}"
-                       -DCMAKE_CXX_FLAGS="$($(tc-getPKG_CONFIG) --cflags 
${blas_profname}) ${CXXFLAGS}"
-                       -DCMAKE_Fortran_FLAGS="$($(tc-getPKG_CONFIG) --cflags 
${blas_profname}) $(get_abi_CFLAGS) 
$(fortran-int64_get_fortran_int64_abi_fflags) ${FCFLAGS}"
-                       
-DLAPACK_PKGCONFIG_FFLAGS="$(fortran-int64_get_fortran_int64_abi_fflags)"
-               )
-               use xblas && \
-                       mycmakeargs+=( 
-DXBLAS_LIBRARY:FILEPATH="${EROOT}usr/$(get_libdir)/lib${xblas_libname}.so" )
-               if $(fortran-int64_is_static_build); then
-                       mycmakeargs+=(
-                               -DBUILD_SHARED_LIBS=OFF
-                               -DBUILD_STATIC_LIBS=ON
-                       )
-               else
-                       mycmakeargs+=(
-                               -DBUILD_SHARED_LIBS=ON
-                               -DBUILD_STATIC_LIBS=OFF
-                       )
-               fi
-               cmake-utils_src_configure
-       }
-       multibuild_foreach_variant fortran-int64_multilib_multibuild_wrapper 
my_src_configure
-}
-
-src_compile() {
-       local MULTIBUILD_VARIANTS=( $(fortran-int64_multilib_get_enabled_abis) )
-       multibuild_foreach_variant fortran-int64_multilib_multibuild_wrapper 
cmake-utils_src_compile
-}
-
-src_test() {
-       local MULTIBUILD_VARIANTS=( $(fortran-int64_multilib_get_enabled_abis) )
-       multibuild_foreach_variant fortran-int64_multilib_multibuild_wrapper 
cmake-utils_src_test
-}
-
-src_install() {
-       local MULTIBUILD_VARIANTS=( $(fortran-int64_multilib_get_enabled_abis) )
-       my_src_install()  {
-               cmake-utils_src_install
-               if ! $(fortran-int64_is_static_build); then
-                       local profname=$(fortran-int64_get_profname)
-                       local provider=$(fortran-int64_get_lapack_provider)
-                       alternatives_for ${provider} 
$(fortran-int64_get_profname "reference") 0 \
-                               /usr/$(get_libdir)/pkgconfig/${provider}.pc 
${profname}.pc
-               fi
-       }
-       multibuild_foreach_variant fortran-int64_multilib_multibuild_wrapper 
my_src_install
-}

diff --git a/sci-libs/lapack-reference/lapack-reference-3.5.0.ebuild 
b/sci-libs/lapack-reference/lapack-reference-3.5.0.ebuild
index e81c5a2..30458b5 100644
--- a/sci-libs/lapack-reference/lapack-reference-3.5.0.ebuild
+++ b/sci-libs/lapack-reference/lapack-reference-3.5.0.ebuild
@@ -1,49 +1,40 @@
-# Copyright 1999-2014 Gentoo Foundation
+# Copyright 1999-2015 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 # $Id$
 
 EAPI=5
-EBASE_PROFNAME="reflapack"
-ESTATIC_MULTIBUILD=1
-inherit fortran-2 cmake-utils multibuild alternatives-2 multilib-build 
toolchain-funcs fortran-int64
-
-if [[ ${PV} == "9999" ]] ; then
-       # The master ESVN_REPO_URI is difficult to access, the git mirror is 
easier
-       # ESVN_REPO_URI="https://icl.cs.utk.edu/svn/lapack-dev/lapack/trunk";
-       # MY_PN=lapack
-       # inherit subversion
-       EGIT_REPO_URI="https://github.com/nschloe/lapack.git";
-       MY_PN=lapack-reference
-       MYP=${MY_PN}-${PV}
-       inherit git-r3
-       KEYWORDS=""
-else
-       MY_PN=lapack
-       MYP=${MY_PN}-${PV}
-       SRC_URI="http://www.netlib.org/lapack/${MYP}.tgz";
-       KEYWORDS="~amd64 ~x86 ~amd64-linux ~x86-linux"
-fi
+
+PYTHON_COMPAT=( python2_7 )
+
+NUMERIC_MODULE_NAME="reflapack"
+
+inherit alternatives-2 cmake-utils fortran-2 numeric-int64-multibuild 
python-any-r1
+
+MY_PN=lapack
+MYP=${MY_PN}-${PV}
 
 DESCRIPTION="Reference implementation of LAPACK"
 HOMEPAGE="http://www.netlib.org/lapack/";
+SRC_URI="http://www.netlib.org/lapack/${MYP}.tgz";
 
 LICENSE="BSD"
 SLOT="0"
+KEYWORDS="~amd64 ~x86 ~amd64-linux ~x86-linux"
+IUSE="static-libs test xblas"
 
-IUSE="int64 static-libs test xblas"
+REQUIRED_USE="test? ( ${PYTHON_REQUIRED_USE} )"
 
 RDEPEND="
-       >=virtual/blas-2.1-r3[int64?]
+       >=virtual/blas-2.1-r3[int64?,${MULTILIB_USEDEP}]
        xblas? ( sci-libs/xblas[fortran,int64?] )"
 DEPEND="${RDEPEND}
-       virtual/pkgconfig"
-PDEPEND="
-       >=virtual/lapack-3.5-r2[int64?]"
+       virtual/pkgconfig
+       test? ( ${PYTHON_DEPS} )"
 
 S="${WORKDIR}/${MYP}"
 
 src_prepare() {
-       fortran-int64_ensure_blas
+       numeric-int64_ensure_blas_int_support
 
        # rename library to avoid collision with other lapack implementations
        # ${PROFNAME}, ${LIBNAME} and ${BLAS_REQUIRES} are not defined here, 
they
@@ -73,12 +64,11 @@ src_prepare() {
 }
 
 src_configure() {
-       local MULTIBUILD_VARIANTS=( $(fortran-int64_multilib_get_enabled_abis) )
-       my_src_configure() {
-               local profname=$(fortran-int64_get_profname)
+       lapack_configure() {
+               local profname=$(numeric-int64_get_module_name)
                local libname="${profname//-/_}"
-               local blas_profname=$(fortran-int64_get_blas_profname)
-               local xblas_profname=$(fortran-int64_get_xblas_profname)
+               local blas_profname=$(numeric-int64_get_blas_alternative)
+               local xblas_profname=$(numeric-int64_get_xblas_alternative)
                local xblas_libname="${xblas_profname//-/_}"
                local blas_requires="${blas_profname}"
                use xblas && \
@@ -93,12 +83,12 @@ src_configure() {
                        $(cmake-utils_use_use xblas XBLAS)
                        -DCMAKE_C_FLAGS="$($(tc-getPKG_CONFIG) --cflags 
${blas_profname}) ${CFLAGS}"
                        -DCMAKE_CXX_FLAGS="$($(tc-getPKG_CONFIG) --cflags 
${blas_profname}) ${CXXFLAGS}"
-                       -DCMAKE_Fortran_FLAGS="$($(tc-getPKG_CONFIG) --cflags 
${blas_profname}) $(get_abi_CFLAGS) 
$(fortran-int64_get_fortran_int64_abi_fflags) ${FCFLAGS}"
-                       
-DLAPACK_PKGCONFIG_FFLAGS="$(fortran-int64_get_fortran_int64_abi_fflags)"
+                       -DCMAKE_Fortran_FLAGS="$($(tc-getPKG_CONFIG) --cflags 
${blas_profname}) $(get_abi_CFLAGS) 
$(numeric-int64_get_fortran_int64_abi_fflags) ${FCFLAGS}"
+                       
-DLAPACK_PKGCONFIG_FFLAGS="$(numeric-int64_get_fortran_int64_abi_fflags)"
                )
                use xblas && \
                        mycmakeargs+=( 
-DXBLAS_LIBRARY:FILEPATH="${EROOT}usr/$(get_libdir)/lib${xblas_libname}.so" )
-               if $(fortran-int64_is_static_build); then
+               if $(numeric-int64_is_static_build); then
                        mycmakeargs+=(
                                -DBUILD_SHARED_LIBS=OFF
                                -DBUILD_STATIC_LIBS=ON
@@ -111,29 +101,18 @@ src_configure() {
                fi
                cmake-utils_src_configure
        }
-       multibuild_foreach_variant fortran-int64_multilib_multibuild_wrapper 
my_src_configure
+       numeric-int64-multibuild_foreach_all_abi_variants lapack_configure
 }
 
 src_compile() {
-       local MULTIBUILD_VARIANTS=( $(fortran-int64_multilib_get_enabled_abis) )
-       multibuild_foreach_variant fortran-int64_multilib_multibuild_wrapper 
cmake-utils_src_compile
+       numeric-int64-multibuild_foreach_all_abi_variants 
cmake-utils_src_compile
 }
 
 src_test() {
-       local MULTIBUILD_VARIANTS=( $(fortran-int64_multilib_get_enabled_abis) )
-       multibuild_foreach_variant fortran-int64_multilib_multibuild_wrapper 
cmake-utils_src_test
+       numeric-int64-multibuild_foreach_all_abi_variants cmake-utils_src_test
 }
 
 src_install() {
-       local MULTIBUILD_VARIANTS=( $(fortran-int64_multilib_get_enabled_abis) )
-       my_src_install()  {
-               cmake-utils_src_install
-               if ! $(fortran-int64_is_static_build); then
-                       local profname=$(fortran-int64_get_profname)
-                       local provider=$(fortran-int64_get_lapack_provider)
-                       alternatives_for ${provider} 
$(fortran-int64_get_profname "reference") 0 \
-                               /usr/$(get_libdir)/pkgconfig/${provider}.pc 
${profname}.pc
-               fi
-       }
-       multibuild_foreach_variant fortran-int64_multilib_multibuild_wrapper 
my_src_install
+       numeric-int64-multibuild_foreach_all_abi_variants 
cmake-utils_src_install
+       numeric-int64-multibuild_install_alternative lapack reference
 }

diff --git a/sci-libs/lapack-reference/lapack-reference-9999.ebuild 
b/sci-libs/lapack-reference/lapack-reference-9999.ebuild
index e81c5a2..466c762 100644
--- a/sci-libs/lapack-reference/lapack-reference-9999.ebuild
+++ b/sci-libs/lapack-reference/lapack-reference-9999.ebuild
@@ -1,49 +1,45 @@
-# Copyright 1999-2014 Gentoo Foundation
+# Copyright 1999-2015 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 # $Id$
 
 EAPI=5
-EBASE_PROFNAME="reflapack"
-ESTATIC_MULTIBUILD=1
-inherit fortran-2 cmake-utils multibuild alternatives-2 multilib-build 
toolchain-funcs fortran-int64
-
-if [[ ${PV} == "9999" ]] ; then
-       # The master ESVN_REPO_URI is difficult to access, the git mirror is 
easier
-       # ESVN_REPO_URI="https://icl.cs.utk.edu/svn/lapack-dev/lapack/trunk";
-       # MY_PN=lapack
-       # inherit subversion
-       EGIT_REPO_URI="https://github.com/nschloe/lapack.git";
-       MY_PN=lapack-reference
-       MYP=${MY_PN}-${PV}
-       inherit git-r3
-       KEYWORDS=""
-else
-       MY_PN=lapack
-       MYP=${MY_PN}-${PV}
-       SRC_URI="http://www.netlib.org/lapack/${MYP}.tgz";
-       KEYWORDS="~amd64 ~x86 ~amd64-linux ~x86-linux"
-fi
+
+PYTHON_COMPAT=( python2_7 )
+
+NUMERIC_MODULE_NAME="reflapack"
+
+inherit alternatives-2 cmake-utils fortran-2 git-r3 numeric-int64-multibuild 
python-any-r1
+
+# The master ESVN_REPO_URI is difficult to access, the git mirror is easier
+# ESVN_REPO_URI="https://icl.cs.utk.edu/svn/lapack-dev/lapack/trunk";
+# MY_PN=lapack
+# inherit subversion
+
+MY_PN=lapack-reference
+MYP=${MY_PN}-${PV}
 
 DESCRIPTION="Reference implementation of LAPACK"
 HOMEPAGE="http://www.netlib.org/lapack/";
+EGIT_REPO_URI="https://github.com/nschloe/lapack.git";
 
 LICENSE="BSD"
 SLOT="0"
+KEYWORDS=""
+IUSE="static-libs test xblas"
 
-IUSE="int64 static-libs test xblas"
+REQUIRED_USE="test? ( ${PYTHON_REQUIRED_USE} )"
 
 RDEPEND="
-       >=virtual/blas-2.1-r3[int64?]
+       >=virtual/blas-2.1-r3[int64?,${MULTILIB_USEDEP}]
        xblas? ( sci-libs/xblas[fortran,int64?] )"
 DEPEND="${RDEPEND}
-       virtual/pkgconfig"
-PDEPEND="
-       >=virtual/lapack-3.5-r2[int64?]"
+       virtual/pkgconfig
+       test? ( ${PYTHON_DEPS} )"
 
 S="${WORKDIR}/${MYP}"
 
 src_prepare() {
-       fortran-int64_ensure_blas
+       numeric-int64_ensure_blas_int_support
 
        # rename library to avoid collision with other lapack implementations
        # ${PROFNAME}, ${LIBNAME} and ${BLAS_REQUIRES} are not defined here, 
they
@@ -73,12 +69,11 @@ src_prepare() {
 }
 
 src_configure() {
-       local MULTIBUILD_VARIANTS=( $(fortran-int64_multilib_get_enabled_abis) )
-       my_src_configure() {
-               local profname=$(fortran-int64_get_profname)
+       lapack_configure() {
+               local profname=$(numeric-int64_get_module_name)
                local libname="${profname//-/_}"
-               local blas_profname=$(fortran-int64_get_blas_profname)
-               local xblas_profname=$(fortran-int64_get_xblas_profname)
+               local blas_profname=$(numeric-int64_get_blas_alternative)
+               local xblas_profname=$(numeric-int64_get_xblas_alternative)
                local xblas_libname="${xblas_profname//-/_}"
                local blas_requires="${blas_profname}"
                use xblas && \
@@ -93,12 +88,12 @@ src_configure() {
                        $(cmake-utils_use_use xblas XBLAS)
                        -DCMAKE_C_FLAGS="$($(tc-getPKG_CONFIG) --cflags 
${blas_profname}) ${CFLAGS}"
                        -DCMAKE_CXX_FLAGS="$($(tc-getPKG_CONFIG) --cflags 
${blas_profname}) ${CXXFLAGS}"
-                       -DCMAKE_Fortran_FLAGS="$($(tc-getPKG_CONFIG) --cflags 
${blas_profname}) $(get_abi_CFLAGS) 
$(fortran-int64_get_fortran_int64_abi_fflags) ${FCFLAGS}"
-                       
-DLAPACK_PKGCONFIG_FFLAGS="$(fortran-int64_get_fortran_int64_abi_fflags)"
+                       -DCMAKE_Fortran_FLAGS="$($(tc-getPKG_CONFIG) --cflags 
${blas_profname}) $(get_abi_CFLAGS) 
$(numeric-int64_get_fortran_int64_abi_fflags) ${FCFLAGS}"
+                       
-DLAPACK_PKGCONFIG_FFLAGS="$(numeric-int64_get_fortran_int64_abi_fflags)"
                )
                use xblas && \
                        mycmakeargs+=( 
-DXBLAS_LIBRARY:FILEPATH="${EROOT}usr/$(get_libdir)/lib${xblas_libname}.so" )
-               if $(fortran-int64_is_static_build); then
+               if $(numeric-int64_is_static_build); then
                        mycmakeargs+=(
                                -DBUILD_SHARED_LIBS=OFF
                                -DBUILD_STATIC_LIBS=ON
@@ -111,29 +106,18 @@ src_configure() {
                fi
                cmake-utils_src_configure
        }
-       multibuild_foreach_variant fortran-int64_multilib_multibuild_wrapper 
my_src_configure
+       numeric-int64-multibuild_foreach_all_abi_variants lapack_configure
 }
 
 src_compile() {
-       local MULTIBUILD_VARIANTS=( $(fortran-int64_multilib_get_enabled_abis) )
-       multibuild_foreach_variant fortran-int64_multilib_multibuild_wrapper 
cmake-utils_src_compile
+       numeric-int64-multibuild_foreach_all_abi_variants 
cmake-utils_src_compile
 }
 
 src_test() {
-       local MULTIBUILD_VARIANTS=( $(fortran-int64_multilib_get_enabled_abis) )
-       multibuild_foreach_variant fortran-int64_multilib_multibuild_wrapper 
cmake-utils_src_test
+       numeric-int64-multibuild_foreach_all_abi_variants cmake-utils_src_test
 }
 
 src_install() {
-       local MULTIBUILD_VARIANTS=( $(fortran-int64_multilib_get_enabled_abis) )
-       my_src_install()  {
-               cmake-utils_src_install
-               if ! $(fortran-int64_is_static_build); then
-                       local profname=$(fortran-int64_get_profname)
-                       local provider=$(fortran-int64_get_lapack_provider)
-                       alternatives_for ${provider} 
$(fortran-int64_get_profname "reference") 0 \
-                               /usr/$(get_libdir)/pkgconfig/${provider}.pc 
${profname}.pc
-               fi
-       }
-       multibuild_foreach_variant fortran-int64_multilib_multibuild_wrapper 
my_src_install
+       numeric-int64-multibuild_foreach_all_abi_variants 
cmake-utils_src_install
+       numeric-int64-multibuild_install_alternative lapack reference
 }

diff --git a/sci-libs/openblas/openblas-0.2.11.ebuild 
b/sci-libs/openblas/openblas-0.2.11.ebuild
deleted file mode 100644
index 3b7d0b7..0000000
--- a/sci-libs/openblas/openblas-0.2.11.ebuild
+++ /dev/null
@@ -1,227 +0,0 @@
-# Copyright 1999-2015 Gentoo Foundation
-# Distributed under the terms of the GNU General Public License v2
-# $Id$
-
-EAPI=5
-
-EBASE_PROFNAME="openblas"
-inherit alternatives-2 eutils multilib fortran-2 multibuild multilib-build 
toolchain-funcs fortran-int64
-
-SRC_URI+="http://dev.gentoo.org/~gienah/distfiles/${PN}-0.2.11-gentoo.patch";
-if [[ ${PV} == "9999" ]] ; then
-       EGIT_REPO_URI="https://github.com/xianyi/OpenBLAS.git";
-       EGIT_BRANCH="develop"
-       inherit git-r3
-       KEYWORDS=""
-else
-       SRC_URI+=" http://github.com/xianyi/OpenBLAS/tarball/v${PV} -> 
${P}.tar.gz"
-       KEYWORDS="~amd64 ~x86 ~amd64-linux ~x86-linux ~x86-macos ~ppc-macos 
~x64-macos"
-fi
-
-DESCRIPTION="Optimized BLAS library based on GotoBLAS2"
-HOMEPAGE="http://xianyi.github.com/OpenBLAS/";
-LICENSE="BSD"
-SLOT="0"
-IUSE="dynamic int64 openmp static-libs threads"
-
-RDEPEND=""
-DEPEND="${RDEPEND}
-       virtual/pkgconfig"
-PDEPEND="
-       >=virtual/blas-2.1-r2[int64?]
-       >=virtual/cblas-2.0-r1[int64?]"
-
-MULTILIB_WRAPPED_HEADERS=(
-       /usr/include/openblas/cblas.h
-       /usr/include/openblas/f77blas.h
-       /usr/include/openblas/openblas_config.h
-)
-
-get_openblas_flags() {
-       local openblas_flags=""
-       use dynamic && \
-               openblas_flags+=" DYNAMIC_ARCH=1 TARGET=GENERIC NUM_THREADS=64 
NO_AFFINITY=1"
-       $(fortran-int64_is_int64_build) && \
-               openblas_flags+=" INTERFACE64=1"
-       # 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_flags+=" USE_THREAD=1 USE_OPENMP=0"
-       elif use openmp; then
-               openblas_flags+=" USE_THREAD=0 USE_OPENMP=1"
-       fi
-       local profname=$(fortran-int64_get_profname)
-       local libname="${profname//-/_}"
-       local underscoresuffix="${libname#${PN}}"
-       if [[ "${underscoresuffix}" != "_" ]]; then
-               local libnamesuffix="${underscoresuffix#_}"
-               openblas_flags+=" LIBNAMESUFFIX=${libnamesuffix}"
-       fi
-       echo "${openblas_flags}"
-}
-
-get_openblas_abi_cflags() {
-       local openblas_abi_cflags=""
-       if [[ "${ABI}" == "x86" ]]; then
-               openblas_abi_cflags="-DOPENBLAS_ARCH_X86=1 
-DOPENBLAS___32BIT__=1"
-       else
-               openblas_abi_cflags="-DOPENBLAS_ARCH_X86_64=1 
-DOPENBLAS___64BIT__=1"
-       fi
-       $(fortran-int64_is_int64_build) && \
-               openblas_abi_cflags+=" -DOPENBLAS_USE64BITINT"
-       echo "${openblas_abi_cflags}"
-}
-
-src_unpack() {
-       if [[ ${PV} == "9999" ]] ; then
-               git-r3_src_unpack
-       else
-               default
-               if [[ ${PV} != "9999" ]] ; then
-                       find "${WORKDIR}" -maxdepth 1 -type d -name 
\*OpenBLAS\* && \
-                               mv "${WORKDIR}"/*OpenBLAS* "${S}"
-               fi
-       fi
-}
-
-src_prepare() {
-       local MULTIBUILD_VARIANTS=( $(fortran-int64_multilib_get_enabled_abis) )
-       epatch "${DISTDIR}/${PN}-0.2.11-gentoo.patch"
-       if [[ ${PV} == "0.2.11" ]] ; then
-               epatch "${FILESDIR}/${PN}-0.2.11-cpuid_x86.patch"
-       fi
-       # lapack and lapacke are not modified from upstream lapack
-       sed \
-               -e "s:^#\s*\(NO_LAPACK\)\s*=.*:\1=1:" \
-               -e "s:^#\s*\(NO_LAPACKE\)\s*=.*:\1=1:" \
-               -i Makefile.rule || die
-       multibuild_copy_sources
-}
-
-src_configure() {
-       local MULTIBUILD_VARIANTS=( $(fortran-int64_multilib_get_enabled_abis) )
-       my_configure() {
-               local openblas_abi_cflags="$(get_openblas_abi_cflags)"
-               local 
internal_openblas_abi_cflags="${openblas_abi_cflags//OPENBLAS_}"
-               sed \
-                       -e "s:^#\s*\(CC\)\s*=.*:\1=$(tc-getCC) 
$(get_abi_CFLAGS):" \
-                       -e "s:^#\s*\(FC\)\s*=.*:\1=$(tc-getFC) 
$(get_abi_CFLAGS):" \
-                       -e "s:^#\s*\(COMMON_OPT\)\s*=.*:\1=${CFLAGS} 
${internal_openblas_abi_cflags}:" \
-                       -i Makefile.rule || die
-       }
-       multibuild_foreach_variant run_in_build_dir 
fortran-int64_multilib_multibuild_wrapper my_configure
-}
-
-src_compile() {
-       local MULTIBUILD_VARIANTS=( $(fortran-int64_multilib_get_enabled_abis) )
-       # openblas already does multi-jobs
-       MAKEOPTS+=" -j1"
-       my_src_compile () {
-               local openblas_flags=$(get_openblas_flags)
-               local profname=$(fortran-int64_get_profname)
-               local libname="${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
-               # Fix Bug 524612 - [science overlay] sci-libs/openblas-0.2.11 - 
Assembler messages:
-               # ../kernel/x86_64/gemm_kernel_8x4_barcelona.S:451: Error: 
missing ')'
-               # The problem is applying this patch in src_prepare() causes 
build failures on
-               # assembler code as the assembler does not understand 
sizeof(float).  So
-               # delay applying the patch until after building the libraries.
-               epatch 
"${FILESDIR}/${PN}-0.2.11-openblas_config_header_same_between_ABIs.patch"
-               rm -f config.h config_last.h
-               # Note: prints this spurious warning: make: Nothing to be done 
for 'config.h'.
-               emake config.h
-               cp config.h config_last.h || die
-               cat <<-EOF > ${profname}.pc
-                       prefix=${EPREFIX}/usr
-                       libdir=\${prefix}/$(get_libdir)
-                       includedir=\${prefix}/include
-                       Name: ${profname}
-                       Description: ${DESCRIPTION}
-                       Version: ${PV}
-                       URL: ${HOMEPAGE}
-                       Libs: -L\${libdir} -l${libname}
-                       Libs.private: -lm
-               EOF
-               local openblas_abi_cflags=$(get_openblas_abi_cflags)
-               local 
openblas_abi_fflags=$(fortran-int64_get_fortran_int64_abi_fflags)
-               cat <<-EOF >> ${profname}.pc
-                       Cflags: -I\${includedir}/${PN} ${openblas_abi_cflags}
-                       Fflags=${openblas_abi_fflags}
-               EOF
-               mv libs/libopenblas* . || die
-       }
-       multibuild_foreach_variant run_in_build_dir 
fortran-int64_multilib_multibuild_wrapper my_src_compile
-}
-
-src_test() {
-       local MULTIBUILD_VARIANTS=( $(fortran-int64_multilib_get_enabled_abis) )
-       my_src_test () {
-               local openblas_flags=$(get_openblas_flags)
-               emake tests ${openblas_flags}
-       }
-       multibuild_foreach_variant run_in_build_dir 
fortran-int64_multilib_multibuild_wrapper my_src_test
-}
-
-src_install() {
-       local MULTIBUILD_VARIANTS=( $(fortran-int64_multilib_get_enabled_abis) )
-       my_src_install() {
-               local openblas_flags=$(get_openblas_flags)
-               local profname=$(fortran-int64_get_profname)
-               local pcfile
-               for pcfile in *.pc; do
-                       local profname=${pcfile%.pc}
-                       # The file /usr/include/openblas/openblas_config.h is 
generated during the install.
-                       # The sed on config_last.h removes the #define's 
OPENBLAS_USE64BITINT
-                       # OPENBLASS__32BIT__ OPENBLASS__64BIT__ 
OPENBLAS__ARCH_X86 OPENBLAS__ARCH_X86_64
-                       # from /usr/include/openblas/openblas_config.h.  We 
then specify it in Cflags in
-                       # the 
/usr/lib64/pkg-config/openblas-int64-{threads,openmp}.pc file.
-                       sed -e '/#define USE64BITINT/d' \
-                               -e '/#define ARCH_X86/d' \
-                               -e '/#define __\(32\|64\)BIT__/d' \
-                               -i config_last.h \
-                               || die "Could not ensure there is no definition 
of USE64BITINT in config_last.h"
-                       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 $(fortran-int64_get_blas_provider) 
${profname} 0 \
-                               
/usr/$(get_libdir)/pkgconfig/$(fortran-int64_get_blas_provider).pc ${pcfile}
-                       alternatives_for $(fortran-int64_get_cblas_provider) 
${profname} 0 \
-                               
/usr/$(get_libdir)/pkgconfig/$(fortran-int64_get_cblas_provider).pc ${pcfile} \
-                               /usr/include/cblas.h ${PN}/cblas.h
-                       insinto /usr/$(get_libdir)/pkgconfig
-                       doins ${pcfile}
-               done
-
-               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 [[ ${#MULTIBUILD_VARIANTS[@]} -gt 1 ]]; then
-                       multilib_prepare_wrappers
-                       multilib_check_headers
-               fi
-       }
-       multibuild_foreach_variant run_in_build_dir 
fortran-int64_multilib_multibuild_wrapper my_src_install
-       multilib_install_wrappers
-
-       dodoc GotoBLAS_{01Readme,03FAQ,04FAQ,05LargePage,06WeirdPerformance}.txt
-       dodoc *md Changelog.txt
-}

diff --git a/sci-libs/openblas/openblas-0.2.12.ebuild 
b/sci-libs/openblas/openblas-0.2.12.ebuild
deleted file mode 100644
index 91736c8..0000000
--- a/sci-libs/openblas/openblas-0.2.12.ebuild
+++ /dev/null
@@ -1,227 +0,0 @@
-# Copyright 1999-2015 Gentoo Foundation
-# Distributed under the terms of the GNU General Public License v2
-# $Id$
-
-EAPI=5
-
-EBASE_PROFNAME="openblas"
-inherit alternatives-2 eutils multilib fortran-2 multibuild multilib-build 
toolchain-funcs fortran-int64
-
-SRC_URI+="http://dev.gentoo.org/~gienah/distfiles/${PN}-0.2.11-gentoo.patch";
-if [[ ${PV} == "9999" ]] ; then
-       EGIT_REPO_URI="https://github.com/xianyi/OpenBLAS.git";
-       EGIT_BRANCH="develop"
-       inherit git-r3
-       KEYWORDS=""
-else
-       SRC_URI+=" http://github.com/xianyi/OpenBLAS/tarball/v${PV} -> 
${P}.tar.gz"
-       KEYWORDS="~amd64 ~x86 ~amd64-linux ~x86-linux ~x86-macos ~ppc-macos 
~x64-macos"
-fi
-
-DESCRIPTION="Optimized BLAS library based on GotoBLAS2"
-HOMEPAGE="http://xianyi.github.com/OpenBLAS/";
-LICENSE="BSD"
-SLOT="0"
-IUSE="dynamic int64 openmp static-libs threads"
-
-RDEPEND=""
-DEPEND="${RDEPEND}
-       virtual/pkgconfig"
-PDEPEND="
-       >=virtual/blas-2.1-r2[int64?]
-       >=virtual/cblas-2.0-r1[int64?]"
-
-MULTILIB_WRAPPED_HEADERS=(
-       /usr/include/openblas/cblas.h
-       /usr/include/openblas/f77blas.h
-       /usr/include/openblas/openblas_config.h
-)
-
-get_openblas_flags() {
-       local openblas_flags=""
-       use dynamic && \
-               openblas_flags+=" DYNAMIC_ARCH=1 TARGET=GENERIC NUM_THREADS=64 
NO_AFFINITY=1"
-       $(fortran-int64_is_int64_build) && \
-               openblas_flags+=" INTERFACE64=1"
-       # 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_flags+=" USE_THREAD=1 USE_OPENMP=0"
-       elif use openmp; then
-               openblas_flags+=" USE_OPENMP=1"
-       fi
-       local profname=$(fortran-int64_get_profname)
-       local libname="${profname//-/_}"
-       local underscoresuffix="${libname#${PN}}"
-       if [[ "${underscoresuffix}" != "_" ]]; then
-               local libnamesuffix="${underscoresuffix#_}"
-               openblas_flags+=" LIBNAMESUFFIX=${libnamesuffix}"
-       fi
-       echo "${openblas_flags}"
-}
-
-get_openblas_abi_cflags() {
-       local openblas_abi_cflags=""
-       if [[ "${ABI}" == "x86" ]]; then
-               openblas_abi_cflags="-DOPENBLAS_ARCH_X86=1 
-DOPENBLAS___32BIT__=1"
-       else
-               openblas_abi_cflags="-DOPENBLAS_ARCH_X86_64=1 
-DOPENBLAS___64BIT__=1"
-       fi
-       $(fortran-int64_is_int64_build) && \
-               openblas_abi_cflags+=" -DOPENBLAS_USE64BITINT"
-       echo "${openblas_abi_cflags}"
-}
-
-src_unpack() {
-       if [[ ${PV} == "9999" ]] ; then
-               git-r3_src_unpack
-       else
-               default
-               if [[ ${PV} != "9999" ]] ; then
-                       find "${WORKDIR}" -maxdepth 1 -type d -name 
\*OpenBLAS\* && \
-                               mv "${WORKDIR}"/*OpenBLAS* "${S}"
-               fi
-       fi
-}
-
-src_prepare() {
-       local MULTIBUILD_VARIANTS=( $(fortran-int64_multilib_get_enabled_abis) )
-       epatch "${DISTDIR}/${PN}-0.2.11-gentoo.patch"
-       if [[ ${PV} == "0.2.11" ]] ; then
-               epatch "${FILESDIR}/${PN}-0.2.11-cpuid_x86.patch"
-       fi
-       # lapack and lapacke are not modified from upstream lapack
-       sed \
-               -e "s:^#\s*\(NO_LAPACK\)\s*=.*:\1=1:" \
-               -e "s:^#\s*\(NO_LAPACKE\)\s*=.*:\1=1:" \
-               -i Makefile.rule || die
-       multibuild_copy_sources
-}
-
-src_configure() {
-       local MULTIBUILD_VARIANTS=( $(fortran-int64_multilib_get_enabled_abis) )
-       my_configure() {
-               local openblas_abi_cflags="$(get_openblas_abi_cflags)"
-               local 
internal_openblas_abi_cflags="${openblas_abi_cflags//OPENBLAS_}"
-               sed \
-                       -e "s:^#\s*\(CC\)\s*=.*:\1=$(tc-getCC) 
$(get_abi_CFLAGS):" \
-                       -e "s:^#\s*\(FC\)\s*=.*:\1=$(tc-getFC) 
$(get_abi_CFLAGS):" \
-                       -e "s:^#\s*\(COMMON_OPT\)\s*=.*:\1=${CFLAGS} 
${internal_openblas_abi_cflags}:" \
-                       -i Makefile.rule || die
-       }
-       multibuild_foreach_variant run_in_build_dir 
fortran-int64_multilib_multibuild_wrapper my_configure
-}
-
-src_compile() {
-       local MULTIBUILD_VARIANTS=( $(fortran-int64_multilib_get_enabled_abis) )
-       # openblas already does multi-jobs
-       MAKEOPTS+=" -j1"
-       my_src_compile () {
-               local openblas_flags=$(get_openblas_flags)
-               local profname=$(fortran-int64_get_profname)
-               local libname="${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
-               # Fix Bug 524612 - [science overlay] sci-libs/openblas-0.2.11 - 
Assembler messages:
-               # ../kernel/x86_64/gemm_kernel_8x4_barcelona.S:451: Error: 
missing ')'
-               # The problem is applying this patch in src_prepare() causes 
build failures on
-               # assembler code as the assembler does not understand 
sizeof(float).  So
-               # delay applying the patch until after building the libraries.
-               epatch 
"${FILESDIR}/${PN}-0.2.11-openblas_config_header_same_between_ABIs.patch"
-               rm -f config.h config_last.h
-               # Note: prints this spurious warning: make: Nothing to be done 
for 'config.h'.
-               emake config.h
-               cp config.h config_last.h || die
-               cat <<-EOF > ${profname}.pc
-                       prefix=${EPREFIX}/usr
-                       libdir=\${prefix}/$(get_libdir)
-                       includedir=\${prefix}/include
-                       Name: ${profname}
-                       Description: ${DESCRIPTION}
-                       Version: ${PV}
-                       URL: ${HOMEPAGE}
-                       Libs: -L\${libdir} -l${libname}
-                       Libs.private: -lm
-               EOF
-               local openblas_abi_cflags=$(get_openblas_abi_cflags)
-               local 
openblas_abi_fflags=$(fortran-int64_get_fortran_int64_abi_fflags)
-               cat <<-EOF >> ${profname}.pc
-                       Cflags: -I\${includedir}/${PN} ${openblas_abi_cflags}
-                       Fflags=${openblas_abi_fflags}
-               EOF
-               mv libs/libopenblas* . || die
-       }
-       multibuild_foreach_variant run_in_build_dir 
fortran-int64_multilib_multibuild_wrapper my_src_compile
-}
-
-src_test() {
-       local MULTIBUILD_VARIANTS=( $(fortran-int64_multilib_get_enabled_abis) )
-       my_src_test () {
-               local openblas_flags=$(get_openblas_flags)
-               emake tests ${openblas_flags}
-       }
-       multibuild_foreach_variant run_in_build_dir 
fortran-int64_multilib_multibuild_wrapper my_src_test
-}
-
-src_install() {
-       local MULTIBUILD_VARIANTS=( $(fortran-int64_multilib_get_enabled_abis) )
-       my_src_install() {
-               local openblas_flags=$(get_openblas_flags)
-               local profname=$(fortran-int64_get_profname)
-               local pcfile
-               for pcfile in *.pc; do
-                       local profname=${pcfile%.pc}
-                       # The file /usr/include/openblas/openblas_config.h is 
generated during the install.
-                       # The sed on config_last.h removes the #define's 
OPENBLAS_USE64BITINT
-                       # OPENBLASS__32BIT__ OPENBLASS__64BIT__ 
OPENBLAS__ARCH_X86 OPENBLAS__ARCH_X86_64
-                       # from /usr/include/openblas/openblas_config.h.  We 
then specify it in Cflags in
-                       # the 
/usr/lib64/pkg-config/openblas-int64-{threads,openmp}.pc file.
-                       sed -e '/#define USE64BITINT/d' \
-                               -e '/#define ARCH_X86/d' \
-                               -e '/#define __\(32\|64\)BIT__/d' \
-                               -i config_last.h \
-                               || die "Could not ensure there is no definition 
of USE64BITINT in config_last.h"
-                       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 $(fortran-int64_get_blas_provider) 
${profname} 0 \
-                               
/usr/$(get_libdir)/pkgconfig/$(fortran-int64_get_blas_provider).pc ${pcfile}
-                       alternatives_for $(fortran-int64_get_cblas_provider) 
${profname} 0 \
-                               
/usr/$(get_libdir)/pkgconfig/$(fortran-int64_get_cblas_provider).pc ${pcfile} \
-                               /usr/include/cblas.h ${PN}/cblas.h
-                       insinto /usr/$(get_libdir)/pkgconfig
-                       doins ${pcfile}
-               done
-
-               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 [[ ${#MULTIBUILD_VARIANTS[@]} -gt 1 ]]; then
-                       multilib_prepare_wrappers
-                       multilib_check_headers
-               fi
-       }
-       multibuild_foreach_variant run_in_build_dir 
fortran-int64_multilib_multibuild_wrapper my_src_install
-       multilib_install_wrappers
-
-       dodoc GotoBLAS_{01Readme,03FAQ,04FAQ,05LargePage,06WeirdPerformance}.txt
-       dodoc *md Changelog.txt
-}

diff --git a/sci-libs/openblas/openblas-0.2.14.ebuild 
b/sci-libs/openblas/openblas-0.2.14.ebuild
index 91736c8..3a92aef 100644
--- a/sci-libs/openblas/openblas-0.2.14.ebuild
+++ b/sci-libs/openblas/openblas-0.2.14.ebuild
@@ -4,32 +4,24 @@
 
 EAPI=5
 
-EBASE_PROFNAME="openblas"
-inherit alternatives-2 eutils multilib fortran-2 multibuild multilib-build 
toolchain-funcs fortran-int64
-
-SRC_URI+="http://dev.gentoo.org/~gienah/distfiles/${PN}-0.2.11-gentoo.patch";
-if [[ ${PV} == "9999" ]] ; then
-       EGIT_REPO_URI="https://github.com/xianyi/OpenBLAS.git";
-       EGIT_BRANCH="develop"
-       inherit git-r3
-       KEYWORDS=""
-else
-       SRC_URI+=" http://github.com/xianyi/OpenBLAS/tarball/v${PV} -> 
${P}.tar.gz"
-       KEYWORDS="~amd64 ~x86 ~amd64-linux ~x86-linux ~x86-macos ~ppc-macos 
~x64-macos"
-fi
+NUMERIC_MODULE_NAME="openblas"
+
+inherit alternatives-2 numeric numeric-int64-multibuild
 
 DESCRIPTION="Optimized BLAS library based on GotoBLAS2"
 HOMEPAGE="http://xianyi.github.com/OpenBLAS/";
+SRC_URI="
+       http://github.com/xianyi/OpenBLAS/tarball/v${PV} -> ${P}.tar.gz
+       http://dev.gentoo.org/~gienah/distfiles/${PN}-0.2.11-gentoo.patch";
+
 LICENSE="BSD"
 SLOT="0"
-IUSE="dynamic int64 openmp static-libs threads"
+KEYWORDS="~amd64 ~x86 ~amd64-linux ~x86-linux ~x86-macos ~ppc-macos ~x64-macos"
+IUSE="dynamic openmp static-libs threads"
 
 RDEPEND=""
 DEPEND="${RDEPEND}
        virtual/pkgconfig"
-PDEPEND="
-       >=virtual/blas-2.1-r2[int64?]
-       >=virtual/cblas-2.0-r1[int64?]"
 
 MULTILIB_WRAPPED_HEADERS=(
        /usr/include/openblas/cblas.h
@@ -38,69 +30,59 @@ MULTILIB_WRAPPED_HEADERS=(
 )
 
 get_openblas_flags() {
-       local openblas_flags=""
+       local openblas_flags=()
        use dynamic && \
-               openblas_flags+=" DYNAMIC_ARCH=1 TARGET=GENERIC NUM_THREADS=64 
NO_AFFINITY=1"
-       $(fortran-int64_is_int64_build) && \
-               openblas_flags+=" INTERFACE64=1"
+               openblas_flags+=( DYNAMIC_ARCH=1 TARGET=GENERIC NUM_THREADS=64 
NO_AFFINITY=1 )
+       $(numeric-int64_is_int64_build) && \
+               openblas_flags+=( INTERFACE64=1 )
        # 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_flags+=" USE_THREAD=1 USE_OPENMP=0"
+               openblas_flags+=( USE_THREAD=1 USE_OPENMP=0 )
        elif use openmp; then
-               openblas_flags+=" USE_OPENMP=1"
+               openblas_flags+=( USE_OPENMP=1 )
        fi
-       local profname=$(fortran-int64_get_profname)
+       local profname=$(numeric-int64_get_module_name)
        local libname="${profname//-/_}"
        local underscoresuffix="${libname#${PN}}"
        if [[ "${underscoresuffix}" != "_" ]]; then
                local libnamesuffix="${underscoresuffix#_}"
-               openblas_flags+=" LIBNAMESUFFIX=${libnamesuffix}"
+               openblas_flags+=( LIBNAMESUFFIX=${libnamesuffix} )
        fi
-       echo "${openblas_flags}"
+       echo "${openblas_flags[@]}"
 }
 
 get_openblas_abi_cflags() {
-       local openblas_abi_cflags=""
+       local openblas_abi_cflags=()
        if [[ "${ABI}" == "x86" ]]; then
-               openblas_abi_cflags="-DOPENBLAS_ARCH_X86=1 
-DOPENBLAS___32BIT__=1"
+               openblas_abi_cflags=( -DOPENBLAS_ARCH_X86=1 
-DOPENBLAS___32BIT__=1 )
        else
-               openblas_abi_cflags="-DOPENBLAS_ARCH_X86_64=1 
-DOPENBLAS___64BIT__=1"
+               openblas_abi_cflags=( -DOPENBLAS_ARCH_X86_64=1 
-DOPENBLAS___64BIT__=1 )
        fi
-       $(fortran-int64_is_int64_build) && \
-               openblas_abi_cflags+=" -DOPENBLAS_USE64BITINT"
-       echo "${openblas_abi_cflags}"
+       $(numeric-int64_is_int64_build) && \
+               openblas_abi_cflags+=( -DOPENBLAS_USE64BITINT )
+       echo "${openblas_abi_cflags[@]}"
 }
 
 src_unpack() {
-       if [[ ${PV} == "9999" ]] ; then
-               git-r3_src_unpack
-       else
-               default
-               if [[ ${PV} != "9999" ]] ; then
-                       find "${WORKDIR}" -maxdepth 1 -type d -name 
\*OpenBLAS\* && \
-                               mv "${WORKDIR}"/*OpenBLAS* "${S}"
-               fi
-       fi
+       default
+       find "${WORKDIR}" -maxdepth 1 -type d -name \*OpenBLAS\* && \
+               mv "${WORKDIR}"/*OpenBLAS* "${S}" || die
 }
 
 src_prepare() {
-       local MULTIBUILD_VARIANTS=( $(fortran-int64_multilib_get_enabled_abis) )
        epatch "${DISTDIR}/${PN}-0.2.11-gentoo.patch"
-       if [[ ${PV} == "0.2.11" ]] ; then
-               epatch "${FILESDIR}/${PN}-0.2.11-cpuid_x86.patch"
-       fi
+
        # lapack and lapacke are not modified from upstream lapack
        sed \
                -e "s:^#\s*\(NO_LAPACK\)\s*=.*:\1=1:" \
                -e "s:^#\s*\(NO_LAPACKE\)\s*=.*:\1=1:" \
                -i Makefile.rule || die
-       multibuild_copy_sources
+       numeric-int64-multibuild_copy_sources
 }
 
 src_configure() {
-       local MULTIBUILD_VARIANTS=( $(fortran-int64_multilib_get_enabled_abis) )
-       my_configure() {
+       blas_configure() {
                local openblas_abi_cflags="$(get_openblas_abi_cflags)"
                local 
internal_openblas_abi_cflags="${openblas_abi_cflags//OPENBLAS_}"
                sed \
@@ -109,28 +91,23 @@ src_configure() {
                        -e "s:^#\s*\(COMMON_OPT\)\s*=.*:\1=${CFLAGS} 
${internal_openblas_abi_cflags}:" \
                        -i Makefile.rule || die
        }
-       multibuild_foreach_variant run_in_build_dir 
fortran-int64_multilib_multibuild_wrapper my_configure
+       numeric-int64-multibuild_foreach_all_abi_variants run_in_build_dir 
blas_configure
 }
 
 src_compile() {
-       local MULTIBUILD_VARIANTS=( $(fortran-int64_multilib_get_enabled_abis) )
        # openblas already does multi-jobs
        MAKEOPTS+=" -j1"
        my_src_compile () {
                local openblas_flags=$(get_openblas_flags)
-               local profname=$(fortran-int64_get_profname)
-               local libname="${profname//-/_}"
-               einfo "Compiling profile ${profname}"
                # cflags already defined twice
-               unset CFLAGS
-               emake clean
-               emake libs shared ${openblas_flags}
-               mkdir -p libs && mv libopenblas* libs/
+               unset CFLAGS || die
+               emake clean && emake libs shared ${openblas_flags}
+               mkdir -p libs && mv libopenblas* libs/ || die
                # 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/
+                       mv libopenblas* libs/ || die
                fi
                # Fix Bug 524612 - [science overlay] sci-libs/openblas-0.2.11 - 
Assembler messages:
                # ../kernel/x86_64/gemm_kernel_8x4_barcelona.S:451: Error: 
missing ')'
@@ -138,79 +115,64 @@ src_compile() {
                # assembler code as the assembler does not understand 
sizeof(float).  So
                # delay applying the patch until after building the libraries.
                epatch 
"${FILESDIR}/${PN}-0.2.11-openblas_config_header_same_between_ABIs.patch"
-               rm -f config.h config_last.h
+               rm -f config.h config_last.h || die
                # Note: prints this spurious warning: make: Nothing to be done 
for 'config.h'.
                emake config.h
                cp config.h config_last.h || die
-               cat <<-EOF > ${profname}.pc
-                       prefix=${EPREFIX}/usr
-                       libdir=\${prefix}/$(get_libdir)
-                       includedir=\${prefix}/include
-                       Name: ${profname}
-                       Description: ${DESCRIPTION}
-                       Version: ${PV}
-                       URL: ${HOMEPAGE}
-                       Libs: -L\${libdir} -l${libname}
-                       Libs.private: -lm
-               EOF
-               local openblas_abi_cflags=$(get_openblas_abi_cflags)
-               local 
openblas_abi_fflags=$(fortran-int64_get_fortran_int64_abi_fflags)
-               cat <<-EOF >> ${profname}.pc
-                       Cflags: -I\${includedir}/${PN} ${openblas_abi_cflags}
-                       Fflags=${openblas_abi_fflags}
-               EOF
+
                mv libs/libopenblas* . || die
        }
-       multibuild_foreach_variant run_in_build_dir 
fortran-int64_multilib_multibuild_wrapper my_src_compile
+       numeric-int64-multibuild_foreach_all_abi_variants run_in_build_dir 
my_src_compile
 }
 
 src_test() {
-       local MULTIBUILD_VARIANTS=( $(fortran-int64_multilib_get_enabled_abis) )
        my_src_test () {
                local openblas_flags=$(get_openblas_flags)
                emake tests ${openblas_flags}
        }
-       multibuild_foreach_variant run_in_build_dir 
fortran-int64_multilib_multibuild_wrapper my_src_test
+       numeric-int64-multibuild_foreach_all_abi_variants run_in_build_dir 
my_src_test
 }
 
 src_install() {
-       local MULTIBUILD_VARIANTS=( $(fortran-int64_multilib_get_enabled_abis) )
        my_src_install() {
                local openblas_flags=$(get_openblas_flags)
-               local profname=$(fortran-int64_get_profname)
+               local profname=$(numeric-int64_get_module_name)
                local pcfile
-               for pcfile in *.pc; do
-                       local profname=${pcfile%.pc}
-                       # The file /usr/include/openblas/openblas_config.h is 
generated during the install.
-                       # The sed on config_last.h removes the #define's 
OPENBLAS_USE64BITINT
-                       # OPENBLASS__32BIT__ OPENBLASS__64BIT__ 
OPENBLAS__ARCH_X86 OPENBLAS__ARCH_X86_64
-                       # from /usr/include/openblas/openblas_config.h.  We 
then specify it in Cflags in
-                       # the 
/usr/lib64/pkg-config/openblas-int64-{threads,openmp}.pc file.
-                       sed -e '/#define USE64BITINT/d' \
-                               -e '/#define ARCH_X86/d' \
-                               -e '/#define __\(32\|64\)BIT__/d' \
-                               -i config_last.h \
-                               || die "Could not ensure there is no definition 
of USE64BITINT in config_last.h"
-                       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 $(fortran-int64_get_blas_provider) 
${profname} 0 \
-                               
/usr/$(get_libdir)/pkgconfig/$(fortran-int64_get_blas_provider).pc ${pcfile}
-                       alternatives_for $(fortran-int64_get_cblas_provider) 
${profname} 0 \
-                               
/usr/$(get_libdir)/pkgconfig/$(fortran-int64_get_cblas_provider).pc ${pcfile} \
-                               /usr/include/cblas.h ${PN}/cblas.h
-                       insinto /usr/$(get_libdir)/pkgconfig
-                       doins ${pcfile}
-               done
+               # The file /usr/include/openblas/openblas_config.h is generated 
during the install.
+               # The sed on config_last.h removes the #define's 
OPENBLAS_USE64BITINT
+               # OPENBLASS__32BIT__ OPENBLASS__64BIT__ OPENBLAS__ARCH_X86 
OPENBLAS__ARCH_X86_64
+               # from /usr/include/openblas/openblas_config.h.  We then 
specify it in Cflags in
+               # the /usr/lib64/pkg-config/openblas-int64-{threads,openmp}.pc 
file.
+               sed -e '/#define USE64BITINT/d' \
+                       -e '/#define ARCH_X86/d' \
+                       -e '/#define __\(32\|64\)BIT__/d' \
+                       -i config_last.h \
+                       || die "Could not ensure there is no definition of 
USE64BITINT in config_last.h"
+               emake install \
+                       PREFIX="${ED}"usr ${openblas_flags} \
+                       OPENBLAS_INCLUDE_DIR="${ED}"usr/include/${PN} \
+                       OPENBLAS_LIBRARY_DIR="${ED}"usr/$(get_libdir)
+               if ! use static-libs; then
+                       rm "${ED}"usr/$(get_libdir)/lib*.a || die
+               fi
+
+               local openblas_abi_cflags=$(get_openblas_abi_cflags)
+               local 
openblas_abi_fflags=$(numeric-int64_get_fortran_int64_abi_fflags)
+               local libname="${profname//-/_}"
+
+               create_pkgconfig \
+                       --name "${profname}" \
+                       --libs "-L\${libdir} -l${libname}" \
+                       --libs-private "-lm" \
+                       --cflags "-I\${includedir}/${PN} 
${openblas_abi_cflags}" \
+                       ${profname}
 
                if [[ ${CHOST} == *-darwin* ]] ; then
-                       cd "${ED}"/usr/$(get_libdir)
+                       cd "${ED}"/usr/$(get_libdir) || die
                        local d
-                       for d in *.dylib ; do
+                       for d in *.dylib; do
                                ebegin "Correcting install_name of ${d}"
-                               install_name_tool -id 
"${EPREFIX}/usr/$(get_libdir)/${d}" "${d}"
+                               install_name_tool -id 
"${EPREFIX}/usr/$(get_libdir)/${d}" "${d}" || die
                                eend $?
                        done
                fi
@@ -219,9 +181,13 @@ src_install() {
                        multilib_check_headers
                fi
        }
-       multibuild_foreach_variant run_in_build_dir 
fortran-int64_multilib_multibuild_wrapper my_src_install
+       numeric-int64-multibuild_foreach_all_abi_variants run_in_build_dir 
my_src_install
+
+       printf "/usr/include/cblas.h ${PN}/cblas.h" > 
"${T}"/alternative-cblas-generic.sh || die
+       numeric-int64-multibuild_install_alternative blas ${NUMERIC_MODULE_NAME}
+       numeric-int64-multibuild_install_alternative cblas 
${NUMERIC_MODULE_NAME}
+
        multilib_install_wrappers
 
-       dodoc GotoBLAS_{01Readme,03FAQ,04FAQ,05LargePage,06WeirdPerformance}.txt
-       dodoc *md Changelog.txt
+       dodoc 
GotoBLAS_{01Readme,03FAQ,04FAQ,05LargePage,06WeirdPerformance}.txt *md 
Changelog.txt
 }

diff --git a/sci-libs/openblas/openblas-0.2.8.ebuild 
b/sci-libs/openblas/openblas-0.2.8.ebuild
deleted file mode 100644
index 05c420f..0000000
--- a/sci-libs/openblas/openblas-0.2.8.ebuild
+++ /dev/null
@@ -1,126 +0,0 @@
-# Copyright 1999-2015 Gentoo Foundation
-# Distributed under the terms of the GNU General Public License v2
-# $Id$
-
-EAPI=5
-
-inherit eutils multilib toolchain-funcs alternatives-2 multilib fortran-2
-
-DESCRIPTION="Optimized BLAS library based on GotoBLAS2"
-HOMEPAGE="http://xianyi.github.com/OpenBLAS/";
-SRC_URI="http://github.com/xianyi/OpenBLAS/tarball/v${PV} -> ${P}.tar.gz"
-KEYWORDS="~amd64 ~x86 ~amd64-linux ~x86-linux ~x86-macos ~ppc-macos ~x64-macos"
-
-LICENSE="BSD"
-SLOT="0"
-
-IUSE="int64 dynamic openmp static-libs threads"
-
-RDEPEND=""
-DEPEND="${RDEPEND}"
-
-src_unpack() {
-       default
-       find "${WORKDIR}" -maxdepth 1 -type d -name \*OpenBLAS\* && \
-               mv "${WORKDIR}"/*OpenBLAS* "${S}"
-}
-
-src_configure() {
-       # lapack and lapacke are not modified from upstream lapack
-       sed -i \
-               -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:" \
-               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
-}
-
-src_compile() {
-       # openblas already does multi-jobs
-       MAKEOPTS+=" -j1"
-       openblas_flags=""
-       local openblas_name=openblas
-       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"
-
-       # 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
-}
-
-src_test() {
-       emake tests ${openblas_flags}
-}
-
-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
-
-       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
-}

diff --git a/sci-libs/openblas/openblas-9999.ebuild 
b/sci-libs/openblas/openblas-9999.ebuild
index 91736c8..25ccea3 100644
--- a/sci-libs/openblas/openblas-9999.ebuild
+++ b/sci-libs/openblas/openblas-9999.ebuild
@@ -4,32 +4,24 @@
 
 EAPI=5
 
-EBASE_PROFNAME="openblas"
-inherit alternatives-2 eutils multilib fortran-2 multibuild multilib-build 
toolchain-funcs fortran-int64
-
-SRC_URI+="http://dev.gentoo.org/~gienah/distfiles/${PN}-0.2.11-gentoo.patch";
-if [[ ${PV} == "9999" ]] ; then
-       EGIT_REPO_URI="https://github.com/xianyi/OpenBLAS.git";
-       EGIT_BRANCH="develop"
-       inherit git-r3
-       KEYWORDS=""
-else
-       SRC_URI+=" http://github.com/xianyi/OpenBLAS/tarball/v${PV} -> 
${P}.tar.gz"
-       KEYWORDS="~amd64 ~x86 ~amd64-linux ~x86-linux ~x86-macos ~ppc-macos 
~x64-macos"
-fi
+NUMERIC_MODULE_NAME="openblas"
+
+inherit alternatives-2 git-r3 numeric numeric-int64-multibuild
 
 DESCRIPTION="Optimized BLAS library based on GotoBLAS2"
 HOMEPAGE="http://xianyi.github.com/OpenBLAS/";
+SRC_URI="http://dev.gentoo.org/~gienah/distfiles/${PN}-0.2.11-gentoo.patch";
+EGIT_REPO_URI="https://github.com/xianyi/OpenBLAS.git";
+EGIT_BRANCH="develop"
+
 LICENSE="BSD"
 SLOT="0"
-IUSE="dynamic int64 openmp static-libs threads"
+KEYWORDS=""
+IUSE="dynamic openmp static-libs threads"
 
 RDEPEND=""
 DEPEND="${RDEPEND}
        virtual/pkgconfig"
-PDEPEND="
-       >=virtual/blas-2.1-r2[int64?]
-       >=virtual/cblas-2.0-r1[int64?]"
 
 MULTILIB_WRAPPED_HEADERS=(
        /usr/include/openblas/cblas.h
@@ -38,69 +30,53 @@ MULTILIB_WRAPPED_HEADERS=(
 )
 
 get_openblas_flags() {
-       local openblas_flags=""
+       local openblas_flags=()
        use dynamic && \
-               openblas_flags+=" DYNAMIC_ARCH=1 TARGET=GENERIC NUM_THREADS=64 
NO_AFFINITY=1"
-       $(fortran-int64_is_int64_build) && \
-               openblas_flags+=" INTERFACE64=1"
+               openblas_flags+=( DYNAMIC_ARCH=1 TARGET=GENERIC NUM_THREADS=64 
NO_AFFINITY=1 )
+       $(numeric-int64_is_int64_build) && \
+               openblas_flags+=( INTERFACE64=1 )
        # 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_flags+=" USE_THREAD=1 USE_OPENMP=0"
+               openblas_flags+=( USE_THREAD=1 USE_OPENMP=0 )
        elif use openmp; then
-               openblas_flags+=" USE_OPENMP=1"
+               openblas_flags+=( USE_OPENMP=1 )
        fi
-       local profname=$(fortran-int64_get_profname)
+       local profname=$(numeric-int64_get_module_name)
        local libname="${profname//-/_}"
        local underscoresuffix="${libname#${PN}}"
        if [[ "${underscoresuffix}" != "_" ]]; then
                local libnamesuffix="${underscoresuffix#_}"
-               openblas_flags+=" LIBNAMESUFFIX=${libnamesuffix}"
+               openblas_flags+=( LIBNAMESUFFIX=${libnamesuffix} )
        fi
-       echo "${openblas_flags}"
+       echo "${openblas_flags[@]}"
 }
 
 get_openblas_abi_cflags() {
-       local openblas_abi_cflags=""
+       local openblas_abi_cflags=()
        if [[ "${ABI}" == "x86" ]]; then
-               openblas_abi_cflags="-DOPENBLAS_ARCH_X86=1 
-DOPENBLAS___32BIT__=1"
-       else
-               openblas_abi_cflags="-DOPENBLAS_ARCH_X86_64=1 
-DOPENBLAS___64BIT__=1"
-       fi
-       $(fortran-int64_is_int64_build) && \
-               openblas_abi_cflags+=" -DOPENBLAS_USE64BITINT"
-       echo "${openblas_abi_cflags}"
-}
-
-src_unpack() {
-       if [[ ${PV} == "9999" ]] ; then
-               git-r3_src_unpack
+               openblas_abi_cflags=( -DOPENBLAS_ARCH_X86=1 
-DOPENBLAS___32BIT__=1 )
        else
-               default
-               if [[ ${PV} != "9999" ]] ; then
-                       find "${WORKDIR}" -maxdepth 1 -type d -name 
\*OpenBLAS\* && \
-                               mv "${WORKDIR}"/*OpenBLAS* "${S}"
-               fi
+               openblas_abi_cflags=( -DOPENBLAS_ARCH_X86_64=1 
-DOPENBLAS___64BIT__=1 )
        fi
+       $(numeric-int64_is_int64_build) && \
+               openblas_abi_cflags+=( -DOPENBLAS_USE64BITINT )
+       echo "${openblas_abi_cflags[@]}"
 }
 
 src_prepare() {
-       local MULTIBUILD_VARIANTS=( $(fortran-int64_multilib_get_enabled_abis) )
        epatch "${DISTDIR}/${PN}-0.2.11-gentoo.patch"
-       if [[ ${PV} == "0.2.11" ]] ; then
-               epatch "${FILESDIR}/${PN}-0.2.11-cpuid_x86.patch"
-       fi
+
        # lapack and lapacke are not modified from upstream lapack
        sed \
                -e "s:^#\s*\(NO_LAPACK\)\s*=.*:\1=1:" \
                -e "s:^#\s*\(NO_LAPACKE\)\s*=.*:\1=1:" \
                -i Makefile.rule || die
-       multibuild_copy_sources
+       numeric-int64-multibuild_copy_sources
 }
 
 src_configure() {
-       local MULTIBUILD_VARIANTS=( $(fortran-int64_multilib_get_enabled_abis) )
-       my_configure() {
+       blas_configure() {
                local openblas_abi_cflags="$(get_openblas_abi_cflags)"
                local 
internal_openblas_abi_cflags="${openblas_abi_cflags//OPENBLAS_}"
                sed \
@@ -109,28 +85,23 @@ src_configure() {
                        -e "s:^#\s*\(COMMON_OPT\)\s*=.*:\1=${CFLAGS} 
${internal_openblas_abi_cflags}:" \
                        -i Makefile.rule || die
        }
-       multibuild_foreach_variant run_in_build_dir 
fortran-int64_multilib_multibuild_wrapper my_configure
+       numeric-int64-multibuild_foreach_all_abi_variants run_in_build_dir 
blas_configure
 }
 
 src_compile() {
-       local MULTIBUILD_VARIANTS=( $(fortran-int64_multilib_get_enabled_abis) )
        # openblas already does multi-jobs
        MAKEOPTS+=" -j1"
        my_src_compile () {
                local openblas_flags=$(get_openblas_flags)
-               local profname=$(fortran-int64_get_profname)
-               local libname="${profname//-/_}"
-               einfo "Compiling profile ${profname}"
                # cflags already defined twice
-               unset CFLAGS
-               emake clean
-               emake libs shared ${openblas_flags}
-               mkdir -p libs && mv libopenblas* libs/
+               unset CFLAGS || die
+               emake clean && emake libs shared ${openblas_flags}
+               mkdir -p libs && mv libopenblas* libs/ || die
                # 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/
+                       mv libopenblas* libs/ || die
                fi
                # Fix Bug 524612 - [science overlay] sci-libs/openblas-0.2.11 - 
Assembler messages:
                # ../kernel/x86_64/gemm_kernel_8x4_barcelona.S:451: Error: 
missing ')'
@@ -138,79 +109,64 @@ src_compile() {
                # assembler code as the assembler does not understand 
sizeof(float).  So
                # delay applying the patch until after building the libraries.
                epatch 
"${FILESDIR}/${PN}-0.2.11-openblas_config_header_same_between_ABIs.patch"
-               rm -f config.h config_last.h
+               rm -f config.h config_last.h || die
                # Note: prints this spurious warning: make: Nothing to be done 
for 'config.h'.
                emake config.h
                cp config.h config_last.h || die
-               cat <<-EOF > ${profname}.pc
-                       prefix=${EPREFIX}/usr
-                       libdir=\${prefix}/$(get_libdir)
-                       includedir=\${prefix}/include
-                       Name: ${profname}
-                       Description: ${DESCRIPTION}
-                       Version: ${PV}
-                       URL: ${HOMEPAGE}
-                       Libs: -L\${libdir} -l${libname}
-                       Libs.private: -lm
-               EOF
-               local openblas_abi_cflags=$(get_openblas_abi_cflags)
-               local 
openblas_abi_fflags=$(fortran-int64_get_fortran_int64_abi_fflags)
-               cat <<-EOF >> ${profname}.pc
-                       Cflags: -I\${includedir}/${PN} ${openblas_abi_cflags}
-                       Fflags=${openblas_abi_fflags}
-               EOF
+
                mv libs/libopenblas* . || die
        }
-       multibuild_foreach_variant run_in_build_dir 
fortran-int64_multilib_multibuild_wrapper my_src_compile
+       numeric-int64-multibuild_foreach_all_abi_variants run_in_build_dir 
my_src_compile
 }
 
 src_test() {
-       local MULTIBUILD_VARIANTS=( $(fortran-int64_multilib_get_enabled_abis) )
        my_src_test () {
                local openblas_flags=$(get_openblas_flags)
                emake tests ${openblas_flags}
        }
-       multibuild_foreach_variant run_in_build_dir 
fortran-int64_multilib_multibuild_wrapper my_src_test
+       numeric-int64-multibuild_foreach_all_abi_variants run_in_build_dir 
my_src_test
 }
 
 src_install() {
-       local MULTIBUILD_VARIANTS=( $(fortran-int64_multilib_get_enabled_abis) )
        my_src_install() {
                local openblas_flags=$(get_openblas_flags)
-               local profname=$(fortran-int64_get_profname)
+               local profname=$(numeric-int64_get_module_name)
                local pcfile
-               for pcfile in *.pc; do
-                       local profname=${pcfile%.pc}
-                       # The file /usr/include/openblas/openblas_config.h is 
generated during the install.
-                       # The sed on config_last.h removes the #define's 
OPENBLAS_USE64BITINT
-                       # OPENBLASS__32BIT__ OPENBLASS__64BIT__ 
OPENBLAS__ARCH_X86 OPENBLAS__ARCH_X86_64
-                       # from /usr/include/openblas/openblas_config.h.  We 
then specify it in Cflags in
-                       # the 
/usr/lib64/pkg-config/openblas-int64-{threads,openmp}.pc file.
-                       sed -e '/#define USE64BITINT/d' \
-                               -e '/#define ARCH_X86/d' \
-                               -e '/#define __\(32\|64\)BIT__/d' \
-                               -i config_last.h \
-                               || die "Could not ensure there is no definition 
of USE64BITINT in config_last.h"
-                       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 $(fortran-int64_get_blas_provider) 
${profname} 0 \
-                               
/usr/$(get_libdir)/pkgconfig/$(fortran-int64_get_blas_provider).pc ${pcfile}
-                       alternatives_for $(fortran-int64_get_cblas_provider) 
${profname} 0 \
-                               
/usr/$(get_libdir)/pkgconfig/$(fortran-int64_get_cblas_provider).pc ${pcfile} \
-                               /usr/include/cblas.h ${PN}/cblas.h
-                       insinto /usr/$(get_libdir)/pkgconfig
-                       doins ${pcfile}
-               done
+               # The file /usr/include/openblas/openblas_config.h is generated 
during the install.
+               # The sed on config_last.h removes the #define's 
OPENBLAS_USE64BITINT
+               # OPENBLASS__32BIT__ OPENBLASS__64BIT__ OPENBLAS__ARCH_X86 
OPENBLAS__ARCH_X86_64
+               # from /usr/include/openblas/openblas_config.h.  We then 
specify it in Cflags in
+               # the /usr/lib64/pkg-config/openblas-int64-{threads,openmp}.pc 
file.
+               sed -e '/#define USE64BITINT/d' \
+                       -e '/#define ARCH_X86/d' \
+                       -e '/#define __\(32\|64\)BIT__/d' \
+                       -i config_last.h \
+                       || die "Could not ensure there is no definition of 
USE64BITINT in config_last.h"
+               emake install \
+                       PREFIX="${ED}"usr ${openblas_flags} \
+                       OPENBLAS_INCLUDE_DIR="${ED}"usr/include/${PN} \
+                       OPENBLAS_LIBRARY_DIR="${ED}"usr/$(get_libdir)
+               if ! use static-libs; then
+                       rm "${ED}"usr/$(get_libdir)/lib*.a || die
+               fi
+
+               local openblas_abi_cflags=$(get_openblas_abi_cflags)
+               local 
openblas_abi_fflags=$(numeric-int64_get_fortran_int64_abi_fflags)
+               local libname="${profname//-/_}"
+
+               create_pkgconfig \
+                       --name "${profname}" \
+                       --libs "-L\${libdir} -l${libname}" \
+                       --libs-private "-lm" \
+                       --cflags "-I\${includedir}/${PN} 
${openblas_abi_cflags}" \
+                       ${profname}
 
                if [[ ${CHOST} == *-darwin* ]] ; then
-                       cd "${ED}"/usr/$(get_libdir)
+                       cd "${ED}"/usr/$(get_libdir) || die
                        local d
-                       for d in *.dylib ; do
+                       for d in *.dylib; do
                                ebegin "Correcting install_name of ${d}"
-                               install_name_tool -id 
"${EPREFIX}/usr/$(get_libdir)/${d}" "${d}"
+                               install_name_tool -id 
"${EPREFIX}/usr/$(get_libdir)/${d}" "${d}" || die
                                eend $?
                        done
                fi
@@ -219,9 +175,13 @@ src_install() {
                        multilib_check_headers
                fi
        }
-       multibuild_foreach_variant run_in_build_dir 
fortran-int64_multilib_multibuild_wrapper my_src_install
+       numeric-int64-multibuild_foreach_all_abi_variants run_in_build_dir 
my_src_install
+
+       printf "/usr/include/cblas.h ${PN}/cblas.h" > 
"${T}"/alternative-cblas-generic.sh
+       numeric-int64-multibuild_install_alternative blas ${NUMERIC_MODULE_NAME}
+       numeric-int64-multibuild_install_alternative cblas 
${NUMERIC_MODULE_NAME}
+
        multilib_install_wrappers
 
-       dodoc GotoBLAS_{01Readme,03FAQ,04FAQ,05LargePage,06WeirdPerformance}.txt
-       dodoc *md Changelog.txt
+       dodoc 
GotoBLAS_{01Readme,03FAQ,04FAQ,05LargePage,06WeirdPerformance}.txt *md 
Changelog.txt
 }

diff --git a/sci-libs/xblas/xblas-1.0.248-r1.ebuild 
b/sci-libs/xblas/xblas-1.0.248-r1.ebuild
index 5005e9d..93ecafd 100644
--- a/sci-libs/xblas/xblas-1.0.248-r1.ebuild
+++ b/sci-libs/xblas/xblas-1.0.248-r1.ebuild
@@ -4,8 +4,10 @@
 
 EAPI=5
 
-EBASE_PROFNAME="xblas"
-inherit eutils flag-o-matic fortran-2 fortran-int64 multibuild multilib 
multilib-build toolchain-funcs versionator
+NUMERIC_MODULE_NAME="xblas"
+FORTRAN_NEEDED=fortran
+
+inherit flag-o-matic fortran-2 numeric-int64-multibuild toolchain-funcs 
versionator
 
 DESCRIPTION="Extra Precise Basic Linear Algebra Subroutines"
 HOMEPAGE="http://www.netlib.org/xblas";
@@ -14,9 +16,9 @@ SRC_URI="${HOMEPAGE}/${P}.tar.gz"
 LICENSE="BSD"
 SLOT="0"
 KEYWORDS="~amd64 ~x86 ~amd64-linux ~x86-linux"
-IUSE="doc fortran int64 static-libs"
+IUSE="doc fortran static-libs"
 
-RDEPEND="fortran? ( virtual/fortran )"
+RDEPEND=""
 DEPEND="${RDEPEND}
        sys-devel/m4"
 
@@ -38,8 +40,8 @@ static_to_shared() {
                        -Wl,--whole-archive ${libstatic} -Wl,--no-whole-archive 
\
                        "$@" -o ${libdir}/${soname} || die "${soname} failed"
                [[ $(get_version_component_count) -gt 1 ]] && \
-                       ln -s ${soname} ${libdir}/${libname}$(get_libname 
$(get_major_version))
-               ln -s ${soname} ${libdir}/${libname}$(get_libname)
+                       ln -s ${soname} ${libdir}/${libname}$(get_libname 
$(get_major_version)) || die
+               ln -s ${soname} ${libdir}/${libname}$(get_libname) || die
        fi
 }
 
@@ -48,23 +50,20 @@ pkg_setup() {
 }
 
 src_prepare() {
-       local MULTIBUILD_VARIANTS=( $(fortran-int64_multilib_get_enabled_abis) )
-       multibuild_copy_sources
+       numeric-int64-multibuild_copy_sources
 }
 
 src_configure() {
-       local MULTIBUILD_VARIANTS=( $(fortran-int64_multilib_get_enabled_abis) )
-       my_configure() {
-               export FCFLAGS="${FCFLAGS} $(get_abi_CFLAGS) 
$(fortran-int64_get_fortran_int64_abi_fflags)"
+       xblas_configure() {
+               export FCFLAGS="${FCFLAGS} $(get_abi_CFLAGS) 
$(numeric-int64_get_fortran_int64_abi_fflags)"
                econf $(use_enable fortran)
        }
-       multibuild_foreach_variant run_in_build_dir 
fortran-int64_multilib_multibuild_wrapper my_configure
+       numeric-int64-multibuild_foreach_all_abi_variants run_in_build_dir 
xblas_configure
 }
 
 src_compile() {
-       local MULTIBUILD_VARIANTS=( $(fortran-int64_multilib_get_enabled_abis) )
-       my_src_compile() {
-               local profname=$(fortran-int64_get_profname)
+       xblas_src_compile() {
+               local profname=$(numeric-int64_get_module_name)
                local libname="${profname//-/_}"
                # default target builds and runs tests - split
                # build first static libs because of fPIC afterwards
@@ -81,42 +80,31 @@ src_compile() {
                emake lib XBLASLIB=lib${libname}.a
                static_to_shared lib${libname}.a
        }
-       multibuild_foreach_variant run_in_build_dir 
fortran-int64_multilib_multibuild_wrapper my_src_compile
+       numeric-int64-multibuild_foreach_all_abi_variants run_in_build_dir 
xblas_src_compile
 }
 
 src_test() {
-       local MULTIBUILD_VARIANTS=( $(fortran-int64_multilib_get_enabled_abis) )
-       my_src_test () {
-               emake tests
-       }
-       multibuild_foreach_variant run_in_build_dir 
fortran-int64_multilib_multibuild_wrapper my_src_test
+       numeric-int64-multibuild_foreach_all_abi_variants run_in_build_dir 
emake tests
 }
 
 src_install() {
-       local MULTIBUILD_VARIANTS=( $(fortran-int64_multilib_get_enabled_abis) )
-       my_src_install() {
-               local profname=$(fortran-int64_get_profname)
+       xblas_src_install() {
+               local profname=$(numeric-int64_get_module_name)
                local libname="${profname//-/_}"
-               dolib.so lib${libname}$(get_libname)*
-               use static-libs && newlib.a lib${libname}_nonpic.a 
lib${libname}.a
-               dodoc README README.devel
-               use doc && dodoc doc/report.ps
-
-               # pkg-config file for our multliple numeric stuff
-               cat > ${profname}.pc <<-EOF
-                       prefix=${EPREFIX}/usr
-                       libdir=\${prefix}/$(get_libdir)
-                       includedir=\${prefix}/include/${PN}
-                       Name: ${profname}
-                       Description: ${DESCRIPTION}
-                       Version: ${PV}
-                       URL: ${HOMEPAGE}
-                       Libs: -L\${libdir} -l${libname}
-                       Cflags: -I\${includedir}
-                       Fflags=$(fortran-int64_get_fortran_int64_abi_fflags)
-               EOF
-               insinto /usr/$(get_libdir)/pkgconfig
-               doins ${profname}.pc
+               if numeric-int64_is_static_build; then
+                       use static-libs && newlib.a lib${libname}_nonpic.a 
lib${libname}.a
+               else
+                       dolib.so lib${libname}$(get_libname)*
+
+                       create_pkgconfig \
+                               --name  ${profname} \
+                               --libs "-L\${libdir} -l${libname}" \
+                               --cflags "-I\${includedir} 
$(numeric-int64_get_fortran_int64_abi_fflags)" \
+                               ${profname}
+               fi
        }
-       multibuild_foreach_variant run_in_build_dir 
fortran-int64_multilib_multibuild_wrapper my_src_install
+       numeric-int64-multibuild_foreach_all_abi_variants run_in_build_dir 
xblas_src_install
+
+       dodoc README README.devel
+       use doc && dodoc doc/report.ps
 }

diff --git a/sci-libs/xblas/xblas-1.0.248.ebuild 
b/sci-libs/xblas/xblas-1.0.248.ebuild
deleted file mode 100644
index 609d8b9..0000000
--- a/sci-libs/xblas/xblas-1.0.248.ebuild
+++ /dev/null
@@ -1,93 +0,0 @@
-# Copyright 1999-2014 Gentoo Foundation
-# Distributed under the terms of the GNU General Public License v2
-# $Id$
-
-EAPI=5
-
-inherit eutils flag-o-matic fortran-2 multilib toolchain-funcs versionator
-
-DESCRIPTION="Extra Precise Basic Linear Algebra Subroutines"
-HOMEPAGE="http://www.netlib.org/xblas";
-SRC_URI="${HOMEPAGE}/${P}.tar.gz"
-
-LICENSE="BSD"
-SLOT="0"
-KEYWORDS="~amd64 ~x86 ~amd64-linux ~x86-linux"
-IUSE="doc fortran static-libs"
-
-RDEPEND="fortran? ( virtual/fortran )"
-DEPEND="${RDEPEND}"
-
-static_to_shared() {
-       local libstatic=${1}; shift
-       local libname=$(basename ${libstatic%.a})
-       local soname=${libname}$(get_libname $(get_version_component_range 1-2))
-       local libdir=$(dirname ${libstatic})
-
-       einfo "Making ${soname} from ${libstatic}"
-       if [[ ${CHOST} == *-darwin* ]] ; then
-               ${LINK:-$(tc-getCC)} ${LDFLAGS}  \
-                       -dynamiclib -install_name 
"${EPREFIX}"/usr/lib/"${soname}" \
-                       -Wl,-all_load -Wl,${libstatic} \
-                       "$@" -o ${libdir}/${soname} || die "${soname} failed"
-       else
-               ${LINK:-$(tc-getCC)} ${LDFLAGS}  \
-                       -shared -Wl,-soname=${soname} \
-                       -Wl,--whole-archive ${libstatic} -Wl,--no-whole-archive 
\
-                       "$@" -o ${libdir}/${soname} || die "${soname} failed"
-               [[ $(get_version_component_count) -gt 1 ]] && \
-                       ln -s ${soname} ${libdir}/${libname}$(get_libname 
$(get_major_version))
-               ln -s ${soname} ${libdir}/${libname}$(get_libname)
-       fi
-}
-
-pkg_setup() {
-       use fortran && fortran-2_pkg_setup
-}
-
-src_configure() {
-       econf $(use_enable fortran)
-}
-
-src_compile() {
-       # default target builds and runs tests - split
-       # build first static libs because of fPIC afterwards
-       # and we link tests with shared ones
-       if use static-libs; then
-               emake makefiles
-               emake lib XBLASLIB=lib${PN}_nonpic.a
-               emake clean
-       fi
-       sed -i \
-               -e 's:\(CFLAGS.*\).*:\1 -fPIC:' \
-               make.inc || die
-       emake makefiles
-       emake lib
-       static_to_shared lib${PN}.a
-}
-
-src_test() {
-       emake tests
-}
-
-src_install() {
-       dolib.so lib${PN}$(get_libname)*
-       use static-libs && newlib.a lib${PN}_nonpic.a lib${PN}.a
-       dodoc README README.devel
-       use doc && dodoc doc/report.ps
-
-       # pkg-config file for our multliple numeric stuff
-       cat > ${PN}.pc <<-EOF
-               prefix=${EPREFIX}/usr
-               libdir=\${prefix}/$(get_libdir)
-               includedir=\${prefix}/include/${PN}
-               Name: ${PN}
-               Description: ${DESCRIPTION}
-               Version: ${PV}
-               URL: ${HOMEPAGE}
-               Libs: -L\${libdir} -l${PN}
-               Cflags: -I\${includedir}
-       EOF
-       insinto /usr/$(get_libdir)/pkgconfig
-       doins ${PN}.pc
-}

diff --git a/virtual/blas/blas-2.1-r1.ebuild b/virtual/blas/blas-2.1-r1.ebuild
deleted file mode 100644
index 7b846bd..0000000
--- a/virtual/blas/blas-2.1-r1.ebuild
+++ /dev/null
@@ -1,38 +0,0 @@
-# Copyright 1999-2014 Gentoo Foundation
-# Distributed under the terms of the GNU General Public License v2
-# $Id$
-
-EAPI=5
-
-inherit multilib
-
-DESCRIPTION="Virtual for FORTRAN 77 BLAS implementation"
-HOMEPAGE=""
-SRC_URI=""
-
-LICENSE=""
-SLOT="0"
-KEYWORDS="~amd64 ~x86 ~amd64-linux ~x86-linux"
-IUSE="doc"
-
-RDEPEND="
-       || (
-               >=sci-libs/blas-reference-20110417
-               >=dev-cpp/eigen-3.1.2
-               sci-libs/atlas[fortran]
-               sci-libs/openblas
-               >=sci-libs/acml-4.4
-               sci-libs/gotoblas2
-               >=sci-libs/mkl-10.3
-       )
-       doc? ( >=app-doc/blas-docs-3.2 )"
-DEPEND=""
-
-pkg_pretend() {
-       if [[ -e "${EROOT%/}"/usr/$(get_libdir)/lib${PN}.so ]]; then
-               ewarn "You have still the old ${PN} library symlink present"
-               ewarn "Please delete"
-               ewarn "${EROOT%/}/usr/$(get_libdir)/lib${PN}.so"
-               ewarn "to avoid problems with new ${PN} structure"
-       fi
-}

diff --git a/virtual/blas/blas-2.1-r2.ebuild b/virtual/blas/blas-2.1-r2.ebuild
deleted file mode 100644
index b7380d0..0000000
--- a/virtual/blas/blas-2.1-r2.ebuild
+++ /dev/null
@@ -1,41 +0,0 @@
-# Copyright 1999-2014 Gentoo Foundation
-# Distributed under the terms of the GNU General Public License v2
-# $Id$
-
-EAPI=5
-
-inherit multilib
-
-DESCRIPTION="Virtual for FORTRAN 77 BLAS implementation"
-HOMEPAGE=""
-SRC_URI=""
-
-LICENSE=""
-SLOT="0"
-KEYWORDS="~amd64 ~x86 ~amd64-linux ~x86-linux"
-IUSE="doc int64"
-
-RDEPEND="
-       int64? (
-               sci-libs/openblas[int64]
-       )
-       || (
-               >=sci-libs/blas-reference-20110417
-               >=dev-cpp/eigen-3.1.2
-               sci-libs/atlas[fortran]
-               sci-libs/openblas[int64?]
-               >=sci-libs/acml-4.4
-               sci-libs/gotoblas2
-               >=sci-libs/mkl-10.3
-       )
-       doc? ( >=app-doc/blas-docs-3.2 )"
-DEPEND=""
-
-pkg_pretend() {
-       if [[ -e "${EROOT%/}"/usr/$(get_libdir)/lib${PN}.so ]]; then
-               ewarn "You have still the old ${PN} library symlink present"
-               ewarn "Please delete"
-               ewarn "${EROOT%/}/usr/$(get_libdir)/lib${PN}.so"
-               ewarn "to avoid problems with new ${PN} structure"
-       fi
-}

diff --git a/virtual/blas/blas-2.1-r3.ebuild b/virtual/blas/blas-2.1-r3.ebuild
index 8c83e53..48f4d0e 100644
--- a/virtual/blas/blas-2.1-r3.ebuild
+++ b/virtual/blas/blas-2.1-r3.ebuild
@@ -4,7 +4,7 @@
 
 EAPI=5
 
-inherit multilib
+inherit multilib-build
 
 DESCRIPTION="Virtual for FORTRAN 77 BLAS implementation"
 HOMEPAGE=""
@@ -18,15 +18,15 @@ IUSE="doc int64"
 RDEPEND="
        int64? (
                || (
-                       >=sci-libs/openblas-0.2.11[int64]
-                       >=sci-libs/blas-reference-20131116-r1[int64]
+                       sci-libs/blas-reference[int64,${MULTILIB_USEDEP}]
+                       >=sci-libs/openblas-0.2.11[int64,${MULTILIB_USEDEP}]
                )
        )
        || (
-               >=sci-libs/blas-reference-20131116-r1[int64?]
+               sci-libs/blas-reference[int64?,${MULTILIB_USEDEP}]
+               >=sci-libs/openblas-0.2.11[int64?,${MULTILIB_USEDEP}]
                >=dev-cpp/eigen-3.1.4
                sci-libs/atlas[fortran]
-               >=sci-libs/openblas-0.2.11[int64?]
                >=sci-libs/acml-4.4
                sci-libs/gotoblas2
                >=sci-libs/mkl-10.3
@@ -40,5 +40,6 @@ pkg_pretend() {
                ewarn "Please delete"
                ewarn "${EROOT%/}/usr/$(get_libdir)/lib${PN}.so"
                ewarn "to avoid problems with new ${PN} structure"
+               die "Old lib${PN} detected"
        fi
 }

diff --git a/virtual/blas/metadata.xml b/virtual/blas/metadata.xml
index a27bb5a..cc94dad 100644
--- a/virtual/blas/metadata.xml
+++ b/virtual/blas/metadata.xml
@@ -6,8 +6,8 @@
   Gentoo virtual package for the Basic Linear Algebra Subprograms
   FORTRAN 77 implementation.
 </longdescription>
-<use>
-  <flag name="int64">Add eselect module for blas libraries built with 64 bits
+  <use>
+    <flag name="int64">Add eselect module for blas libraries built with 64 bits
   integer ABI</flag>
-</use>
+  </use>
 </pkgmetadata>

diff --git a/virtual/cblas/cblas-2.0-r1.ebuild 
b/virtual/cblas/cblas-2.0-r1.ebuild
deleted file mode 100644
index aab813f..0000000
--- a/virtual/cblas/cblas-2.0-r1.ebuild
+++ /dev/null
@@ -1,28 +0,0 @@
-# Copyright 1999-2014 Gentoo Foundation
-# Distributed under the terms of the GNU General Public License v2
-# $Id$
-
-EAPI=5
-
-DESCRIPTION="Virtual for BLAS C implementation"
-HOMEPAGE=""
-SRC_URI=""
-
-LICENSE=""
-SLOT="0"
-KEYWORDS="~amd64 ~x86 ~amd64-linux ~x86-linux"
-IUSE="int64"
-
-RDEPEND="
-       int64? (
-               sci-libs/openblas[int64]
-       )
-       || (
-               >=sci-libs/cblas-reference-20110218
-               sci-libs/openblas[int64?]
-               >=sci-libs/gsl-1.15-r3[-cblas-external]
-               >=sci-libs/gotoblas2-1.13
-               >=sci-libs/atlas-3.9.34
-               >=sci-libs/mkl-10.3
-       )"
-DEPEND=""

diff --git a/virtual/cblas/cblas-2.0-r2.ebuild 
b/virtual/cblas/cblas-2.0-r2.ebuild
deleted file mode 100644
index a4772e2..0000000
--- a/virtual/cblas/cblas-2.0-r2.ebuild
+++ /dev/null
@@ -1,31 +0,0 @@
-# Copyright 1999-2014 Gentoo Foundation
-# Distributed under the terms of the GNU General Public License v2
-# $Id$
-
-EAPI=5
-
-DESCRIPTION="Virtual for BLAS C implementation"
-HOMEPAGE=""
-SRC_URI=""
-
-LICENSE=""
-SLOT="0"
-KEYWORDS="~alpha ~amd64 ~hppa ~ppc ~ppc64 ~s390 ~sparc ~x86 ~x86-fbsd 
~amd64-linux ~x86-linux ~x64-macos ~x86-macos"
-IUSE="int64"
-
-RDEPEND="
-       int64? (
-               || (
-                       >=sci-libs/openblas-0.2.11[int64]
-                       >=sci-libs/cblas-reference-20110218-r1[int64]
-               )
-       )
-       || (
-               >=sci-libs/cblas-reference-20110218-r1[int64?]
-               >=sci-libs/openblas-0.2.11[int64?]
-               >=sci-libs/gsl-1.15-r3[-cblas-external]
-               >=sci-libs/gotoblas2-1.13
-               >=sci-libs/atlas-3.9.34
-               >=sci-libs/mkl-10.3
-       )"
-DEPEND=""

diff --git a/virtual/cblas/cblas-2.0-r3.ebuild 
b/virtual/cblas/cblas-2.0-r3.ebuild
index 252154d..852a70f 100644
--- a/virtual/cblas/cblas-2.0-r3.ebuild
+++ b/virtual/cblas/cblas-2.0-r3.ebuild
@@ -26,10 +26,14 @@ RDEPEND="
                
>=sci-libs/cblas-reference-20110218-r1[int64?,${MULTILIB_USEDEP}]
                >=sci-libs/openblas-0.2.11[int64?,${MULTILIB_USEDEP}]
                >=sci-libs/gsl-1.16-r2[-cblas-external,${MULTILIB_USEDEP}]
-               abi_x86_64? ( !abi_x86_32? ( || (
-                       >=sci-libs/gotoblas2-1.13
-                       >=sci-libs/atlas-3.9.34
-                       >=sci-libs/mkl-10.3
-               ) ) )
+               abi_x86_64? (
+                       !abi_x86_32? (
+                               || (
+                                       >=sci-libs/gotoblas2-1.13
+                                       >=sci-libs/atlas-3.9.34
+                                       >=sci-libs/mkl-10.3
+                               )
+                       )
+               )
        )"
 DEPEND=""

diff --git a/virtual/cblas/cblas-2.0.ebuild b/virtual/cblas/cblas-2.0.ebuild
deleted file mode 100644
index cb1449e..0000000
--- a/virtual/cblas/cblas-2.0.ebuild
+++ /dev/null
@@ -1,24 +0,0 @@
-# Copyright 1999-2014 Gentoo Foundation
-# Distributed under the terms of the GNU General Public License v2
-# $Id$
-
-EAPI=5
-
-DESCRIPTION="Virtual for BLAS C implementation"
-HOMEPAGE=""
-SRC_URI=""
-
-LICENSE=""
-SLOT="0"
-KEYWORDS="~amd64 ~x86 ~amd64-linux ~x86-linux"
-IUSE=""
-
-RDEPEND="|| (
-               >=sci-libs/cblas-reference-20110218
-               sci-libs/openblas
-               >=sci-libs/gsl-1.15-r3[-cblas-external]
-               >=sci-libs/gotoblas2-1.13
-               >=sci-libs/atlas-3.9.34
-               >=sci-libs/mkl-10.3
-       )"
-DEPEND=""

diff --git a/virtual/lapack/lapack-3.4-r1.ebuild 
b/virtual/lapack/lapack-3.4-r1.ebuild
deleted file mode 100644
index 57124ab..0000000
--- a/virtual/lapack/lapack-3.4-r1.ebuild
+++ /dev/null
@@ -1,35 +0,0 @@
-# Copyright 1999-2014 Gentoo Foundation
-# Distributed under the terms of the GNU General Public License v2
-# $Id$
-
-EAPI=5
-
-inherit multilib
-
-DESCRIPTION="Virtual for Linear Algebra Package FORTRAN 77 implementation"
-HOMEPAGE=""
-SRC_URI=""
-
-LICENSE=""
-SLOT="0"
-KEYWORDS="~amd64 ~x86 ~amd64-linux"
-IUSE="doc"
-
-RDEPEND="
-       || (
-               >=sci-libs/lapack-reference-${PV}
-               >=sci-libs/atlas-3.10.1[lapack]
-               >=sci-libs/mkl-11.0
-               >=sci-libs/acml-5.3
-       )
-       doc? ( >=app-doc/lapack-docs-3.3 )"
-DEPEND=""
-
-pkg_pretend() {
-       if [[ -e "${EPREFIX}"/usr/$(get_libdir)/lib${PN}.so ]]; then
-               ewarn "You have still the old ${PN} library symlink present"
-               ewarn "Please delete"
-               ewarn "${EPREFIX}/usr/$(get_libdir)/lib${PN}.so"
-               ewarn "to avoid problems with new ${PN} structure"
-       fi
-}

diff --git a/virtual/lapack/lapack-3.5-r1.ebuild 
b/virtual/lapack/lapack-3.5-r1.ebuild
deleted file mode 100644
index 2c127c0..0000000
--- a/virtual/lapack/lapack-3.5-r1.ebuild
+++ /dev/null
@@ -1,33 +0,0 @@
-# Copyright 1999-2014 Gentoo Foundation
-# Distributed under the terms of the GNU General Public License v2
-# $Id$
-
-EAPI=5
-
-inherit multilib
-
-DESCRIPTION="Virtual for Linear Algebra Package FORTRAN 77 implementation"
-HOMEPAGE=""
-SRC_URI=""
-
-LICENSE=""
-SLOT="0"
-KEYWORDS="~amd64 ~x86 ~amd64-linux ~x86-linux"
-IUSE="doc"
-
-RDEPEND="
-       || (
-               >=sci-libs/lapack-reference-${PV}
-               >=sci-libs/atlas-3.10.1[lapack]
-       )
-       doc? ( >=app-doc/lapack-docs-3.3 )"
-DEPEND=""
-
-pkg_pretend() {
-       if [[ -e "${EROOT%/}"/usr/$(get_libdir)/lib${PN}.so ]]; then
-               ewarn "You have still the old ${PN} library symlink present"
-               ewarn "Please delete"
-               ewarn "${EROOT%/}/usr/$(get_libdir)/lib${PN}.so"
-               ewarn "to avoid problems with new ${PN} structure"
-       fi
-}

diff --git a/virtual/lapack/lapack-3.5-r2.ebuild 
b/virtual/lapack/lapack-3.5-r2.ebuild
index 2282d98..7bbf0a1 100644
--- a/virtual/lapack/lapack-3.5-r2.ebuild
+++ b/virtual/lapack/lapack-3.5-r2.ebuild
@@ -4,7 +4,7 @@
 
 EAPI=5
 
-inherit multilib
+inherit multilib-build
 
 DESCRIPTION="Virtual for Linear Algebra Package FORTRAN 77 implementation"
 HOMEPAGE=""
@@ -17,10 +17,10 @@ IUSE="doc int64"
 
 RDEPEND="
        || (
-               >=sci-libs/lapack-reference-${PV}[int64?]
+               >=sci-libs/lapack-reference-${PV}[int64?,${MULTILIB_USEDEP}]
                >=sci-libs/atlas-3.10.1[lapack]
        )
-       int64? ( >=sci-libs/lapack-reference-${PV}[int64] )
+       int64? ( >=sci-libs/lapack-reference-${PV}[int64,${MULTILIB_USEDEP}] )
        doc? ( >=app-doc/lapack-docs-3.3 )"
 DEPEND=""
 

Reply via email to