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 7.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296
  1. #######################################################################
  2. # Top-level SConstruct
  3. import os
  4. import os.path
  5. import sys
  6. #######################################################################
  7. # Configuration options
  8. #
  9. # For example, invoke scons as
  10. #
  11. # scons debug=1 dri=0 machine=x86
  12. #
  13. # to set configuration variables. Or you can write those options to a file
  14. # named config.py:
  15. #
  16. # # config.py
  17. # debug=1
  18. # dri=0
  19. # machine='x86'
  20. #
  21. # Invoke
  22. #
  23. # scons -h
  24. #
  25. # to get the full list of options. See scons manpage for more info.
  26. #
  27. platform_map = {
  28. 'linux2': 'linux',
  29. 'win32': 'winddk',
  30. }
  31. default_platform = platform_map.get(sys.platform, sys.platform)
  32. if default_platform in ('linux', 'freebsd', 'darwin'):
  33. default_statetrackers = 'mesa'
  34. default_drivers = 'softpipe,failover,i915simple,i965simple'
  35. default_winsys = 'xlib'
  36. elif default_platform in ('winddk',):
  37. default_statetrackers = 'none'
  38. default_drivers = 'softpipe,i915simple'
  39. default_winsys = 'none'
  40. else:
  41. default_drivers = 'all'
  42. default_winsys = 'all'
  43. # TODO: auto-detect defaults
  44. opts = Options('config.py')
  45. opts.Add(BoolOption('debug', 'build debug version', False))
  46. opts.Add(EnumOption('machine', 'use machine-specific assembly code', 'x86',
  47. allowed_values=('generic', 'x86', 'x86-64')))
  48. opts.Add(EnumOption('platform', 'target platform', default_platform,
  49. allowed_values=('linux', 'cell', 'winddk')))
  50. opts.Add(ListOption('statetrackers', 'state_trackers to build', default_statetrackers,
  51. [
  52. 'mesa',
  53. ],
  54. ))
  55. opts.Add(ListOption('drivers', 'pipe drivers to build', default_drivers,
  56. [
  57. 'softpipe',
  58. 'failover',
  59. 'i915simple',
  60. 'i965simple',
  61. 'cell',
  62. ],
  63. ))
  64. opts.Add(ListOption('winsys', 'winsys drivers to build', default_winsys,
  65. [
  66. 'xlib',
  67. 'intel',
  68. ],
  69. ))
  70. opts.Add(BoolOption('llvm', 'use LLVM', 'no'))
  71. opts.Add(BoolOption('dri', 'build DRI drivers', 'no'))
  72. env = Environment(
  73. options = opts,
  74. ENV = os.environ)
  75. Help(opts.GenerateHelpText(env))
  76. # for debugging
  77. #print env.Dump()
  78. # replicate options values in local variables
  79. debug = env['debug']
  80. dri = env['dri']
  81. llvm = env['llvm']
  82. machine = env['machine']
  83. platform = env['platform']
  84. # derived options
  85. x86 = machine == 'x86'
  86. gcc = platform in ('linux', 'freebsd', 'darwin')
  87. msvc = platform in ('win32', 'winddk')
  88. Export([
  89. 'debug',
  90. 'x86',
  91. 'dri',
  92. 'llvm',
  93. 'platform',
  94. 'gcc',
  95. 'msvc',
  96. ])
  97. #######################################################################
  98. # Environment setup
  99. #
  100. # TODO: put the compiler specific settings in separate files
  101. # TODO: auto-detect as much as possible
  102. if platform == 'winddk':
  103. import ntpath
  104. escape = env['ESCAPE']
  105. env.Tool('winddk', '.')
  106. if 'BASEDIR' in os.environ:
  107. WINDDK = os.environ['BASEDIR']
  108. else:
  109. WINDDK = "C:\\WINDDK\\3790.1830"
  110. # NOTE: We need this elaborate construct to get the absolute paths and
  111. # forward slashes to msvc unharmed when cross compiling from posix platforms
  112. env.Append(CPPFLAGS = [
  113. escape('/I' + ntpath.join(WINDDK, 'inc\\ddk\\wxp')),
  114. escape('/I' + ntpath.join(WINDDK, 'inc\\ddk\\wdm\\wxp')),
  115. escape('/I' + ntpath.join(WINDDK, 'inc\\crt')),
  116. ])
  117. env.Append(CPPDEFINES = [
  118. ('i386', '1'),
  119. ])
  120. if debug:
  121. env.Append(CPPDEFINES = ['DBG'])
  122. # Optimization flags
  123. if gcc:
  124. if debug:
  125. env.Append(CFLAGS = '-O0 -g3')
  126. env.Append(CXXFLAGS = '-O0 -g3')
  127. else:
  128. env.Append(CFLAGS = '-O3 -g3')
  129. env.Append(CXXFLAGS = '-O3 -g3')
  130. env.Append(CFLAGS = '-Wall -Wmissing-prototypes -Wno-long-long -ffast-math -pedantic')
  131. env.Append(CXXFLAGS = '-Wall -pedantic')
  132. # Be nice to Eclipse
  133. env.Append(CFLAGS = '-fmessage-length=0')
  134. env.Append(CXXFLAGS = '-fmessage-length=0')
  135. # Defines
  136. if debug:
  137. env.Append(CPPDEFINES = ['DEBUG'])
  138. else:
  139. env.Append(CPPDEFINES = ['NDEBUG'])
  140. # Includes
  141. env.Append(CPPPATH = [
  142. '#/include',
  143. '#/src/gallium/include',
  144. '#/src/gallium/auxiliary',
  145. '#/src/gallium/drivers',
  146. ])
  147. # x86 assembly
  148. if x86:
  149. env.Append(CPPDEFINES = [
  150. 'USE_X86_ASM',
  151. 'USE_MMX_ASM',
  152. 'USE_3DNOW_ASM',
  153. 'USE_SSE_ASM',
  154. ])
  155. if gcc:
  156. env.Append(CFLAGS = '-m32')
  157. env.Append(CXXFLAGS = '-m32')
  158. # Posix
  159. if platform in ('posix', 'linux', 'freebsd', 'darwin'):
  160. env.Append(CPPDEFINES = [
  161. '_POSIX_SOURCE',
  162. ('_POSIX_C_SOURCE', '199309L'),
  163. '_SVID_SOURCE',
  164. '_BSD_SOURCE',
  165. '_GNU_SOURCE',
  166. 'PTHREADS',
  167. 'HAVE_POSIX_MEMALIGN',
  168. ])
  169. env.Append(CPPPATH = ['/usr/X11R6/include'])
  170. env.Append(LIBPATH = ['/usr/X11R6/lib'])
  171. env.Append(LIBS = [
  172. 'm',
  173. 'pthread',
  174. 'expat',
  175. 'dl',
  176. ])
  177. # DRI
  178. if dri:
  179. env.ParseConfig('pkg-config --cflags --libs libdrm')
  180. env.Append(CPPDEFINES = [
  181. ('USE_EXTERNAL_DXTN_LIB', '1'),
  182. 'IN_DRI_DRIVER',
  183. 'GLX_DIRECT_RENDERING',
  184. 'GLX_INDIRECT_RENDERING',
  185. ])
  186. # LLVM
  187. if llvm:
  188. # See also http://www.scons.org/wiki/UsingPkgConfig
  189. env.ParseConfig('llvm-config --cflags --ldflags --libs')
  190. env.Append(CPPDEFINES = ['MESA_LLVM'])
  191. env.Append(CXXFLAGS = ['-Wno-long-long'])
  192. # libGL
  193. if 1:
  194. env.Append(LIBS = [
  195. 'X11',
  196. 'Xext',
  197. 'Xxf86vm',
  198. 'Xdamage',
  199. 'Xfixes',
  200. ])
  201. Export('env')
  202. #######################################################################
  203. # Convenience Library Builder
  204. # based on the stock StaticLibrary and SharedLibrary builders
  205. def createConvenienceLibBuilder(env):
  206. """This is a utility function that creates the ConvenienceLibrary
  207. Builder in an Environment if it is not there already.
  208. If it is already there, we return the existing one.
  209. """
  210. try:
  211. convenience_lib = env['BUILDERS']['ConvenienceLibrary']
  212. except KeyError:
  213. action_list = [ Action("$ARCOM", "$ARCOMSTR") ]
  214. if env.Detect('ranlib'):
  215. ranlib_action = Action("$RANLIBCOM", "$RANLIBCOMSTR")
  216. action_list.append(ranlib_action)
  217. convenience_lib = Builder(action = action_list,
  218. emitter = '$LIBEMITTER',
  219. prefix = '$LIBPREFIX',
  220. suffix = '$LIBSUFFIX',
  221. src_suffix = '$SHOBJSUFFIX',
  222. src_builder = 'SharedObject')
  223. env['BUILDERS']['ConvenienceLibrary'] = convenience_lib
  224. env['BUILDERS']['Library'] = convenience_lib
  225. return convenience_lib
  226. createConvenienceLibBuilder(env)
  227. #######################################################################
  228. # Invoke SConscripts
  229. # Put build output in a separate dir, which depends on the current configuration
  230. # See also http://www.scons.org/wiki/AdvancedBuildExample
  231. build_topdir = 'build'
  232. build_subdir = platform
  233. if dri:
  234. build_subdir += "-dri"
  235. if llvm:
  236. build_subdir += "-llvm"
  237. if x86:
  238. build_subdir += "-x86"
  239. if debug:
  240. build_subdir += "-debug"
  241. build_dir = os.path.join(build_topdir, build_subdir)
  242. # TODO: Build several variants at the same time?
  243. # http://www.scons.org/wiki/SimultaneousVariantBuilds
  244. SConscript(
  245. 'src/SConscript',
  246. build_dir = build_dir,
  247. duplicate = 0 # http://www.scons.org/doc/0.97/HTML/scons-user/x2261.html
  248. )