Subject: [PATCH] gnu: Add gfortran-toolchain

From: Konrad Hinsen <[email-masked]>
Date: Wed, 11 Dec 2019 11:30:38 +0100

* gnu/packages/commencement.scm: (gfortran-toolchain): New variable.
* gnu/packages/commencement.scm: (make-gcc-toolchain): Added argument "language"
---
 gnu/packages/commencement.scm | 54 ++++++++++++++++++++++++-----------
 1 file changed, 38 insertions(+), 16 deletions(-)

diff --git a/gnu/packages/commencement.scm b/gnu/packages/commencement.scm
index 68030376fc..e147836fc5 100644
--- a/gnu/packages/commencement.scm
+++ b/gnu/packages/commencement.scm
@@ -2517,16 +2517,29 @@ COREUTILS-FINAL vs. COREUTILS, etc."
 ;;; GCC toolchain.
 ;;;
 
-;; Using the following procedure, a gcc toolchain targeting glibc-2.27 can be
-;; instantiated like this:
-;;
-;; (define-public gcc-glibc-2.27-toolchain
-;;   (make-gcc-toolchain gcc glibc-2.27))
+;;; Toolchain packages combine everything needed for compilation,
+;;; and ensure that ld-wrapper comes before binutils' ld in the
+;;; user's profile, as otherwise dynamic library lookup would not
+;;; work correctly.
+
+;; The synopsis and description must be literal strings (not constructed
+;; using string-append or format) to make them translatable.
+(define gcc-synopsis
+  "Complete GCC tool chain for C/C++ development")
+(define gcc-description
+  "This package provides a complete GCC tool chain for C/C++ development to
+be installed in user profiles.  This includes GCC, as well as libc (headers
+and binaries, plus debugging symbols in the @code{debug} output), and
+binutils.")
 
 (define* (make-gcc-toolchain gcc
-                            #:optional
-                            (libc #f))
-  "Return a complete toolchain for GCC. If LIBC is specified, target that libc."
+                             #:optional
+                             (synopsis gcc-synopsis)
+                             (description gcc-description)
+                             (libc #f))
+  "Return a complete toolchain for GCC.  If SYNOPSIS and/or
+DESCRIPTION are given, use them for documentation instead of the
+defaults for the C/C++ toolchain. If LIBC is specified, target that libc."
   (let ((gcc (if libc (make-gcc-libc gcc libc) gcc))
         (libc (if libc libc glibc-final)))
     (package
@@ -2559,17 +2572,11 @@ COREUTILS-FINAL vs. COREUTILS, etc."
       (search-paths (package-search-paths gcc))
 
       (license (package-license gcc))
-      (synopsis "Complete GCC tool chain for C/C++ development")
-      (description
-       "This package provides a complete GCC tool chain for C/C++ development to
-be   installed in user profiles.  This includes GCC, as well as libc (headers
-an  d binaries, plus debugging symbols in the @code{debug} output), and Binutils.")
+      (synopsis synopsis)
+      (description description)
       (home-page "https://gcc.gnu.org/")
       (outputs '("out" "debug" "static"))
 
-      ;; The main raison d'être of this "meta-package" is (1) to conveniently
-      ;; install everything that we need, and (2) to make sure ld-wrapper comes
-      ;; before Binutils' ld in the user's profile.
       (inputs `(("gcc" ,gcc)
                 ("ld-wrapper" ,(car (assoc-ref %final-inputs "ld-wrapper")))
                 ("binutils" ,binutils-final)
@@ -2601,4 +2608,19 @@ an  d binaries, plus debugging symbols in the @code{debug} output), and Binutils
 (define-public gcc-toolchain-9
   (make-gcc-toolchain gcc-9))
 
+;; Provide the Fortran toolchain package only for the version of gfortran that
+;; is used by Guix intenally to build Fortran libraries, because combining
+;; code compiled with different versions can cause problems.
+
+(define gfortran-synopsis
+  "Complete GCC tool chain for Fortran development")
+(define gfortran-description
+  "This package provides a complete GCC tool chain for Fortran development to
+be installed in user profiles.  This includes GCC, as well as libc (headers
+and binaries, plus debugging symbols in the @code{debug} output), and
+binutils.")
+
+(define-public gfortran-toolchain
+  (make-gcc-toolchain gfortran gfortran-synopsis gfortran-description))
+
 ;;; commencement.scm ends here
-- 
2.24.0