third_party:waf: update to upstream 2.0.4 release
[sfrench/samba-autobuild/.git] / third_party / waf / waflib / extras / fc_open64.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 import Utils
11 from waflib.Tools import fc,fc_config,fc_scan
12 from waflib.Configure import conf
13
14 from waflib.Tools.compiler_fc import fc_compiler
15 fc_compiler['linux'].insert(0, 'fc_open64')
16
17 @conf
18 def find_openf95(conf):
19         """Find the Open64 Fortran Compiler (will look in the environment variable 'FC')"""
20
21         fc = conf.find_program(['openf95', 'openf90'], var='FC')
22         conf.get_open64_version(fc)
23         conf.env.FC_NAME = 'OPEN64'
24         conf.env.FC_MOD_CAPITALIZATION = 'UPPER.mod'
25
26 @conf
27 def openf95_flags(conf):
28         v = conf.env
29         v['FCFLAGS_DEBUG'] = ['-fullwarn']
30
31 @conf
32 def openf95_modifier_platform(conf):
33         dest_os = conf.env['DEST_OS'] or Utils.unversioned_sys_platform()
34         openf95_modifier_func = getattr(conf, 'openf95_modifier_' + dest_os, None)
35         if openf95_modifier_func:
36                 openf95_modifier_func()
37
38 @conf
39 def get_open64_version(conf, fc):
40         """Get the Open64 compiler version"""
41
42         version_re = re.compile(r"Open64 Compiler Suite: *Version *(?P<major>\d*)\.(?P<minor>\d*)", re.I).search
43         cmd = fc + ['-version']
44
45         out, err = fc_config.getoutput(conf,cmd,stdin=False)
46         if out:
47                 match = version_re(out)
48         else:
49                 match = version_re(err)
50         if not match:
51                 conf.fatal('Could not determine the Open64 version.')
52         k = match.groupdict()
53         conf.env['FC_VERSION'] = (k['major'], k['minor'])
54
55 def configure(conf):
56         conf.find_openf95()
57         conf.find_ar()
58         conf.fc_flags()
59         conf.fc_add_flags()
60         conf.openf95_flags()
61         conf.openf95_modifier_platform()
62