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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239
  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. default_dri = 'yes'
  33. elif common.default_platform in ('winddk',):
  34. default_statetrackers = 'none'
  35. default_drivers = 'softpipe,i915simple'
  36. default_winsys = 'none'
  37. default_dri = 'no'
  38. else:
  39. default_drivers = 'all'
  40. default_winsys = 'all'
  41. default_dri = 'no'
  42. opts = common.Options()
  43. opts.Add(ListOption('statetrackers', 'state_trackers to build', default_statetrackers,
  44. ['mesa']))
  45. opts.Add(ListOption('drivers', 'pipe drivers to build', default_drivers,
  46. ['softpipe', 'failover', 'i915simple', 'i965simple', 'cell']))
  47. opts.Add(ListOption('winsys', 'winsys drivers to build', default_winsys,
  48. ['xlib', 'intel']))
  49. env = Environment(
  50. options = opts,
  51. ENV = os.environ)
  52. Help(opts.GenerateHelpText(env))
  53. # for debugging
  54. #print env.Dump()
  55. # replicate options values in local variables
  56. debug = env['debug']
  57. dri = env['dri']
  58. llvm = env['llvm']
  59. machine = env['machine']
  60. platform = env['platform']
  61. # derived options
  62. x86 = machine == 'x86'
  63. gcc = platform in ('linux', 'freebsd', 'darwin')
  64. msvc = platform in ('win32', 'winddk')
  65. Export([
  66. 'debug',
  67. 'x86',
  68. 'dri',
  69. 'llvm',
  70. 'platform',
  71. 'gcc',
  72. 'msvc',
  73. ])
  74. #######################################################################
  75. # Environment setup
  76. #
  77. # TODO: put the compiler specific settings in separate files
  78. # TODO: auto-detect as much as possible
  79. if platform == 'winddk':
  80. env.Tool('winddk', ['.'])
  81. env.Append(CPPPATH = [
  82. env['SDK_INC_PATH'],
  83. env['DDK_INC_PATH'],
  84. env['WDM_INC_PATH'],
  85. env['CRT_INC_PATH'],
  86. ])
  87. # Optimization flags
  88. if gcc:
  89. if debug:
  90. env.Append(CFLAGS = '-O0 -g3')
  91. env.Append(CXXFLAGS = '-O0 -g3')
  92. else:
  93. env.Append(CFLAGS = '-O3 -g3')
  94. env.Append(CXXFLAGS = '-O3 -g3')
  95. env.Append(CFLAGS = '-Wall -Wmissing-prototypes -Wno-long-long -ffast-math -pedantic')
  96. env.Append(CXXFLAGS = '-Wall -pedantic')
  97. # Be nice to Eclipse
  98. env.Append(CFLAGS = '-fmessage-length=0')
  99. env.Append(CXXFLAGS = '-fmessage-length=0')
  100. if msvc:
  101. env.Append(CFLAGS = '/W3')
  102. if debug:
  103. cflags = [
  104. '/Od', # disable optimizations
  105. '/Oy-', # disable frame pointer omission
  106. ]
  107. else:
  108. cflags = [
  109. '/Ox', # maximum optimizations
  110. '/Os', # favor code space
  111. ]
  112. env.Append(CFLAGS = cflags)
  113. env.Append(CXXFLAGS = cflags)
  114. # Put debugging information in a separate .pdb file for each object file as
  115. # descrived in the scons manpage
  116. env['CCPDBFLAGS'] = '/Zi /Fd${TARGET}.pdb'
  117. # Defines
  118. if debug:
  119. if gcc:
  120. env.Append(CPPDEFINES = ['DEBUG'])
  121. if msvc:
  122. env.Append(CPPDEFINES = [
  123. ('DBG', '1'),
  124. ('DEBUG', '1'),
  125. ('_DEBUG', '1'),
  126. ])
  127. else:
  128. env.Append(CPPDEFINES = ['NDEBUG'])
  129. # Includes
  130. env.Append(CPPPATH = [
  131. '#/include',
  132. '#/src/gallium/include',
  133. '#/src/gallium/auxiliary',
  134. '#/src/gallium/drivers',
  135. ])
  136. # x86 assembly
  137. if x86:
  138. env.Append(CPPDEFINES = [
  139. 'USE_X86_ASM',
  140. 'USE_MMX_ASM',
  141. 'USE_3DNOW_ASM',
  142. 'USE_SSE_ASM',
  143. ])
  144. if gcc:
  145. env.Append(CFLAGS = '-m32')
  146. env.Append(CXXFLAGS = '-m32')
  147. # Posix
  148. if platform in ('posix', 'linux', 'freebsd', 'darwin'):
  149. env.Append(CPPDEFINES = [
  150. '_POSIX_SOURCE',
  151. ('_POSIX_C_SOURCE', '199309L'),
  152. '_SVID_SOURCE',
  153. '_BSD_SOURCE',
  154. '_GNU_SOURCE',
  155. 'PTHREADS',
  156. 'HAVE_POSIX_MEMALIGN',
  157. ])
  158. env.Append(CPPPATH = ['/usr/X11R6/include'])
  159. env.Append(LIBPATH = ['/usr/X11R6/lib'])
  160. env.Append(LIBS = [
  161. 'm',
  162. 'pthread',
  163. 'expat',
  164. 'dl',
  165. ])
  166. # DRI
  167. if dri:
  168. env.ParseConfig('pkg-config --cflags --libs libdrm')
  169. env.Append(CPPDEFINES = [
  170. ('USE_EXTERNAL_DXTN_LIB', '1'),
  171. 'IN_DRI_DRIVER',
  172. 'GLX_DIRECT_RENDERING',
  173. 'GLX_INDIRECT_RENDERING',
  174. ])
  175. # LLVM
  176. if llvm:
  177. # See also http://www.scons.org/wiki/UsingPkgConfig
  178. env.ParseConfig('llvm-config --cflags --ldflags --libs')
  179. env.Append(CPPDEFINES = ['MESA_LLVM'])
  180. env.Append(CXXFLAGS = ['-Wno-long-long'])
  181. # libGL
  182. if platform not in ('winddk',):
  183. env.Append(LIBS = [
  184. 'X11',
  185. 'Xext',
  186. 'Xxf86vm',
  187. 'Xdamage',
  188. 'Xfixes',
  189. ])
  190. # Convenience library support
  191. common.createConvenienceLibBuilder(env)
  192. Export('env')
  193. #######################################################################
  194. # Invoke SConscripts
  195. # TODO: Build several variants at the same time?
  196. # http://www.scons.org/wiki/SimultaneousVariantBuilds
  197. SConscript(
  198. 'src/SConscript',
  199. build_dir = common.make_build_dir(env),
  200. duplicate = 0 # http://www.scons.org/doc/0.97/HTML/scons-user/x2261.html
  201. )