Clone of mesa.
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

gallium.py 23KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647
  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 generate(env):
  88. """Common environment generation code"""
  89. # Tell tools which machine to compile for
  90. env['TARGET_ARCH'] = env['machine']
  91. env['MSVS_ARCH'] = env['machine']
  92. # Toolchain
  93. platform = env['platform']
  94. if env['toolchain'] == 'default':
  95. if platform == 'winddk':
  96. env['toolchain'] = 'winddk'
  97. elif platform == 'wince':
  98. env['toolchain'] = 'wcesdk'
  99. env.Tool(env['toolchain'])
  100. # Allow override compiler and specify additional flags from environment
  101. if os.environ.has_key('CC'):
  102. env['CC'] = os.environ['CC']
  103. # Update CCVERSION to match
  104. pipe = SCons.Action._subproc(env, [env['CC'], '--version'],
  105. stdin = 'devnull',
  106. stderr = 'devnull',
  107. stdout = subprocess.PIPE)
  108. if pipe.wait() == 0:
  109. line = pipe.stdout.readline()
  110. match = re.search(r'[0-9]+(\.[0-9]+)+', line)
  111. if match:
  112. env['CCVERSION'] = match.group(0)
  113. if os.environ.has_key('CFLAGS'):
  114. env['CCFLAGS'] += SCons.Util.CLVar(os.environ['CFLAGS'])
  115. if os.environ.has_key('CXX'):
  116. env['CXX'] = os.environ['CXX']
  117. if os.environ.has_key('CXXFLAGS'):
  118. env['CXXFLAGS'] += SCons.Util.CLVar(os.environ['CXXFLAGS'])
  119. if os.environ.has_key('LDFLAGS'):
  120. env['LINKFLAGS'] += SCons.Util.CLVar(os.environ['LDFLAGS'])
  121. env['gcc'] = 'gcc' in os.path.basename(env['CC']).split('-')
  122. env['msvc'] = env['CC'] == 'cl'
  123. if env['msvc'] and env['toolchain'] == 'default' and env['machine'] == 'x86_64':
  124. # MSVC x64 support is broken in earlier versions of scons
  125. env.EnsurePythonVersion(2, 0)
  126. # shortcuts
  127. machine = env['machine']
  128. platform = env['platform']
  129. x86 = env['machine'] == 'x86'
  130. ppc = env['machine'] == 'ppc'
  131. gcc = env['gcc']
  132. msvc = env['msvc']
  133. # Determine whether we are cross compiling; in particular, whether we need
  134. # to compile code generators with a different compiler as the target code.
  135. host_platform = _platform.system().lower()
  136. if host_platform.startswith('cygwin'):
  137. host_platform = 'cygwin'
  138. host_machine = os.environ.get('PROCESSOR_ARCHITEW6432', os.environ.get('PROCESSOR_ARCHITECTURE', _platform.machine()))
  139. host_machine = {
  140. 'x86': 'x86',
  141. 'i386': 'x86',
  142. 'i486': 'x86',
  143. 'i586': 'x86',
  144. 'i686': 'x86',
  145. 'ppc' : 'ppc',
  146. 'AMD64': 'x86_64',
  147. 'x86_64': 'x86_64',
  148. }.get(host_machine, 'generic')
  149. env['crosscompile'] = platform != host_platform
  150. if machine == 'x86_64' and host_machine != 'x86_64':
  151. env['crosscompile'] = True
  152. env['hostonly'] = False
  153. # Backwards compatability with the debug= profile= options
  154. if env['build'] == 'debug':
  155. if not env['debug']:
  156. print 'scons: warning: debug option is deprecated and will be removed eventually; use instead'
  157. print
  158. print ' scons build=release'
  159. print
  160. env['build'] = 'release'
  161. if env['profile']:
  162. print 'scons: warning: profile option is deprecated and will be removed eventually; use instead'
  163. print
  164. print ' scons build=profile'
  165. print
  166. env['build'] = 'profile'
  167. if False:
  168. # Enforce SConscripts to use the new build variable
  169. env.popitem('debug')
  170. env.popitem('profile')
  171. else:
  172. # Backwards portability with older sconscripts
  173. if env['build'] in ('debug', 'checked'):
  174. env['debug'] = True
  175. env['profile'] = False
  176. if env['build'] == 'profile':
  177. env['debug'] = False
  178. env['profile'] = True
  179. if env['build'] == 'release':
  180. env['debug'] = False
  181. env['profile'] = False
  182. # Put build output in a separate dir, which depends on the current
  183. # configuration. See also http://www.scons.org/wiki/AdvancedBuildExample
  184. build_topdir = 'build'
  185. build_subdir = env['platform']
  186. if env['embedded']:
  187. build_subdir = 'embedded-' + build_subdir
  188. if env['machine'] != 'generic':
  189. build_subdir += '-' + env['machine']
  190. if env['build'] != 'release':
  191. build_subdir += '-' + env['build']
  192. build_dir = os.path.join(build_topdir, build_subdir)
  193. # Place the .sconsign file in the build dir too, to avoid issues with
  194. # different scons versions building the same source file
  195. env['build_dir'] = build_dir
  196. env.SConsignFile(os.path.join(build_dir, '.sconsign'))
  197. if 'SCONS_CACHE_DIR' in os.environ:
  198. print 'scons: Using build cache in %s.' % (os.environ['SCONS_CACHE_DIR'],)
  199. env.CacheDir(os.environ['SCONS_CACHE_DIR'])
  200. env['CONFIGUREDIR'] = os.path.join(build_dir, 'conf')
  201. env['CONFIGURELOG'] = os.path.join(os.path.abspath(build_dir), 'config.log')
  202. # Parallel build
  203. if env.GetOption('num_jobs') <= 1:
  204. env.SetOption('num_jobs', num_jobs())
  205. env.Decider('MD5-timestamp')
  206. env.SetOption('max_drift', 60)
  207. # C preprocessor options
  208. cppdefines = []
  209. if env['build'] in ('debug', 'checked'):
  210. cppdefines += ['DEBUG']
  211. else:
  212. cppdefines += ['NDEBUG']
  213. if env['build'] == 'profile':
  214. cppdefines += ['PROFILE']
  215. if env['platform'] in ('posix', 'linux', 'freebsd', 'darwin'):
  216. cppdefines += [
  217. '_POSIX_SOURCE',
  218. ('_POSIX_C_SOURCE', '199309L'),
  219. '_SVID_SOURCE',
  220. '_BSD_SOURCE',
  221. '_GNU_SOURCE',
  222. 'PTHREADS',
  223. 'HAVE_POSIX_MEMALIGN',
  224. ]
  225. if env['platform'] == 'darwin':
  226. cppdefines += [
  227. '_DARWIN_C_SOURCE',
  228. 'GLX_USE_APPLEGL',
  229. 'GLX_DIRECT_RENDERING',
  230. ]
  231. else:
  232. cppdefines += [
  233. 'GLX_DIRECT_RENDERING',
  234. 'GLX_INDIRECT_RENDERING',
  235. ]
  236. if env['platform'] in ('linux', 'freebsd'):
  237. cppdefines += ['HAVE_ALIAS']
  238. else:
  239. cppdefines += ['GLX_ALIAS_UNSUPPORTED']
  240. if platform == 'windows':
  241. cppdefines += [
  242. 'WIN32',
  243. '_WINDOWS',
  244. #'_UNICODE',
  245. #'UNICODE',
  246. # http://msdn.microsoft.com/en-us/library/aa383745.aspx
  247. ('_WIN32_WINNT', '0x0601'),
  248. ('WINVER', '0x0601'),
  249. ]
  250. if gcc:
  251. cppdefines += [('__MSVCRT_VERSION__', '0x0700')]
  252. if msvc and env['toolchain'] != 'winddk':
  253. cppdefines += [
  254. 'VC_EXTRALEAN',
  255. '_USE_MATH_DEFINES',
  256. '_CRT_SECURE_NO_WARNINGS',
  257. '_CRT_SECURE_NO_DEPRECATE',
  258. '_SCL_SECURE_NO_WARNINGS',
  259. '_SCL_SECURE_NO_DEPRECATE',
  260. ]
  261. if env['build'] in ('debug', 'checked'):
  262. cppdefines += ['_DEBUG']
  263. if env['toolchain'] == 'winddk':
  264. # Mimic WINDDK's builtin flags. See also:
  265. # - WINDDK's bin/makefile.new i386mk.inc for more info.
  266. # - buildchk_wxp_x86.log files, generated by the WINDDK's build
  267. # - http://alter.org.ua/docs/nt_kernel/vc8_proj/
  268. if machine == 'x86':
  269. cppdefines += ['_X86_', 'i386']
  270. if machine == 'x86_64':
  271. cppdefines += ['_AMD64_', 'AMD64']
  272. if platform == 'winddk':
  273. cppdefines += [
  274. 'STD_CALL',
  275. ('CONDITION_HANDLING', '1'),
  276. ('NT_INST', '0'),
  277. ('WIN32', '100'),
  278. ('_NT1X_', '100'),
  279. ('WINNT', '1'),
  280. ('_WIN32_WINNT', '0x0501'), # minimum required OS version
  281. ('WINVER', '0x0501'),
  282. ('_WIN32_IE', '0x0603'),
  283. ('WIN32_LEAN_AND_MEAN', '1'),
  284. ('DEVL', '1'),
  285. ('__BUILDMACHINE__', 'WinDDK'),
  286. ('FPO', '0'),
  287. ]
  288. if env['build'] in ('debug', 'checked'):
  289. cppdefines += [('DBG', 1)]
  290. if platform == 'wince':
  291. cppdefines += [
  292. '_CRT_SECURE_NO_DEPRECATE',
  293. '_USE_32BIT_TIME_T',
  294. 'UNICODE',
  295. '_UNICODE',
  296. ('UNDER_CE', '600'),
  297. ('_WIN32_WCE', '0x600'),
  298. 'WINCEOEM',
  299. 'WINCEINTERNAL',
  300. 'WIN32',
  301. 'STRICT',
  302. 'x86',
  303. '_X86_',
  304. 'INTERNATIONAL',
  305. ('INTLMSG_CODEPAGE', '1252'),
  306. ]
  307. if platform == 'windows':
  308. cppdefines += ['PIPE_SUBSYSTEM_WINDOWS_USER']
  309. if platform == 'winddk':
  310. cppdefines += ['PIPE_SUBSYSTEM_WINDOWS_DISPLAY']
  311. if platform == 'wince':
  312. cppdefines += ['PIPE_SUBSYSTEM_WINDOWS_CE']
  313. cppdefines += ['PIPE_SUBSYSTEM_WINDOWS_CE_OGL']
  314. if env['embedded']:
  315. cppdefines += ['PIPE_SUBSYSTEM_EMBEDDED']
  316. env.Append(CPPDEFINES = cppdefines)
  317. # C compiler options
  318. cflags = [] # C
  319. cxxflags = [] # C++
  320. ccflags = [] # C & C++
  321. if gcc:
  322. ccversion = env['CCVERSION']
  323. if env['build'] == 'debug':
  324. ccflags += ['-O0']
  325. elif ccversion.startswith('4.2.'):
  326. # gcc 4.2.x optimizer is broken
  327. print "warning: gcc 4.2.x optimizer is broken -- disabling optimizations"
  328. ccflags += ['-O0']
  329. else:
  330. ccflags += ['-O3']
  331. # Work around aliasing bugs - developers should comment this out
  332. ccflags += ['-fno-strict-aliasing']
  333. ccflags += ['-g']
  334. if env['build'] in ('checked', 'profile'):
  335. # See http://code.google.com/p/jrfonseca/wiki/Gprof2Dot#Which_options_should_I_pass_to_gcc_when_compiling_for_profiling?
  336. ccflags += [
  337. '-fno-omit-frame-pointer',
  338. '-fno-optimize-sibling-calls',
  339. ]
  340. if env['machine'] == 'x86':
  341. ccflags += [
  342. '-m32',
  343. #'-march=pentium4',
  344. ]
  345. if distutils.version.LooseVersion(ccversion) >= distutils.version.LooseVersion('4.2') \
  346. and (platform != 'windows' or env['build'] == 'debug' or True):
  347. # NOTE: We need to ensure stack is realigned given that we
  348. # produce shared objects, and have no control over the stack
  349. # alignment policy of the application. Therefore we need
  350. # -mstackrealign ore -mincoming-stack-boundary=2.
  351. #
  352. # XXX: -O and -mstackrealign causes stack corruption on MinGW
  353. #
  354. # XXX: We could have SSE without -mstackrealign if we always used
  355. # __attribute__((force_align_arg_pointer)), but that's not
  356. # always the case.
  357. ccflags += [
  358. '-mstackrealign', # ensure stack is aligned
  359. '-mmmx', '-msse', '-msse2', # enable SIMD intrinsics
  360. #'-mfpmath=sse',
  361. ]
  362. if platform in ['windows', 'darwin']:
  363. # Workaround http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37216
  364. ccflags += ['-fno-common']
  365. if env['machine'] == 'x86_64':
  366. ccflags += ['-m64']
  367. if platform == 'darwin':
  368. ccflags += ['-fno-common']
  369. if env['platform'] != 'windows':
  370. ccflags += ['-fvisibility=hidden']
  371. # See also:
  372. # - http://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html
  373. ccflags += [
  374. '-Wall',
  375. '-Wno-long-long',
  376. '-ffast-math',
  377. '-fmessage-length=0', # be nice to Eclipse
  378. ]
  379. cflags += [
  380. '-Wmissing-prototypes',
  381. '-std=gnu99',
  382. ]
  383. if distutils.version.LooseVersion(ccversion) >= distutils.version.LooseVersion('4.0'):
  384. ccflags += [
  385. '-Wmissing-field-initializers',
  386. ]
  387. if distutils.version.LooseVersion(ccversion) >= distutils.version.LooseVersion('4.2'):
  388. ccflags += [
  389. '-Wpointer-arith',
  390. ]
  391. cflags += [
  392. '-Wdeclaration-after-statement',
  393. ]
  394. if msvc:
  395. # See also:
  396. # - http://msdn.microsoft.com/en-us/library/19z1t1wy.aspx
  397. # - cl /?
  398. if env['build'] == 'debug':
  399. ccflags += [
  400. '/Od', # disable optimizations
  401. '/Oi', # enable intrinsic functions
  402. '/Oy-', # disable frame pointer omission
  403. ]
  404. else:
  405. ccflags += [
  406. '/O2', # optimize for speed
  407. ]
  408. if env['build'] == 'release':
  409. ccflags += [
  410. '/GL', # enable whole program optimization
  411. ]
  412. else:
  413. ccflags += [
  414. '/GL-', # disable whole program optimization
  415. ]
  416. ccflags += [
  417. '/fp:fast', # fast floating point
  418. '/W3', # warning level
  419. #'/Wp64', # enable 64 bit porting warnings
  420. ]
  421. if env['machine'] == 'x86':
  422. ccflags += [
  423. #'/arch:SSE2', # use the SSE2 instructions
  424. ]
  425. if platform == 'windows':
  426. ccflags += [
  427. # TODO
  428. ]
  429. if platform == 'winddk':
  430. ccflags += [
  431. '/Zl', # omit default library name in .OBJ
  432. '/Zp8', # 8bytes struct member alignment
  433. '/Gy', # separate functions for linker
  434. '/Gm-', # disable minimal rebuild
  435. '/WX', # treat warnings as errors
  436. '/Gz', # __stdcall Calling convention
  437. '/GX-', # disable C++ EH
  438. '/GR-', # disable C++ RTTI
  439. '/GF', # enable read-only string pooling
  440. '/G6', # optimize for PPro, P-II, P-III
  441. '/Ze', # enable extensions
  442. '/Gi-', # disable incremental compilation
  443. '/QIfdiv-', # disable Pentium FDIV fix
  444. '/hotpatch', # prepares an image for hotpatching.
  445. #'/Z7', #enable old-style debug info
  446. ]
  447. if platform == 'wince':
  448. # See also C:\WINCE600\public\common\oak\misc\makefile.def
  449. ccflags += [
  450. '/Zl', # omit default library name in .OBJ
  451. '/GF', # enable read-only string pooling
  452. '/GR-', # disable C++ RTTI
  453. '/GS', # enable security checks
  454. # Allow disabling language conformance to maintain backward compat
  455. #'/Zc:wchar_t-', # don't force wchar_t as native type, instead of typedef
  456. #'/Zc:forScope-', # don't enforce Standard C++ for scoping rules
  457. #'/wd4867',
  458. #'/wd4430',
  459. #'/MT',
  460. #'/U_MT',
  461. ]
  462. # Automatic pdb generation
  463. # See http://scons.tigris.org/issues/show_bug.cgi?id=1656
  464. env.EnsureSConsVersion(0, 98, 0)
  465. env['PDB'] = '${TARGET.base}.pdb'
  466. env.Append(CCFLAGS = ccflags)
  467. env.Append(CFLAGS = cflags)
  468. env.Append(CXXFLAGS = cxxflags)
  469. if env['platform'] == 'windows' and msvc:
  470. # Choose the appropriate MSVC CRT
  471. # http://msdn.microsoft.com/en-us/library/2kzt1wy3.aspx
  472. if env['build'] in ('debug', 'checked'):
  473. env.Append(CCFLAGS = ['/MTd'])
  474. env.Append(SHCCFLAGS = ['/LDd'])
  475. else:
  476. env.Append(CCFLAGS = ['/MT'])
  477. env.Append(SHCCFLAGS = ['/LD'])
  478. # Assembler options
  479. if gcc:
  480. if env['machine'] == 'x86':
  481. env.Append(ASFLAGS = ['-m32'])
  482. if env['machine'] == 'x86_64':
  483. env.Append(ASFLAGS = ['-m64'])
  484. # Linker options
  485. linkflags = []
  486. shlinkflags = []
  487. if gcc:
  488. if env['machine'] == 'x86':
  489. linkflags += ['-m32']
  490. if env['machine'] == 'x86_64':
  491. linkflags += ['-m64']
  492. if env['platform'] not in ('darwin'):
  493. shlinkflags += [
  494. '-Wl,-Bsymbolic',
  495. ]
  496. # Handle circular dependencies in the libraries
  497. if env['platform'] in ('darwin'):
  498. pass
  499. else:
  500. env['_LIBFLAGS'] = '-Wl,--start-group ' + env['_LIBFLAGS'] + ' -Wl,--end-group'
  501. if env['platform'] == 'windows':
  502. # Avoid depending on gcc runtime DLLs
  503. linkflags += ['-static-libgcc']
  504. if env['machine'] == 'x86_64':
  505. linkflags += ['-static-libstdc++']
  506. # Handle the @xx symbol munging of DLL exports
  507. shlinkflags += ['-Wl,--enable-stdcall-fixup']
  508. #shlinkflags += ['-Wl,--kill-at']
  509. if msvc:
  510. if env['build'] == 'release':
  511. # enable Link-time Code Generation
  512. linkflags += ['/LTCG']
  513. env.Append(ARFLAGS = ['/LTCG'])
  514. if platform == 'windows' and msvc:
  515. # See also:
  516. # - http://msdn2.microsoft.com/en-us/library/y0zzbyt4.aspx
  517. linkflags += [
  518. '/fixed:no',
  519. '/incremental:no',
  520. ]
  521. if platform == 'winddk':
  522. linkflags += [
  523. '/merge:_PAGE=PAGE',
  524. '/merge:_TEXT=.text',
  525. '/section:INIT,d',
  526. '/opt:ref',
  527. '/opt:icf',
  528. '/ignore:4198,4010,4037,4039,4065,4070,4078,4087,4089,4221',
  529. '/incremental:no',
  530. '/fullbuild',
  531. '/release',
  532. '/nodefaultlib',
  533. '/wx',
  534. '/debug',
  535. '/debugtype:cv',
  536. '/version:5.1',
  537. '/osversion:5.1',
  538. '/functionpadmin:5',
  539. '/safeseh',
  540. '/pdbcompress',
  541. '/stack:0x40000,0x1000',
  542. '/driver',
  543. '/align:0x80',
  544. '/subsystem:native,5.01',
  545. '/base:0x10000',
  546. '/entry:DrvEnableDriver',
  547. ]
  548. if env['build'] != 'release':
  549. linkflags += [
  550. '/MAP', # http://msdn.microsoft.com/en-us/library/k7xkk3e2.aspx
  551. ]
  552. if platform == 'wince':
  553. linkflags += [
  554. '/nodefaultlib',
  555. #'/incremental:no',
  556. #'/fullbuild',
  557. '/entry:_DllMainCRTStartup',
  558. ]
  559. env.Append(LINKFLAGS = linkflags)
  560. env.Append(SHLINKFLAGS = shlinkflags)
  561. # We have C++ in several libraries, so always link with the C++ compiler
  562. if env['gcc']:
  563. env['LINK'] = env['CXX']
  564. # Default libs
  565. libs = []
  566. if env['platform'] in ('posix', 'linux', 'freebsd', 'darwin'):
  567. libs += ['m', 'pthread', 'dl']
  568. env.Append(LIBS = libs)
  569. # OpenMP
  570. if env['openmp']:
  571. if env['msvc']:
  572. env.Append(CCFLAGS = ['/openmp'])
  573. # When building openmp release VS2008 link.exe crashes with LNK1103 error.
  574. # Workaround: overwrite PDB flags with empty value as it isn't required anyways
  575. if env['build'] == 'release':
  576. env['PDB'] = ''
  577. if env['gcc']:
  578. env.Append(CCFLAGS = ['-fopenmp'])
  579. env.Append(LIBS = ['gomp'])
  580. # Load tools
  581. env.Tool('lex')
  582. env.Tool('yacc')
  583. if env['llvm']:
  584. env.Tool('llvm')
  585. # Custom builders and methods
  586. env.Tool('custom')
  587. createInstallMethods(env)
  588. env.PkgCheckModules('X11', ['x11', 'xext', 'xdamage', 'xfixes'])
  589. env.PkgCheckModules('XF86VIDMODE', ['xxf86vm'])
  590. env.PkgCheckModules('DRM', ['libdrm'])
  591. env.PkgCheckModules('DRM_INTEL', ['libdrm_intel'])
  592. env.PkgCheckModules('DRM_RADEON', ['libdrm_radeon'])
  593. env.PkgCheckModules('XORG', ['xorg-server'])
  594. env.PkgCheckModules('KMS', ['libkms'])
  595. env.PkgCheckModules('UDEV', ['libudev'])
  596. env['dri'] = env['x11'] and env['drm']
  597. # for debugging
  598. #print env.Dump()
  599. def exists(env):
  600. return 1