jack2 codebase
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

69 lines
1.6KB

  1. #!/usr/bin/env python
  2. # encoding: utf-8
  3. # Antoine Dechaume 2011
  4. """
  5. Detect the PGI C compiler
  6. """
  7. import sys, re
  8. from waflib.Configure import conf
  9. from waflib.Tools.compiler_c import c_compiler
  10. c_compiler['linux'].append('pgicc')
  11. @conf
  12. def find_pgi_compiler(conf, var, name):
  13. """
  14. Find the program name, and execute it to ensure it really is itself.
  15. """
  16. if sys.platform == 'cygwin':
  17. conf.fatal('The PGI compiler does not work on Cygwin')
  18. v = conf.env
  19. cc = None
  20. if v[var]: cc = v[var]
  21. elif var in conf.environ: cc = conf.environ[var]
  22. if not cc: cc = conf.find_program(name, var=var)
  23. if not cc: conf.fatal('PGI Compiler (%s) was not found' % name)
  24. v[var + '_VERSION'] = conf.get_pgi_version(cc)
  25. v[var] = cc
  26. v[var + '_NAME'] = 'pgi'
  27. @conf
  28. def get_pgi_version(conf, cc):
  29. """Find the version of a pgi compiler."""
  30. version_re = re.compile(r"The Portland Group", re.I).search
  31. cmd = cc + ['-V', '-E'] # Issue 1078, prevent wrappers from linking
  32. try:
  33. out, err = conf.cmd_and_log(cmd, output=0)
  34. except Exception:
  35. conf.fatal('Could not find pgi compiler %r' % cmd)
  36. if out: match = version_re(out)
  37. else: match = version_re(err)
  38. if not match:
  39. conf.fatal('Could not verify PGI signature')
  40. cmd = cc + ['-help=variable']
  41. try:
  42. out, err = conf.cmd_and_log(cmd, output=0)
  43. except Exception:
  44. conf.fatal('Could not find pgi compiler %r' % cmd)
  45. version = re.findall('^COMPVER\s*=(.*)', out, re.M)
  46. if len(version) != 1:
  47. conf.fatal('Could not determine the compiler version')
  48. return version[0]
  49. def configure(conf):
  50. conf.find_pgi_compiler('CC', 'pgcc')
  51. conf.find_ar()
  52. conf.gcc_common_flags()
  53. conf.cc_load_tools()
  54. conf.cc_add_flags()
  55. conf.link_add_flags()