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.

158 lines
4.0KB

  1. #!/usr/bin/env python
  2. # encoding: utf-8
  3. # Thomas Nagy, 2006-2018 (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. Finds 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. if not v.LINK_CXX:
  28. 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. v.cxxprogram_PATTERN = '%s'
  42. v.CXXFLAGS_cxxshlib = ['-fPIC']
  43. v.LINKFLAGS_cxxshlib = ['-shared']
  44. v.cxxshlib_PATTERN = 'lib%s.so'
  45. v.LINKFLAGS_cxxstlib = ['-Wl,-Bstatic']
  46. v.cxxstlib_PATTERN = 'lib%s.a'
  47. v.LINKFLAGS_MACBUNDLE = ['-bundle', '-undefined', 'dynamic_lookup']
  48. v.CXXFLAGS_MACBUNDLE = ['-fPIC']
  49. v.macbundle_PATTERN = '%s.bundle'
  50. @conf
  51. def gxx_modifier_win32(conf):
  52. """Configuration flags for executing gcc on Windows"""
  53. v = conf.env
  54. v.cxxprogram_PATTERN = '%s.exe'
  55. v.cxxshlib_PATTERN = '%s.dll'
  56. v.implib_PATTERN = '%s.dll.a'
  57. v.IMPLIB_ST = '-Wl,--out-implib,%s'
  58. v.CXXFLAGS_cxxshlib = []
  59. # Auto-import is enabled by default even without this option,
  60. # but enabling it explicitly has the nice effect of suppressing the rather boring, debug-level messages
  61. # that the linker emits otherwise.
  62. v.append_value('LINKFLAGS', ['-Wl,--enable-auto-import'])
  63. @conf
  64. def gxx_modifier_cygwin(conf):
  65. """Configuration flags for executing g++ on Cygwin"""
  66. gxx_modifier_win32(conf)
  67. v = conf.env
  68. v.cxxshlib_PATTERN = 'cyg%s.dll'
  69. v.append_value('LINKFLAGS_cxxshlib', ['-Wl,--enable-auto-image-base'])
  70. v.CXXFLAGS_cxxshlib = []
  71. @conf
  72. def gxx_modifier_darwin(conf):
  73. """Configuration flags for executing g++ on MacOS"""
  74. v = conf.env
  75. v.CXXFLAGS_cxxshlib = ['-fPIC']
  76. v.LINKFLAGS_cxxshlib = ['-dynamiclib']
  77. v.cxxshlib_PATTERN = 'lib%s.dylib'
  78. v.FRAMEWORKPATH_ST = '-F%s'
  79. v.FRAMEWORK_ST = ['-framework']
  80. v.ARCH_ST = ['-arch']
  81. v.LINKFLAGS_cxxstlib = []
  82. v.SHLIB_MARKER = []
  83. v.STLIB_MARKER = []
  84. v.SONAME_ST = []
  85. @conf
  86. def gxx_modifier_aix(conf):
  87. """Configuration flags for executing g++ on AIX"""
  88. v = conf.env
  89. v.LINKFLAGS_cxxprogram= ['-Wl,-brtl']
  90. v.LINKFLAGS_cxxshlib = ['-shared', '-Wl,-brtl,-bexpfull']
  91. v.SHLIB_MARKER = []
  92. @conf
  93. def gxx_modifier_hpux(conf):
  94. v = conf.env
  95. v.SHLIB_MARKER = []
  96. v.STLIB_MARKER = []
  97. v.CFLAGS_cxxshlib = ['-fPIC','-DPIC']
  98. v.cxxshlib_PATTERN = 'lib%s.sl'
  99. @conf
  100. def gxx_modifier_openbsd(conf):
  101. conf.env.SONAME_ST = []
  102. @conf
  103. def gcc_modifier_osf1V(conf):
  104. v = conf.env
  105. v.SHLIB_MARKER = []
  106. v.STLIB_MARKER = []
  107. v.SONAME_ST = []
  108. @conf
  109. def gxx_modifier_platform(conf):
  110. """Execute platform-specific functions based on *gxx_modifier_+NAME*"""
  111. # * set configurations specific for a platform.
  112. # * the destination platform is detected automatically by looking at the macros the compiler predefines,
  113. # and if it's not recognised, it fallbacks to sys.platform.
  114. gxx_modifier_func = getattr(conf, 'gxx_modifier_' + conf.env.DEST_OS, None)
  115. if gxx_modifier_func:
  116. gxx_modifier_func()
  117. def configure(conf):
  118. """
  119. Configuration for g++
  120. """
  121. conf.find_gxx()
  122. conf.find_ar()
  123. conf.gxx_common_flags()
  124. conf.gxx_modifier_platform()
  125. conf.cxx_load_tools()
  126. conf.cxx_add_flags()
  127. conf.link_add_flags()
  128. conf.check_gcc_o_space('cxx')