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.1KB

  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. gcc/llvm detection.
  8. """
  9. from waflib.Tools import ccroot, ar
  10. from waflib.Configure import conf
  11. @conf
  12. def find_gcc(conf):
  13. """
  14. Find the program gcc, and if present, try to detect its version number
  15. """
  16. cc = conf.find_program(['gcc', 'cc'], var='CC')
  17. conf.get_cc_version(cc, gcc=True)
  18. conf.env.CC_NAME = 'gcc'
  19. @conf
  20. def gcc_common_flags(conf):
  21. """
  22. Common flags for gcc on nearly all platforms
  23. """
  24. v = conf.env
  25. v['CC_SRC_F'] = []
  26. v['CC_TGT_F'] = ['-c', '-o']
  27. # linker
  28. if not v['LINK_CC']: v['LINK_CC'] = v['CC']
  29. v['CCLNK_SRC_F'] = []
  30. v['CCLNK_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['cprogram_PATTERN'] = '%s'
  43. # shared librar
  44. v['CFLAGS_cshlib'] = ['-fPIC']
  45. v['LINKFLAGS_cshlib'] = ['-shared']
  46. v['cshlib_PATTERN'] = 'lib%s.so'
  47. # static lib
  48. v['LINKFLAGS_cstlib'] = ['-Wl,-Bstatic']
  49. v['cstlib_PATTERN'] = 'lib%s.a'
  50. # osx stuff
  51. v['LINKFLAGS_MACBUNDLE'] = ['-bundle', '-undefined', 'dynamic_lookup']
  52. v['CFLAGS_MACBUNDLE'] = ['-fPIC']
  53. v['macbundle_PATTERN'] = '%s.bundle'
  54. @conf
  55. def gcc_modifier_win32(conf):
  56. """Configuration flags for executing gcc on Windows"""
  57. v = conf.env
  58. v['cprogram_PATTERN'] = '%s.exe'
  59. v['cshlib_PATTERN'] = '%s.dll'
  60. v['implib_PATTERN'] = 'lib%s.dll.a'
  61. v['IMPLIB_ST'] = '-Wl,--out-implib,%s'
  62. v['CFLAGS_cshlib'] = []
  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 gcc_modifier_cygwin(conf):
  69. """Configuration flags for executing gcc on Cygwin"""
  70. gcc_modifier_win32(conf)
  71. v = conf.env
  72. v['cshlib_PATTERN'] = 'cyg%s.dll'
  73. v.append_value('LINKFLAGS_cshlib', ['-Wl,--enable-auto-image-base'])
  74. v['CFLAGS_cshlib'] = []
  75. @conf
  76. def gcc_modifier_darwin(conf):
  77. """Configuration flags for executing gcc on MacOS"""
  78. v = conf.env
  79. v['CFLAGS_cshlib'] = ['-fPIC']
  80. v['LINKFLAGS_cshlib'] = ['-dynamiclib']
  81. v['cshlib_PATTERN'] = 'lib%s.dylib'
  82. v['FRAMEWORKPATH_ST'] = '-F%s'
  83. v['FRAMEWORK_ST'] = ['-framework']
  84. v['ARCH_ST'] = ['-arch']
  85. v['LINKFLAGS_cstlib'] = []
  86. v['SHLIB_MARKER'] = []
  87. v['STLIB_MARKER'] = []
  88. v['SONAME_ST'] = []
  89. @conf
  90. def gcc_modifier_aix(conf):
  91. """Configuration flags for executing gcc on AIX"""
  92. v = conf.env
  93. v['LINKFLAGS_cprogram'] = ['-Wl,-brtl']
  94. v['LINKFLAGS_cshlib'] = ['-shared','-Wl,-brtl,-bexpfull']
  95. v['SHLIB_MARKER'] = []
  96. @conf
  97. def gcc_modifier_hpux(conf):
  98. v = conf.env
  99. v['SHLIB_MARKER'] = []
  100. v['STLIB_MARKER'] = []
  101. v['CFLAGS_cshlib'] = ['-fPIC','-DPIC']
  102. v['cshlib_PATTERN'] = 'lib%s.sl'
  103. @conf
  104. def gcc_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 gcc_modifier_platform(conf):
  114. """Execute platform-specific functions based on *gcc_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. gcc_modifier_func = getattr(conf, 'gcc_modifier_' + conf.env.DEST_OS, None)
  119. if gcc_modifier_func:
  120. gcc_modifier_func()
  121. def configure(conf):
  122. """
  123. Configuration for gcc
  124. """
  125. conf.find_gcc()
  126. conf.find_ar()
  127. conf.gcc_common_flags()
  128. conf.gcc_modifier_platform()
  129. conf.cc_load_tools()
  130. conf.cc_add_flags()
  131. conf.link_add_flags()