fc_cray.py (1446B)
1 #! /usr/bin/env python 2 # encoding: utf-8 3 # harald at klimachs.de 4 5 import re 6 from waflib.Tools import fc, fc_config, fc_scan 7 from waflib.Configure import conf 8 9 from waflib.Tools.compiler_fc import fc_compiler 10 fc_compiler['linux'].append('fc_cray') 11 12 @conf 13 def find_crayftn(conf): 14 """Find the Cray fortran compiler (will look in the environment variable 'FC')""" 15 fc = conf.find_program(['crayftn'], var='FC') 16 conf.get_crayftn_version(fc) 17 conf.env.FC_NAME = 'CRAY' 18 conf.env.FC_MOD_CAPITALIZATION = 'UPPER.mod' 19 20 @conf 21 def crayftn_flags(conf): 22 v = conf.env 23 v['_FCMODOUTFLAGS'] = ['-em', '-J.'] # enable module files and put them in the current directory 24 v['FCFLAGS_DEBUG'] = ['-m1'] # more verbose compiler warnings 25 v['FCFLAGS_fcshlib'] = ['-h pic'] 26 v['LINKFLAGS_fcshlib'] = ['-h shared'] 27 28 v['FCSTLIB_MARKER'] = '-h static' 29 v['FCSHLIB_MARKER'] = '-h dynamic' 30 31 @conf 32 def get_crayftn_version(conf, fc): 33 version_re = re.compile(r"Cray Fortran\s*:\s*Version\s*(?P<major>\d*)\.(?P<minor>\d*)", re.I).search 34 cmd = fc + ['-V'] 35 out,err = fc_config.getoutput(conf, cmd, stdin=False) 36 if out: 37 match = version_re(out) 38 else: 39 match = version_re(err) 40 if not match: 41 conf.fatal('Could not determine the Cray Fortran compiler version.') 42 k = match.groupdict() 43 conf.env['FC_VERSION'] = (k['major'], k['minor']) 44 45 def configure(conf): 46 conf.find_crayftn() 47 conf.find_ar() 48 conf.fc_flags() 49 conf.fc_add_flags() 50 conf.crayftn_flags() 51