c_nec.py 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. #! /usr/bin/env python
  2. # encoding: utf-8
  3. # harald at klimachs.de
  4. """
  5. NEC SX Compiler for SX vector systems
  6. """
  7. import re
  8. from waflib import Utils
  9. from waflib.Tools import ccroot,ar
  10. from waflib.Configure import conf
  11. from waflib.Tools import xlc # method xlc_common_flags
  12. from waflib.Tools.compiler_c import c_compiler
  13. c_compiler['linux'].append('c_nec')
  14. @conf
  15. def find_sxc(conf):
  16. cc = conf.find_program(['sxcc'], var='CC')
  17. conf.get_sxc_version(cc)
  18. conf.env.CC = cc
  19. conf.env.CC_NAME = 'sxcc'
  20. @conf
  21. def get_sxc_version(conf, fc):
  22. version_re = re.compile(r"C\+\+/SX\s*Version\s*(?P<major>\d*)\.(?P<minor>\d*)", re.I).search
  23. cmd = fc + ['-V']
  24. p = Utils.subprocess.Popen(cmd, stdin=False, stdout=Utils.subprocess.PIPE, stderr=Utils.subprocess.PIPE, env=None)
  25. out, err = p.communicate()
  26. if out:
  27. match = version_re(out)
  28. else:
  29. match = version_re(err)
  30. if not match:
  31. conf.fatal('Could not determine the NEC C compiler version.')
  32. k = match.groupdict()
  33. conf.env['C_VERSION'] = (k['major'], k['minor'])
  34. @conf
  35. def sxc_common_flags(conf):
  36. v=conf.env
  37. v['CC_SRC_F']=[]
  38. v['CC_TGT_F']=['-c','-o']
  39. if not v['LINK_CC']:
  40. v['LINK_CC']=v['CC']
  41. v['CCLNK_SRC_F']=[]
  42. v['CCLNK_TGT_F']=['-o']
  43. v['CPPPATH_ST']='-I%s'
  44. v['DEFINES_ST']='-D%s'
  45. v['LIB_ST']='-l%s'
  46. v['LIBPATH_ST']='-L%s'
  47. v['STLIB_ST']='-l%s'
  48. v['STLIBPATH_ST']='-L%s'
  49. v['RPATH_ST']=''
  50. v['SONAME_ST']=[]
  51. v['SHLIB_MARKER']=[]
  52. v['STLIB_MARKER']=[]
  53. v['LINKFLAGS_cprogram']=['']
  54. v['cprogram_PATTERN']='%s'
  55. v['CFLAGS_cshlib']=['-fPIC']
  56. v['LINKFLAGS_cshlib']=['']
  57. v['cshlib_PATTERN']='lib%s.so'
  58. v['LINKFLAGS_cstlib']=[]
  59. v['cstlib_PATTERN']='lib%s.a'
  60. def configure(conf):
  61. conf.find_sxc()
  62. conf.find_program('sxar',VAR='AR')
  63. conf.sxc_common_flags()
  64. conf.cc_load_tools()
  65. conf.cc_add_flags()
  66. conf.link_add_flags()