aboutsummaryrefslogtreecommitdiff
path: root/eclass
diff options
context:
space:
mode:
authorJustin Lecher <jlec@gentoo.org>2015-09-19 09:14:19 +0200
committerJustin Lecher <jlec@gentoo.org>2015-11-28 18:25:09 +0100
commitbc36b5406f2bb289a3920ef13d50853a567bc83d (patch)
treeee431372f2726c8ffbc5ca294fd07076be18f737 /eclass
parentdev-util/amdapp: Version bump; Fixes issue #542 (diff)
downloadsci-bc36b5406f2bb289a3920ef13d50853a567bc83d.tar.gz
sci-bc36b5406f2bb289a3920ef13d50853a567bc83d.tar.bz2
sci-bc36b5406f2bb289a3920ef13d50853a567bc83d.zip
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@gentoo.org>
Diffstat (limited to 'eclass')
-rw-r--r--eclass/alternatives-2.eclass10
-rw-r--r--eclass/fortran-2.eclass276
-rw-r--r--eclass/fortran-int64.eclass300
-rw-r--r--eclass/numeric-int64-multibuild.eclass397
-rw-r--r--eclass/numeric.eclass35
5 files changed, 709 insertions, 309 deletions
diff --git a/eclass/alternatives-2.eclass b/eclass/alternatives-2.eclass
index 749cda814..19e830629 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 000000000..5cb6d7d72
--- /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:
+# jlec@gentoo.org
+# sci@gentoo.org
+# @AUTHOR:
+# Author Justin Lecher <jlec@gentoo.org>
+# 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 09980c88f..000000000
--- 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 <sci@gentoo.org>
-# @AUTHOR:
-# Author: Mark Wright <gienah@gentoo.org>
-# @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 000000000..a55db3108
--- /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 <sci@gentoo.org>
+# @AUTHOR:
+# Author: Mark Wright <gienah@gentoo.org>
+# Author: Justin Lecher <jlec@gentoo.org>
+# @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 b3f92bef6..adee3c53b 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