Deleted Added
sdiff udiff text old ( 6168:ba6fe02228db ) new ( 6654:4c84e771cca7 )
full compact
1# -*- mode:python -*-
2
3# Copyright (c) 2009 The Hewlett-Packard Development Company
4# Copyright (c) 2004-2005 The Regents of The University of Michigan
5# All rights reserved.
6#
7# Redistribution and use in source and binary forms, with or without
8# modification, are permitted provided that the following conditions are

--- 82 unchanged lines hidden (view full) ---

91'python' first or (2) explicitly invoking an alternative interpreter
92on the scons script.
93
94For more details, see:
95 http://m5sim.org/wiki/index.php/Using_a_non-default_Python_installation
96"""
97 raise
98
99import os
100import re
101import subprocess
102import sys
103
104from os import mkdir, environ
105from os.path import abspath, basename, dirname, expanduser, normpath
106from os.path import exists, isdir, isfile
107from os.path import join as joinpath, split as splitpath
108
109import SCons
110import SCons.Node
111
112def read_command(cmd, **kwargs):
113 """run the command cmd, read the results and return them
114 this is sorta like `cmd` in shell"""
115 from subprocess import Popen, PIPE, STDOUT
116
117 if isinstance(cmd, str):
118 cmd = cmd.split()
119
120 no_exception = 'exception' in kwargs
121 exception = kwargs.pop('exception', None)
122
123 kwargs.setdefault('shell', False)
124 kwargs.setdefault('stdout', PIPE)
125 kwargs.setdefault('stderr', STDOUT)
126 kwargs.setdefault('close_fds', True)
127 try:
128 subp = Popen(cmd, **kwargs)
129 except Exception, e:
130 if no_exception:
131 return exception
132 raise
133
134 return subp.communicate()[0]
135
136# helper function: compare arrays or strings of version numbers.
137# E.g., compare_version((1,3,25), (1,4,1)')
138# returns -1, 0, 1 if v1 is <, ==, > v2
139def compare_versions(v1, v2):
140 def make_version_list(v):
141 if isinstance(v, (list,tuple)):
142 return v
143 elif isinstance(v, str):
144 return map(lambda x: int(re.match('\d+', x).group()), v.split('.'))
145 else:
146 raise TypeError
147
148 v1 = make_version_list(v1)
149 v2 = make_version_list(v2)
150 # Compare corresponding elements of lists
151 for n1,n2 in zip(v1, v2):
152 if n1 < n2: return -1
153 if n1 > n2: return 1
154 # all corresponding values are equal... see if one has extra values
155 if len(v1) < len(v2): return -1
156 if len(v1) > len(v2): return 1
157 return 0
158
159########################################################################
160#
161# Set up the main build environment.
162#
163########################################################################
164use_vars = set([ 'AS', 'AR', 'CC', 'CXX', 'HOME', 'LD_LIBRARY_PATH', 'PATH',
165 'RANLIB' ])
166

--- 45 unchanged lines hidden (view full) ---

212run the style hook. It is important.
213"""
214
215hg_info = "Unknown"
216if hgdir.exists():
217 # 1) Grab repository revision if we know it.
218 cmd = "hg id -n -i -t -b"
219 try:
220 hg_info = read_command(cmd, cwd=main.root.abspath).strip()
221 except OSError:
222 print mercurial_bin_not_found
223
224 # 2) Ensure that the style hook is in place.
225 try:
226 ui = None
227 if ARGUMENTS.get('IGNORE_STYLE') != 'True':
228 from mercurial import ui

--- 147 unchanged lines hidden (view full) ---

376Export('extras_dir_list')
377
378# the ext directory should be on the #includes path
379main.Append(CPPPATH=[Dir('ext')])
380
381# M5_PLY is used by isa_parser.py to find the PLY package.
382main.Append(ENV = { 'M5_PLY' : Dir('ext/ply').abspath })
383
384CXX_version = read_command([main['CXX'],'--version'], exception=False)
385CXX_V = read_command([main['CXX'],'-V'], exception=False)
386
387main['GCC'] = CXX_version and CXX_version.find('g++') >= 0
388main['SUNCC'] = CXX_V and CXX_V.find('Sun C++') >= 0
389main['ICC'] = CXX_V and CXX_V.find('Intel') >= 0
390if main['GCC'] + main['SUNCC'] + main['ICC'] > 1:
391 print 'Error: How can we have two at the same time?'
392 Exit(1)
393

--- 36 unchanged lines hidden (view full) ---

430
431# Check for SWIG
432if not main.has_key('SWIG'):
433 print 'Error: SWIG utility not found.'
434 print ' Please install (see http://www.swig.org) and retry.'
435 Exit(1)
436
437# Check for appropriate SWIG version
438swig_version = read_command(('swig', '-version'), exception='').split()
439# First 3 words should be "SWIG Version x.y.z"
440if len(swig_version) < 3 or \
441 swig_version[0] != 'SWIG' or swig_version[1] != 'Version':
442 print 'Error determining SWIG version.'
443 Exit(1)
444
445min_swig_version = '1.3.28'
446if compare_versions(swig_version[2], min_swig_version) < 0:
447 print 'Error: SWIG version', min_swig_version, 'or newer required.'
448 print ' Installed version:', swig_version[2]
449 Exit(1)
450
451# Set up SWIG flags & scanner
452swig_flags=Split('-c++ -python -modern -templatereduce $_CPPINCFLAGS')
453main.Append(SWIGFLAGS=swig_flags)
454

--- 54 unchanged lines hidden (view full) ---

509# Check for leading underscores. Don't really need to worry either
510# way so don't need to check the return code.
511conf.CheckLeading()
512
513# Check if we should compile a 64 bit binary on Mac OS X/Darwin
514try:
515 import platform
516 uname = platform.uname()
517 if uname[0] == 'Darwin' and compare_versions(uname[2], '9.0.0') >= 0:
518 if int(read_command('sysctl -n hw.cpu64bit_capable')[0]):
519 main.Append(CCFLAGS='-arch x86_64')
520 main.Append(CFLAGS='-arch x86_64')
521 main.Append(LINKFLAGS='-arch x86_64')
522 main.Append(ASFLAGS='-arch x86_64')
523except:
524 pass
525
526# Recent versions of scons substitute a "Null" object for Configure()

--- 83 unchanged lines hidden (view full) ---

610#
611# Check for mysql.
612#
613mysql_config = WhereIs('mysql_config')
614have_mysql = bool(mysql_config)
615
616# Check MySQL version.
617if have_mysql:
618 mysql_version = read_command(mysql_config + ' --version')
619 min_mysql_version = '4.1'
620 if compare_versions(mysql_version, min_mysql_version) < 0:
621 print 'Warning: MySQL', min_mysql_version, 'or newer required.'
622 print ' Version', mysql_version, 'detected.'
623 have_mysql = False
624
625# Set up mysql_config commands.
626if have_mysql:
627 mysql_config_include = mysql_config + ' --include'
628 if os.system(mysql_config_include + ' > /dev/null') != 0:

--- 278 unchanged lines hidden ---