waf

FORK: waf with some random patches
git clone https://git.neptards.moe/neptards/waf.git
Log | Files | Refs | README

g95.py (1522B)


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