third_party:waf: update to upstream 2.0.4 release
[samba.git] / third_party / waf / waflib / extras / fc_cray.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_cray')
15
16 @conf
17 def find_crayftn(conf):
18         """Find the Cray fortran compiler (will look in the environment variable 'FC')"""
19         fc = conf.find_program(['crayftn'], var='FC')
20         conf.get_crayftn_version(fc)
21         conf.env.FC_NAME = 'CRAY'
22         conf.env.FC_MOD_CAPITALIZATION = 'UPPER.mod'
23
24 @conf
25 def crayftn_flags(conf):
26         v = conf.env
27         v['_FCMODOUTFLAGS']  = ['-em', '-J.'] # enable module files and put them in the current directoy
28         v['FCFLAGS_DEBUG'] = ['-m1'] # more verbose compiler warnings
29         v['FCFLAGS_fcshlib']   = ['-h pic']
30         v['LINKFLAGS_fcshlib'] = ['-h shared']
31
32         v['FCSTLIB_MARKER'] = '-h static'
33         v['FCSHLIB_MARKER'] = '-h dynamic'
34
35 @conf
36 def get_crayftn_version(conf, fc):
37                 version_re = re.compile(r"Cray Fortran\s*:\s*Version\s*(?P<major>\d*)\.(?P<minor>\d*)", re.I).search
38                 cmd = fc + ['-V']
39                 out,err = fc_config.getoutput(conf, cmd, stdin=False)
40                 if out:
41                         match = version_re(out)
42                 else:
43                         match = version_re(err)
44                 if not match:
45                                 conf.fatal('Could not determine the Cray Fortran compiler version.')
46                 k = match.groupdict()
47                 conf.env['FC_VERSION'] = (k['major'], k['minor'])
48
49 def configure(conf):
50         conf.find_crayftn()
51         conf.find_ar()
52         conf.fc_flags()
53         conf.fc_add_flags()
54         conf.crayftn_flags()
55