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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650
  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. # gcc's builtin memcmp is slower than glibc's
  332. # http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43052
  333. ccflags += ['-fno-builtin-memcmp']
  334. # Work around aliasing bugs - developers should comment this out
  335. ccflags += ['-fno-strict-aliasing']
  336. ccflags += ['-g']
  337. if env['build'] in ('checked', 'profile'):
  338. # See http://code.google.com/p/jrfonseca/wiki/Gprof2Dot#Which_options_should_I_pass_to_gcc_when_compiling_for_profiling?
  339. ccflags += [
  340. '-fno-omit-frame-pointer',
  341. '-fno-optimize-sibling-calls',
  342. ]
  343. if env['machine'] == 'x86':
  344. ccflags += [
  345. '-m32',
  346. #'-march=pentium4',
  347. ]
  348. if distutils.version.LooseVersion(ccversion) >= distutils.version.LooseVersion('4.2') \
  349. and (platform != 'windows' or env['build'] == 'debug' or True):
  350. # NOTE: We need to ensure stack is realigned given that we
  351. # produce shared objects, and have no control over the stack
  352. # alignment policy of the application. Therefore we need
  353. # -mstackrealign ore -mincoming-stack-boundary=2.
  354. #
  355. # XXX: -O and -mstackrealign causes stack corruption on MinGW
  356. #
  357. # XXX: We could have SSE without -mstackrealign if we always used
  358. # __attribute__((force_align_arg_pointer)), but that's not
  359. # always the case.
  360. ccflags += [
  361. '-mstackrealign', # ensure stack is aligned
  362. '-mmmx', '-msse', '-msse2', # enable SIMD intrinsics
  363. #'-mfpmath=sse',
  364. ]
  365. if platform in ['windows', 'darwin']:
  366. # Workaround http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37216
  367. ccflags += ['-fno-common']
  368. if env['machine'] == 'x86_64':
  369. ccflags += ['-m64']
  370. if platform == 'darwin':
  371. ccflags += ['-fno-common']
  372. if env['platform'] != 'windows':
  373. ccflags += ['-fvisibility=hidden']
  374. # See also:
  375. # - http://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html
  376. ccflags += [
  377. '-Wall',
  378. '-Wno-long-long',
  379. '-ffast-math',
  380. '-fmessage-length=0', # be nice to Eclipse
  381. ]
  382. cflags += [
  383. '-Wmissing-prototypes',
  384. '-std=gnu99',
  385. ]
  386. if distutils.version.LooseVersion(ccversion) >= distutils.version.LooseVersion('4.0'):
  387. ccflags += [
  388. '-Wmissing-field-initializers',
  389. ]
  390. if distutils.version.LooseVersion(ccversion) >= distutils.version.LooseVersion('4.2'):
  391. ccflags += [
  392. '-Wpointer-arith',
  393. ]
  394. cflags += [
  395. '-Wdeclaration-after-statement',
  396. ]
  397. if msvc:
  398. # See also:
  399. # - http://msdn.microsoft.com/en-us/library/19z1t1wy.aspx
  400. # - cl /?
  401. if env['build'] == 'debug':
  402. ccflags += [
  403. '/Od', # disable optimizations
  404. '/Oi', # enable intrinsic functions
  405. '/Oy-', # disable frame pointer omission
  406. ]
  407. else:
  408. ccflags += [
  409. '/O2', # optimize for speed
  410. ]
  411. if env['build'] == 'release':
  412. ccflags += [
  413. '/GL', # enable whole program optimization
  414. ]
  415. else:
  416. ccflags += [
  417. '/GL-', # disable whole program optimization
  418. ]
  419. ccflags += [
  420. '/fp:fast', # fast floating point
  421. '/W3', # warning level
  422. #'/Wp64', # enable 64 bit porting warnings
  423. ]
  424. if env['machine'] == 'x86':
  425. ccflags += [
  426. #'/arch:SSE2', # use the SSE2 instructions
  427. ]
  428. if platform == 'windows':
  429. ccflags += [
  430. # TODO
  431. ]
  432. if platform == 'winddk':
  433. ccflags += [
  434. '/Zl', # omit default library name in .OBJ
  435. '/Zp8', # 8bytes struct member alignment
  436. '/Gy', # separate functions for linker
  437. '/Gm-', # disable minimal rebuild
  438. '/WX', # treat warnings as errors
  439. '/Gz', # __stdcall Calling convention
  440. '/GX-', # disable C++ EH
  441. '/GR-', # disable C++ RTTI
  442. '/GF', # enable read-only string pooling
  443. '/G6', # optimize for PPro, P-II, P-III
  444. '/Ze', # enable extensions
  445. '/Gi-', # disable incremental compilation
  446. '/QIfdiv-', # disable Pentium FDIV fix
  447. '/hotpatch', # prepares an image for hotpatching.
  448. #'/Z7', #enable old-style debug info
  449. ]
  450. if platform == 'wince':
  451. # See also C:\WINCE600\public\common\oak\misc\makefile.def
  452. ccflags += [
  453. '/Zl', # omit default library name in .OBJ
  454. '/GF', # enable read-only string pooling
  455. '/GR-', # disable C++ RTTI
  456. '/GS', # enable security checks
  457. # Allow disabling language conformance to maintain backward compat
  458. #'/Zc:wchar_t-', # don't force wchar_t as native type, instead of typedef
  459. #'/Zc:forScope-', # don't enforce Standard C++ for scoping rules
  460. #'/wd4867',
  461. #'/wd4430',
  462. #'/MT',
  463. #'/U_MT',
  464. ]
  465. # Automatic pdb generation
  466. # See http://scons.tigris.org/issues/show_bug.cgi?id=1656
  467. env.EnsureSConsVersion(0, 98, 0)
  468. env['PDB'] = '${TARGET.base}.pdb'
  469. env.Append(CCFLAGS = ccflags)
  470. env.Append(CFLAGS = cflags)
  471. env.Append(CXXFLAGS = cxxflags)
  472. if env['platform'] == 'windows' and msvc:
  473. # Choose the appropriate MSVC CRT
  474. # http://msdn.microsoft.com/en-us/library/2kzt1wy3.aspx
  475. if env['build'] in ('debug', 'checked'):
  476. env.Append(CCFLAGS = ['/MTd'])
  477. env.Append(SHCCFLAGS = ['/LDd'])
  478. else:
  479. env.Append(CCFLAGS = ['/MT'])
  480. env.Append(SHCCFLAGS = ['/LD'])
  481. # Assembler options
  482. if gcc:
  483. if env['machine'] == 'x86':
  484. env.Append(ASFLAGS = ['-m32'])
  485. if env['machine'] == 'x86_64':
  486. env.Append(ASFLAGS = ['-m64'])
  487. # Linker options
  488. linkflags = []
  489. shlinkflags = []
  490. if gcc:
  491. if env['machine'] == 'x86':
  492. linkflags += ['-m32']
  493. if env['machine'] == 'x86_64':
  494. linkflags += ['-m64']
  495. if env['platform'] not in ('darwin'):
  496. shlinkflags += [
  497. '-Wl,-Bsymbolic',
  498. ]
  499. # Handle circular dependencies in the libraries
  500. if env['platform'] in ('darwin'):
  501. pass
  502. else:
  503. env['_LIBFLAGS'] = '-Wl,--start-group ' + env['_LIBFLAGS'] + ' -Wl,--end-group'
  504. if env['platform'] == 'windows':
  505. # Avoid depending on gcc runtime DLLs
  506. linkflags += ['-static-libgcc']
  507. if env['machine'] == 'x86_64':
  508. linkflags += ['-static-libstdc++']
  509. # Handle the @xx symbol munging of DLL exports
  510. shlinkflags += ['-Wl,--enable-stdcall-fixup']
  511. #shlinkflags += ['-Wl,--kill-at']
  512. if msvc:
  513. if env['build'] == 'release':
  514. # enable Link-time Code Generation
  515. linkflags += ['/LTCG']
  516. env.Append(ARFLAGS = ['/LTCG'])
  517. if platform == 'windows' and msvc:
  518. # See also:
  519. # - http://msdn2.microsoft.com/en-us/library/y0zzbyt4.aspx
  520. linkflags += [
  521. '/fixed:no',
  522. '/incremental:no',
  523. ]
  524. if platform == 'winddk':
  525. linkflags += [
  526. '/merge:_PAGE=PAGE',
  527. '/merge:_TEXT=.text',
  528. '/section:INIT,d',
  529. '/opt:ref',
  530. '/opt:icf',
  531. '/ignore:4198,4010,4037,4039,4065,4070,4078,4087,4089,4221',
  532. '/incremental:no',
  533. '/fullbuild',
  534. '/release',
  535. '/nodefaultlib',
  536. '/wx',
  537. '/debug',
  538. '/debugtype:cv',
  539. '/version:5.1',
  540. '/osversion:5.1',
  541. '/functionpadmin:5',
  542. '/safeseh',
  543. '/pdbcompress',
  544. '/stack:0x40000,0x1000',
  545. '/driver',
  546. '/align:0x80',
  547. '/subsystem:native,5.01',
  548. '/base:0x10000',
  549. '/entry:DrvEnableDriver',
  550. ]
  551. if env['build'] != 'release':
  552. linkflags += [
  553. '/MAP', # http://msdn.microsoft.com/en-us/library/k7xkk3e2.aspx
  554. ]
  555. if platform == 'wince':
  556. linkflags += [
  557. '/nodefaultlib',
  558. #'/incremental:no',
  559. #'/fullbuild',
  560. '/entry:_DllMainCRTStartup',
  561. ]
  562. env.Append(LINKFLAGS = linkflags)
  563. env.Append(SHLINKFLAGS = shlinkflags)
  564. # We have C++ in several libraries, so always link with the C++ compiler
  565. if env['gcc']:
  566. env['LINK'] = env['CXX']
  567. # Default libs
  568. libs = []
  569. if env['platform'] in ('posix', 'linux', 'freebsd', 'darwin'):
  570. libs += ['m', 'pthread', 'dl']
  571. env.Append(LIBS = libs)
  572. # OpenMP
  573. if env['openmp']:
  574. if env['msvc']:
  575. env.Append(CCFLAGS = ['/openmp'])
  576. # When building openmp release VS2008 link.exe crashes with LNK1103 error.
  577. # Workaround: overwrite PDB flags with empty value as it isn't required anyways
  578. if env['build'] == 'release':
  579. env['PDB'] = ''
  580. if env['gcc']:
  581. env.Append(CCFLAGS = ['-fopenmp'])
  582. env.Append(LIBS = ['gomp'])
  583. # Load tools
  584. env.Tool('lex')
  585. env.Tool('yacc')
  586. if env['llvm']:
  587. env.Tool('llvm')
  588. # Custom builders and methods
  589. env.Tool('custom')
  590. createInstallMethods(env)
  591. env.PkgCheckModules('X11', ['x11', 'xext', 'xdamage', 'xfixes'])
  592. env.PkgCheckModules('XF86VIDMODE', ['xxf86vm'])
  593. env.PkgCheckModules('DRM', ['libdrm'])
  594. env.PkgCheckModules('DRM_INTEL', ['libdrm_intel'])
  595. env.PkgCheckModules('DRM_RADEON', ['libdrm_radeon'])
  596. env.PkgCheckModules('XORG', ['xorg-server'])
  597. env.PkgCheckModules('KMS', ['libkms'])
  598. env.PkgCheckModules('UDEV', ['libudev'])
  599. env['dri'] = env['x11'] and env['drm']
  600. # for debugging
  601. #print env.Dump()
  602. def exists(env):
  603. return 1