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.

157 lines
3.9KB

  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. 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. if not v.LINK_CC:
  28. 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. v.cprogram_PATTERN = '%s'
  42. v.CFLAGS_cshlib = ['-fPIC']
  43. v.LINKFLAGS_cshlib = ['-shared']
  44. v.cshlib_PATTERN = 'lib%s.so'
  45. v.LINKFLAGS_cstlib = ['-Wl,-Bstatic']
  46. v.cstlib_PATTERN = 'lib%s.a'
  47. v.LINKFLAGS_MACBUNDLE = ['-bundle', '-undefined', 'dynamic_lookup']
  48. v.CFLAGS_MACBUNDLE = ['-fPIC']
  49. v.macbundle_PATTERN = '%s.bundle'
  50. @conf
  51. def gcc_modifier_win32(conf):
  52. """Configuration flags for executing gcc on Windows"""
  53. v = conf.env
  54. v.cprogram_PATTERN = '%s.exe'
  55. v.cshlib_PATTERN = '%s.dll'
  56. v.implib_PATTERN = '%s.dll.a'
  57. v.IMPLIB_ST = '-Wl,--out-implib,%s'
  58. v.CFLAGS_cshlib = []
  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 gcc_modifier_cygwin(conf):
  65. """Configuration flags for executing gcc on Cygwin"""
  66. gcc_modifier_win32(conf)
  67. v = conf.env
  68. v.cshlib_PATTERN = 'cyg%s.dll'
  69. v.append_value('LINKFLAGS_cshlib', ['-Wl,--enable-auto-image-base'])
  70. v.CFLAGS_cshlib = []
  71. @conf
  72. def gcc_modifier_darwin(conf):
  73. """Configuration flags for executing gcc on MacOS"""
  74. v = conf.env
  75. v.CFLAGS_cshlib = ['-fPIC']
  76. v.LINKFLAGS_cshlib = ['-dynamiclib']
  77. v.cshlib_PATTERN = 'lib%s.dylib'
  78. v.FRAMEWORKPATH_ST = '-F%s'
  79. v.FRAMEWORK_ST = ['-framework']
  80. v.ARCH_ST = ['-arch']
  81. v.LINKFLAGS_cstlib = []
  82. v.SHLIB_MARKER = []
  83. v.STLIB_MARKER = []
  84. v.SONAME_ST = []
  85. @conf
  86. def gcc_modifier_aix(conf):
  87. """Configuration flags for executing gcc on AIX"""
  88. v = conf.env
  89. v.LINKFLAGS_cprogram = ['-Wl,-brtl']
  90. v.LINKFLAGS_cshlib = ['-shared','-Wl,-brtl,-bexpfull']
  91. v.SHLIB_MARKER = []
  92. @conf
  93. def gcc_modifier_hpux(conf):
  94. v = conf.env
  95. v.SHLIB_MARKER = []
  96. v.STLIB_MARKER = []
  97. v.CFLAGS_cshlib = ['-fPIC','-DPIC']
  98. v.cshlib_PATTERN = 'lib%s.sl'
  99. @conf
  100. def gcc_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 gcc_modifier_platform(conf):
  110. """Execute platform-specific functions based on *gcc_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. gcc_modifier_func = getattr(conf, 'gcc_modifier_' + conf.env.DEST_OS, None)
  115. if gcc_modifier_func:
  116. gcc_modifier_func()
  117. def configure(conf):
  118. """
  119. Configuration for gcc
  120. """
  121. conf.find_gcc()
  122. conf.find_ar()
  123. conf.gcc_common_flags()
  124. conf.gcc_modifier_platform()
  125. conf.cc_load_tools()
  126. conf.cc_add_flags()
  127. conf.link_add_flags()
  128. conf.check_gcc_o_space()