diff options
author | Robin H. Johnson <robbat2@gentoo.org> | 2015-08-08 13:49:04 -0700 |
---|---|---|
committer | Robin H. Johnson <robbat2@gentoo.org> | 2015-08-08 17:38:18 -0700 |
commit | 56bd759df1d0c750a065b8c845e93d5dfa6b549d (patch) | |
tree | 3f91093cdb475e565ae857f1c5a7fd339e2d781e /eclass/fortran-2.eclass | |
download | gentoo-56bd759df1d0c750a065b8c845e93d5dfa6b549d.tar.gz gentoo-56bd759df1d0c750a065b8c845e93d5dfa6b549d.tar.bz2 gentoo-56bd759df1d0c750a065b8c845e93d5dfa6b549d.zip |
proj/gentoo: Initial commit
This commit represents a new era for Gentoo:
Storing the gentoo-x86 tree in Git, as converted from CVS.
This commit is the start of the NEW history.
Any historical data is intended to be grafted onto this point.
Creation process:
1. Take final CVS checkout snapshot
2. Remove ALL ChangeLog* files
3. Transform all Manifests to thin
4. Remove empty Manifests
5. Convert all stale $Header$/$Id$ CVS keywords to non-expanded Git $Id$
5.1. Do not touch files with -kb/-ko keyword flags.
Signed-off-by: Robin H. Johnson <robbat2@gentoo.org>
X-Thanks: Alec Warner <antarus@gentoo.org> - did the GSoC 2006 migration tests
X-Thanks: Robin H. Johnson <robbat2@gentoo.org> - infra guy, herding this project
X-Thanks: Nguyen Thai Ngoc Duy <pclouds@gentoo.org> - Former Gentoo developer, wrote Git features for the migration
X-Thanks: Brian Harring <ferringb@gentoo.org> - wrote much python to improve cvs2svn
X-Thanks: Rich Freeman <rich0@gentoo.org> - validation scripts
X-Thanks: Patrick Lauer <patrick@gentoo.org> - Gentoo dev, running new 2014 work in migration
X-Thanks: Michał Górny <mgorny@gentoo.org> - scripts, QA, nagging
X-Thanks: All of other Gentoo developers - many ideas and lots of paint on the bikeshed
Diffstat (limited to 'eclass/fortran-2.eclass')
-rw-r--r-- | eclass/fortran-2.eclass | 256 |
1 files changed, 256 insertions, 0 deletions
diff --git a/eclass/fortran-2.eclass b/eclass/fortran-2.eclass new file mode 100644 index 000000000000..03fb46225790 --- /dev/null +++ b/eclass/fortran-2.eclass @@ -0,0 +1,256 @@ +# Copyright 1999-2013 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 + +# @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_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 + |