1#! /usr/bin/env python 2# encoding: utf-8 3# Detection of the NEC Fortran compiler for Aurora Tsubasa 4 5import re 6from waflib.Tools import fc,fc_config,fc_scan 7from waflib.Configure import conf 8from waflib.Tools.compiler_fc import fc_compiler 9fc_compiler['linux'].append('fc_nfort') 10 11@conf 12def find_nfort(conf): 13 fc=conf.find_program(['nfort'],var='FC') 14 conf.get_nfort_version(fc) 15 conf.env.FC_NAME='NFORT' 16 conf.env.FC_MOD_CAPITALIZATION='lower' 17 18@conf 19def nfort_flags(conf): 20 v=conf.env 21 v['_FCMODOUTFLAGS']=[] 22 v['FCFLAGS_DEBUG']=[] 23 v['FCFLAGS_fcshlib']=[] 24 v['LINKFLAGS_fcshlib']=[] 25 v['FCSTLIB_MARKER']='' 26 v['FCSHLIB_MARKER']='' 27 28@conf 29def get_nfort_version(conf,fc): 30 version_re=re.compile(r"nfort\s*\(NFORT\)\s*(?P<major>\d+)\.(?P<minor>\d+)\.",re.I).search 31 cmd=fc+['--version'] 32 out,err=fc_config.getoutput(conf,cmd,stdin=False) 33 if out: 34 match=version_re(out) 35 else: 36 match=version_re(err) 37 if not match: 38 return(False) 39 conf.fatal('Could not determine the NEC NFORT Fortran compiler version.') 40 else: 41 k=match.groupdict() 42 conf.env['FC_VERSION']=(k['major'],k['minor']) 43 44def configure(conf): 45 conf.find_nfort() 46 conf.find_program('nar',var='AR') 47 conf.add_os_flags('ARFLAGS') 48 if not conf.env.ARFLAGS: 49 conf.env.ARFLAGS=['rcs'] 50 conf.fc_flags() 51 conf.fc_add_flags() 52 conf.nfort_flags() 53