third_party:waf: update to upstream 2.0.4 release
[amitay/samba.git] / third_party / waf / waflib / extras / fc_solstudio.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'].append('fc_solstudio')
16
17 @conf
18 def find_solstudio(conf):
19         """Find the Solaris Studio compiler (will look in the environment variable 'FC')"""
20
21         fc = conf.find_program(['sunf95', 'f95', 'sunf90', 'f90'], var='FC')
22         conf.get_solstudio_version(fc)
23         conf.env.FC_NAME = 'SOL'
24
25 @conf
26 def solstudio_flags(conf):
27         v = conf.env
28         v['FCFLAGS_fcshlib'] = ['-Kpic']
29         v['FCFLAGS_DEBUG'] = ['-w3']
30         v['LINKFLAGS_fcshlib'] = ['-G']
31         v['FCSTLIB_MARKER'] = '-Bstatic'
32         v['FCSHLIB_MARKER'] = '-Bdynamic'
33         v['SONAME_ST']      = '-h %s'
34
35 @conf
36 def solstudio_modifier_platform(conf):
37         dest_os = conf.env['DEST_OS'] or Utils.unversioned_sys_platform()
38         solstudio_modifier_func = getattr(conf, 'solstudio_modifier_' + dest_os, None)
39         if solstudio_modifier_func:
40                 solstudio_modifier_func()
41
42 @conf
43 def get_solstudio_version(conf, fc):
44         """Get the compiler version"""
45
46         version_re = re.compile(r"Sun Fortran 95 *(?P<major>\d*)\.(?P<minor>\d*)", re.I).search
47         cmd = fc + ['-V']
48
49         out, err = fc_config.getoutput(conf,cmd,stdin=False)
50         if out:
51                 match = version_re(out)
52         else:
53                 match = version_re(err)
54         if not match:
55                 conf.fatal('Could not determine the Sun Studio Fortran version.')
56         k = match.groupdict()
57         conf.env['FC_VERSION'] = (k['major'], k['minor'])
58
59 def configure(conf):
60         conf.find_solstudio()
61         conf.find_ar()
62         conf.fc_flags()
63         conf.fc_add_flags()
64         conf.solstudio_flags()
65         conf.solstudio_modifier_platform()
66