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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241
  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']))
  48. opts.Add(ListVariable('winsys', 'winsys drivers to build', default_winsys,
  49. ['xlib', 'vmware', 'intel', 'i965', 'gdi', 'radeon']))
  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. drawllvm = 'llvmpipe' in env['drivers']
  74. # LLVM support in the Draw module
  75. if drawllvm:
  76. env.Tool('llvm')
  77. if not env.has_key('LLVM_VERSION'):
  78. drawllvm = False
  79. # derived options
  80. x86 = machine == 'x86'
  81. ppc = machine == 'ppc'
  82. gcc = platform in ('linux', 'freebsd', 'darwin', 'embedded')
  83. msvc = platform in ('windows', 'winddk')
  84. Export([
  85. 'debug',
  86. 'x86',
  87. 'ppc',
  88. 'dri',
  89. 'drawllvm',
  90. 'platform',
  91. 'gcc',
  92. 'msvc',
  93. ])
  94. #######################################################################
  95. # Environment setup
  96. # Always build trace and identity drivers
  97. if 'trace' not in env['drivers']:
  98. env['drivers'].append('trace')
  99. if 'identity' not in env['drivers']:
  100. env['drivers'].append('identity')
  101. # Includes
  102. env.Append(CPPPATH = [
  103. '#/include',
  104. '#/src/gallium/include',
  105. '#/src/gallium/auxiliary',
  106. '#/src/gallium/drivers',
  107. '#/src/gallium/winsys',
  108. ])
  109. if env['msvc']:
  110. env.Append(CPPPATH = ['#include/c99'])
  111. # Embedded
  112. if platform == 'embedded':
  113. env.Append(CPPDEFINES = [
  114. '_POSIX_SOURCE',
  115. ('_POSIX_C_SOURCE', '199309L'),
  116. '_SVID_SOURCE',
  117. '_BSD_SOURCE',
  118. '_GNU_SOURCE',
  119. 'PTHREADS',
  120. ])
  121. env.Append(LIBS = [
  122. 'm',
  123. 'pthread',
  124. 'dl',
  125. ])
  126. # Posix
  127. if platform in ('posix', 'linux', 'freebsd', 'darwin'):
  128. env.Append(CPPDEFINES = [
  129. '_POSIX_SOURCE',
  130. ('_POSIX_C_SOURCE', '199309L'),
  131. '_SVID_SOURCE',
  132. '_BSD_SOURCE',
  133. '_GNU_SOURCE',
  134. 'PTHREADS',
  135. 'HAVE_POSIX_MEMALIGN',
  136. ])
  137. if platform == 'darwin':
  138. env.Append(CPPDEFINES = ['_DARWIN_C_SOURCE'])
  139. env.Append(CPPPATH = ['/usr/X11R6/include'])
  140. env.Append(LIBPATH = ['/usr/X11R6/lib'])
  141. env.Append(LIBS = [
  142. 'm',
  143. 'pthread',
  144. 'expat',
  145. 'dl',
  146. ])
  147. # DRI
  148. if dri:
  149. env.ParseConfig('pkg-config --cflags --libs libdrm')
  150. env.Append(CPPDEFINES = [
  151. ('USE_EXTERNAL_DXTN_LIB', '1'),
  152. 'IN_DRI_DRIVER',
  153. 'GLX_DIRECT_RENDERING',
  154. 'GLX_INDIRECT_RENDERING',
  155. ])
  156. # LLVM support in the Draw module
  157. if drawllvm:
  158. env.Append(CPPDEFINES = ['DRAW_LLVM'])
  159. # libGL
  160. if platform in ('linux', 'freebsd', 'darwin'):
  161. env.Append(LIBS = [
  162. 'X11',
  163. 'Xext',
  164. 'Xxf86vm',
  165. 'Xdamage',
  166. 'Xfixes',
  167. ])
  168. # for debugging
  169. #print env.Dump()
  170. Export('env')
  171. #######################################################################
  172. # Invoke SConscripts
  173. # TODO: Build several variants at the same time?
  174. # http://www.scons.org/wiki/SimultaneousVariantBuilds
  175. if env['platform'] != common.default_platform:
  176. # GLSL code has to be built twice -- one for the host OS, another for the target OS...
  177. host_env = Environment(
  178. # options are ignored
  179. # default tool is used
  180. tools = ['default', 'custom'],
  181. toolpath = ['#scons'],
  182. ENV = os.environ,
  183. )
  184. host_env['platform'] = common.default_platform
  185. host_env['machine'] = common.default_machine
  186. host_env['debug'] = env['debug']
  187. SConscript(
  188. 'src/glsl/SConscript',
  189. variant_dir = os.path.join(env['build'], 'host'),
  190. duplicate = 0, # http://www.scons.org/doc/0.97/HTML/scons-user/x2261.html
  191. exports={'env':host_env},
  192. )
  193. SConscript(
  194. 'src/SConscript',
  195. variant_dir = env['build'],
  196. duplicate = 0 # http://www.scons.org/doc/0.97/HTML/scons-user/x2261.html
  197. )
  198. env.Default('src')
  199. SConscript(
  200. 'progs/SConscript',
  201. variant_dir = os.path.join('progs', env['build']),
  202. duplicate = 0 # http://www.scons.org/doc/0.97/HTML/scons-user/x2261.html
  203. )