Clone of mesa.
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.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198
  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. default_statetrackers = 'mesa'
  29. if common.default_platform in ('linux', 'freebsd', 'darwin'):
  30. default_drivers = 'softpipe,failover,svga,i915,i965,trace,identity,llvmpipe'
  31. default_winsys = 'xlib'
  32. elif common.default_platform in ('winddk',):
  33. default_drivers = 'softpipe,svga,i915,i965,trace,identity'
  34. default_winsys = 'all'
  35. else:
  36. default_drivers = 'all'
  37. default_winsys = 'all'
  38. opts = Variables('config.py')
  39. common.AddOptions(opts)
  40. opts.Add(ListVariable('statetrackers', 'state trackers to build', default_statetrackers,
  41. ['mesa', 'python', 'xorg']))
  42. opts.Add(ListVariable('drivers', 'pipe drivers to build', default_drivers,
  43. ['softpipe', 'failover', 'svga', 'i915', 'i965', 'trace', 'r300', 'identity', 'llvmpipe']))
  44. opts.Add(ListVariable('winsys', 'winsys drivers to build', default_winsys,
  45. ['xlib', 'vmware', 'intel', 'i965', 'gdi', 'radeon']))
  46. opts.Add(EnumVariable('MSVS_VERSION', 'MS Visual C++ version', None, allowed_values=('7.1', '8.0', '9.0')))
  47. env = Environment(
  48. options = opts,
  49. tools = ['gallium'],
  50. toolpath = ['#scons'],
  51. ENV = os.environ,
  52. )
  53. Help(opts.GenerateHelpText(env))
  54. # replicate options values in local variables
  55. debug = env['debug']
  56. dri = env['dri']
  57. llvm = env['llvm']
  58. machine = env['machine']
  59. platform = env['platform']
  60. # derived options
  61. x86 = machine == 'x86'
  62. ppc = machine == 'ppc'
  63. gcc = platform in ('linux', 'freebsd', 'darwin')
  64. msvc = platform in ('windows', 'winddk')
  65. Export([
  66. 'debug',
  67. 'x86',
  68. 'ppc',
  69. 'dri',
  70. 'llvm',
  71. 'platform',
  72. 'gcc',
  73. 'msvc',
  74. ])
  75. #######################################################################
  76. # Environment setup
  77. # Includes
  78. env.Append(CPPPATH = [
  79. '#/include',
  80. '#/src/gallium/include',
  81. '#/src/gallium/auxiliary',
  82. '#/src/gallium/drivers',
  83. ])
  84. if env['msvc']:
  85. env.Append(CPPPATH = ['#include/c99'])
  86. # Posix
  87. if platform in ('posix', 'linux', 'freebsd', 'darwin'):
  88. env.Append(CPPDEFINES = [
  89. '_POSIX_SOURCE',
  90. ('_POSIX_C_SOURCE', '199309L'),
  91. '_SVID_SOURCE',
  92. '_BSD_SOURCE',
  93. '_GNU_SOURCE',
  94. 'PTHREADS',
  95. 'HAVE_POSIX_MEMALIGN',
  96. ])
  97. env.Append(CPPPATH = ['/usr/X11R6/include'])
  98. env.Append(LIBPATH = ['/usr/X11R6/lib'])
  99. env.Append(LIBS = [
  100. 'm',
  101. 'pthread',
  102. 'expat',
  103. 'dl',
  104. ])
  105. # DRI
  106. if dri:
  107. env.ParseConfig('pkg-config --cflags --libs libdrm')
  108. env.Append(CPPDEFINES = [
  109. ('USE_EXTERNAL_DXTN_LIB', '1'),
  110. 'IN_DRI_DRIVER',
  111. 'GLX_DIRECT_RENDERING',
  112. 'GLX_INDIRECT_RENDERING',
  113. ])
  114. # LLVM
  115. if llvm:
  116. # See also http://www.scons.org/wiki/UsingPkgConfig
  117. env.ParseConfig('llvm-config --cflags --ldflags --libs backend bitreader engine instrumentation interpreter ipo')
  118. env.Append(CPPDEFINES = ['MESA_LLVM'])
  119. # Force C++ linkage
  120. env['LINK'] = env['CXX']
  121. # libGL
  122. if platform in ('linux', 'freebsd', 'darwin'):
  123. env.Append(LIBS = [
  124. 'X11',
  125. 'Xext',
  126. 'Xxf86vm',
  127. 'Xdamage',
  128. 'Xfixes',
  129. ])
  130. # for debugging
  131. #print env.Dump()
  132. Export('env')
  133. #######################################################################
  134. # Invoke SConscripts
  135. # TODO: Build several variants at the same time?
  136. # http://www.scons.org/wiki/SimultaneousVariantBuilds
  137. if env['platform'] != common.default_platform:
  138. # GLSL code has to be built twice -- one for the host OS, another for the target OS...
  139. host_env = Environment(
  140. # options are ignored
  141. # default tool is used
  142. tools = ['default', 'custom'],
  143. toolpath = ['#scons'],
  144. ENV = os.environ,
  145. )
  146. host_env['platform'] = common.default_platform
  147. host_env['machine'] = common.default_machine
  148. host_env['debug'] = env['debug']
  149. SConscript(
  150. 'src/glsl/SConscript',
  151. variant_dir = os.path.join(env['build'], 'host'),
  152. duplicate = 0, # http://www.scons.org/doc/0.97/HTML/scons-user/x2261.html
  153. exports={'env':host_env},
  154. )
  155. SConscript(
  156. 'src/SConscript',
  157. variant_dir = env['build'],
  158. duplicate = 0 # http://www.scons.org/doc/0.97/HTML/scons-user/x2261.html
  159. )
  160. SConscript(
  161. 'progs/SConscript',
  162. variant_dir = os.path.join('progs', env['build']),
  163. duplicate = 0 # http://www.scons.org/doc/0.97/HTML/scons-user/x2261.html
  164. )