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.

SConstruct 5.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212
  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 SCons.Util
  26. import common
  27. #######################################################################
  28. # Configuration options
  29. default_statetrackers = 'mesa'
  30. if common.default_platform in ('linux', 'freebsd', 'darwin'):
  31. default_drivers = 'softpipe,failover,svga,i915,i965,trace,identity,llvmpipe'
  32. default_winsys = 'xlib'
  33. elif common.default_platform in ('winddk',):
  34. default_drivers = 'softpipe,svga,i915,i965,trace,identity'
  35. default_winsys = 'all'
  36. elif common.default_platform in ('embedded',):
  37. default_drivers = 'softpipe,llvmpipe'
  38. default_winsys = 'xlib'
  39. else:
  40. default_drivers = 'all'
  41. default_winsys = 'all'
  42. opts = Variables('config.py')
  43. common.AddOptions(opts)
  44. opts.Add(ListVariable('statetrackers', 'state trackers to build', default_statetrackers,
  45. ['mesa', 'python', 'xorg']))
  46. opts.Add(ListVariable('drivers', 'pipe drivers to build', default_drivers,
  47. ['softpipe', 'failover', 'svga', 'i915', 'i965', 'trace', 'r300', 'identity', 'llvmpipe', 'nouveau', 'nv50', 'nvfx']))
  48. opts.Add(ListVariable('winsys', 'winsys drivers to build', default_winsys,
  49. ['xlib', 'vmware', 'i915', 'i965', 'gdi', 'radeon', 'graw-xlib']))
  50. opts.Add(EnumVariable('MSVS_VERSION', 'MS Visual C++ version', None, allowed_values=('7.1', '8.0', '9.0')))
  51. env = Environment(
  52. options = opts,
  53. tools = ['gallium'],
  54. toolpath = ['#scons'],
  55. ENV = os.environ,
  56. )
  57. if os.environ.has_key('CC'):
  58. env['CC'] = os.environ['CC']
  59. if os.environ.has_key('CFLAGS'):
  60. env['CCFLAGS'] += SCons.Util.CLVar(os.environ['CFLAGS'])
  61. if os.environ.has_key('CXX'):
  62. env['CXX'] = os.environ['CXX']
  63. if os.environ.has_key('CXXFLAGS'):
  64. env['CXXFLAGS'] += SCons.Util.CLVar(os.environ['CXXFLAGS'])
  65. if os.environ.has_key('LDFLAGS'):
  66. env['LINKFLAGS'] += SCons.Util.CLVar(os.environ['LDFLAGS'])
  67. Help(opts.GenerateHelpText(env))
  68. # replicate options values in local variables
  69. debug = env['debug']
  70. dri = env['dri']
  71. machine = env['machine']
  72. platform = env['platform']
  73. # derived options
  74. x86 = machine == 'x86'
  75. ppc = machine == 'ppc'
  76. gcc = platform in ('linux', 'freebsd', 'darwin', 'embedded')
  77. msvc = platform in ('windows', 'winddk')
  78. Export([
  79. 'debug',
  80. 'x86',
  81. 'ppc',
  82. 'dri',
  83. 'platform',
  84. 'gcc',
  85. 'msvc',
  86. ])
  87. #######################################################################
  88. # Environment setup
  89. # Always build trace, identity, softpipe, and llvmpipe (where possible)
  90. if 'trace' not in env['drivers']:
  91. env['drivers'].append('trace')
  92. if 'identity' not in env['drivers']:
  93. env['drivers'].append('identity')
  94. if 'softpipe' not in env['drivers']:
  95. env['drivers'].append('softpipe')
  96. if env['llvm'] and 'llvmpipe' not in env['drivers']:
  97. env['drivers'].append('llvmpipe')
  98. # Includes
  99. env.Prepend(CPPPATH = [
  100. '#/include',
  101. ])
  102. env.Append(CPPPATH = [
  103. '#/src/gallium/include',
  104. '#/src/gallium/auxiliary',
  105. '#/src/gallium/drivers',
  106. '#/src/gallium/winsys',
  107. ])
  108. if env['msvc']:
  109. env.Append(CPPPATH = ['#include/c99'])
  110. # Embedded
  111. if platform == 'embedded':
  112. env.Append(CPPDEFINES = [
  113. '_POSIX_SOURCE',
  114. ('_POSIX_C_SOURCE', '199309L'),
  115. '_SVID_SOURCE',
  116. '_BSD_SOURCE',
  117. '_GNU_SOURCE',
  118. 'PTHREADS',
  119. ])
  120. env.Append(LIBS = [
  121. 'm',
  122. 'pthread',
  123. 'dl',
  124. ])
  125. # Posix
  126. if platform in ('posix', 'linux', 'freebsd', 'darwin'):
  127. env.Append(CPPDEFINES = [
  128. '_POSIX_SOURCE',
  129. ('_POSIX_C_SOURCE', '199309L'),
  130. '_SVID_SOURCE',
  131. '_BSD_SOURCE',
  132. '_GNU_SOURCE',
  133. 'PTHREADS',
  134. 'HAVE_POSIX_MEMALIGN',
  135. ])
  136. if platform == 'darwin':
  137. env.Append(CPPDEFINES = ['_DARWIN_C_SOURCE'])
  138. env.Append(LIBS = [
  139. 'm',
  140. 'pthread',
  141. 'dl',
  142. ])
  143. # for debugging
  144. #print env.Dump()
  145. Export('env')
  146. #######################################################################
  147. # Invoke SConscripts
  148. # TODO: Build several variants at the same time?
  149. # http://www.scons.org/wiki/SimultaneousVariantBuilds
  150. if env['platform'] != common.default_platform:
  151. # GLSL code has to be built twice -- one for the host OS, another for the target OS...
  152. host_env = Environment(
  153. # options are ignored
  154. # default tool is used
  155. tools = ['default', 'custom'],
  156. toolpath = ['#scons'],
  157. ENV = os.environ,
  158. )
  159. host_env['platform'] = common.default_platform
  160. host_env['machine'] = common.default_machine
  161. host_env['debug'] = env['debug']
  162. SConscript(
  163. 'src/glsl/SConscript',
  164. variant_dir = os.path.join(env['build'], 'host'),
  165. duplicate = 0, # http://www.scons.org/doc/0.97/HTML/scons-user/x2261.html
  166. exports={'env':host_env},
  167. )
  168. SConscript(
  169. 'src/SConscript',
  170. variant_dir = env['build'],
  171. duplicate = 0 # http://www.scons.org/doc/0.97/HTML/scons-user/x2261.html
  172. )
  173. env.Default('src')
  174. SConscript(
  175. 'progs/SConscript',
  176. variant_dir = os.path.join('progs', env['build']),
  177. duplicate = 0 # http://www.scons.org/doc/0.97/HTML/scons-user/x2261.html
  178. )