Merge commit 'origin/gallium-0.1' into gallium-0.2
[mesa.git] / scons / gallium.py
index 43603e510446c8741b59399eb5648670d5f25fdf..f7ac5e543e395f1cec333584d66f9fe80d101160 100644 (file)
@@ -140,6 +140,29 @@ def createCodeGenerateMethod(env):
     env.AddMethod(code_generate, 'CodeGenerate')
 
 
+def symlink(target, source, env):
+    target = str(target[0])
+    source = str(source[0])
+    if os.path.islink(target) or os.path.exists(target):
+        os.remove(target)
+    os.symlink(os.path.basename(source), target)
+
+def install_shared_library(env, source, version = ()):
+    source = str(source[0])
+    version = tuple(map(str, version))
+    target_dir =  os.path.join(env.Dir('#.').srcnode().abspath, env['build'], 'lib')
+    target_name = '.'.join((str(source),) + version)
+    last = env.InstallAs(os.path.join(target_dir, target_name), source)
+    while len(version):
+        version = version[:-1]
+        target_name = '.'.join((str(source),) + version)
+        action = SCons.Action.Action(symlink, "$TARGET -> $SOURCE")
+        last = env.Command(os.path.join(target_dir, target_name), last, action) 
+
+def createInstallMethods(env):
+    env.AddMethod(install_shared_library, 'InstallSharedLibrary')
+
+
 def generate(env):
     """Common environment generation code"""
 
@@ -147,21 +170,24 @@ def generate(env):
     #if env.get('quiet', False):
     #    quietCommandLines(env)
 
+    # Toolchain
+    platform = env['platform']
+    if env['toolchain'] == 'default':
+        if platform == 'winddk':
+            env['toolchain'] == 'winddk'
+        elif platform == 'wince':
+            env.Tool('wcesdk')
+            env['toolchain'] == 'wcesdk'
+    env.Tool(env['toolchain'])
+
     # shortcuts
     debug = env['debug']
     machine = env['machine']
     platform = env['platform']
     x86 = env['machine'] == 'x86'
-    gcc = env['platform'] in ('linux', 'freebsd', 'darwin')
-    msvc = env['platform'] in ('windows', 'winddk', 'wince')
-
-    # Tool
-    if platform == 'winddk':
-        env.Tool('winddk')
-    elif platform == 'wince':
-        env.Tool('wcesdk')
-    else:
-        env.Tool('default')
+    ppc = env['machine'] == 'ppc'
+    gcc = env['platform'] in ('linux', 'freebsd', 'darwin') or env['toolchain'] == 'crossmingw'
+    msvc = env['platform'] in ('windows', 'winddk', 'wince') and env['toolchain'] != 'crossmingw'
 
     # Put build output in a separate dir, which depends on the current
     # configuration. See also http://www.scons.org/wiki/AdvancedBuildExample
@@ -251,6 +277,7 @@ def generate(env):
         cppdefines += ['PIPE_SUBSYSTEM_WINDOWS_DISPLAY']
     if platform == 'wince':
         cppdefines += ['PIPE_SUBSYSTEM_WINDOWS_CE']
+        cppdefines += ['PIPE_SUBSYSTEM_WINDOWS_CE_OGL']
     env.Append(CPPDEFINES = cppdefines)
 
     # C preprocessor includes
@@ -290,7 +317,7 @@ def generate(env):
         ]
     if msvc:
         # See also:
-        # - http://msdn2.microsoft.com/en-us/library/y0zzbyt4.aspx
+        # - http://msdn.microsoft.com/en-us/library/19z1t1wy.aspx
         # - cl /?
         if debug:
             cflags += [
@@ -302,7 +329,8 @@ def generate(env):
             cflags += [
               '/Ox', # maximum optimizations
               '/Oi', # enable intrinsic functions
-              '/Os', # favor code space
+              '/Ot', # favor code speed
+              #'/fp:fast', # fast floating point 
             ]
         if env['profile']:
             cflags += [
@@ -313,6 +341,11 @@ def generate(env):
             '/W3', # warning level
             #'/Wp64', # enable 64 bit porting warnings
         ]
+        if env['machine'] == 'x86':
+            cflags += [
+                #'/QIfist', # Suppress _ftol
+                #'/arch:SSE2', # use the SSE2 instructions
+            ]
         if platform == 'windows':
             cflags += [
                 # TODO
@@ -420,6 +453,7 @@ def generate(env):
     # Custom builders and methods
     createConvenienceLibBuilder(env)
     createCodeGenerateMethod(env)
+    createInstallMethods(env)
 
     # for debugging
     #print env.Dump()