Clone of mesa.
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

SConstruct 5.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228
  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. # TODO: auto-detect defaults
  28. opts = Options('config.py')
  29. opts.Add(BoolOption('debug', 'build debug version', False))
  30. opts.Add(BoolOption('dri', 'build dri drivers', False))
  31. opts.Add(EnumOption('machine', 'use machine-specific assembly code', 'x86',
  32. allowed_values=('generic', 'x86', 'x86-64')))
  33. env = Environment(
  34. options = opts,
  35. ENV = os.environ)
  36. Help(opts.GenerateHelpText(env))
  37. # for debugging
  38. #print env.Dump()
  39. if 0:
  40. # platform will be typically 'posix' or 'win32'
  41. platform = env['PLATFORM']
  42. else:
  43. # platform will be one of 'linux', 'freebsd', 'win32', 'darwin', etc.
  44. platform = sys.platform
  45. if platform == 'linux2':
  46. platform = 'linux'
  47. # replicate options values in local variables
  48. debug = env['debug']
  49. dri = env['dri']
  50. machine = env['machine']
  51. # derived options
  52. x86 = machine == 'x86'
  53. gcc = platform in ('posix', 'linux', 'freebsd', 'darwin')
  54. msvc = platform == 'win32'
  55. Export([
  56. 'debug',
  57. 'x86',
  58. 'dri',
  59. 'platform',
  60. 'gcc',
  61. 'msvc',
  62. ])
  63. #######################################################################
  64. # Environment setup
  65. #
  66. # TODO: put the compiler specific settings in seperate files
  67. # TODO: auto-detect as much as possible
  68. # Optimization flags
  69. if gcc:
  70. if debug:
  71. env.Append(CFLAGS = '-O0 -g3')
  72. env.Append(CXXFLAGS = '-O0 -g3')
  73. else:
  74. env.Append(CFLAGS = '-O3 -g3')
  75. env.Append(CXXFLAGS = '-O3 -g3')
  76. env.Append(CFLAGS = '-Wall -Wmissing-prototypes -std=c99 -ffast-math -pedantic')
  77. env.Append(CXXFLAGS = '-Wall -pedantic')
  78. # Be nice to Eclipse
  79. env.Append(CFLAGS = '-fmessage-length=0')
  80. env.Append(CXXFLAGS = '-fmessage-length=0')
  81. # Defines
  82. if debug:
  83. env.Append(CPPDEFINES = ['DEBUG'])
  84. else:
  85. env.Append(CPPDEFINES = ['NDEBUG'])
  86. # Includes
  87. env.Append(CPPPATH = [
  88. '#/include',
  89. '#/src/mesa',
  90. '#/src/mesa/main',
  91. '#/src/mesa/pipe',
  92. ])
  93. # x86 assembly
  94. if x86:
  95. env.Append(CPPDEFINES = [
  96. 'USE_X86_ASM',
  97. 'USE_MMX_ASM',
  98. 'USE_3DNOW_ASM',
  99. 'USE_SSE_ASM',
  100. ])
  101. if gcc:
  102. env.Append(CFLAGS = '-m32')
  103. env.Append(CXXFLAGS = '-m32')
  104. # Posix
  105. if platform in ('posix', 'linux', 'freebsd', 'darwin'):
  106. env.Append(CPPDEFINES = [
  107. '_POSIX_SOURCE',
  108. ('_POSIX_C_SOURCE', '199309L'),
  109. '_SVID_SOURCE',
  110. '_BSD_SOURCE',
  111. '_GNU_SOURCE',
  112. 'PTHREADS',
  113. 'HAVE_POSIX_MEMALIGN',
  114. ])
  115. env.Append(CPPPATH = ['/usr/X11R6/include'])
  116. env.Append(LIBPATH = ['/usr/X11R6/lib'])
  117. env.Append(LIBS = [
  118. 'm',
  119. 'pthread',
  120. 'expat',
  121. 'dl',
  122. ])
  123. # DRI
  124. if dri:
  125. env.ParseConfig('pkg-config --cflags --libs libdrm')
  126. env.Append(CPPDEFINES = [
  127. ('USE_EXTERNAL_DXTN_LIB', '1'),
  128. 'IN_DRI_DRIVER',
  129. 'GLX_DIRECT_RENDERING',
  130. 'GLX_INDIRECT_RENDERING',
  131. ])
  132. # libGL
  133. if 1:
  134. env.Append(LIBS = [
  135. 'X11',
  136. 'Xext',
  137. 'Xxf86vm',
  138. 'Xdamage',
  139. 'Xfixes',
  140. ])
  141. Export('env')
  142. #######################################################################
  143. # Convenience Library Builder
  144. # based on the stock StaticLibrary and SharedLibrary builders
  145. def createConvenienceLibBuilder(env):
  146. """This is a utility function that creates the ConvenienceLibrary
  147. Builder in an Environment if it is not there already.
  148. If it is already there, we return the existing one.
  149. """
  150. try:
  151. convenience_lib = env['BUILDERS']['ConvenienceLibrary']
  152. except KeyError:
  153. action_list = [ Action("$ARCOM", "$ARCOMSTR") ]
  154. if env.Detect('ranlib'):
  155. ranlib_action = Action("$RANLIBCOM", "$RANLIBCOMSTR")
  156. action_list.append(ranlib_action)
  157. convenience_lib = Builder(action = action_list,
  158. emitter = '$LIBEMITTER',
  159. prefix = '$LIBPREFIX',
  160. suffix = '$LIBSUFFIX',
  161. src_suffix = '$SHOBJSUFFIX',
  162. src_builder = 'SharedObject')
  163. env['BUILDERS']['ConvenienceLibrary'] = convenience_lib
  164. env['BUILDERS']['Library'] = convenience_lib
  165. return convenience_lib
  166. createConvenienceLibBuilder(env)
  167. #######################################################################
  168. # Invoke SConscripts
  169. # Put build output in a separate dir, which depends on the current configuration
  170. # See also http://www.scons.org/wiki/AdvancedBuildExample
  171. build_topdir = 'build'
  172. build_subdir = platform
  173. if dri:
  174. build_subdir += "-dri"
  175. if x86:
  176. build_subdir += "-x86"
  177. if debug:
  178. build_subdir += "-debug"
  179. build_dir = os.path.join(build_topdir, build_subdir)
  180. # TODO: Build several variants at the same time?
  181. # http://www.scons.org/wiki/SimultaneousVariantBuilds
  182. SConscript(
  183. 'src/mesa/SConscript',
  184. build_dir = build_dir,
  185. duplicate = 0 # http://www.scons.org/doc/0.97/HTML/scons-user/x2261.html
  186. )