+conf = Configure(main,
+ conf_dir = joinpath(build_root, '.scons_config'),
+ log_file = joinpath(build_root, 'scons_config.log'),
+ custom_tests = { 'CheckLeading' : CheckLeading })
+
+# Check for leading underscores. Don't really need to worry either
+# way so don't need to check the return code.
+conf.CheckLeading()
+
+# Check if we should compile a 64 bit binary on Mac OS X/Darwin
+try:
+ import platform
+ uname = platform.uname()
+ if uname[0] == 'Darwin' and compareVersions(uname[2], '9.0.0') >= 0:
+ if int(readCommand('sysctl -n hw.cpu64bit_capable')[0]):
+ main.Append(CCFLAGS='-arch x86_64')
+ main.Append(CFLAGS='-arch x86_64')
+ main.Append(LINKFLAGS='-arch x86_64')
+ main.Append(ASFLAGS='-arch x86_64')
+except:
+ pass
+
+# Recent versions of scons substitute a "Null" object for Configure()
+# when configuration isn't necessary, e.g., if the "--help" option is
+# present. Unfortuantely this Null object always returns false,
+# breaking all our configuration checks. We replace it with our own
+# more optimistic null object that returns True instead.
+if not conf:
+ def NullCheck(*args, **kwargs):
+ return True
+
+ class NullConf:
+ def __init__(self, env):
+ self.env = env
+ def Finish(self):
+ return self.env
+ def __getattr__(self, mname):
+ return NullCheck
+
+ conf = NullConf(main)
+
+# Find Python include and library directories for embedding the
+# interpreter. For consistency, we will use the same Python
+# installation used to run scons (and thus this script). If you want
+# to link in an alternate version, see above for instructions on how
+# to invoke scons with a different copy of the Python interpreter.
+from distutils import sysconfig
+
+py_getvar = sysconfig.get_config_var
+
+py_version = 'python' + py_getvar('VERSION')
+
+py_general_include = sysconfig.get_python_inc()
+py_platform_include = sysconfig.get_python_inc(plat_specific=True)
+py_includes = [ py_general_include ]
+if py_platform_include != py_general_include:
+ py_includes.append(py_platform_include)
+
+py_lib_path = [ py_getvar('LIBDIR') ]
+# add the prefix/lib/pythonX.Y/config dir, but only if there is no
+# shared library in prefix/lib/.
+if not py_getvar('Py_ENABLE_SHARED'):
+ py_lib_path.append(py_getvar('LIBPL'))
+
+py_libs = []
+for lib in py_getvar('LIBS').split() + py_getvar('SYSLIBS').split():
+ assert lib.startswith('-l')
+ lib = lib[2:]
+ if lib not in py_libs:
+ py_libs.append(lib)
+py_libs.append(py_version)
+
+main.Append(CPPPATH=py_includes)
+main.Append(LIBPATH=py_lib_path)
+
+# verify that this stuff works
+if not conf.CheckHeader('Python.h', '<>'):
+ print "Error: can't find Python.h header in", py_includes
+ Exit(1)
+
+for lib in py_libs:
+ if not conf.CheckLib(lib):
+ print "Error: can't find library %s required by python" % lib
+ Exit(1)
+
+# On Solaris you need to use libsocket for socket ops
+if not conf.CheckLibWithHeader(None, 'sys/socket.h', 'C++', 'accept(0,0,0);'):
+ if not conf.CheckLibWithHeader('socket', 'sys/socket.h', 'C++', 'accept(0,0,0);'):
+ print "Can't find library with socket calls (e.g. accept())"
+ Exit(1)
+
+# Check for zlib. If the check passes, libz will be automatically
+# added to the LIBS environment variable.
+if not conf.CheckLibWithHeader('z', 'zlib.h', 'C++','zlibVersion();'):
+ print 'Error: did not find needed zlib compression library '\
+ 'and/or zlib.h header file.'
+ print ' Please install zlib and try again.'
+ Exit(1)