fc_open64.py (1510B)
1 #! /usr/bin/env python 2 # encoding: utf-8 3 # harald at klimachs.de 4 5 import re 6 from waflib import Utils 7 from waflib.Tools import fc,fc_config,fc_scan 8 from waflib.Configure import conf 9 10 from waflib.Tools.compiler_fc import fc_compiler 11 fc_compiler['linux'].insert(0, 'fc_open64') 12 13 @conf 14 def find_openf95(conf): 15 """Find the Open64 Fortran Compiler (will look in the environment variable 'FC')""" 16 17 fc = conf.find_program(['openf95', 'openf90'], var='FC') 18 conf.get_open64_version(fc) 19 conf.env.FC_NAME = 'OPEN64' 20 conf.env.FC_MOD_CAPITALIZATION = 'UPPER.mod' 21 22 @conf 23 def openf95_flags(conf): 24 v = conf.env 25 v['FCFLAGS_DEBUG'] = ['-fullwarn'] 26 27 @conf 28 def openf95_modifier_platform(conf): 29 dest_os = conf.env['DEST_OS'] or Utils.unversioned_sys_platform() 30 openf95_modifier_func = getattr(conf, 'openf95_modifier_' + dest_os, None) 31 if openf95_modifier_func: 32 openf95_modifier_func() 33 34 @conf 35 def get_open64_version(conf, fc): 36 """Get the Open64 compiler version""" 37 38 version_re = re.compile(r"Open64 Compiler Suite: *Version *(?P<major>\d*)\.(?P<minor>\d*)", re.I).search 39 cmd = fc + ['-version'] 40 41 out, err = fc_config.getoutput(conf,cmd,stdin=False) 42 if out: 43 match = version_re(out) 44 else: 45 match = version_re(err) 46 if not match: 47 conf.fatal('Could not determine the Open64 version.') 48 k = match.groupdict() 49 conf.env['FC_VERSION'] = (k['major'], k['minor']) 50 51 def configure(conf): 52 conf.find_openf95() 53 conf.find_ar() 54 conf.fc_flags() 55 conf.fc_add_flags() 56 conf.openf95_flags() 57 conf.openf95_modifier_platform() 58