3 # Antoine Dechaume 2011
6 Detect the PGI C compiler
10 from waflib import Errors
11 from waflib.Configure import conf
12 from waflib.Tools.compiler_c import c_compiler
13 c_compiler['linux'].append('pgicc')
16 def find_pgi_compiler(conf, var, name):
18 Find the program name, and execute it to ensure it really is itself.
20 if sys.platform == 'cygwin':
21 conf.fatal('The PGI compiler does not work on Cygwin')
27 elif var in conf.environ:
28 cc = conf.environ[var]
30 cc = conf.find_program(name, var=var)
32 conf.fatal('PGI Compiler (%s) was not found' % name)
34 v[var + '_VERSION'] = conf.get_pgi_version(cc)
36 v[var + '_NAME'] = 'pgi'
39 def get_pgi_version(conf, cc):
40 """Find the version of a pgi compiler."""
41 version_re = re.compile(r"The Portland Group", re.I).search
42 cmd = cc + ['-V', '-E'] # Issue 1078, prevent wrappers from linking
45 out, err = conf.cmd_and_log(cmd, output=0)
46 except Errors.WafError:
47 conf.fatal('Could not find pgi compiler %r' % cmd)
50 match = version_re(out)
52 match = version_re(err)
55 conf.fatal('Could not verify PGI signature')
57 cmd = cc + ['-help=variable']
59 out, err = conf.cmd_and_log(cmd, output=0)
60 except Errors.WafError:
61 conf.fatal('Could not find pgi compiler %r' % cmd)
63 version = re.findall(r'^COMPVER\s*=(.*)', out, re.M)
65 conf.fatal('Could not determine the compiler version')
69 conf.find_pgi_compiler('CC', 'pgcc')
71 conf.gcc_common_flags()