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.

162 lines
4.3KB

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