--- SConstruct.orig 2009-12-10 14:58:55 UTC +++ SConstruct @@ -16,7 +16,7 @@ picLibBuilder = Builder( env['BUILDERS']['StaticLibrary'] = picLibBuilder env['BUILDERS']['Library'] = picLibBuilder -opts = Options(['options.cache']) +opts = Variables(['options.cache']) #opts.Add('CC', 'C compiler') #opts.Add('CXX', 'C++ compiler') opts.Add('CCFLAGS', 'General options that are passed to the C compiler') @@ -30,12 +30,13 @@ opts.Add('CPPPATH', 'extra cpp path') if sys.platform != "win32": opts.Add('prefix', 'prefix for **nix packaging', '') + opts.Add('DESTDIR', 'staging dir (also for packaging)', '') opts.Add('lib_dir', 'resources directory (default: prefix/lib)', '') opts.Add('plugins_dir', 'plugins directory (default: prefix/lib/btanks)', '') opts.Add('resources_dir', 'resources directory (default: prefix/share/btanks)', '') - opts.Add(BoolOption('gcc_visibility', 'gcc visibility', 'true')) + opts.Add(BoolVariable('gcc_visibility', 'gcc visibility', 'true')) -opts.Add(EnumOption('mode', 'build mode', 'release', allowed_values=('debug','release'))) +opts.Add(EnumVariable('mode', 'build mode', 'release', allowed_values=('debug','release'))) opts.Update(env) opts.Save('options.cache', env.Clone()) @@ -47,16 +48,18 @@ debug = buildmode == "debug" Export('debug') import SCons.Util -if os.environ.has_key('CC'): +if 'CC' in os.environ: env['CC'] = os.environ['CC'] -if os.environ.has_key('CFLAGS'): +if 'CFLAGS' in os.environ: env['CCFLAGS'] += SCons.Util.CLVar(os.environ['CFLAGS']) -if os.environ.has_key('CXX'): +if 'CXX' in os.environ: env['CXX'] = os.environ['CXX'] -if os.environ.has_key('CXXFLAGS'): +if 'CXXFLAGS' in os.environ: env['CXXFLAGS'] += SCons.Util.CLVar(os.environ['CXXFLAGS']) -if os.environ.has_key('LDFLAGS'): +if 'LDFLAGS' in os.environ: env['LINKFLAGS'] += SCons.Util.CLVar(os.environ['LDFLAGS']) +if 'CPPPATH' in os.environ: + env['CPPPATH'] = os.environ['CPPPATH'].split() if (sys.platform != "win32" and env['gcc_visibility']): env.Append(CCFLAGS=['-fvisibility=hidden', '-DGCC_HASCLASSVISIBILITY']) @@ -98,9 +101,6 @@ else: if debug: env.Append(CCFLAGS=['-ggdb', '-D_FORTIFY_SOURCE=2']) env.Append(CPPFLAGS=['-ggdb', '-D_FORTIFY_SOURCE=2']) - else: - env.Append(CCFLAGS=['-O3']) - env.Append(CPPFLAGS=['-O3']) env.Append(CPPFLAGS=['-Wall', '-Wno-deprecated', '-pedantic', '-Wno-long-long', '-pipe', '-pthread']) env.Append(CCFLAGS=['-Wall', '-Wno-deprecated', '-pedantic', '-Wno-long-long', '-pipe', '-pthread']) @@ -205,7 +205,7 @@ try : except: info = sys.exc_info() - print "%s %s %s" %(info[0], info[1], info[2]) + print("%s %s %s" %(info[0], info[1], info[2])) except : svnversion = os.popen('svnversion -n .', 'r') version = svnversion.readline().strip() @@ -238,7 +238,10 @@ except : env.Append(CPPDEFINES='PLUGINS_DIR="\\"' + plugins_dir + '\\""') version = version[version.rfind(':') + 1:] -revision = int(version.replace('M', '')) +try: + revision = int(version.replace('M', '')) +except ValueError: + revision = 0 Export('version') Export('revision') @@ -246,31 +249,35 @@ Export('lib_dir') Export('plugins_dir') version = '0.9.%s' %version -print "version: %s" %version +print("version: %s" %version) bt_sublibs = ['mrt', 'sdlx', 'objects', 'clunk'] env.Append(CPPPATH=['#']) if (os.path.exists('private')): dir = 'private' - BuildDir('#/build/' + buildmode + '/' + dir, dir, 0) + VariantDir('#/build/' + buildmode + '/' + dir, dir, 0) SConscript('#/build/' + buildmode + '/' + dir + '/SConscript') for dir in bt_sublibs: - BuildDir('#/build/' + buildmode + '/' + dir, dir, 0) + VariantDir('#/build/' + buildmode + '/' + dir, dir, 0) SConscript('#/build/' + buildmode + '/' + dir + '/SConscript') for dir in bt_sublibs: env.Append(LIBPATH=['#/build/' + buildmode + '/' + dir]) -env.BuildDir('#/build/' + buildmode + '/editor', 'editor', 0) +env.VariantDir('#/build/' + buildmode + '/editor', 'editor', 0) SConscript('#/build/' + buildmode + '/editor/SConscript') env.Append(LIBPATH=['#/build/' + buildmode + '/engine']) -env.BuildDir('#/build/' + buildmode + '/engine', 'engine', 0) +env.VariantDir('#/build/' + buildmode + '/engine', 'engine', 0) SConscript('#/build/' + buildmode + '/engine/' + 'SConscript') if len(install_targets) > 0: - install_targets.append(env.Command(resources_dir + '/resources.dat', '#/data', 'zip -q -0 -r $TARGET * -x \*.svn\* -x \*.wav', chdir='data')) + install_targets.append( + env.Command(env['DESTDIR'] + resources_dir + '/resources.dat', + '#/data', + 'zip -q -0 -r $TARGET * -x \*.svn\* -x \*.wav', + chdir='data')) env.Alias('install', install_targets)