fc_nec.py 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. #! /usr/bin/env python
  2. # encoding: utf-8
  3. # harald at klimachs.de
  4. import re
  5. from waflib.Tools import fc, fc_config, fc_scan
  6. from waflib.Configure import conf
  7. from waflib.Tools.compiler_fc import fc_compiler
  8. fc_compiler['linux'].append('fc_nec')
  9. @conf
  10. def find_sxfc(conf):
  11. """Find the NEC fortran compiler (will look in the environment variable 'FC')"""
  12. fc = conf.find_program(['sxf90','sxf03'], var='FC')
  13. conf.get_sxfc_version(fc)
  14. conf.env.FC_NAME = 'NEC'
  15. conf.env.FC_MOD_CAPITALIZATION = 'lower'
  16. @conf
  17. def sxfc_flags(conf):
  18. v = conf.env
  19. v['_FCMODOUTFLAGS'] = [] # enable module files and put them in the current directoy
  20. v['FCFLAGS_DEBUG'] = [] # more verbose compiler warnings
  21. v['FCFLAGS_fcshlib'] = []
  22. v['LINKFLAGS_fcshlib'] = []
  23. v['FCSTLIB_MARKER'] = ''
  24. v['FCSHLIB_MARKER'] = ''
  25. @conf
  26. def get_sxfc_version(conf, fc):
  27. version_re = re.compile(r"FORTRAN90/SX\s*Version\s*(?P<major>\d*)\.(?P<minor>\d*)", re.I).search
  28. cmd = fc + ['-V']
  29. out,err = fc_config.getoutput(conf, cmd, stdin=False)
  30. if out:
  31. match = version_re(out)
  32. else:
  33. match = version_re(err)
  34. if not match:
  35. version_re=re.compile(r"NEC Fortran 2003 Compiler for\s*(?P<major>\S*)\s*\(c\)\s*(?P<minor>\d*)",re.I).search
  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 NEC Fortran compiler version.')
  42. k = match.groupdict()
  43. conf.env['FC_VERSION'] = (k['major'], k['minor'])
  44. def configure(conf):
  45. conf.find_sxfc()
  46. conf.find_program('sxar',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.sxfc_flags()