3 # harald at klimachs.de
6 from waflib.Tools import fc, fc_config, fc_scan
7 from waflib.Configure import conf
9 from waflib.Tools.compiler_fc import fc_compiler
10 fc_compiler['linux'].append('fc_pgfortran')
13 def find_pgfortran(conf):
14 """Find the PGI fortran compiler (will look in the environment variable 'FC')"""
15 fc = conf.find_program(['pgfortran', 'pgf95', 'pgf90'], var='FC')
16 conf.get_pgfortran_version(fc)
17 conf.env.FC_NAME = 'PGFC'
20 def pgfortran_flags(conf):
22 v['FCFLAGS_fcshlib'] = ['-shared']
23 v['FCFLAGS_DEBUG'] = ['-Minform=inform', '-Mstandard'] # why not
24 v['FCSTLIB_MARKER'] = '-Bstatic'
25 v['FCSHLIB_MARKER'] = '-Bdynamic'
26 v['SONAME_ST'] = '-soname %s'
29 def get_pgfortran_version(conf,fc):
30 version_re = re.compile(r"The Portland Group", re.I).search
32 out,err = fc_config.getoutput(conf, cmd, stdin=False)
34 match = version_re(out)
36 match = version_re(err)
38 conf.fatal('Could not verify PGI signature')
39 cmd = fc + ['-help=variable']
40 out,err = fc_config.getoutput(conf, cmd, stdin=False)
41 if out.find('COMPVER')<0:
42 conf.fatal('Could not determine the compiler type')
45 out = out.splitlines()
47 lst = line.partition('=')
55 prevk = line.partition(' ')[0]
59 return var in k and k[var]!='0'
60 conf.env['FC_VERSION'] = (k['COMPVER'].split('.'))
67 conf.pgfortran_flags()