Refresh autogenerated glcpp parser.
[mesa.git] / scons / gallium.py
index b065b7bc49fca8b8600bd04a6e482fec0c10d238..75e9b9e7fc302fcbe9a1dc8635381fb9c9d8444a 100644 (file)
@@ -50,29 +50,34 @@ def symlink(target, source, env):
 
 def install(env, source, subdir):
     target_dir = os.path.join(env.Dir('#.').srcnode().abspath, env['build_dir'], subdir)
-    env.Install(target_dir, source)
+    return env.Install(target_dir, source)
 
 def install_program(env, source):
-    install(env, source, 'bin')
+    return install(env, source, 'bin')
 
 def install_shared_library(env, sources, version = ()):
+    targets = []
     install_dir = os.path.join(env.Dir('#.').srcnode().abspath, env['build_dir'])
     version = tuple(map(str, version))
     if env['SHLIBSUFFIX'] == '.dll':
         dlls = env.FindIxes(sources, 'SHLIBPREFIX', 'SHLIBSUFFIX')
-        install(env, dlls, 'bin')
+        targets += install(env, dlls, 'bin')
         libs = env.FindIxes(sources, 'LIBPREFIX', 'LIBSUFFIX')
-        install(env, libs, 'lib')
+        targets += install(env, libs, 'lib')
     else:
         for source in sources:
             target_dir =  os.path.join(install_dir, 'lib')
             target_name = '.'.join((str(source),) + version)
             last = env.InstallAs(os.path.join(target_dir, target_name), source)
+            targets += last
             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) 
+                targets += last
+    return targets
+
 
 def createInstallMethods(env):
     env.AddMethod(install_program, 'InstallProgram')
@@ -98,6 +103,41 @@ def num_jobs():
     return 1
 
 
+def pkg_config_modules(env, name, modules):
+    '''Simple wrapper for pkg-config.'''
+
+    env[name] = False
+
+    if env['platform'] == 'windows':
+        return
+
+    if not env.Detect('pkg-config'):
+        return
+
+    if subprocess.call(["pkg-config", "--exists", ' '.join(modules)]) != 0:
+        return
+
+    # Put -I and -L flags directly into the environment, as these don't affect
+    # the compilation of targets that do not use them
+    try:
+        env.ParseConfig('pkg-config --cflags-only-I --libs-only-L ' + ' '.join(modules))
+    except OSError:
+        return
+
+    # Other flags may affect the compilation of unrelated targets, so store
+    # them with a prefix, (e.g., XXX_CFLAGS, XXX_LIBS, etc)
+    try:
+        flags = env.ParseFlags('!pkg-config --cflags-only-other --libs-only-l --libs-only-other ' + ' '.join(modules))
+    except OSError:
+        return
+    prefix = name.upper() + '_'
+    for flag_name, flag_value in flags.iteritems():
+        env[prefix + flag_name] = flag_value
+
+    env[name] = True
+
+
+
 def generate(env):
     """Common environment generation code"""
 
@@ -110,21 +150,27 @@ def generate(env):
             env['toolchain'] = 'wcesdk'
     env.Tool(env['toolchain'])
 
-    if env['platform'] == 'embedded':
-        # Allow overriding compiler from environment
-        if os.environ.has_key('CC'):
-            env['CC'] = os.environ['CC']
-            # Update CCVERSION to match
-            pipe = SCons.Action._subproc(env, [env['CC'], '--version'],
-                                         stdin = 'devnull',
-                                         stderr = 'devnull',
-                                         stdout = subprocess.PIPE)
-            if pipe.wait() == 0:
-                line = pipe.stdout.readline()
-                match = re.search(r'[0-9]+(\.[0-9]+)+', line)
-                if match:
-                    env['CCVERSION'] = match.group(0)
-            
+    # Allow override compiler and specify additional flags from environment
+    if os.environ.has_key('CC'):
+        env['CC'] = os.environ['CC']
+        # Update CCVERSION to match
+        pipe = SCons.Action._subproc(env, [env['CC'], '--version'],
+                                     stdin = 'devnull',
+                                     stderr = 'devnull',
+                                     stdout = subprocess.PIPE)
+        if pipe.wait() == 0:
+            line = pipe.stdout.readline()
+            match = re.search(r'[0-9]+(\.[0-9]+)+', line)
+            if match:
+                env['CCVERSION'] = match.group(0)
+    if os.environ.has_key('CFLAGS'):
+        env['CCFLAGS'] += SCons.Util.CLVar(os.environ['CFLAGS'])
+    if os.environ.has_key('CXX'):
+        env['CXX'] = os.environ['CXX']
+    if os.environ.has_key('CXXFLAGS'):
+        env['CXXFLAGS'] += SCons.Util.CLVar(os.environ['CXXFLAGS'])
+    if os.environ.has_key('LDFLAGS'):
+        env['LINKFLAGS'] += SCons.Util.CLVar(os.environ['LDFLAGS'])
 
     env['gcc'] = 'gcc' in os.path.basename(env['CC']).split('-')
     env['msvc'] = env['CC'] == 'cl'
@@ -140,10 +186,16 @@ def generate(env):
     # Backwards compatability with the debug= profile= options
     if env['build'] == 'debug':
         if not env['debug']:
-            print 'scons: debug option is deprecated: use instead build=release'
+            print 'scons: warning: debug option is deprecated and will be removed eventually; use instead'
+            print
+            print ' scons build=release'
+            print
             env['build'] = 'release'
         if env['profile']:
-            print 'scons: profile option is deprecated: use instead build=profile'
+            print 'scons: warning: profile option is deprecated and will be removed eventually; use instead'
+            print
+            print ' scons build=profile'
+            print
             env['build'] = 'profile'
     if False:
         # Enforce SConscripts to use the new build variable
@@ -184,6 +236,9 @@ def generate(env):
     if env.GetOption('num_jobs') <= 1:
         env.SetOption('num_jobs', num_jobs())
 
+    env.Decider('MD5-timestamp')
+    env.SetOption('max_drift', 60)
+
     # C preprocessor options
     cppdefines = []
     if env['build'] in ('debug', 'checked'):
@@ -499,9 +554,19 @@ def generate(env):
     # Default libs
     env.Append(LIBS = [])
 
-    # Load LLVM
+    # Load tools
     if env['llvm']:
         env.Tool('llvm')
+        env.Tool('udis86')
+    
+    pkg_config_modules(env, 'x11', ['x11', 'xext'])
+    pkg_config_modules(env, 'drm', ['libdrm'])
+    pkg_config_modules(env, 'drm_intel', ['libdrm_intel'])
+    pkg_config_modules(env, 'drm_radeon', ['libdrm_radeon'])
+    pkg_config_modules(env, 'xorg', ['xorg-server'])
+    pkg_config_modules(env, 'kms', ['libkms'])
+
+    env['dri'] = env['x11'] and env['drm']
 
     # Custom builders and methods
     env.Tool('custom')