fc_solstudio.py 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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'].append('fc_solstudio')
  10. @conf
  11. def find_solstudio(conf):
  12. """Find the Solaris Studio compiler (will look in the environment variable 'FC')"""
  13. fc = conf.find_program(['sunf95', 'f95', 'sunf90', 'f90'], var='FC')
  14. conf.get_solstudio_version(fc)
  15. conf.env.FC_NAME = 'SOL'
  16. @conf
  17. def solstudio_flags(conf):
  18. v = conf.env
  19. v['FCFLAGS_fcshlib'] = ['-Kpic']
  20. v['FCFLAGS_DEBUG'] = ['-w3']
  21. v['LINKFLAGS_fcshlib'] = ['-G']
  22. v['FCSTLIB_MARKER'] = '-Bstatic'
  23. v['FCSHLIB_MARKER'] = '-Bdynamic'
  24. v['SONAME_ST'] = '-h %s'
  25. @conf
  26. def solstudio_modifier_platform(conf):
  27. dest_os = conf.env['DEST_OS'] or Utils.unversioned_sys_platform()
  28. solstudio_modifier_func = getattr(conf, 'solstudio_modifier_' + dest_os, None)
  29. if solstudio_modifier_func:
  30. solstudio_modifier_func()
  31. @conf
  32. def get_solstudio_version(conf, fc):
  33. """Get the compiler version"""
  34. version_re = re.compile(r"Sun Fortran 95 *(?P<major>\d*)\.(?P<minor>\d*)", re.I).search
  35. cmd = fc + ['-V']
  36. out, err = fc_config.getoutput(conf,cmd,stdin=False)
  37. if out:
  38. match = version_re(out)
  39. else:
  40. match = version_re(err)
  41. if not match:
  42. conf.fatal('Could not determine the Sun Studio Fortran version.')
  43. k = match.groupdict()
  44. conf.env['FC_VERSION'] = (k['major'], k['minor'])
  45. def configure(conf):
  46. conf.find_solstudio()
  47. conf.find_ar()
  48. conf.fc_flags()
  49. conf.fc_add_flags()
  50. conf.solstudio_flags()
  51. conf.solstudio_modifier_platform()