33e7dfc79e2de488344a620eb287e1292a5dc141
[bbaumbach/samba-autobuild/.git] / third_party / waf / waflib / Tools / g95.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 # KWS 2010
8 # Thomas Nagy 2016 (ita)
9
10 import re
11 from waflib import Utils
12 from waflib.Tools import fc, fc_config, fc_scan, ar
13 from waflib.Configure import conf
14
15 @conf
16 def find_g95(conf):
17         fc = conf.find_program('g95', var='FC')
18         conf.get_g95_version(fc)
19         conf.env.FC_NAME = 'G95'
20
21 @conf
22 def g95_flags(conf):
23         v = conf.env
24         v.FCFLAGS_fcshlib   = ['-fPIC']
25         v.FORTRANMODFLAG  = ['-fmod=', ''] # template for module path
26         v.FCFLAGS_DEBUG = ['-Werror'] # why not
27
28 @conf
29 def g95_modifier_win32(conf):
30         fc_config.fortran_modifier_win32(conf)
31
32 @conf
33 def g95_modifier_cygwin(conf):
34         fc_config.fortran_modifier_cygwin(conf)
35
36 @conf
37 def g95_modifier_darwin(conf):
38         fc_config.fortran_modifier_darwin(conf)
39
40 @conf
41 def g95_modifier_platform(conf):
42         dest_os = conf.env.DEST_OS or Utils.unversioned_sys_platform()
43         g95_modifier_func = getattr(conf, 'g95_modifier_' + dest_os, None)
44         if g95_modifier_func:
45                 g95_modifier_func()
46
47 @conf
48 def get_g95_version(conf, fc):
49         """get the compiler version"""
50
51         version_re = re.compile(r"g95\s*(?P<major>\d*)\.(?P<minor>\d*)").search
52         cmd = fc + ['--version']
53         out, err = fc_config.getoutput(conf, cmd, stdin=False)
54         if out:
55                 match = version_re(out)
56         else:
57                 match = version_re(err)
58         if not match:
59                 conf.fatal('cannot determine g95 version')
60         k = match.groupdict()
61         conf.env.FC_VERSION = (k['major'], k['minor'])
62
63 def configure(conf):
64         conf.find_g95()
65         conf.find_ar()
66         conf.fc_flags()
67         conf.fc_add_flags()
68         conf.g95_flags()
69         conf.g95_modifier_platform()