3 # WARNING! Do not edit! https://waf.io/book/index.html#_obtaining_the_waf_file
8 # Thomas Nagy 2016-2018 (ita)
11 from waflib import Utils
12 from waflib.Tools import fc, fc_config, fc_scan, ar
13 from waflib.Configure import conf
16 def find_gfortran(conf):
17 """Find the gfortran program (will look in the environment variable 'FC')"""
18 fc = conf.find_program(['gfortran','g77'], var='FC')
19 # (fallback to g77 for systems, where no gfortran is available)
20 conf.get_gfortran_version(fc)
21 conf.env.FC_NAME = 'GFORTRAN'
24 def gfortran_flags(conf):
26 v.FCFLAGS_fcshlib = ['-fPIC']
27 v.FORTRANMODFLAG = ['-J', ''] # template for module path
28 v.FCFLAGS_DEBUG = ['-Werror'] # why not
31 def gfortran_modifier_win32(conf):
32 fc_config.fortran_modifier_win32(conf)
35 def gfortran_modifier_cygwin(conf):
36 fc_config.fortran_modifier_cygwin(conf)
39 def gfortran_modifier_darwin(conf):
40 fc_config.fortran_modifier_darwin(conf)
43 def gfortran_modifier_platform(conf):
44 dest_os = conf.env.DEST_OS or Utils.unversioned_sys_platform()
45 gfortran_modifier_func = getattr(conf, 'gfortran_modifier_' + dest_os, None)
46 if gfortran_modifier_func:
47 gfortran_modifier_func()
50 def get_gfortran_version(conf, fc):
51 """Get the compiler version"""
53 # ensure this is actually gfortran, not an imposter.
54 version_re = re.compile(r"GNU\s*Fortran", re.I).search
55 cmd = fc + ['--version']
56 out, err = fc_config.getoutput(conf, cmd, stdin=False)
58 match = version_re(out)
60 match = version_re(err)
62 conf.fatal('Could not determine the compiler type')
64 # --- now get more detailed info -- see c_config.get_cc_version
65 cmd = fc + ['-dM', '-E', '-']
66 out, err = fc_config.getoutput(conf, cmd, stdin=True)
68 if out.find('__GNUC__') < 0:
69 conf.fatal('Could not determine the compiler type')
72 out = out.splitlines()
76 lst = shlex.split(line)
86 return var in k and k[var] != '0'
88 conf.env.FC_VERSION = (k['__GNUC__'], k['__GNUC_MINOR__'], k['__GNUC_PATCHLEVEL__'])
96 conf.gfortran_modifier_platform()
97 conf.check_gfortran_o_space()