waf

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

fc_pgfortran.py (1780B)


      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_pgfortran')
     11 
     12 @conf
     13 def find_pgfortran(conf):
     14 	"""Find the PGI fortran compiler (will look in the environment variable 'FC')"""
     15 	fc = conf.find_program(['pgfortran', 'pgf95', 'pgf90'], var='FC')
     16 	conf.get_pgfortran_version(fc)
     17 	conf.env.FC_NAME = 'PGFC'
     18 
     19 @conf
     20 def pgfortran_flags(conf):
     21 	v = conf.env
     22 	v['FCFLAGS_fcshlib']   = ['-shared']
     23 	v['FCFLAGS_DEBUG'] = ['-Minform=inform', '-Mstandard'] # why not
     24 	v['FCSTLIB_MARKER'] = '-Bstatic'
     25 	v['FCSHLIB_MARKER'] = '-Bdynamic'
     26 	v['SONAME_ST']	  = '-soname %s'
     27 
     28 @conf
     29 def get_pgfortran_version(conf,fc):
     30 		version_re = re.compile(r"The Portland Group", re.I).search
     31 		cmd = fc + ['-V']
     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 				conf.fatal('Could not verify PGI signature')
     39 		cmd = fc + ['-help=variable']
     40 		out,err = fc_config.getoutput(conf, cmd, stdin=False)
     41 		if out.find('COMPVER')<0:
     42 				conf.fatal('Could not determine the compiler type')
     43 		k = {}
     44 		prevk = ''
     45 		out = out.splitlines()
     46 		for line in out:
     47 				lst = line.partition('=')
     48 				if lst[1] == '=':
     49 						key = lst[0].rstrip()
     50 						if key == '':
     51 							key = prevk
     52 						val = lst[2].rstrip()
     53 						k[key] = val
     54 				else:
     55 					prevk = line.partition(' ')[0]
     56 		def isD(var):
     57 				return var in k
     58 		def isT(var):
     59 				return var in k and k[var]!='0'
     60 		conf.env['FC_VERSION'] = (k['COMPVER'].split('.'))
     61 
     62 def configure(conf):
     63 	conf.find_pgfortran()
     64 	conf.find_ar()
     65 	conf.fc_flags()
     66 	conf.fc_add_flags()
     67 	conf.pgfortran_flags()
     68