José Fonseca | b04aa71 | 2008-06-06 14:48:57 +0900 | [diff] [blame] | 1 | """gallium |
| 2 | |
| 3 | Frontend-tool for Gallium3D architecture. |
| 4 | |
| 5 | """ |
| 6 | |
José Fonseca | 381e348 | 2008-07-17 11:23:43 +0900 | [diff] [blame] | 7 | # |
José Fonseca | b04aa71 | 2008-06-06 14:48:57 +0900 | [diff] [blame] | 8 | # Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas. |
| 9 | # All Rights Reserved. |
José Fonseca | 381e348 | 2008-07-17 11:23:43 +0900 | [diff] [blame] | 10 | # |
José Fonseca | b04aa71 | 2008-06-06 14:48:57 +0900 | [diff] [blame] | 11 | # Permission is hereby granted, free of charge, to any person obtaining a |
| 12 | # copy of this software and associated documentation files (the |
| 13 | # "Software"), to deal in the Software without restriction, including |
| 14 | # without limitation the rights to use, copy, modify, merge, publish, |
| 15 | # distribute, sub license, and/or sell copies of the Software, and to |
| 16 | # permit persons to whom the Software is furnished to do so, subject to |
| 17 | # the following conditions: |
José Fonseca | 381e348 | 2008-07-17 11:23:43 +0900 | [diff] [blame] | 18 | # |
José Fonseca | b04aa71 | 2008-06-06 14:48:57 +0900 | [diff] [blame] | 19 | # The above copyright notice and this permission notice (including the |
| 20 | # next paragraph) shall be included in all copies or substantial portions |
| 21 | # of the Software. |
José Fonseca | 381e348 | 2008-07-17 11:23:43 +0900 | [diff] [blame] | 22 | # |
José Fonseca | b04aa71 | 2008-06-06 14:48:57 +0900 | [diff] [blame] | 23 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS |
| 24 | # OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
| 25 | # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. |
| 26 | # IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR |
| 27 | # ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, |
| 28 | # TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE |
| 29 | # SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
José Fonseca | 381e348 | 2008-07-17 11:23:43 +0900 | [diff] [blame] | 30 | # |
José Fonseca | b04aa71 | 2008-06-06 14:48:57 +0900 | [diff] [blame] | 31 | |
| 32 | |
José Fonseca | 27d8d6f | 2008-07-03 12:42:23 +0900 | [diff] [blame] | 33 | import os |
José Fonseca | b04aa71 | 2008-06-06 14:48:57 +0900 | [diff] [blame] | 34 | import os.path |
José Fonseca | 27d8d6f | 2008-07-03 12:42:23 +0900 | [diff] [blame] | 35 | import re |
José Fonseca | b04aa71 | 2008-06-06 14:48:57 +0900 | [diff] [blame] | 36 | |
| 37 | import SCons.Action |
| 38 | import SCons.Builder |
José Fonseca | 27d8d6f | 2008-07-03 12:42:23 +0900 | [diff] [blame] | 39 | import SCons.Scanner |
José Fonseca | b04aa71 | 2008-06-06 14:48:57 +0900 | [diff] [blame] | 40 | |
José Fonseca | 27d8d6f | 2008-07-03 12:42:23 +0900 | [diff] [blame] | 41 | |
José Fonseca | 52c2dd1 | 2008-09-08 07:54:15 +0900 | [diff] [blame] | 42 | def symlink(target, source, env): |
| 43 | target = str(target[0]) |
| 44 | source = str(source[0]) |
| 45 | if os.path.islink(target) or os.path.exists(target): |
| 46 | os.remove(target) |
| 47 | os.symlink(os.path.basename(source), target) |
| 48 | |
José Fonseca | 8a318ed | 2010-01-01 22:35:28 +0000 | [diff] [blame^] | 49 | def install(env, source, subdir): |
| 50 | target_dir = os.path.join(env.Dir('#.').srcnode().abspath, env['build'], subdir) |
| 51 | env.Install(target_dir, source) |
José Fonseca | b5a408b | 2009-12-23 15:21:56 +0000 | [diff] [blame] | 52 | |
José Fonseca | 8a318ed | 2010-01-01 22:35:28 +0000 | [diff] [blame^] | 53 | def install_program(env, source): |
| 54 | install(env, source, 'bin') |
| 55 | |
| 56 | def install_shared_library(env, sources, version = ()): |
| 57 | install_dir = os.path.join(env.Dir('#.').srcnode().abspath, env['build']) |
José Fonseca | 52c2dd1 | 2008-09-08 07:54:15 +0900 | [diff] [blame] | 58 | version = tuple(map(str, version)) |
José Fonseca | 8a318ed | 2010-01-01 22:35:28 +0000 | [diff] [blame^] | 59 | if env['SHLIBSUFFIX'] == '.dll': |
| 60 | dlls = env.FindIxes(sources, 'SHLIBPREFIX', 'SHLIBSUFFIX') |
| 61 | install(env, dlls, 'bin') |
| 62 | libs = env.FindIxes(sources, 'LIBPREFIX', 'LIBSUFFIX') |
| 63 | install(env, libs, 'lib') |
José Fonseca | b2e4064 | 2010-01-01 21:54:51 +0000 | [diff] [blame] | 64 | else: |
José Fonseca | 8a318ed | 2010-01-01 22:35:28 +0000 | [diff] [blame^] | 65 | for source in sources: |
| 66 | target_dir = os.path.join(install_dir, 'lib') |
| 67 | target_name = '.'.join((str(source),) + version) |
| 68 | last = env.InstallAs(os.path.join(target_dir, target_name), source) |
| 69 | while len(version): |
| 70 | version = version[:-1] |
| 71 | target_name = '.'.join((str(source),) + version) |
| 72 | action = SCons.Action.Action(symlink, "$TARGET -> $SOURCE") |
| 73 | last = env.Command(os.path.join(target_dir, target_name), last, action) |
José Fonseca | 52c2dd1 | 2008-09-08 07:54:15 +0900 | [diff] [blame] | 74 | |
| 75 | def createInstallMethods(env): |
José Fonseca | b5a408b | 2009-12-23 15:21:56 +0000 | [diff] [blame] | 76 | env.AddMethod(install_program, 'InstallProgram') |
José Fonseca | 52c2dd1 | 2008-09-08 07:54:15 +0900 | [diff] [blame] | 77 | env.AddMethod(install_shared_library, 'InstallSharedLibrary') |
| 78 | |
| 79 | |
José Fonseca | 1e8177e | 2009-02-10 18:11:56 +0000 | [diff] [blame] | 80 | def num_jobs(): |
| 81 | try: |
| 82 | return int(os.environ['NUMBER_OF_PROCESSORS']) |
| 83 | except (ValueError, KeyError): |
| 84 | pass |
| 85 | |
| 86 | try: |
| 87 | return os.sysconf('SC_NPROCESSORS_ONLN') |
| 88 | except (ValueError, OSError, AttributeError): |
| 89 | pass |
| 90 | |
| 91 | try: |
| 92 | return int(os.popen2("sysctl -n hw.ncpu")[1].read()) |
| 93 | except ValueError: |
| 94 | pass |
| 95 | |
| 96 | return 1 |
| 97 | |
| 98 | |
José Fonseca | b04aa71 | 2008-06-06 14:48:57 +0900 | [diff] [blame] | 99 | def generate(env): |
José Fonseca | 381e348 | 2008-07-17 11:23:43 +0900 | [diff] [blame] | 100 | """Common environment generation code""" |
José Fonseca | b04aa71 | 2008-06-06 14:48:57 +0900 | [diff] [blame] | 101 | |
José Fonseca | 6cf59e1 | 2008-11-18 19:13:32 +0900 | [diff] [blame] | 102 | # Toolchain |
| 103 | platform = env['platform'] |
| 104 | if env['toolchain'] == 'default': |
| 105 | if platform == 'winddk': |
Michal Krol | 4f3dcf3 | 2008-11-19 20:31:38 +0100 | [diff] [blame] | 106 | env['toolchain'] = 'winddk' |
José Fonseca | 6cf59e1 | 2008-11-18 19:13:32 +0900 | [diff] [blame] | 107 | elif platform == 'wince': |
Michal Krol | 4f3dcf3 | 2008-11-19 20:31:38 +0100 | [diff] [blame] | 108 | env['toolchain'] = 'wcesdk' |
José Fonseca | 6cf59e1 | 2008-11-18 19:13:32 +0900 | [diff] [blame] | 109 | env.Tool(env['toolchain']) |
| 110 | |
José Fonseca | 26e27ba | 2009-03-25 19:24:16 +0000 | [diff] [blame] | 111 | env['gcc'] = 'gcc' in os.path.basename(env['CC']).split('-') |
| 112 | env['msvc'] = env['CC'] == 'cl' |
| 113 | |
José Fonseca | 381e348 | 2008-07-17 11:23:43 +0900 | [diff] [blame] | 114 | # shortcuts |
| 115 | debug = env['debug'] |
| 116 | machine = env['machine'] |
| 117 | platform = env['platform'] |
| 118 | x86 = env['machine'] == 'x86' |
Michel Dänzer | 6b69e3c | 2008-10-23 10:28:48 +0200 | [diff] [blame] | 119 | ppc = env['machine'] == 'ppc' |
José Fonseca | 26e27ba | 2009-03-25 19:24:16 +0000 | [diff] [blame] | 120 | gcc = env['gcc'] |
| 121 | msvc = env['msvc'] |
José Fonseca | b04aa71 | 2008-06-06 14:48:57 +0900 | [diff] [blame] | 122 | |
José Fonseca | 381e348 | 2008-07-17 11:23:43 +0900 | [diff] [blame] | 123 | # Put build output in a separate dir, which depends on the current |
| 124 | # configuration. See also http://www.scons.org/wiki/AdvancedBuildExample |
| 125 | build_topdir = 'build' |
| 126 | build_subdir = env['platform'] |
José Fonseca | 381e348 | 2008-07-17 11:23:43 +0900 | [diff] [blame] | 127 | if env['llvm']: |
| 128 | build_subdir += "-llvm" |
| 129 | if env['machine'] != 'generic': |
| 130 | build_subdir += '-' + env['machine'] |
| 131 | if env['debug']: |
| 132 | build_subdir += "-debug" |
| 133 | if env['profile']: |
| 134 | build_subdir += "-profile" |
| 135 | build_dir = os.path.join(build_topdir, build_subdir) |
| 136 | # Place the .sconsign file in the build dir too, to avoid issues with |
| 137 | # different scons versions building the same source file |
| 138 | env['build'] = build_dir |
| 139 | env.SConsignFile(os.path.join(build_dir, '.sconsign')) |
José Fonseca | 18170bb | 2009-01-23 21:01:16 +0000 | [diff] [blame] | 140 | env.CacheDir('build/cache') |
José Fonseca | 8b75526 | 2009-12-25 17:39:47 +0000 | [diff] [blame] | 141 | env['CONFIGUREDIR'] = os.path.join(build_dir, 'conf') |
| 142 | env['CONFIGURELOG'] = os.path.join(os.path.abspath(build_dir), 'config.log') |
José Fonseca | b04aa71 | 2008-06-06 14:48:57 +0900 | [diff] [blame] | 143 | |
José Fonseca | 1e8177e | 2009-02-10 18:11:56 +0000 | [diff] [blame] | 144 | # Parallel build |
| 145 | if env.GetOption('num_jobs') <= 1: |
| 146 | env.SetOption('num_jobs', num_jobs()) |
| 147 | |
José Fonseca | 381e348 | 2008-07-17 11:23:43 +0900 | [diff] [blame] | 148 | # C preprocessor options |
| 149 | cppdefines = [] |
| 150 | if debug: |
| 151 | cppdefines += ['DEBUG'] |
| 152 | else: |
| 153 | cppdefines += ['NDEBUG'] |
| 154 | if env['profile']: |
| 155 | cppdefines += ['PROFILE'] |
| 156 | if platform == 'windows': |
| 157 | cppdefines += [ |
| 158 | 'WIN32', |
| 159 | '_WINDOWS', |
José Fonseca | 42be010 | 2009-01-22 14:26:30 +0000 | [diff] [blame] | 160 | #'_UNICODE', |
| 161 | #'UNICODE', |
José Fonseca | 129c6ed | 2008-12-01 11:53:26 -0800 | [diff] [blame] | 162 | ('_WIN32_WINNT', '0x0501'), # minimum required OS version |
| 163 | ('WINVER', '0x0501'), |
José Fonseca | 381e348 | 2008-07-17 11:23:43 +0900 | [diff] [blame] | 164 | ] |
José Fonseca | 71793e0f | 2009-04-14 21:39:54 +0100 | [diff] [blame] | 165 | if msvc and env['toolchain'] != 'winddk': |
José Fonseca | b3e03ed | 2009-03-25 19:32:54 +0000 | [diff] [blame] | 166 | cppdefines += [ |
| 167 | 'VC_EXTRALEAN', |
José Fonseca | ad0975f | 2009-10-26 15:11:11 +0000 | [diff] [blame] | 168 | '_USE_MATH_DEFINES', |
José Fonseca | 1acd891 | 2009-10-21 17:03:52 +0100 | [diff] [blame] | 169 | '_CRT_SECURE_NO_WARNINGS', |
José Fonseca | b3e03ed | 2009-03-25 19:32:54 +0000 | [diff] [blame] | 170 | '_CRT_SECURE_NO_DEPRECATE', |
José Fonseca | 1acd891 | 2009-10-21 17:03:52 +0100 | [diff] [blame] | 171 | '_SCL_SECURE_NO_WARNINGS', |
| 172 | '_SCL_SECURE_NO_DEPRECATE', |
José Fonseca | b3e03ed | 2009-03-25 19:32:54 +0000 | [diff] [blame] | 173 | ] |
José Fonseca | 381e348 | 2008-07-17 11:23:43 +0900 | [diff] [blame] | 174 | if debug: |
| 175 | cppdefines += ['_DEBUG'] |
José Fonseca | 71793e0f | 2009-04-14 21:39:54 +0100 | [diff] [blame] | 176 | if env['toolchain'] == 'winddk': |
José Fonseca | 381e348 | 2008-07-17 11:23:43 +0900 | [diff] [blame] | 177 | # Mimic WINDDK's builtin flags. See also: |
| 178 | # - WINDDK's bin/makefile.new i386mk.inc for more info. |
| 179 | # - buildchk_wxp_x86.log files, generated by the WINDDK's build |
| 180 | # - http://alter.org.ua/docs/nt_kernel/vc8_proj/ |
José Fonseca | 71793e0f | 2009-04-14 21:39:54 +0100 | [diff] [blame] | 181 | if machine == 'x86': |
| 182 | cppdefines += ['_X86_', 'i386'] |
| 183 | if machine == 'x86_64': |
| 184 | cppdefines += ['_AMD64_', 'AMD64'] |
| 185 | if platform == 'winddk': |
José Fonseca | 381e348 | 2008-07-17 11:23:43 +0900 | [diff] [blame] | 186 | cppdefines += [ |
José Fonseca | 381e348 | 2008-07-17 11:23:43 +0900 | [diff] [blame] | 187 | 'STD_CALL', |
| 188 | ('CONDITION_HANDLING', '1'), |
| 189 | ('NT_INST', '0'), |
| 190 | ('WIN32', '100'), |
| 191 | ('_NT1X_', '100'), |
| 192 | ('WINNT', '1'), |
| 193 | ('_WIN32_WINNT', '0x0501'), # minimum required OS version |
| 194 | ('WINVER', '0x0501'), |
| 195 | ('_WIN32_IE', '0x0603'), |
| 196 | ('WIN32_LEAN_AND_MEAN', '1'), |
| 197 | ('DEVL', '1'), |
| 198 | ('__BUILDMACHINE__', 'WinDDK'), |
| 199 | ('FPO', '0'), |
| 200 | ] |
| 201 | if debug: |
| 202 | cppdefines += [('DBG', 1)] |
| 203 | if platform == 'wince': |
| 204 | cppdefines += [ |
| 205 | '_CRT_SECURE_NO_DEPRECATE', |
| 206 | '_USE_32BIT_TIME_T', |
| 207 | 'UNICODE', |
| 208 | '_UNICODE', |
| 209 | ('UNDER_CE', '600'), |
| 210 | ('_WIN32_WCE', '0x600'), |
| 211 | 'WINCEOEM', |
| 212 | 'WINCEINTERNAL', |
| 213 | 'WIN32', |
| 214 | 'STRICT', |
| 215 | 'x86', |
| 216 | '_X86_', |
| 217 | 'INTERNATIONAL', |
| 218 | ('INTLMSG_CODEPAGE', '1252'), |
| 219 | ] |
| 220 | if platform == 'windows': |
| 221 | cppdefines += ['PIPE_SUBSYSTEM_WINDOWS_USER'] |
| 222 | if platform == 'winddk': |
| 223 | cppdefines += ['PIPE_SUBSYSTEM_WINDOWS_DISPLAY'] |
| 224 | if platform == 'wince': |
| 225 | cppdefines += ['PIPE_SUBSYSTEM_WINDOWS_CE'] |
José Fonseca | 40b3bb0 | 2008-11-04 10:53:02 +0900 | [diff] [blame] | 226 | cppdefines += ['PIPE_SUBSYSTEM_WINDOWS_CE_OGL'] |
José Fonseca | 381e348 | 2008-07-17 11:23:43 +0900 | [diff] [blame] | 227 | env.Append(CPPDEFINES = cppdefines) |
José Fonseca | b04aa71 | 2008-06-06 14:48:57 +0900 | [diff] [blame] | 228 | |
José Fonseca | 381e348 | 2008-07-17 11:23:43 +0900 | [diff] [blame] | 229 | # C compiler options |
José Fonseca | 25f6c93 | 2009-06-26 19:50:12 +0100 | [diff] [blame] | 230 | cflags = [] # C |
| 231 | cxxflags = [] # C++ |
| 232 | ccflags = [] # C & C++ |
José Fonseca | 381e348 | 2008-07-17 11:23:43 +0900 | [diff] [blame] | 233 | if gcc: |
| 234 | if debug: |
José Fonseca | 25f6c93 | 2009-06-26 19:50:12 +0100 | [diff] [blame] | 235 | ccflags += ['-O0', '-g3'] |
José Fonseca | bb8f309 | 2009-06-28 11:12:22 +0100 | [diff] [blame] | 236 | elif env['CCVERSION'].startswith('4.2.'): |
| 237 | # gcc 4.2.x optimizer is broken |
| 238 | print "warning: gcc 4.2.x optimizer is broken -- disabling optimizations" |
| 239 | ccflags += ['-O0', '-g3'] |
José Fonseca | 381e348 | 2008-07-17 11:23:43 +0900 | [diff] [blame] | 240 | else: |
José Fonseca | 25f6c93 | 2009-06-26 19:50:12 +0100 | [diff] [blame] | 241 | ccflags += ['-O3', '-g3'] |
José Fonseca | 381e348 | 2008-07-17 11:23:43 +0900 | [diff] [blame] | 242 | if env['profile']: |
José Fonseca | 1a9eec8 | 2009-09-20 18:07:16 +0100 | [diff] [blame] | 243 | # See http://code.google.com/p/jrfonseca/wiki/Gprof2Dot#Which_options_should_I_pass_to_gcc_when_compiling_for_profiling? |
| 244 | ccflags += [ |
| 245 | '-fno-omit-frame-pointer', |
| 246 | '-fno-optimize-sibling-calls', |
| 247 | ] |
José Fonseca | 381e348 | 2008-07-17 11:23:43 +0900 | [diff] [blame] | 248 | if env['machine'] == 'x86': |
José Fonseca | 25f6c93 | 2009-06-26 19:50:12 +0100 | [diff] [blame] | 249 | ccflags += [ |
José Fonseca | 381e348 | 2008-07-17 11:23:43 +0900 | [diff] [blame] | 250 | '-m32', |
| 251 | #'-march=pentium4', |
José Fonseca | 381e348 | 2008-07-17 11:23:43 +0900 | [diff] [blame] | 252 | #'-mfpmath=sse', |
| 253 | ] |
José Fonseca | 5ba645f | 2009-10-14 16:16:40 +0100 | [diff] [blame] | 254 | if platform != 'windows': |
| 255 | # XXX: -mstackrealign causes stack corruption on MinGW. Ditto |
| 256 | # for -mincoming-stack-boundary=2. Still enable it on other |
| 257 | # platforms for now, but we can't rely on it for cross platform |
| 258 | # code. We have to use __attribute__((force_align_arg_pointer)) |
| 259 | # instead. |
| 260 | ccflags += [ |
| 261 | '-mmmx', '-msse', '-msse2', # enable SIMD intrinsics |
| 262 | '-mstackrealign', # ensure stack is aligned |
| 263 | ] |
José Fonseca | 381e348 | 2008-07-17 11:23:43 +0900 | [diff] [blame] | 264 | if env['machine'] == 'x86_64': |
José Fonseca | 25f6c93 | 2009-06-26 19:50:12 +0100 | [diff] [blame] | 265 | ccflags += ['-m64'] |
José Fonseca | 102cb5c | 2009-03-13 16:21:30 +0000 | [diff] [blame] | 266 | # See also: |
| 267 | # - http://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html |
José Fonseca | 25f6c93 | 2009-06-26 19:50:12 +0100 | [diff] [blame] | 268 | ccflags += [ |
José Fonseca | 381e348 | 2008-07-17 11:23:43 +0900 | [diff] [blame] | 269 | '-Wall', |
José Fonseca | 102cb5c | 2009-03-13 16:21:30 +0000 | [diff] [blame] | 270 | '-Wmissing-field-initializers', |
José Fonseca | 2348f6d | 2009-11-27 16:01:36 +0000 | [diff] [blame] | 271 | '-Werror=pointer-arith', |
José Fonseca | 381e348 | 2008-07-17 11:23:43 +0900 | [diff] [blame] | 272 | '-Wno-long-long', |
| 273 | '-ffast-math', |
José Fonseca | 381e348 | 2008-07-17 11:23:43 +0900 | [diff] [blame] | 274 | '-fmessage-length=0', # be nice to Eclipse |
| 275 | ] |
José Fonseca | 25f6c93 | 2009-06-26 19:50:12 +0100 | [diff] [blame] | 276 | cflags += [ |
| 277 | '-Werror=declaration-after-statement', |
| 278 | '-Wmissing-prototypes', |
| 279 | '-std=gnu99', |
| 280 | ] |
José Fonseca | 381e348 | 2008-07-17 11:23:43 +0900 | [diff] [blame] | 281 | if msvc: |
| 282 | # See also: |
José Fonseca | a6c7258 | 2008-09-01 09:47:40 +0900 | [diff] [blame] | 283 | # - http://msdn.microsoft.com/en-us/library/19z1t1wy.aspx |
José Fonseca | 381e348 | 2008-07-17 11:23:43 +0900 | [diff] [blame] | 284 | # - cl /? |
| 285 | if debug: |
José Fonseca | 25f6c93 | 2009-06-26 19:50:12 +0100 | [diff] [blame] | 286 | ccflags += [ |
José Fonseca | 381e348 | 2008-07-17 11:23:43 +0900 | [diff] [blame] | 287 | '/Od', # disable optimizations |
| 288 | '/Oi', # enable intrinsic functions |
| 289 | '/Oy-', # disable frame pointer omission |
José Fonseca | 73ccabc | 2009-02-12 11:57:45 +0000 | [diff] [blame] | 290 | '/GL-', # disable whole program optimization |
José Fonseca | 381e348 | 2008-07-17 11:23:43 +0900 | [diff] [blame] | 291 | ] |
| 292 | else: |
José Fonseca | 25f6c93 | 2009-06-26 19:50:12 +0100 | [diff] [blame] | 293 | ccflags += [ |
José Fonseca | 78dad27 | 2009-06-04 10:34:02 -0700 | [diff] [blame] | 294 | '/O2', # optimize for speed |
José Fonseca | da3bc49 | 2009-12-11 15:16:22 +0000 | [diff] [blame] | 295 | '/GL', # enable whole program optimization |
José Fonseca | 381e348 | 2008-07-17 11:23:43 +0900 | [diff] [blame] | 296 | ] |
José Fonseca | 25f6c93 | 2009-06-26 19:50:12 +0100 | [diff] [blame] | 297 | ccflags += [ |
José Fonseca | da3bc49 | 2009-12-11 15:16:22 +0000 | [diff] [blame] | 298 | '/fp:fast', # fast floating point |
José Fonseca | 381e348 | 2008-07-17 11:23:43 +0900 | [diff] [blame] | 299 | '/W3', # warning level |
| 300 | #'/Wp64', # enable 64 bit porting warnings |
| 301 | ] |
José Fonseca | a6c7258 | 2008-09-01 09:47:40 +0900 | [diff] [blame] | 302 | if env['machine'] == 'x86': |
José Fonseca | 25f6c93 | 2009-06-26 19:50:12 +0100 | [diff] [blame] | 303 | ccflags += [ |
José Fonseca | a6c7258 | 2008-09-01 09:47:40 +0900 | [diff] [blame] | 304 | #'/arch:SSE2', # use the SSE2 instructions |
| 305 | ] |
José Fonseca | 381e348 | 2008-07-17 11:23:43 +0900 | [diff] [blame] | 306 | if platform == 'windows': |
José Fonseca | 25f6c93 | 2009-06-26 19:50:12 +0100 | [diff] [blame] | 307 | ccflags += [ |
José Fonseca | 381e348 | 2008-07-17 11:23:43 +0900 | [diff] [blame] | 308 | # TODO |
| 309 | ] |
| 310 | if platform == 'winddk': |
José Fonseca | 25f6c93 | 2009-06-26 19:50:12 +0100 | [diff] [blame] | 311 | ccflags += [ |
José Fonseca | 381e348 | 2008-07-17 11:23:43 +0900 | [diff] [blame] | 312 | '/Zl', # omit default library name in .OBJ |
| 313 | '/Zp8', # 8bytes struct member alignment |
| 314 | '/Gy', # separate functions for linker |
| 315 | '/Gm-', # disable minimal rebuild |
| 316 | '/WX', # treat warnings as errors |
| 317 | '/Gz', # __stdcall Calling convention |
| 318 | '/GX-', # disable C++ EH |
| 319 | '/GR-', # disable C++ RTTI |
| 320 | '/GF', # enable read-only string pooling |
| 321 | '/G6', # optimize for PPro, P-II, P-III |
| 322 | '/Ze', # enable extensions |
| 323 | '/Gi-', # disable incremental compilation |
| 324 | '/QIfdiv-', # disable Pentium FDIV fix |
| 325 | '/hotpatch', # prepares an image for hotpatching. |
| 326 | #'/Z7', #enable old-style debug info |
| 327 | ] |
| 328 | if platform == 'wince': |
| 329 | # See also C:\WINCE600\public\common\oak\misc\makefile.def |
José Fonseca | 25f6c93 | 2009-06-26 19:50:12 +0100 | [diff] [blame] | 330 | ccflags += [ |
José Fonseca | 381e348 | 2008-07-17 11:23:43 +0900 | [diff] [blame] | 331 | '/Zl', # omit default library name in .OBJ |
| 332 | '/GF', # enable read-only string pooling |
| 333 | '/GR-', # disable C++ RTTI |
| 334 | '/GS', # enable security checks |
| 335 | # Allow disabling language conformance to maintain backward compat |
| 336 | #'/Zc:wchar_t-', # don't force wchar_t as native type, instead of typedef |
| 337 | #'/Zc:forScope-', # don't enforce Standard C++ for scoping rules |
| 338 | #'/wd4867', |
| 339 | #'/wd4430', |
| 340 | #'/MT', |
| 341 | #'/U_MT', |
| 342 | ] |
| 343 | # Automatic pdb generation |
| 344 | # See http://scons.tigris.org/issues/show_bug.cgi?id=1656 |
| 345 | env.EnsureSConsVersion(0, 98, 0) |
| 346 | env['PDB'] = '${TARGET.base}.pdb' |
José Fonseca | 25f6c93 | 2009-06-26 19:50:12 +0100 | [diff] [blame] | 347 | env.Append(CCFLAGS = ccflags) |
José Fonseca | 381e348 | 2008-07-17 11:23:43 +0900 | [diff] [blame] | 348 | env.Append(CFLAGS = cflags) |
José Fonseca | 25f6c93 | 2009-06-26 19:50:12 +0100 | [diff] [blame] | 349 | env.Append(CXXFLAGS = cxxflags) |
José Fonseca | b04aa71 | 2008-06-06 14:48:57 +0900 | [diff] [blame] | 350 | |
José Fonseca | 1781d7f | 2009-01-06 16:16:38 +0000 | [diff] [blame] | 351 | if env['platform'] == 'windows' and msvc: |
| 352 | # Choose the appropriate MSVC CRT |
| 353 | # http://msdn.microsoft.com/en-us/library/2kzt1wy3.aspx |
| 354 | if env['debug']: |
| 355 | env.Append(CCFLAGS = ['/MTd']) |
| 356 | env.Append(SHCCFLAGS = ['/LDd']) |
| 357 | else: |
| 358 | env.Append(CCFLAGS = ['/MT']) |
| 359 | env.Append(SHCCFLAGS = ['/LD']) |
| 360 | |
José Fonseca | 381e348 | 2008-07-17 11:23:43 +0900 | [diff] [blame] | 361 | # Assembler options |
| 362 | if gcc: |
| 363 | if env['machine'] == 'x86': |
| 364 | env.Append(ASFLAGS = ['-m32']) |
| 365 | if env['machine'] == 'x86_64': |
| 366 | env.Append(ASFLAGS = ['-m64']) |
José Fonseca | 27d8d6f | 2008-07-03 12:42:23 +0900 | [diff] [blame] | 367 | |
José Fonseca | 381e348 | 2008-07-17 11:23:43 +0900 | [diff] [blame] | 368 | # Linker options |
| 369 | linkflags = [] |
José Fonseca | 72ad039 | 2009-06-28 10:54:23 +0100 | [diff] [blame] | 370 | shlinkflags = [] |
José Fonseca | 381e348 | 2008-07-17 11:23:43 +0900 | [diff] [blame] | 371 | if gcc: |
| 372 | if env['machine'] == 'x86': |
| 373 | linkflags += ['-m32'] |
| 374 | if env['machine'] == 'x86_64': |
| 375 | linkflags += ['-m64'] |
José Fonseca | 72ad039 | 2009-06-28 10:54:23 +0100 | [diff] [blame] | 376 | shlinkflags += [ |
| 377 | '-Wl,-Bsymbolic', |
| 378 | ] |
José Fonseca | 7b39194 | 2009-08-13 16:32:51 +0100 | [diff] [blame] | 379 | # Handle circular dependencies in the libraries |
| 380 | env['_LIBFLAGS'] = '-Wl,--start-group ' + env['_LIBFLAGS'] + ' -Wl,--end-group' |
José Fonseca | da3bc49 | 2009-12-11 15:16:22 +0000 | [diff] [blame] | 381 | if msvc: |
| 382 | if not env['debug']: |
| 383 | # enable Link-time Code Generation |
| 384 | linkflags += ['/LTCG'] |
| 385 | env.Append(ARFLAGS = ['/LTCG']) |
José Fonseca | 6fe421c | 2009-02-12 12:59:58 +0000 | [diff] [blame] | 386 | if platform == 'windows' and msvc: |
José Fonseca | 381e348 | 2008-07-17 11:23:43 +0900 | [diff] [blame] | 387 | # See also: |
| 388 | # - http://msdn2.microsoft.com/en-us/library/y0zzbyt4.aspx |
| 389 | linkflags += [ |
José Fonseca | 73ccabc | 2009-02-12 11:57:45 +0000 | [diff] [blame] | 390 | '/fixed:no', |
| 391 | '/incremental:no', |
| 392 | ] |
| 393 | if platform == 'winddk': |
| 394 | linkflags += [ |
José Fonseca | 381e348 | 2008-07-17 11:23:43 +0900 | [diff] [blame] | 395 | '/merge:_PAGE=PAGE', |
| 396 | '/merge:_TEXT=.text', |
| 397 | '/section:INIT,d', |
| 398 | '/opt:ref', |
| 399 | '/opt:icf', |
| 400 | '/ignore:4198,4010,4037,4039,4065,4070,4078,4087,4089,4221', |
| 401 | '/incremental:no', |
| 402 | '/fullbuild', |
| 403 | '/release', |
| 404 | '/nodefaultlib', |
| 405 | '/wx', |
| 406 | '/debug', |
| 407 | '/debugtype:cv', |
| 408 | '/version:5.1', |
| 409 | '/osversion:5.1', |
| 410 | '/functionpadmin:5', |
| 411 | '/safeseh', |
| 412 | '/pdbcompress', |
| 413 | '/stack:0x40000,0x1000', |
| 414 | '/driver', |
| 415 | '/align:0x80', |
| 416 | '/subsystem:native,5.01', |
| 417 | '/base:0x10000', |
| 418 | |
| 419 | '/entry:DrvEnableDriver', |
| 420 | ] |
José Fonseca | 4672803 | 2009-02-18 15:05:23 +0000 | [diff] [blame] | 421 | if env['debug'] or env['profile']: |
José Fonseca | 381e348 | 2008-07-17 11:23:43 +0900 | [diff] [blame] | 422 | linkflags += [ |
| 423 | '/MAP', # http://msdn.microsoft.com/en-us/library/k7xkk3e2.aspx |
| 424 | ] |
| 425 | if platform == 'wince': |
| 426 | linkflags += [ |
| 427 | '/nodefaultlib', |
| 428 | #'/incremental:no', |
| 429 | #'/fullbuild', |
| 430 | '/entry:_DllMainCRTStartup', |
| 431 | ] |
| 432 | env.Append(LINKFLAGS = linkflags) |
José Fonseca | 72ad039 | 2009-06-28 10:54:23 +0100 | [diff] [blame] | 433 | env.Append(SHLINKFLAGS = shlinkflags) |
José Fonseca | 381e348 | 2008-07-17 11:23:43 +0900 | [diff] [blame] | 434 | |
José Fonseca | c76787a | 2008-07-17 11:25:20 +0900 | [diff] [blame] | 435 | # Default libs |
| 436 | env.Append(LIBS = []) |
| 437 | |
José Fonseca | 381e348 | 2008-07-17 11:23:43 +0900 | [diff] [blame] | 438 | # Custom builders and methods |
José Fonseca | 97e2c5a | 2009-12-31 17:58:56 +0000 | [diff] [blame] | 439 | env.Tool('custom') |
José Fonseca | 52c2dd1 | 2008-09-08 07:54:15 +0900 | [diff] [blame] | 440 | createInstallMethods(env) |
José Fonseca | 381e348 | 2008-07-17 11:23:43 +0900 | [diff] [blame] | 441 | |
| 442 | # for debugging |
| 443 | #print env.Dump() |
José Fonseca | b04aa71 | 2008-06-06 14:48:57 +0900 | [diff] [blame] | 444 | |
| 445 | |
| 446 | def exists(env): |
José Fonseca | 381e348 | 2008-07-17 11:23:43 +0900 | [diff] [blame] | 447 | return 1 |