From b472c1380331cc414582f8f5bcb9045e468457c9 Mon Sep 17 00:00:00 2001
From: Sergey Kosukhin <sergey.kosukhin@mpimet.mpg.de>
Date: Tue, 3 Mar 2020 22:13:38 +0100
Subject: [PATCH] Fix FCFLAGS handling for Autotools packages (#14788)

Spack's fflags are meant for both f77 and fc. Therefore, they must
be passed as FFLAGS and FCFLAGS to the configure scripts of
Autotools-based packages.
---
 lib/spack/env/cc                           | 2 +-
 lib/spack/spack/build_systems/autotools.py | 6 ++++++
 2 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/lib/spack/env/cc b/lib/spack/env/cc
index 73c5759dfe..f2b8bf577f 100755
--- a/lib/spack/env/cc
+++ b/lib/spack/env/cc
@@ -43,7 +43,7 @@ parameters=(
 # The compiler input variables are checked for sanity later:
 #   SPACK_CC, SPACK_CXX, SPACK_F77, SPACK_FC
 # The default compiler flags are passed from these variables:
-#   SPACK_CFLAGS, SPACK_CXXFLAGS, SPACK_FCFLAGS, SPACK_FFLAGS,
+#   SPACK_CFLAGS, SPACK_CXXFLAGS, SPACK_FFLAGS,
 #   SPACK_LDFLAGS, SPACK_LDLIBS
 # Debug env var is optional; set to "TRUE" for debug logging:
 #   SPACK_DEBUG
diff --git a/lib/spack/spack/build_systems/autotools.py b/lib/spack/spack/build_systems/autotools.py
index c21b8dad71..5b4f223d41 100644
--- a/lib/spack/spack/build_systems/autotools.py
+++ b/lib/spack/spack/build_systems/autotools.py
@@ -263,6 +263,12 @@ def flags_to_build_system_args(self, flags):
             if values:
                 values_str = '{0}={1}'.format(flag.upper(), ' '.join(values))
                 self.configure_flag_args.append(values_str)
+        # Spack's fflags are meant for both F77 and FC, therefore we
+        # additionaly set FCFLAGS if required.
+        values = flags.get('fflags', None)
+        if values:
+            values_str = 'FCFLAGS={0}'.format(' '.join(values))
+            self.configure_flag_args.append(values_str)
 
     def configure(self, spec, prefix):
         """Runs configure with the arguments specified in
-- 
GitLab