From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id C1F38138334 for ; Thu, 1 Nov 2018 22:28:26 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 2FFC8E07DF; Thu, 1 Nov 2018 22:28:22 +0000 (UTC) Received: from smtp.gentoo.org (dev.gentoo.org [IPv6:2001:470:ea4a:1:5054:ff:fec7:86e4]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id BF990E07D4 for ; Thu, 1 Nov 2018 22:28:21 +0000 (UTC) Received: from localhost (unknown [91.246.83.227]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: bircoph) by smtp.gentoo.org (Postfix) with ESMTPSA id 8DB3D335C94 for ; Thu, 1 Nov 2018 22:28:19 +0000 (UTC) Date: Fri, 2 Nov 2018 01:25:20 +0300 From: Andrew Savchenko To: gentoo-dev@lists.gentoo.org Subject: Re: [gentoo-dev] [PATCH v2] fortran-2.eclass: support EAPI 7 Message-Id: <20181102012520.bcf256d577c0493a55570dac@gentoo.org> In-Reply-To: <20181028013841.7bd52f2b363d0b11fbe97dd1@gentoo.org> References: <20181028013841.7bd52f2b363d0b11fbe97dd1@gentoo.org> X-Mailer: Sylpheed 3.7.0 (GTK+ 2.24.30; i686-pc-linux-gnu) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-dev@lists.gentoo.org Reply-to: gentoo-dev@lists.gentoo.org Mime-Version: 1.0 Content-Type: multipart/signed; protocol="application/pgp-signature"; micalg="PGP-SHA512"; boundary="Signature=_Fri__2_Nov_2018_01_25_20_+0300_.eeY8lbgRKqn_Jky" X-Archives-Salt: b38159f4-9da7-4b4f-90b1-29a2b6d905f5 X-Archives-Hash: c53b6bba3bec92a05961592953d583cd --Signature=_Fri__2_Nov_2018_01_25_20_+0300_.eeY8lbgRKqn_Jky Content-Type: text/plain; charset=US-ASCII Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Hi all! Here follows the updated version with improvements proposed by mgorny and dilfridge. diff --git a/eclass/fortran-2.eclass b/eclass/fortran-2.eclass index 820cbbcb49bd..a0243714b674 100644 --- a/eclass/fortran-2.eclass +++ b/eclass/fortran-2.eclass @@ -1,285 +1,289 @@ -# Copyright 1999-2017 Gentoo Foundation +# Copyright 1999-2018 Gentoo Authors # Distributed under the terms of the GNU General Public License v2 =20 # @ECLASS: fortran-2.eclass # @MAINTAINER: # jlec@gentoo.org # sci@gentoo.org # @AUTHOR: # Author Justin Lecher # Test functions provided by Sebastien Fabbro and Kacper Kowalik -# @SUPPORTED_EAPIS: 4 5 6 +# @SUPPORTED_EAPIS: 4 5 6 7 # @BLURB: Simplify fortran compiler management # @DESCRIPTION: # If you need a fortran compiler, then you should be inheriting this eclas= s. # In case you only need optional support, please export FORTRAN_NEEDED bef= ore # 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=3D"lapack fortran" # # inherit fortran-2 # # FORTRAN_NEED_OPENMP=3D1 =20 -inherit eutils toolchain-funcs +inherit toolchain-funcs +case ${EAPI:-0} in + # not used in the eclass, but left for backward compatibility with legacy= users + 4|5|6) inherit eutils ;; + 7) ;; + *) die "EAPI=3D${EAPI} is not supported" ;; +esac =20 case ${EAPI:-0} in - 4|5|6) EXPORT_FUNCTIONS pkg_setup ;; + 4|5|6|7) EXPORT_FUNCTIONS pkg_setup ;; *) die "EAPI=3D${EAPI} is not supported" ;; esac =20 if [[ ! ${_FORTRAN_2_CLASS} ]]; then =20 # @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:=3D0} =20 # @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:=3D77} =20 # @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=3Dlapack would result in # # DEPEND=3D"lapack? ( virtual/fortran )" # # If unset, we always depend on virtual/fortran. : ${FORTRAN_NEEDED:=3Dalways} =20 for _f_use in ${FORTRAN_NEEDED}; do case ${_f_use} in always) DEPEND+=3D" virtual/fortran" RDEPEND+=3D" virtual/fortran" break ;; no) break ;; test) DEPEND+=3D" ${_f_use}? ( virtual/fortran )" ;; *) DEPEND+=3D" ${_f_use}? ( virtual/fortran )" RDEPEND+=3D" ${_f_use}? ( virtual/fortran )" ;; esac done unset _f_use =20 # @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} "${@}" =20 - _FC=3D$(tc-getFC) + local _FC=3D$(tc-getFC) if [[ ${_FC} =3D=3D *gfortran* ]]; then echo "-fdefault-integer-8" elif [[ ${_FC} =3D=3D ifort ]]; then echo "-integer-size 64" else die "Compiler flag for 64bit interger for ${_FC} unknown" fi } =20 # @FUNCTION: _fortran_write_testsuite # @INTERNAL # @DESCRIPTION: # writes fortran test code _fortran_write_testsuite() { debug-print-function ${FUNCNAME} "${@}" =20 local filebase=3D${T}/test-fortran =20 # f77 code - cat <<- EOF > "${filebase}.f" + cat <<- EOF > "${filebase}.f" || die end EOF =20 # f90/95 code - cat <<- EOF > "${filebase}.f90" + cat <<- EOF > "${filebase}.f90" || die end EOF =20 # f2003 code - cat <<- EOF > "${filebase}.f03" + cat <<- EOF > "${filebase}.f03" || die procedure(), pointer :: p end EOF } =20 # @FUNCTION: _fortran_compile_test # @USAGE: [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() { debug-print-function ${FUNCNAME} "${@}" =20 local filebase=3D${T}/test-fortran local fcomp=3D${1} local fdia=3D${2} local fcode=3D${filebase}.f${fdia} local ret =20 [[ $# -lt 1 ]] && \ die "_fortran_compile_test() needs at least one argument" =20 [[ -f ${fcode} ]] || _fortran_write_testsuite =20 ${fcomp} "${fcode}" -o "${fcode}.x" \ >> "${T}"/_fortran_compile_test.log 2>&1 ret=3D$? =20 rm -f "${fcode}.x" return ${ret} } =20 # @FUNCTION: _fortran-has-openmp # @RETURN: return code of the compiler # @INTERNAL # @DESCRIPTION: # See if the fortran supports OpenMP. _fortran-has-openmp() { debug-print-function ${FUNCNAME} "${@}" =20 local flag local filebase=3D${T}/test-fc-openmp local fcode=3D${filebase}.f - local ret local _fc=3D$(tc-getFC) =20 - cat <<- EOF > "${fcode}" + cat <<- EOF > "${fcode}" || die call omp_get_num_threads end EOF =20 for flag in -fopenmp -xopenmp -openmp -mp -omp -qsmp=3Domp; do ${_fc} ${flag} "${fcode}" -o "${fcode}.x" \ &>> "${T}"/_fortran_compile_test.log - ret=3D$? - (( ${ret} )) || break + [[ $? =3D=3D 0 ]] && break done =20 rm -f "${fcode}.x" return ${ret} } =20 # @FUNCTION: _fortran_die_msg # @INTERNAL # @DESCRIPTION: # Detailed description how to handle fortran support _fortran_die_msg() { debug-print-function ${FUNCNAME} "${@}" =20 - echo + eerror eerror "Please install currently selected gcc version with USE=3Dfortran." 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 + eerror die "Currently no working fortran compiler is available (see ${T}/_fortra= n_compile_test.log for information)" } =20 # @FUNCTION: _fortran_test_function # @INTERNAL # @DESCRIPTION: # Internal test function for working fortran compiler. # It is called in fortran-2_pkg_setup. _fortran_test_function() { debug-print-function ${FUNCNAME} "${@}" =20 local dialect =20 : ${F77:=3D$(tc-getFC)} =20 : ${FORTRAN_STANDARD:=3D77} 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 =20 tc-export F77 FC einfo "Using following Fortran compiler:" einfo " F77: ${F77}" einfo " FC: ${FC}" =20 if [[ ${FORTRAN_NEED_OPENMP} =3D=3D 1 ]]; then if _fortran-has-openmp; then einfo "${FC} has OPENMP support" else die "Please install current gcc with USE=3Dopenmp or set the FC variabl= e to a compiler that supports OpenMP" fi fi } =20 # @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 + _fortran_test_function && break 2 ;; no) einfo "Forcing fortran support off" break ;; *) if use ${_f_use}; then - _fortran_test_function && break + _fortran_test_function && break 2 else unset FC unset F77 fi ;; esac done } =20 =20 # @FUNCTION: fortran-2_pkg_setup # @DESCRIPTION: # Setup functionality, # checks for a valid fortran compiler and optionally for its openmp suppor= t. fortran-2_pkg_setup() { debug-print-function ${FUNCNAME} "${@}" =20 if [[ ${MERGE_TYPE} !=3D binary ]]; then _fortran-2_pkg_setup fi } =20 _FORTRAN_2_ECLASS=3D1 fi Best regards, Andrew Savchenko --Signature=_Fri__2_Nov_2018_01_25_20_+0300_.eeY8lbgRKqn_Jky Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- iQIzBAEBCgAdFiEE63ZIHsdeM+1XgNer9lNaM7oe5I0FAlvbfVAACgkQ9lNaM7oe 5I2ADw/9HSXFAYQ/jvaLwc7vtdNK0rrkR3RHrSpevtY9/1JnXYLopvNLoIl1oRaq 3s8G8XWTj8nRqREyasZumAkGA7enjKuPb1N0f/f06QYUcPvUF/ldJan7ocevNp0F zoYDeD4cZQyvHyudpyrpM0A5oX1VeKyhdjWBrkPpB5cQWLyKrp7WyXjhGuPR83K+ eg0cg738lNkaS3Fm9MYc98bBY02EQ/+FWrixgj1kjXqppxR+nlZlQBW0XoKyiNUh D8G9MQaF1rH/t7Ma5AKoeUXdJQp+k3Jbeop43XGYMp6KVkHS59Oitoqkp9WDuM9R 9m36ItOtXI1pqdkRlXJ8uG/VAm12F7Q3lL+Xc9+yfwGGMOhpzE120nrX40as/8/0 O5N0k8nkmhK0lYC0BB8VMq7Avq2zwrFYMOGYSpGAN17ePJRai9LFtHhFSPq+Qn/l YuBhy896jCLdmb4YA8FEygzidUoZ2CGjP09rJXsfDngcMa4c38oyxfL/pP54MCRO 6PNMNX52nTC5rASwkNEB+kCdVaUJbQuUTQ9lFnbscHnRC9JmU6FoCVEjmW0aIX9z LfwSglbqY/sSv/wASpxzcvGh5IAftkYrw17QLMhxqRmjeMMM5TmNvkcknpgI0GXw oVyB3cYfhQZ1LrUsfPD4vyBYdL+vOEB9Mt6w+35tMluB/gKg+sc= =krV6 -----END PGP SIGNATURE----- --Signature=_Fri__2_Nov_2018_01_25_20_+0300_.eeY8lbgRKqn_Jky--