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.

160 lines
4.2KB

  1. #!/usr/bin/env python
  2. # encoding: utf-8
  3. # Thomas Nagy, 2006-2010 (ita)
  4. # Ralf Habacker, 2006 (rh)
  5. # Yinon Ehrlich, 2009
  6. """
  7. g++/llvm detection.
  8. """
  9. from waflib.Tools import ccroot, ar
  10. from waflib.Configure import conf
  11. @conf
  12. def find_gxx(conf):
  13. """
  14. Find the program g++, and if present, try to detect its version number
  15. """
  16. cxx = conf.find_program(['g++', 'c++'], var='CXX')
  17. conf.get_cc_version(cxx, gcc=True)
  18. conf.env.CXX_NAME = 'gcc'
  19. @conf
  20. def gxx_common_flags(conf):
  21. """
  22. Common flags for g++ on nearly all platforms
  23. """
  24. v = conf.env
  25. v['CXX_SRC_F'] = []
  26. v['CXX_TGT_F'] = ['-c', '-o']
  27. # linker
  28. if not v['LINK_CXX']: v['LINK_CXX'] = v['CXX']
  29. v['CXXLNK_SRC_F'] = []
  30. v['CXXLNK_TGT_F'] = ['-o']
  31. v['CPPPATH_ST'] = '-I%s'
  32. v['DEFINES_ST'] = '-D%s'
  33. v['LIB_ST'] = '-l%s' # template for adding libs
  34. v['LIBPATH_ST'] = '-L%s' # template for adding libpaths
  35. v['STLIB_ST'] = '-l%s'
  36. v['STLIBPATH_ST'] = '-L%s'
  37. v['RPATH_ST'] = '-Wl,-rpath,%s'
  38. v['SONAME_ST'] = '-Wl,-h,%s'
  39. v['SHLIB_MARKER'] = '-Wl,-Bdynamic'
  40. v['STLIB_MARKER'] = '-Wl,-Bstatic'
  41. # program
  42. v['cxxprogram_PATTERN'] = '%s'
  43. # shared library
  44. v['CXXFLAGS_cxxshlib'] = ['-fPIC']
  45. v['LINKFLAGS_cxxshlib'] = ['-shared']
  46. v['cxxshlib_PATTERN'] = 'lib%s.so'
  47. # static lib
  48. v['LINKFLAGS_cxxstlib'] = ['-Wl,-Bstatic']
  49. v['cxxstlib_PATTERN'] = 'lib%s.a'
  50. # osx stuff
  51. v['LINKFLAGS_MACBUNDLE'] = ['-bundle', '-undefined', 'dynamic_lookup']
  52. v['CXXFLAGS_MACBUNDLE'] = ['-fPIC']
  53. v['macbundle_PATTERN'] = '%s.bundle'
  54. @conf
  55. def gxx_modifier_win32(conf):
  56. """Configuration flags for executing gcc on Windows"""
  57. v = conf.env
  58. v['cxxprogram_PATTERN'] = '%s.exe'
  59. v['cxxshlib_PATTERN'] = '%s.dll'
  60. v['implib_PATTERN'] = 'lib%s.dll.a'
  61. v['IMPLIB_ST'] = '-Wl,--out-implib,%s'
  62. v['CXXFLAGS_cxxshlib'] = []
  63. # Auto-import is enabled by default even without this option,
  64. # but enabling it explicitly has the nice effect of suppressing the rather boring, debug-level messages
  65. # that the linker emits otherwise.
  66. v.append_value('LINKFLAGS', ['-Wl,--enable-auto-import'])
  67. @conf
  68. def gxx_modifier_cygwin(conf):
  69. """Configuration flags for executing g++ on Cygwin"""
  70. gxx_modifier_win32(conf)
  71. v = conf.env
  72. v['cxxshlib_PATTERN'] = 'cyg%s.dll'
  73. v.append_value('LINKFLAGS_cxxshlib', ['-Wl,--enable-auto-image-base'])
  74. v['CXXFLAGS_cxxshlib'] = []
  75. @conf
  76. def gxx_modifier_darwin(conf):
  77. """Configuration flags for executing g++ on MacOS"""
  78. v = conf.env
  79. v['CXXFLAGS_cxxshlib'] = ['-fPIC']
  80. v['LINKFLAGS_cxxshlib'] = ['-dynamiclib']
  81. v['cxxshlib_PATTERN'] = 'lib%s.dylib'
  82. v['FRAMEWORKPATH_ST'] = '-F%s'
  83. v['FRAMEWORK_ST'] = ['-framework']
  84. v['ARCH_ST'] = ['-arch']
  85. v['LINKFLAGS_cxxstlib'] = []
  86. v['SHLIB_MARKER'] = []
  87. v['STLIB_MARKER'] = []
  88. v['SONAME_ST'] = []
  89. @conf
  90. def gxx_modifier_aix(conf):
  91. """Configuration flags for executing g++ on AIX"""
  92. v = conf.env
  93. v['LINKFLAGS_cxxprogram']= ['-Wl,-brtl']
  94. v['LINKFLAGS_cxxshlib'] = ['-shared', '-Wl,-brtl,-bexpfull']
  95. v['SHLIB_MARKER'] = []
  96. @conf
  97. def gxx_modifier_hpux(conf):
  98. v = conf.env
  99. v['SHLIB_MARKER'] = []
  100. v['STLIB_MARKER'] = []
  101. v['CFLAGS_cxxshlib'] = ['-fPIC','-DPIC']
  102. v['cxxshlib_PATTERN'] = 'lib%s.sl'
  103. @conf
  104. def gxx_modifier_openbsd(conf):
  105. conf.env.SONAME_ST = []
  106. @conf
  107. def gcc_modifier_osf1V(conf):
  108. v = conf.env
  109. v['SHLIB_MARKER'] = []
  110. v['STLIB_MARKER'] = []
  111. v['SONAME_ST'] = []
  112. @conf
  113. def gxx_modifier_platform(conf):
  114. """Execute platform-specific functions based on *gxx_modifier_+NAME*"""
  115. # * set configurations specific for a platform.
  116. # * the destination platform is detected automatically by looking at the macros the compiler predefines,
  117. # and if it's not recognised, it fallbacks to sys.platform.
  118. gxx_modifier_func = getattr(conf, 'gxx_modifier_' + conf.env.DEST_OS, None)
  119. if gxx_modifier_func:
  120. gxx_modifier_func()
  121. def configure(conf):
  122. """
  123. Configuration for g++
  124. """
  125. conf.find_gxx()
  126. conf.find_ar()
  127. conf.gxx_common_flags()
  128. conf.gxx_modifier_platform()
  129. conf.cxx_load_tools()
  130. conf.cxx_add_flags()
  131. conf.link_add_flags()