waf

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

fc_xlf.py (1615B)


      1 #! /usr/bin/env python
      2 # encoding: utf-8
      3 # harald at klimachs.de
      4 
      5 import re
      6 from waflib import Utils,Errors
      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['aix'].insert(0, 'fc_xlf')
     12 
     13 @conf
     14 def find_xlf(conf):
     15 	"""Find the xlf program (will look in the environment variable 'FC')"""
     16 
     17 	fc = conf.find_program(['xlf2003_r', 'xlf2003', 'xlf95_r', 'xlf95', 'xlf90_r', 'xlf90', 'xlf_r', 'xlf'], var='FC')
     18 	conf.get_xlf_version(fc)
     19 	conf.env.FC_NAME='XLF'
     20 
     21 @conf
     22 def xlf_flags(conf):
     23 	v = conf.env
     24 	v['FCDEFINES_ST'] = '-WF,-D%s'
     25 	v['FCFLAGS_fcshlib'] = ['-qpic=small']
     26 	v['FCFLAGS_DEBUG'] = ['-qhalt=w']
     27 	v['LINKFLAGS_fcshlib'] = ['-Wl,-shared']
     28 
     29 @conf
     30 def xlf_modifier_platform(conf):
     31 	dest_os = conf.env['DEST_OS'] or Utils.unversioned_sys_platform()
     32 	xlf_modifier_func = getattr(conf, 'xlf_modifier_' + dest_os, None)
     33 	if xlf_modifier_func:
     34 		xlf_modifier_func()
     35 
     36 @conf
     37 def get_xlf_version(conf, fc):
     38 	"""Get the compiler version"""
     39 
     40 	cmd = fc + ['-qversion']
     41 	try:
     42 		out, err = conf.cmd_and_log(cmd, output=0)
     43 	except Errors.WafError:
     44 		conf.fatal('Could not find xlf %r' % cmd)
     45 
     46 	for v in (r"IBM XL Fortran.* V(?P<major>\d*)\.(?P<minor>\d*)",):
     47 		version_re = re.compile(v, re.I).search
     48 		match = version_re(out or err)
     49 		if match:
     50 			k = match.groupdict()
     51 			conf.env['FC_VERSION'] = (k['major'], k['minor'])
     52 			break
     53 	else:
     54 		conf.fatal('Could not determine the XLF version.')
     55 
     56 def configure(conf):
     57 	conf.find_xlf()
     58 	conf.find_ar()
     59 	conf.fc_flags()
     60 	conf.fc_add_flags()
     61 	conf.xlf_flags()
     62 	conf.xlf_modifier_platform()
     63