SConstruct (9740:101441a7b420) | SConstruct (9812:9265bcff11b7) |
---|---|
1# -*- mode:python -*- 2 | 1# -*- mode:python -*- 2 |
3# Copyright (c) 2013 ARM Limited 4# All rights reserved. 5# 6# The license below extends only to copyright in the software and shall 7# not be construed as granting a license to any other intellectual 8# property including but not limited to intellectual property relating 9# to a hardware implementation of the functionality of the software 10# licensed hereunder. You may use the software subject to the license 11# terms below provided that you ensure that this notice is replicated 12# unmodified and in its entirety in all distributions of the software, 13# modified or unmodified, in source code or in binary form. 14# |
|
3# Copyright (c) 2011 Advanced Micro Devices, Inc. 4# Copyright (c) 2009 The Hewlett-Packard Development Company 5# Copyright (c) 2004-2005 The Regents of The University of Michigan 6# All rights reserved. 7# 8# Redistribution and use in source and binary forms, with or without 9# modification, are permitted provided that the following conditions are 10# met: redistributions of source code must retain the above copyright --- 65 unchanged lines hidden (view full) --- 76 EnsureSConsVersion(0, 98, 1) 77except SystemExit, e: 78 print """ 79For more details, see: 80 http://gem5.org/Dependencies 81""" 82 raise 83 | 15# Copyright (c) 2011 Advanced Micro Devices, Inc. 16# Copyright (c) 2009 The Hewlett-Packard Development Company 17# Copyright (c) 2004-2005 The Regents of The University of Michigan 18# All rights reserved. 19# 20# Redistribution and use in source and binary forms, with or without 21# modification, are permitted provided that the following conditions are 22# met: redistributions of source code must retain the above copyright --- 65 unchanged lines hidden (view full) --- 88 EnsureSConsVersion(0, 98, 1) 89except SystemExit, e: 90 print """ 91For more details, see: 92 http://gem5.org/Dependencies 93""" 94 raise 95 |
84# We ensure the python version early because we have stuff that 85# requires python 2.4 | 96# We ensure the python version early because because python-config 97# requires python 2.5 |
86try: | 98try: |
87 EnsurePythonVersion(2, 4) | 99 EnsurePythonVersion(2, 5) |
88except SystemExit, e: 89 print """ 90You can use a non-default installation of the Python interpreter by | 100except SystemExit, e: 101 print """ 102You can use a non-default installation of the Python interpreter by |
91either (1) rearranging your PATH so that scons finds the non-default 92'python' first or (2) explicitly invoking an alternative interpreter 93on the scons script. | 103rearranging your PATH so that scons finds the non-default 'python' and 104'python-config' first. |
94 95For more details, see: 96 http://gem5.org/wiki/index.php/Using_a_non-default_Python_installation 97""" 98 raise 99 100# Global Python includes 101import os --- 720 unchanged lines hidden (view full) --- 822 self.env = env 823 def Finish(self): 824 return self.env 825 def __getattr__(self, mname): 826 return NullCheck 827 828 conf = NullConf(main) 829 | 105 106For more details, see: 107 http://gem5.org/wiki/index.php/Using_a_non-default_Python_installation 108""" 109 raise 110 111# Global Python includes 112import os --- 720 unchanged lines hidden (view full) --- 833 self.env = env 834 def Finish(self): 835 return self.env 836 def __getattr__(self, mname): 837 return NullCheck 838 839 conf = NullConf(main) 840 |
830# Find Python include and library directories for embedding the 831# interpreter. For consistency, we will use the same Python 832# installation used to run scons (and thus this script). If you want 833# to link in an alternate version, see above for instructions on how 834# to invoke scons with a different copy of the Python interpreter. 835from distutils import sysconfig 836 837py_getvar = sysconfig.get_config_var 838 839py_debug = getattr(sys, 'pydebug', False) 840py_version = 'python' + py_getvar('VERSION') + (py_debug and "_d" or "") 841 842py_general_include = sysconfig.get_python_inc() 843py_platform_include = sysconfig.get_python_inc(plat_specific=True) 844py_includes = [ py_general_include ] 845if py_platform_include != py_general_include: 846 py_includes.append(py_platform_include) 847 848py_lib_path = [ py_getvar('LIBDIR') ] 849# add the prefix/lib/pythonX.Y/config dir, but only if there is no 850# shared library in prefix/lib/. 851if not py_getvar('Py_ENABLE_SHARED'): 852 py_lib_path.append(py_getvar('LIBPL')) 853 # Python requires the flags in LINKFORSHARED to be added the 854 # linker flags when linking with a statically with Python. Failing 855 # to do so can lead to errors from the Python's dynamic module 856 # loader at start up. 857 main.Append(LINKFLAGS=[py_getvar('LINKFORSHARED').split()]) 858 859py_libs = [] 860for lib in py_getvar('LIBS').split() + py_getvar('SYSLIBS').split(): 861 if not lib.startswith('-l'): 862 # Python requires some special flags to link (e.g. -framework 863 # common on OS X systems), assume appending preserves order 864 main.Append(LINKFLAGS=[lib]) 865 else: 866 lib = lib[2:] 867 if lib not in py_libs: 868 py_libs.append(lib) 869py_libs.append(py_version) 870 871main.Append(CPPPATH=py_includes) 872main.Append(LIBPATH=py_lib_path) 873 | |
874# Cache build files in the supplied directory. 875if main['M5_BUILD_CACHE']: 876 print 'Using build cache located at', main['M5_BUILD_CACHE'] 877 CacheDir(main['M5_BUILD_CACHE']) 878 | 841# Cache build files in the supplied directory. 842if main['M5_BUILD_CACHE']: 843 print 'Using build cache located at', main['M5_BUILD_CACHE'] 844 CacheDir(main['M5_BUILD_CACHE']) 845 |
846# Find Python include and library directories for embedding the 847# interpreter. We rely on python-config to resolve the appropriate 848# includes and linker flags. ParseConfig does not seem to understand 849# the more exotic linker flags such as -Xlinker and -export-dynamic so 850# we add them explicitly below. If you want to link in an alternate 851# version of python, see above for instructions on how to invoke 852# scons with the appropriate PATH set. 853py_includes = readCommand(['python-config', '--includes'], 854 exception='').split() 855# Strip the -I from the include folders before adding them to the 856# CPPPATH 857main.Append(CPPPATH=map(lambda inc: inc[2:], py_includes)) |
|
879 | 858 |
859# Read the linker flags and split them into libraries and other link 860# flags. The libraries are added later through the call the CheckLib. 861py_ld_flags = readCommand(['python-config', '--ldflags'], exception='').split() 862py_libs = [] 863for lib in py_ld_flags: 864 if not lib.startswith('-l'): 865 main.Append(LINKFLAGS=[lib]) 866 else: 867 lib = lib[2:] 868 if lib not in py_libs: 869 py_libs.append(lib) 870 |
|
880# verify that this stuff works 881if not conf.CheckHeader('Python.h', '<>'): 882 print "Error: can't find Python.h header in", py_includes 883 print "Install Python headers (package python-dev on Ubuntu and RedHat)" 884 Exit(1) 885 886for lib in py_libs: 887 if not conf.CheckLib(lib): --- 381 unchanged lines hidden --- | 871# verify that this stuff works 872if not conf.CheckHeader('Python.h', '<>'): 873 print "Error: can't find Python.h header in", py_includes 874 print "Install Python headers (package python-dev on Ubuntu and RedHat)" 875 Exit(1) 876 877for lib in py_libs: 878 if not conf.CheckLib(lib): --- 381 unchanged lines hidden --- |