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.

gallium.py 22KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624
  1. """gallium
  2. Frontend-tool for Gallium3D architecture.
  3. """
  4. #
  5. # Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas.
  6. # All Rights Reserved.
  7. #
  8. # Permission is hereby granted, free of charge, to any person obtaining a
  9. # copy of this software and associated documentation files (the
  10. # "Software"), to deal in the Software without restriction, including
  11. # without limitation the rights to use, copy, modify, merge, publish,
  12. # distribute, sub license, and/or sell copies of the Software, and to
  13. # permit persons to whom the Software is furnished to do so, subject to
  14. # the following conditions:
  15. #
  16. # The above copyright notice and this permission notice (including the
  17. # next paragraph) shall be included in all copies or substantial portions
  18. # of the Software.
  19. #
  20. # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  21. # OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  22. # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
  23. # IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
  24. # ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
  25. # TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
  26. # SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  27. #
  28. import distutils.version
  29. import os
  30. import os.path
  31. import re
  32. import subprocess
  33. import platform as _platform
  34. import SCons.Action
  35. import SCons.Builder
  36. import SCons.Scanner
  37. def symlink(target, source, env):
  38. target = str(target[0])
  39. source = str(source[0])
  40. if os.path.islink(target) or os.path.exists(target):
  41. os.remove(target)
  42. os.symlink(os.path.basename(source), target)
  43. def install(env, source, subdir):
  44. target_dir = os.path.join(env.Dir('#.').srcnode().abspath, env['build_dir'], subdir)
  45. return env.Install(target_dir, source)
  46. def install_program(env, source):
  47. return install(env, source, 'bin')
  48. def install_shared_library(env, sources, version = ()):
  49. targets = []
  50. install_dir = os.path.join(env.Dir('#.').srcnode().abspath, env['build_dir'])
  51. version = tuple(map(str, version))
  52. if env['SHLIBSUFFIX'] == '.dll':
  53. dlls = env.FindIxes(sources, 'SHLIBPREFIX', 'SHLIBSUFFIX')
  54. targets += install(env, dlls, 'bin')
  55. libs = env.FindIxes(sources, 'LIBPREFIX', 'LIBSUFFIX')
  56. targets += install(env, libs, 'lib')
  57. else:
  58. for source in sources:
  59. target_dir = os.path.join(install_dir, 'lib')
  60. target_name = '.'.join((str(source),) + version)
  61. last = env.InstallAs(os.path.join(target_dir, target_name), source)
  62. targets += last
  63. while len(version):
  64. version = version[:-1]
  65. target_name = '.'.join((str(source),) + version)
  66. action = SCons.Action.Action(symlink, " Symlinking $TARGET ...")
  67. last = env.Command(os.path.join(target_dir, target_name), last, action)
  68. targets += last
  69. return targets
  70. def createInstallMethods(env):
  71. env.AddMethod(install_program, 'InstallProgram')
  72. env.AddMethod(install_shared_library, 'InstallSharedLibrary')
  73. def num_jobs():
  74. try:
  75. return int(os.environ['NUMBER_OF_PROCESSORS'])
  76. except (ValueError, KeyError):
  77. pass
  78. try:
  79. return os.sysconf('SC_NPROCESSORS_ONLN')
  80. except (ValueError, OSError, AttributeError):
  81. pass
  82. try:
  83. return int(os.popen2("sysctl -n hw.ncpu")[1].read())
  84. except ValueError:
  85. pass
  86. return 1
  87. def pkg_config_modules(env, name, modules):
  88. '''Simple wrapper for pkg-config.'''
  89. env[name] = False
  90. if env['platform'] == 'windows':
  91. return
  92. if not env.Detect('pkg-config'):
  93. return
  94. if subprocess.call(["pkg-config", "--exists", ' '.join(modules)]) != 0:
  95. return
  96. # Put -I and -L flags directly into the environment, as these don't affect
  97. # the compilation of targets that do not use them
  98. try:
  99. env.ParseConfig('pkg-config --cflags-only-I --libs-only-L ' + ' '.join(modules))
  100. except OSError:
  101. return
  102. # Other flags may affect the compilation of unrelated targets, so store
  103. # them with a prefix, (e.g., XXX_CFLAGS, XXX_LIBS, etc)
  104. try:
  105. flags = env.ParseFlags('!pkg-config --cflags-only-other --libs-only-l --libs-only-other ' + ' '.join(modules))
  106. except OSError:
  107. return
  108. prefix = name.upper() + '_'
  109. for flag_name, flag_value in flags.iteritems():
  110. env[prefix + flag_name] = flag_value
  111. env[name] = True
  112. def generate(env):
  113. """Common environment generation code"""
  114. # Tell tools which machine to compile for
  115. env['TARGET_ARCH'] = env['machine']
  116. env['MSVS_ARCH'] = env['machine']
  117. # Toolchain
  118. platform = env['platform']
  119. if env['toolchain'] == 'default':
  120. if platform == 'winddk':
  121. env['toolchain'] = 'winddk'
  122. elif platform == 'wince':
  123. env['toolchain'] = 'wcesdk'
  124. env.Tool(env['toolchain'])
  125. # Allow override compiler and specify additional flags from environment
  126. if os.environ.has_key('CC'):
  127. env['CC'] = os.environ['CC']
  128. # Update CCVERSION to match
  129. pipe = SCons.Action._subproc(env, [env['CC'], '--version'],
  130. stdin = 'devnull',
  131. stderr = 'devnull',
  132. stdout = subprocess.PIPE)
  133. if pipe.wait() == 0:
  134. line = pipe.stdout.readline()
  135. match = re.search(r'[0-9]+(\.[0-9]+)+', line)
  136. if match:
  137. env['CCVERSION'] = match.group(0)
  138. if os.environ.has_key('CFLAGS'):
  139. env['CCFLAGS'] += SCons.Util.CLVar(os.environ['CFLAGS'])
  140. if os.environ.has_key('CXX'):
  141. env['CXX'] = os.environ['CXX']
  142. if os.environ.has_key('CXXFLAGS'):
  143. env['CXXFLAGS'] += SCons.Util.CLVar(os.environ['CXXFLAGS'])
  144. if os.environ.has_key('LDFLAGS'):
  145. env['LINKFLAGS'] += SCons.Util.CLVar(os.environ['LDFLAGS'])
  146. env['gcc'] = 'gcc' in os.path.basename(env['CC']).split('-')
  147. env['msvc'] = env['CC'] == 'cl'
  148. if env['msvc'] and env['toolchain'] == 'default' and env['machine'] == 'x86_64':
  149. # MSVC x64 support is broken in earlier versions of scons
  150. env.EnsurePythonVersion(2, 0)
  151. # shortcuts
  152. machine = env['machine']
  153. platform = env['platform']
  154. x86 = env['machine'] == 'x86'
  155. ppc = env['machine'] == 'ppc'
  156. gcc = env['gcc']
  157. msvc = env['msvc']
  158. # Determine whether we are cross compiling; in particular, whether we need
  159. # to compile code generators with a different compiler as the target code.
  160. host_platform = _platform.system().lower()
  161. if host_platform.startswith('cygwin'):
  162. host_platform = 'cygwin'
  163. host_machine = os.environ.get('PROCESSOR_ARCHITEW6432', os.environ.get('PROCESSOR_ARCHITECTURE', _platform.machine()))
  164. host_machine = {
  165. 'x86': 'x86',
  166. 'i386': 'x86',
  167. 'i486': 'x86',
  168. 'i586': 'x86',
  169. 'i686': 'x86',
  170. 'ppc' : 'ppc',
  171. 'AMD64': 'x86_64',
  172. 'x86_64': 'x86_64',
  173. }.get(host_machine, 'generic')
  174. env['crosscompile'] = platform != host_platform
  175. if machine == 'x86_64' and host_machine != 'x86_64':
  176. env['crosscompile'] = True
  177. env['hostonly'] = False
  178. # Backwards compatability with the debug= profile= options
  179. if env['build'] == 'debug':
  180. if not env['debug']:
  181. print 'scons: warning: debug option is deprecated and will be removed eventually; use instead'
  182. print
  183. print ' scons build=release'
  184. print
  185. env['build'] = 'release'
  186. if env['profile']:
  187. print 'scons: warning: profile option is deprecated and will be removed eventually; use instead'
  188. print
  189. print ' scons build=profile'
  190. print
  191. env['build'] = 'profile'
  192. if False:
  193. # Enforce SConscripts to use the new build variable
  194. env.popitem('debug')
  195. env.popitem('profile')
  196. else:
  197. # Backwards portability with older sconscripts
  198. if env['build'] in ('debug', 'checked'):
  199. env['debug'] = True
  200. env['profile'] = False
  201. if env['build'] == 'profile':
  202. env['debug'] = False
  203. env['profile'] = True
  204. if env['build'] == 'release':
  205. env['debug'] = False
  206. env['profile'] = False
  207. # Put build output in a separate dir, which depends on the current
  208. # configuration. See also http://www.scons.org/wiki/AdvancedBuildExample
  209. build_topdir = 'build'
  210. build_subdir = env['platform']
  211. if env['machine'] != 'generic':
  212. build_subdir += '-' + env['machine']
  213. if env['build'] != 'release':
  214. build_subdir += '-' + env['build']
  215. build_dir = os.path.join(build_topdir, build_subdir)
  216. # Place the .sconsign file in the build dir too, to avoid issues with
  217. # different scons versions building the same source file
  218. env['build_dir'] = build_dir
  219. env.SConsignFile(os.path.join(build_dir, '.sconsign'))
  220. if 'SCONS_CACHE_DIR' in os.environ:
  221. print 'scons: Using build cache in %s.' % (os.environ['SCONS_CACHE_DIR'],)
  222. env.CacheDir(os.environ['SCONS_CACHE_DIR'])
  223. env['CONFIGUREDIR'] = os.path.join(build_dir, 'conf')
  224. env['CONFIGURELOG'] = os.path.join(os.path.abspath(build_dir), 'config.log')
  225. # Parallel build
  226. if env.GetOption('num_jobs') <= 1:
  227. env.SetOption('num_jobs', num_jobs())
  228. env.Decider('MD5-timestamp')
  229. env.SetOption('max_drift', 60)
  230. # C preprocessor options
  231. cppdefines = []
  232. if env['build'] in ('debug', 'checked'):
  233. cppdefines += ['DEBUG']
  234. else:
  235. cppdefines += ['NDEBUG']
  236. if env['build'] == 'profile':
  237. cppdefines += ['PROFILE']
  238. if platform == 'windows':
  239. cppdefines += [
  240. 'WIN32',
  241. '_WINDOWS',
  242. #'_UNICODE',
  243. #'UNICODE',
  244. # http://msdn.microsoft.com/en-us/library/aa383745.aspx
  245. ('_WIN32_WINNT', '0x0601'),
  246. ('WINVER', '0x0601'),
  247. ]
  248. if msvc and env['toolchain'] != 'winddk':
  249. cppdefines += [
  250. 'VC_EXTRALEAN',
  251. '_USE_MATH_DEFINES',
  252. '_CRT_SECURE_NO_WARNINGS',
  253. '_CRT_SECURE_NO_DEPRECATE',
  254. '_SCL_SECURE_NO_WARNINGS',
  255. '_SCL_SECURE_NO_DEPRECATE',
  256. ]
  257. if env['build'] in ('debug', 'checked'):
  258. cppdefines += ['_DEBUG']
  259. if env['toolchain'] == 'winddk':
  260. # Mimic WINDDK's builtin flags. See also:
  261. # - WINDDK's bin/makefile.new i386mk.inc for more info.
  262. # - buildchk_wxp_x86.log files, generated by the WINDDK's build
  263. # - http://alter.org.ua/docs/nt_kernel/vc8_proj/
  264. if machine == 'x86':
  265. cppdefines += ['_X86_', 'i386']
  266. if machine == 'x86_64':
  267. cppdefines += ['_AMD64_', 'AMD64']
  268. if platform == 'winddk':
  269. cppdefines += [
  270. 'STD_CALL',
  271. ('CONDITION_HANDLING', '1'),
  272. ('NT_INST', '0'),
  273. ('WIN32', '100'),
  274. ('_NT1X_', '100'),
  275. ('WINNT', '1'),
  276. ('_WIN32_WINNT', '0x0501'), # minimum required OS version
  277. ('WINVER', '0x0501'),
  278. ('_WIN32_IE', '0x0603'),
  279. ('WIN32_LEAN_AND_MEAN', '1'),
  280. ('DEVL', '1'),
  281. ('__BUILDMACHINE__', 'WinDDK'),
  282. ('FPO', '0'),
  283. ]
  284. if env['build'] in ('debug', 'checked'):
  285. cppdefines += [('DBG', 1)]
  286. if platform == 'wince':
  287. cppdefines += [
  288. '_CRT_SECURE_NO_DEPRECATE',
  289. '_USE_32BIT_TIME_T',
  290. 'UNICODE',
  291. '_UNICODE',
  292. ('UNDER_CE', '600'),
  293. ('_WIN32_WCE', '0x600'),
  294. 'WINCEOEM',
  295. 'WINCEINTERNAL',
  296. 'WIN32',
  297. 'STRICT',
  298. 'x86',
  299. '_X86_',
  300. 'INTERNATIONAL',
  301. ('INTLMSG_CODEPAGE', '1252'),
  302. ]
  303. if platform == 'windows':
  304. cppdefines += ['PIPE_SUBSYSTEM_WINDOWS_USER']
  305. if platform == 'winddk':
  306. cppdefines += ['PIPE_SUBSYSTEM_WINDOWS_DISPLAY']
  307. if platform == 'wince':
  308. cppdefines += ['PIPE_SUBSYSTEM_WINDOWS_CE']
  309. cppdefines += ['PIPE_SUBSYSTEM_WINDOWS_CE_OGL']
  310. if platform == 'embedded':
  311. cppdefines += ['PIPE_OS_EMBEDDED']
  312. env.Append(CPPDEFINES = cppdefines)
  313. # C compiler options
  314. cflags = [] # C
  315. cxxflags = [] # C++
  316. ccflags = [] # C & C++
  317. if gcc:
  318. ccversion = env['CCVERSION']
  319. if env['build'] == 'debug':
  320. ccflags += ['-O0']
  321. elif ccversion.startswith('4.2.'):
  322. # gcc 4.2.x optimizer is broken
  323. print "warning: gcc 4.2.x optimizer is broken -- disabling optimizations"
  324. ccflags += ['-O0']
  325. else:
  326. ccflags += ['-O3']
  327. ccflags += ['-g3']
  328. if env['build'] in ('checked', 'profile'):
  329. # See http://code.google.com/p/jrfonseca/wiki/Gprof2Dot#Which_options_should_I_pass_to_gcc_when_compiling_for_profiling?
  330. ccflags += [
  331. '-fno-omit-frame-pointer',
  332. '-fno-optimize-sibling-calls',
  333. ]
  334. if env['machine'] == 'x86':
  335. ccflags += [
  336. '-m32',
  337. #'-march=pentium4',
  338. ]
  339. if distutils.version.LooseVersion(ccversion) >= distutils.version.LooseVersion('4.2') \
  340. and (platform != 'windows' or env['build'] == 'debug' or True):
  341. # NOTE: We need to ensure stack is realigned given that we
  342. # produce shared objects, and have no control over the stack
  343. # alignment policy of the application. Therefore we need
  344. # -mstackrealign ore -mincoming-stack-boundary=2.
  345. #
  346. # XXX: -O and -mstackrealign causes stack corruption on MinGW
  347. #
  348. # XXX: We could have SSE without -mstackrealign if we always used
  349. # __attribute__((force_align_arg_pointer)), but that's not
  350. # always the case.
  351. ccflags += [
  352. '-mstackrealign', # ensure stack is aligned
  353. '-mmmx', '-msse', '-msse2', # enable SIMD intrinsics
  354. #'-mfpmath=sse',
  355. ]
  356. if platform in ['windows', 'darwin']:
  357. # Workaround http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37216
  358. ccflags += ['-fno-common']
  359. if env['machine'] == 'x86_64':
  360. ccflags += ['-m64']
  361. if platform == 'darwin':
  362. ccflags += ['-fno-common']
  363. # See also:
  364. # - http://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html
  365. ccflags += [
  366. '-Wall',
  367. '-Wno-long-long',
  368. '-ffast-math',
  369. '-fmessage-length=0', # be nice to Eclipse
  370. ]
  371. cflags += [
  372. '-Wmissing-prototypes',
  373. '-std=gnu99',
  374. ]
  375. if distutils.version.LooseVersion(ccversion) >= distutils.version.LooseVersion('4.0'):
  376. ccflags += [
  377. '-Wmissing-field-initializers',
  378. ]
  379. if distutils.version.LooseVersion(ccversion) >= distutils.version.LooseVersion('4.2'):
  380. ccflags += [
  381. '-Werror=pointer-arith',
  382. ]
  383. cflags += [
  384. '-Werror=declaration-after-statement',
  385. ]
  386. if msvc:
  387. # See also:
  388. # - http://msdn.microsoft.com/en-us/library/19z1t1wy.aspx
  389. # - cl /?
  390. if env['build'] == 'debug':
  391. ccflags += [
  392. '/Od', # disable optimizations
  393. '/Oi', # enable intrinsic functions
  394. '/Oy-', # disable frame pointer omission
  395. ]
  396. else:
  397. ccflags += [
  398. '/O2', # optimize for speed
  399. ]
  400. if env['build'] == 'release':
  401. ccflags += [
  402. '/GL', # enable whole program optimization
  403. ]
  404. else:
  405. ccflags += [
  406. '/GL-', # disable whole program optimization
  407. ]
  408. ccflags += [
  409. '/fp:fast', # fast floating point
  410. '/W3', # warning level
  411. #'/Wp64', # enable 64 bit porting warnings
  412. ]
  413. if env['machine'] == 'x86':
  414. ccflags += [
  415. #'/arch:SSE2', # use the SSE2 instructions
  416. ]
  417. if platform == 'windows':
  418. ccflags += [
  419. # TODO
  420. ]
  421. if platform == 'winddk':
  422. ccflags += [
  423. '/Zl', # omit default library name in .OBJ
  424. '/Zp8', # 8bytes struct member alignment
  425. '/Gy', # separate functions for linker
  426. '/Gm-', # disable minimal rebuild
  427. '/WX', # treat warnings as errors
  428. '/Gz', # __stdcall Calling convention
  429. '/GX-', # disable C++ EH
  430. '/GR-', # disable C++ RTTI
  431. '/GF', # enable read-only string pooling
  432. '/G6', # optimize for PPro, P-II, P-III
  433. '/Ze', # enable extensions
  434. '/Gi-', # disable incremental compilation
  435. '/QIfdiv-', # disable Pentium FDIV fix
  436. '/hotpatch', # prepares an image for hotpatching.
  437. #'/Z7', #enable old-style debug info
  438. ]
  439. if platform == 'wince':
  440. # See also C:\WINCE600\public\common\oak\misc\makefile.def
  441. ccflags += [
  442. '/Zl', # omit default library name in .OBJ
  443. '/GF', # enable read-only string pooling
  444. '/GR-', # disable C++ RTTI
  445. '/GS', # enable security checks
  446. # Allow disabling language conformance to maintain backward compat
  447. #'/Zc:wchar_t-', # don't force wchar_t as native type, instead of typedef
  448. #'/Zc:forScope-', # don't enforce Standard C++ for scoping rules
  449. #'/wd4867',
  450. #'/wd4430',
  451. #'/MT',
  452. #'/U_MT',
  453. ]
  454. # Automatic pdb generation
  455. # See http://scons.tigris.org/issues/show_bug.cgi?id=1656
  456. env.EnsureSConsVersion(0, 98, 0)
  457. env['PDB'] = '${TARGET.base}.pdb'
  458. env.Append(CCFLAGS = ccflags)
  459. env.Append(CFLAGS = cflags)
  460. env.Append(CXXFLAGS = cxxflags)
  461. if env['platform'] == 'windows' and msvc:
  462. # Choose the appropriate MSVC CRT
  463. # http://msdn.microsoft.com/en-us/library/2kzt1wy3.aspx
  464. if env['build'] in ('debug', 'checked'):
  465. env.Append(CCFLAGS = ['/MTd'])
  466. env.Append(SHCCFLAGS = ['/LDd'])
  467. else:
  468. env.Append(CCFLAGS = ['/MT'])
  469. env.Append(SHCCFLAGS = ['/LD'])
  470. # Assembler options
  471. if gcc:
  472. if env['machine'] == 'x86':
  473. env.Append(ASFLAGS = ['-m32'])
  474. if env['machine'] == 'x86_64':
  475. env.Append(ASFLAGS = ['-m64'])
  476. # Linker options
  477. linkflags = []
  478. shlinkflags = []
  479. if gcc:
  480. if env['machine'] == 'x86':
  481. linkflags += ['-m32']
  482. if env['machine'] == 'x86_64':
  483. linkflags += ['-m64']
  484. if env['platform'] not in ('darwin'):
  485. shlinkflags += [
  486. '-Wl,-Bsymbolic',
  487. ]
  488. # Handle circular dependencies in the libraries
  489. if env['platform'] in ('darwin'):
  490. pass
  491. else:
  492. env['_LIBFLAGS'] = '-Wl,--start-group ' + env['_LIBFLAGS'] + ' -Wl,--end-group'
  493. if msvc:
  494. if env['build'] == 'release':
  495. # enable Link-time Code Generation
  496. linkflags += ['/LTCG']
  497. env.Append(ARFLAGS = ['/LTCG'])
  498. if platform == 'windows' and msvc:
  499. # See also:
  500. # - http://msdn2.microsoft.com/en-us/library/y0zzbyt4.aspx
  501. linkflags += [
  502. '/fixed:no',
  503. '/incremental:no',
  504. ]
  505. if platform == 'winddk':
  506. linkflags += [
  507. '/merge:_PAGE=PAGE',
  508. '/merge:_TEXT=.text',
  509. '/section:INIT,d',
  510. '/opt:ref',
  511. '/opt:icf',
  512. '/ignore:4198,4010,4037,4039,4065,4070,4078,4087,4089,4221',
  513. '/incremental:no',
  514. '/fullbuild',
  515. '/release',
  516. '/nodefaultlib',
  517. '/wx',
  518. '/debug',
  519. '/debugtype:cv',
  520. '/version:5.1',
  521. '/osversion:5.1',
  522. '/functionpadmin:5',
  523. '/safeseh',
  524. '/pdbcompress',
  525. '/stack:0x40000,0x1000',
  526. '/driver',
  527. '/align:0x80',
  528. '/subsystem:native,5.01',
  529. '/base:0x10000',
  530. '/entry:DrvEnableDriver',
  531. ]
  532. if env['build'] != 'release':
  533. linkflags += [
  534. '/MAP', # http://msdn.microsoft.com/en-us/library/k7xkk3e2.aspx
  535. ]
  536. if platform == 'wince':
  537. linkflags += [
  538. '/nodefaultlib',
  539. #'/incremental:no',
  540. #'/fullbuild',
  541. '/entry:_DllMainCRTStartup',
  542. ]
  543. env.Append(LINKFLAGS = linkflags)
  544. env.Append(SHLINKFLAGS = shlinkflags)
  545. # We have C++ in several libraries, so always link with the C++ compiler
  546. if env['gcc']:
  547. env['LINK'] = env['CXX']
  548. # Default libs
  549. env.Append(LIBS = [])
  550. # Load tools
  551. env.Tool('lex')
  552. env.Tool('yacc')
  553. if env['llvm']:
  554. env.Tool('llvm')
  555. pkg_config_modules(env, 'x11', ['x11', 'xext'])
  556. pkg_config_modules(env, 'drm', ['libdrm'])
  557. pkg_config_modules(env, 'drm_intel', ['libdrm_intel'])
  558. pkg_config_modules(env, 'drm_radeon', ['libdrm_radeon'])
  559. pkg_config_modules(env, 'xorg', ['xorg-server'])
  560. pkg_config_modules(env, 'kms', ['libkms'])
  561. env['dri'] = env['x11'] and env['drm']
  562. # Custom builders and methods
  563. env.Tool('custom')
  564. createInstallMethods(env)
  565. # for debugging
  566. #print env.Dump()
  567. def exists(env):
  568. return 1