Merge branch 'gallium-0.1' into gallium-0.2
[mesa.git] / scons / python.py
1 """gallium
2
3 Frontend-tool for Gallium3D architecture.
4
5 """
6
7 #
8 # Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas.
9 # All Rights Reserved.
10 #
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:
18 #
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.
22 #
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.
30 #
31
32
33 import sys
34 import distutils.sysconfig
35 import os.path
36
37
38 def generate(env):
39 # See http://www.scons.org/wiki/PythonExtensions
40
41 if sys.platform in ['windows']:
42 python_root = sys.prefix
43 python_version = '%u%u' % sys.version_info[:2]
44 python_include = os.path.join(python_root, 'include')
45 python_libs = os.path.join(python_root, 'libs')
46 python_lib = os.path.join(python_libs, 'python' + python_version + '.lib')
47
48 env.Append(CPPPATH = [python_include])
49 env.Append(LIBPATH = [python_libs])
50 env.Append(LIBS = ['python' + python_version + '.lib'])
51 env.Replace(SHLIBPREFIX = '')
52 env.Replace(SHLIBSUFFIX = '.pyd')
53
54 # XXX; python25_d.lib is not included in Python for windows, and
55 # we'll get missing symbols unless we undefine _DEBUG
56 cppdefines = env['CPPDEFINES']
57 cppdefines = [define for define in cppdefines if define != '_DEBUG']
58 env.Replace(CPPDEFINES = cppdefines)
59 else:
60 #env.ParseConfig('python-config --cflags --ldflags --libs')
61 env.AppendUnique(CPPPATH = [distutils.sysconfig.get_python_inc()])
62 env.Replace(SHLIBPREFIX = '')
63 env.Replace(SHLIBSUFFIX = distutils.sysconfig.get_config_vars()['SO'])
64
65 # for debugging
66 #print env.Dump()
67
68
69 def exists(env):
70 return 1