fc_open64.py 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. #! /usr/bin/env python
  2. # encoding: utf-8
  3. # harald at klimachs.de
  4. import re
  5. from waflib import Utils
  6. from waflib.Tools import fc,fc_config,fc_scan
  7. from waflib.Configure import conf
  8. from waflib.Tools.compiler_fc import fc_compiler
  9. fc_compiler['linux'].insert(0, 'fc_open64')
  10. @conf
  11. def find_openf95(conf):
  12. """Find the Open64 Fortran Compiler (will look in the environment variable 'FC')"""
  13. fc = conf.find_program(['openf95', 'openf90'], var='FC')
  14. conf.get_open64_version(fc)
  15. conf.env.FC_NAME = 'OPEN64'
  16. conf.env.FC_MOD_CAPITALIZATION = 'UPPER.mod'
  17. @conf
  18. def openf95_flags(conf):
  19. v = conf.env
  20. v['FCFLAGS_DEBUG'] = ['-fullwarn']
  21. @conf
  22. def openf95_modifier_platform(conf):
  23. dest_os = conf.env['DEST_OS'] or Utils.unversioned_sys_platform()
  24. openf95_modifier_func = getattr(conf, 'openf95_modifier_' + dest_os, None)
  25. if openf95_modifier_func:
  26. openf95_modifier_func()
  27. @conf
  28. def get_open64_version(conf, fc):
  29. """Get the Open64 compiler version"""
  30. version_re = re.compile(r"Open64 Compiler Suite: *Version *(?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. conf.fatal('Could not determine the Open64 version.')
  39. k = match.groupdict()
  40. conf.env['FC_VERSION'] = (k['major'], k['minor'])
  41. def configure(conf):
  42. conf.find_openf95()
  43. conf.find_ar()
  44. conf.fc_flags()
  45. conf.fc_add_flags()
  46. conf.openf95_flags()
  47. conf.openf95_modifier_platform()