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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643
  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['embedded']:
  212. build_subdir = 'embedded-' + build_subdir
  213. if env['machine'] != 'generic':
  214. build_subdir += '-' + env['machine']
  215. if env['build'] != 'release':
  216. build_subdir += '-' + env['build']
  217. build_dir = os.path.join(build_topdir, build_subdir)
  218. # Place the .sconsign file in the build dir too, to avoid issues with
  219. # different scons versions building the same source file
  220. env['build_dir'] = build_dir
  221. env.SConsignFile(os.path.join(build_dir, '.sconsign'))
  222. if 'SCONS_CACHE_DIR' in os.environ:
  223. print 'scons: Using build cache in %s.' % (os.environ['SCONS_CACHE_DIR'],)
  224. env.CacheDir(os.environ['SCONS_CACHE_DIR'])
  225. env['CONFIGUREDIR'] = os.path.join(build_dir, 'conf')
  226. env['CONFIGURELOG'] = os.path.join(os.path.abspath(build_dir), 'config.log')
  227. # Parallel build
  228. if env.GetOption('num_jobs') <= 1:
  229. env.SetOption('num_jobs', num_jobs())
  230. env.Decider('MD5-timestamp')
  231. env.SetOption('max_drift', 60)
  232. # C preprocessor options
  233. cppdefines = []
  234. if env['build'] in ('debug', 'checked'):
  235. cppdefines += ['DEBUG']
  236. else:
  237. cppdefines += ['NDEBUG']
  238. if env['build'] == 'profile':
  239. cppdefines += ['PROFILE']
  240. if env['platform'] in ('posix', 'linux', 'freebsd', 'darwin'):
  241. cppdefines += [
  242. '_POSIX_SOURCE',
  243. ('_POSIX_C_SOURCE', '199309L'),
  244. '_SVID_SOURCE',
  245. '_BSD_SOURCE',
  246. '_GNU_SOURCE',
  247. 'PTHREADS',
  248. 'HAVE_POSIX_MEMALIGN',
  249. ]
  250. if env['platform'] == 'darwin':
  251. cppdefines += ['_DARWIN_C_SOURCE']
  252. if platform == 'windows':
  253. cppdefines += [
  254. 'WIN32',
  255. '_WINDOWS',
  256. #'_UNICODE',
  257. #'UNICODE',
  258. # http://msdn.microsoft.com/en-us/library/aa383745.aspx
  259. ('_WIN32_WINNT', '0x0601'),
  260. ('WINVER', '0x0601'),
  261. ]
  262. if msvc and env['toolchain'] != 'winddk':
  263. cppdefines += [
  264. 'VC_EXTRALEAN',
  265. '_USE_MATH_DEFINES',
  266. '_CRT_SECURE_NO_WARNINGS',
  267. '_CRT_SECURE_NO_DEPRECATE',
  268. '_SCL_SECURE_NO_WARNINGS',
  269. '_SCL_SECURE_NO_DEPRECATE',
  270. ]
  271. if env['build'] in ('debug', 'checked'):
  272. cppdefines += ['_DEBUG']
  273. if env['toolchain'] == 'winddk':
  274. # Mimic WINDDK's builtin flags. See also:
  275. # - WINDDK's bin/makefile.new i386mk.inc for more info.
  276. # - buildchk_wxp_x86.log files, generated by the WINDDK's build
  277. # - http://alter.org.ua/docs/nt_kernel/vc8_proj/
  278. if machine == 'x86':
  279. cppdefines += ['_X86_', 'i386']
  280. if machine == 'x86_64':
  281. cppdefines += ['_AMD64_', 'AMD64']
  282. if platform == 'winddk':
  283. cppdefines += [
  284. 'STD_CALL',
  285. ('CONDITION_HANDLING', '1'),
  286. ('NT_INST', '0'),
  287. ('WIN32', '100'),
  288. ('_NT1X_', '100'),
  289. ('WINNT', '1'),
  290. ('_WIN32_WINNT', '0x0501'), # minimum required OS version
  291. ('WINVER', '0x0501'),
  292. ('_WIN32_IE', '0x0603'),
  293. ('WIN32_LEAN_AND_MEAN', '1'),
  294. ('DEVL', '1'),
  295. ('__BUILDMACHINE__', 'WinDDK'),
  296. ('FPO', '0'),
  297. ]
  298. if env['build'] in ('debug', 'checked'):
  299. cppdefines += [('DBG', 1)]
  300. if platform == 'wince':
  301. cppdefines += [
  302. '_CRT_SECURE_NO_DEPRECATE',
  303. '_USE_32BIT_TIME_T',
  304. 'UNICODE',
  305. '_UNICODE',
  306. ('UNDER_CE', '600'),
  307. ('_WIN32_WCE', '0x600'),
  308. 'WINCEOEM',
  309. 'WINCEINTERNAL',
  310. 'WIN32',
  311. 'STRICT',
  312. 'x86',
  313. '_X86_',
  314. 'INTERNATIONAL',
  315. ('INTLMSG_CODEPAGE', '1252'),
  316. ]
  317. if platform == 'windows':
  318. cppdefines += ['PIPE_SUBSYSTEM_WINDOWS_USER']
  319. if platform == 'winddk':
  320. cppdefines += ['PIPE_SUBSYSTEM_WINDOWS_DISPLAY']
  321. if platform == 'wince':
  322. cppdefines += ['PIPE_SUBSYSTEM_WINDOWS_CE']
  323. cppdefines += ['PIPE_SUBSYSTEM_WINDOWS_CE_OGL']
  324. if env['embedded']:
  325. cppdefines += ['PIPE_SUBSYSTEM_EMBEDDED']
  326. env.Append(CPPDEFINES = cppdefines)
  327. # C compiler options
  328. cflags = [] # C
  329. cxxflags = [] # C++
  330. ccflags = [] # C & C++
  331. if gcc:
  332. ccversion = env['CCVERSION']
  333. if env['build'] == 'debug':
  334. ccflags += ['-O0']
  335. elif ccversion.startswith('4.2.'):
  336. # gcc 4.2.x optimizer is broken
  337. print "warning: gcc 4.2.x optimizer is broken -- disabling optimizations"
  338. ccflags += ['-O0']
  339. else:
  340. ccflags += ['-O3']
  341. ccflags += ['-g3']
  342. if env['build'] in ('checked', 'profile'):
  343. # See http://code.google.com/p/jrfonseca/wiki/Gprof2Dot#Which_options_should_I_pass_to_gcc_when_compiling_for_profiling?
  344. ccflags += [
  345. '-fno-omit-frame-pointer',
  346. '-fno-optimize-sibling-calls',
  347. ]
  348. if env['machine'] == 'x86':
  349. ccflags += [
  350. '-m32',
  351. #'-march=pentium4',
  352. ]
  353. if distutils.version.LooseVersion(ccversion) >= distutils.version.LooseVersion('4.2') \
  354. and (platform != 'windows' or env['build'] == 'debug' or True):
  355. # NOTE: We need to ensure stack is realigned given that we
  356. # produce shared objects, and have no control over the stack
  357. # alignment policy of the application. Therefore we need
  358. # -mstackrealign ore -mincoming-stack-boundary=2.
  359. #
  360. # XXX: -O and -mstackrealign causes stack corruption on MinGW
  361. #
  362. # XXX: We could have SSE without -mstackrealign if we always used
  363. # __attribute__((force_align_arg_pointer)), but that's not
  364. # always the case.
  365. ccflags += [
  366. '-mstackrealign', # ensure stack is aligned
  367. '-mmmx', '-msse', '-msse2', # enable SIMD intrinsics
  368. #'-mfpmath=sse',
  369. ]
  370. if platform in ['windows', 'darwin']:
  371. # Workaround http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37216
  372. ccflags += ['-fno-common']
  373. if env['machine'] == 'x86_64':
  374. ccflags += ['-m64']
  375. if platform == 'darwin':
  376. ccflags += ['-fno-common']
  377. if env['platform'] != 'windows':
  378. ccflags += ['-fvisibility=hidden']
  379. # See also:
  380. # - http://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html
  381. ccflags += [
  382. '-Wall',
  383. '-Wno-long-long',
  384. '-ffast-math',
  385. '-fmessage-length=0', # be nice to Eclipse
  386. ]
  387. cflags += [
  388. '-Wmissing-prototypes',
  389. '-std=gnu99',
  390. ]
  391. if distutils.version.LooseVersion(ccversion) >= distutils.version.LooseVersion('4.0'):
  392. ccflags += [
  393. '-Wmissing-field-initializers',
  394. ]
  395. if distutils.version.LooseVersion(ccversion) >= distutils.version.LooseVersion('4.2'):
  396. ccflags += [
  397. '-Werror=pointer-arith',
  398. ]
  399. cflags += [
  400. '-Werror=declaration-after-statement',
  401. ]
  402. if msvc:
  403. # See also:
  404. # - http://msdn.microsoft.com/en-us/library/19z1t1wy.aspx
  405. # - cl /?
  406. if env['build'] == 'debug':
  407. ccflags += [
  408. '/Od', # disable optimizations
  409. '/Oi', # enable intrinsic functions
  410. '/Oy-', # disable frame pointer omission
  411. ]
  412. else:
  413. ccflags += [
  414. '/O2', # optimize for speed
  415. ]
  416. if env['build'] == 'release':
  417. ccflags += [
  418. '/GL', # enable whole program optimization
  419. ]
  420. else:
  421. ccflags += [
  422. '/GL-', # disable whole program optimization
  423. ]
  424. ccflags += [
  425. '/fp:fast', # fast floating point
  426. '/W3', # warning level
  427. #'/Wp64', # enable 64 bit porting warnings
  428. ]
  429. if env['machine'] == 'x86':
  430. ccflags += [
  431. #'/arch:SSE2', # use the SSE2 instructions
  432. ]
  433. if platform == 'windows':
  434. ccflags += [
  435. # TODO
  436. ]
  437. if platform == 'winddk':
  438. ccflags += [
  439. '/Zl', # omit default library name in .OBJ
  440. '/Zp8', # 8bytes struct member alignment
  441. '/Gy', # separate functions for linker
  442. '/Gm-', # disable minimal rebuild
  443. '/WX', # treat warnings as errors
  444. '/Gz', # __stdcall Calling convention
  445. '/GX-', # disable C++ EH
  446. '/GR-', # disable C++ RTTI
  447. '/GF', # enable read-only string pooling
  448. '/G6', # optimize for PPro, P-II, P-III
  449. '/Ze', # enable extensions
  450. '/Gi-', # disable incremental compilation
  451. '/QIfdiv-', # disable Pentium FDIV fix
  452. '/hotpatch', # prepares an image for hotpatching.
  453. #'/Z7', #enable old-style debug info
  454. ]
  455. if platform == 'wince':
  456. # See also C:\WINCE600\public\common\oak\misc\makefile.def
  457. ccflags += [
  458. '/Zl', # omit default library name in .OBJ
  459. '/GF', # enable read-only string pooling
  460. '/GR-', # disable C++ RTTI
  461. '/GS', # enable security checks
  462. # Allow disabling language conformance to maintain backward compat
  463. #'/Zc:wchar_t-', # don't force wchar_t as native type, instead of typedef
  464. #'/Zc:forScope-', # don't enforce Standard C++ for scoping rules
  465. #'/wd4867',
  466. #'/wd4430',
  467. #'/MT',
  468. #'/U_MT',
  469. ]
  470. # Automatic pdb generation
  471. # See http://scons.tigris.org/issues/show_bug.cgi?id=1656
  472. env.EnsureSConsVersion(0, 98, 0)
  473. env['PDB'] = '${TARGET.base}.pdb'
  474. env.Append(CCFLAGS = ccflags)
  475. env.Append(CFLAGS = cflags)
  476. env.Append(CXXFLAGS = cxxflags)
  477. if env['platform'] == 'windows' and msvc:
  478. # Choose the appropriate MSVC CRT
  479. # http://msdn.microsoft.com/en-us/library/2kzt1wy3.aspx
  480. if env['build'] in ('debug', 'checked'):
  481. env.Append(CCFLAGS = ['/MTd'])
  482. env.Append(SHCCFLAGS = ['/LDd'])
  483. else:
  484. env.Append(CCFLAGS = ['/MT'])
  485. env.Append(SHCCFLAGS = ['/LD'])
  486. # Assembler options
  487. if gcc:
  488. if env['machine'] == 'x86':
  489. env.Append(ASFLAGS = ['-m32'])
  490. if env['machine'] == 'x86_64':
  491. env.Append(ASFLAGS = ['-m64'])
  492. # Linker options
  493. linkflags = []
  494. shlinkflags = []
  495. if gcc:
  496. if env['machine'] == 'x86':
  497. linkflags += ['-m32']
  498. if env['machine'] == 'x86_64':
  499. linkflags += ['-m64']
  500. if env['platform'] not in ('darwin'):
  501. shlinkflags += [
  502. '-Wl,-Bsymbolic',
  503. ]
  504. # Handle circular dependencies in the libraries
  505. if env['platform'] in ('darwin'):
  506. pass
  507. else:
  508. env['_LIBFLAGS'] = '-Wl,--start-group ' + env['_LIBFLAGS'] + ' -Wl,--end-group'
  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. # Load tools
  570. env.Tool('lex')
  571. env.Tool('yacc')
  572. if env['llvm']:
  573. env.Tool('llvm')
  574. pkg_config_modules(env, 'x11', ['x11', 'xext'])
  575. pkg_config_modules(env, 'drm', ['libdrm'])
  576. pkg_config_modules(env, 'drm_intel', ['libdrm_intel'])
  577. pkg_config_modules(env, 'drm_radeon', ['libdrm_radeon'])
  578. pkg_config_modules(env, 'xorg', ['xorg-server'])
  579. pkg_config_modules(env, 'kms', ['libkms'])
  580. env['dri'] = env['x11'] and env['drm']
  581. # Custom builders and methods
  582. env.Tool('custom')
  583. createInstallMethods(env)
  584. # for debugging
  585. #print env.Dump()
  586. def exists(env):
  587. return 1