-# SCons version numbers need special processing because they can have
-# charecters and an release date embedded in them. This function does
-# the magic to extract them in a similar way to the SCons internal function
-# function does and then checks that the current version is not contained in
-# a list of version tuples (bad_ver_strs)
-def CheckSCons(bad_ver_strs):
- def scons_ver(v):
- num_parts = v.split(' ')[0].split('.')
- major = int(num_parts[0])
- minor = int(re.match('\d+', num_parts[1]).group())
- rev = 0
- rdate = 0
- if len(num_parts) > 2:
- try: rev = int(re.match('\d+', num_parts[2]).group())
- except: pass
- rev_parts = num_parts[2].split('d')
- if len(rev_parts) > 1:
- rdate = int(re.match('\d+', rev_parts[1]).group())
-
- return (major, minor, rev, rdate)
-
- sc_ver = scons_ver(SCons.__version__)
- for bad_ver in bad_ver_strs:
- bv = (scons_ver(bad_ver[0]), scons_ver(bad_ver[1]))
- if compare_versions(sc_ver, bv[0]) != -1 and\
- compare_versions(sc_ver, bv[1]) != 1:
- print "The version of SCons that you have installed: ", SCons.__version__
- print "has a bug that prevents it from working correctly with M5."
- print "Please install a version NOT contained within the following",
- print "ranges (inclusive):"
- for bad_ver in bad_ver_strs:
- print " %s - %s" % bad_ver
- Exit(2)
-
-CheckSCons((
- # We need a version that is 0.96.91 or newer
- ('0.0.0', '0.96.90'),
- ))
-
-
-# The absolute path to the current directory (where this file lives).
-ROOT = Dir('.').abspath
-
-# Path to the M5 source tree.
-SRCDIR = joinpath(ROOT, 'src')
-
-# tell python where to find m5 python code
-sys.path.append(joinpath(ROOT, 'src/python'))
-
-def check_style_hook(ui):
- ui.readconfig(joinpath(ROOT, '.hg', 'hgrc'))
- style_hook = ui.config('hooks', 'pretxncommit.style', None)
-
- if not style_hook:
- print """\
+########################################################################
+#
+# Set up the main build environment.
+#
+########################################################################
+use_vars = set([ 'AS', 'AR', 'CC', 'CXX', 'HOME', 'LD_LIBRARY_PATH', 'PATH',
+ 'RANLIB' ])
+
+use_env = {}
+for key,val in os.environ.iteritems():
+ if key in use_vars or key.startswith("M5"):
+ use_env[key] = val
+
+main = Environment(ENV=use_env)
+main.root = Dir(".") # The current directory (where this file lives).
+main.srcdir = Dir("src") # The source directory
+
+########################################################################
+#
+# Mercurial Stuff.
+#
+# If the M5 directory is a mercurial repository, we should do some
+# extra things.
+#
+########################################################################
+
+hgdir = main.root.Dir(".hg")
+
+mercurial_style_message = """