Clone of mesa.
Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221
  1. #######################################################################
  2. # Top-level SConstruct
  3. #
  4. # For example, invoke scons as
  5. #
  6. # scons debug=1 dri=0 machine=x86
  7. #
  8. # to set configuration variables. Or you can write those options to a file
  9. # named config.py:
  10. #
  11. # # config.py
  12. # debug=1
  13. # dri=0
  14. # machine='x86'
  15. #
  16. # Invoke
  17. #
  18. # scons -h
  19. #
  20. # to get the full list of options. See scons manpage for more info.
  21. #
  22. import os
  23. import os.path
  24. import sys
  25. import common
  26. #######################################################################
  27. # Configuration options
  28. if common.default_platform in ('linux', 'freebsd', 'darwin'):
  29. default_statetrackers = 'mesa'
  30. default_drivers = 'softpipe,failover,i915simple,i965simple'
  31. default_winsys = 'xlib'
  32. elif common.default_platform in ('winddk',):
  33. default_statetrackers = 'none'
  34. default_drivers = 'softpipe,i915simple'
  35. default_winsys = 'none'
  36. else:
  37. default_drivers = 'all'
  38. default_winsys = 'all'
  39. opts = Options('config.py')
  40. common.AddOptions(opts)
  41. opts.Add(ListOption('statetrackers', 'state_trackers to build', default_statetrackers,
  42. ['mesa']))
  43. opts.Add(ListOption('drivers', 'pipe drivers to build', default_drivers,
  44. ['softpipe', 'failover', 'i915simple', 'i965simple', 'cell']))
  45. opts.Add(ListOption('winsys', 'winsys drivers to build', default_winsys,
  46. ['xlib', 'intel']))
  47. env = Environment(
  48. options = opts,
  49. ENV = os.environ)
  50. Help(opts.GenerateHelpText(env))
  51. # replicate options values in local variables
  52. debug = env['debug']
  53. dri = env['dri']
  54. llvm = env['llvm']
  55. machine = env['machine']
  56. platform = env['platform']
  57. # derived options
  58. x86 = machine == 'x86'
  59. gcc = platform in ('linux', 'freebsd', 'darwin')
  60. msvc = platform in ('win32', 'winddk')
  61. Export([
  62. 'debug',
  63. 'x86',
  64. 'dri',
  65. 'llvm',
  66. 'platform',
  67. 'gcc',
  68. 'msvc',
  69. ])
  70. #######################################################################
  71. # Environment setup
  72. #
  73. # TODO: put the compiler specific settings in separate files
  74. # TODO: auto-detect as much as possible
  75. common.generate(env)
  76. if platform == 'winddk':
  77. env.Tool('winddk', ['.'])
  78. env.Append(CPPPATH = [
  79. env['SDK_INC_PATH'],
  80. env['DDK_INC_PATH'],
  81. env['WDM_INC_PATH'],
  82. env['CRT_INC_PATH'],
  83. ])
  84. # Optimization flags
  85. if gcc:
  86. if debug:
  87. env.Append(CFLAGS = '-O0 -g3')
  88. env.Append(CXXFLAGS = '-O0 -g3')
  89. else:
  90. env.Append(CFLAGS = '-O3 -g3')
  91. env.Append(CXXFLAGS = '-O3 -g3')
  92. env.Append(CFLAGS = '-Wall -Wmissing-prototypes -Wno-long-long -ffast-math -pedantic')
  93. env.Append(CXXFLAGS = '-Wall -pedantic')
  94. # Be nice to Eclipse
  95. env.Append(CFLAGS = '-fmessage-length=0')
  96. env.Append(CXXFLAGS = '-fmessage-length=0')
  97. if msvc:
  98. cflags = [
  99. #'/Wp64', # enable 64 bit porting warnings
  100. ]
  101. env.Append(CFLAGS = cflags)
  102. env.Append(CXXFLAGS = cflags)
  103. # Put debugging information in a separate .pdb file for each object file as
  104. # descrived in the scons manpage
  105. env['CCPDBFLAGS'] = '/Zi /Fd${TARGET}.pdb'
  106. # Defines
  107. if debug:
  108. env.Append(CPPDEFINES = ['DEBUG'])
  109. else:
  110. env.Append(CPPDEFINES = ['NDEBUG'])
  111. # Includes
  112. env.Append(CPPPATH = [
  113. '#/include',
  114. '#/src/gallium/include',
  115. '#/src/gallium/auxiliary',
  116. '#/src/gallium/drivers',
  117. ])
  118. # x86 assembly
  119. if x86:
  120. env.Append(CPPDEFINES = [
  121. 'USE_X86_ASM',
  122. 'USE_MMX_ASM',
  123. 'USE_3DNOW_ASM',
  124. 'USE_SSE_ASM',
  125. ])
  126. if gcc:
  127. env.Append(CFLAGS = '-m32')
  128. env.Append(CXXFLAGS = '-m32')
  129. # Posix
  130. if platform in ('posix', 'linux', 'freebsd', 'darwin'):
  131. env.Append(CPPDEFINES = [
  132. '_POSIX_SOURCE',
  133. ('_POSIX_C_SOURCE', '199309L'),
  134. '_SVID_SOURCE',
  135. '_BSD_SOURCE',
  136. '_GNU_SOURCE',
  137. 'PTHREADS',
  138. 'HAVE_POSIX_MEMALIGN',
  139. ])
  140. env.Append(CPPPATH = ['/usr/X11R6/include'])
  141. env.Append(LIBPATH = ['/usr/X11R6/lib'])
  142. env.Append(LIBS = [
  143. 'm',
  144. 'pthread',
  145. 'expat',
  146. 'dl',
  147. ])
  148. # DRI
  149. if dri:
  150. env.ParseConfig('pkg-config --cflags --libs libdrm')
  151. env.Append(CPPDEFINES = [
  152. ('USE_EXTERNAL_DXTN_LIB', '1'),
  153. 'IN_DRI_DRIVER',
  154. 'GLX_DIRECT_RENDERING',
  155. 'GLX_INDIRECT_RENDERING',
  156. ])
  157. # LLVM
  158. if llvm:
  159. # See also http://www.scons.org/wiki/UsingPkgConfig
  160. env.ParseConfig('llvm-config --cflags --ldflags --libs')
  161. env.Append(CPPDEFINES = ['MESA_LLVM'])
  162. env.Append(CXXFLAGS = ['-Wno-long-long'])
  163. # Force C++ linkage
  164. env['LINK'] = env['CXX']
  165. # libGL
  166. if platform not in ('winddk',):
  167. env.Append(LIBS = [
  168. 'X11',
  169. 'Xext',
  170. 'Xxf86vm',
  171. 'Xdamage',
  172. 'Xfixes',
  173. ])
  174. # for debugging
  175. #print env.Dump()
  176. Export('env')
  177. #######################################################################
  178. # Invoke SConscripts
  179. # TODO: Build several variants at the same time?
  180. # http://www.scons.org/wiki/SimultaneousVariantBuilds
  181. SConscript(
  182. 'src/SConscript',
  183. build_dir = common.make_build_dir(env),
  184. duplicate = 0 # http://www.scons.org/doc/0.97/HTML/scons-user/x2261.html
  185. )