bc62279a3060a146c753f5f25d8fbcdd85d2a4c7
[bbaumbach/samba-autobuild/.git] / third_party / waf / waflib / extras / fc_pgfortran.py
1 #! /usr/bin/env python
2 # encoding: utf-8
3 # WARNING! Do not edit! https://waf.io/book/index.html#_obtaining_the_waf_file
4
5 #! /usr/bin/env python
6 # encoding: utf-8
7 # harald at klimachs.de
8
9 import re
10 from waflib.Tools import fc, fc_config, fc_scan
11 from waflib.Configure import conf
12
13 from waflib.Tools.compiler_fc import fc_compiler
14 fc_compiler['linux'].append('fc_pgfortran')
15
16 @conf
17 def find_pgfortran(conf):
18         """Find the PGI fortran compiler (will look in the environment variable 'FC')"""
19         fc = conf.find_program(['pgfortran', 'pgf95', 'pgf90'], var='FC')
20         conf.get_pgfortran_version(fc)
21         conf.env.FC_NAME = 'PGFC'
22
23 @conf
24 def pgfortran_flags(conf):
25         v = conf.env
26         v['FCFLAGS_fcshlib']   = ['-shared']
27         v['FCFLAGS_DEBUG'] = ['-Minform=inform', '-Mstandard'] # why not
28         v['FCSTLIB_MARKER'] = '-Bstatic'
29         v['FCSHLIB_MARKER'] = '-Bdynamic'
30         v['SONAME_ST']    = '-soname %s'
31
32 @conf
33 def get_pgfortran_version(conf,fc):
34                 version_re = re.compile(r"The Portland Group", re.I).search
35                 cmd = fc + ['-V']
36                 out,err = fc_config.getoutput(conf, cmd, stdin=False)
37                 if out:
38                         match = version_re(out)
39                 else:
40                         match = version_re(err)
41                 if not match:
42                                 conf.fatal('Could not verify PGI signature')
43                 cmd = fc + ['-help=variable']
44                 out,err = fc_config.getoutput(conf, cmd, stdin=False)
45                 if out.find('COMPVER')<0:
46                                 conf.fatal('Could not determine the compiler type')
47                 k = {}
48                 prevk = ''
49                 out = out.splitlines()
50                 for line in out:
51                                 lst = line.partition('=')
52                                 if lst[1] == '=':
53                                                 key = lst[0].rstrip()
54                                                 if key == '':
55                                                         key = prevk
56                                                 val = lst[2].rstrip()
57                                                 k[key] = val
58                                 else:
59                                         prevk = line.partition(' ')[0]
60                 def isD(var):
61                                 return var in k
62                 def isT(var):
63                                 return var in k and k[var]!='0'
64                 conf.env['FC_VERSION'] = (k['COMPVER'].split('.'))
65
66 def configure(conf):
67         conf.find_pgfortran()
68         conf.find_ar()
69         conf.fc_flags()
70         conf.fc_add_flags()
71         conf.pgfortran_flags()
72