--- ./SConstruct.debug	2008-12-12 17:33:25.000000000 +0100
+++ ./SConstruct	2009-01-14 17:29:41.000000000 +0100
@@ -157,6 +157,8 @@
 opts.Add(('APPEND_LINKFLAGS', 'Additional linker flags'))
 # build options
 opts.Add(BoolOption('DEBUG', 'Build executables with debugging information', 'no'))
+opts.Add(BoolOption('DEBUG_SYMBOLS', 'Build with debugging information, but none of the side effects of DEBUG', 'no'))
+opts.Add(BoolOption('OPT', 'Build with optimization', 'yes'))
 opts.Add(PathOption('CODESIGNER', 'A program used to sign executables', None))
 opts.Add(BoolOption('STRIP', 'Strips executables of any unrequired data such as symbols', 'yes'))
 opts.Add(BoolOption('STRIP_CP', 'Strips cross-platform executables of any unrequired data such as symbols', 'yes'))
--- ./SCons/Config/gnu.debug	2009-01-14 17:24:59.000000000 +0100
+++ ./SCons/Config/gnu	2009-01-14 17:29:02.000000000 +0100
@@ -66,8 +66,11 @@
 stub_env = defenv.Clone()
 cross_env(stub_env)
 
-if not defenv['DEBUG']:
-	stub_env.Append(CCFLAGS = ['-Os'])                # optimize for size
+if defenv['DEBUG_SYMBOLS']:
+	stub_env.Append(LINKFLAGS = '-g')           # debugging
+	stub_env.Append(CCFLAGS = '-g')             # debugging
+if not defenv['DEBUG'] and defenv['OPT']:
+	stub_env.Append(CCFLAGS = ['-O2'])          # optimize
 stub_env.Append(CCFLAGS = ['-Wall'])                # all warnings
 stub_env.Append(CCFLAGS = ['-xc'])                  # force compile as c
 stub_env.Append(CCFLAGS = ['-fno-strict-aliasing']) # not safe for strict aliasing
@@ -83,15 +86,18 @@
 ### makensis environment
 
 makensis_env = defenv.Clone()
-
-if not defenv['DEBUG']:
-	makensis_env.Append(CCFLAGS = ['-O2'])            # optimize
+  
+if defenv['DEBUG_SYMBOLS']:
+	makensis_env.Append(LINKFLAGS = '-g')       # debugging
+	makensis_env.Append(CCFLAGS = '-g')         # debugging
+if not defenv['DEBUG'] and defenv['OPT']:
+	makensis_env.Append(CCFLAGS = ['-O2'])      # optimize
 makensis_env.Append(CCFLAGS = ['-Wall'])            # all warnings
 makensis_env.Append(CXXFLAGS = ['-Wno-non-virtual-dtor']) # ignore virtual dtor warnings
 
 conf = FlagsConfigure(makensis_env)
 conf.CheckLinkFlag('$MAP_FLAG')                   # generate map file
-if not defenv['DEBUG'] and defenv['STRIP'] and defenv['STRIP_CP']:
+if not defenv['DEBUG'] and not defenv['DEBUG_SYMBOLS'] and defenv['STRIP'] and defenv['STRIP_CP']:
 	TestStrip(conf)                                 # strip
 conf.Finish()
 
@@ -100,13 +106,16 @@
 plugin_env = defenv.Clone()
 cross_env(plugin_env)
 
-if not defenv['DEBUG']:
-	plugin_env.Append(CCFLAGS = ['-Os'])              # optimize for size
+if defenv['DEBUG_SYMBOLS']:
+	plugin_env.Append(LINKFLAGS = '-g')           # debugging
+	plugin_env.Append(CCFLAGS = '-g')             # debugging
+if not defenv['DEBUG'] and defenv['OPT']:
+	plugin_env.Append(CCFLAGS = ['-O2'])        # optimize
 plugin_env.Append(CCFLAGS = ['-Wall'])              # level 3 warnings
 plugin_env.Append(CCFLAGS = ['-fno-strict-aliasing']) # not safe for strict aliasing
 
 if not defenv['DEBUG'] and defenv['STRIP'] and defenv['STRIP_W32']:
-	plugin_env.Append(LINKFLAGS = ['-s'])             # strip
+	plugin_env.Append(LINKFLAGS = ['-s'])       # strip
 plugin_env.Append(LINKFLAGS = ['-mwindows'])        # build windows executables
 plugin_env.Append(LINKFLAGS = ['$ALIGN_FLAG'])      # 512 bytes align
 plugin_env.Append(LINKFLAGS = ['$MAP_FLAG'])        # generate map file
@@ -115,7 +124,10 @@
 
 cp_util_env = defenv.Clone()
 
-if not defenv['DEBUG']:
+if defenv['DEBUG_SYMBOLS']:
+	cp_util_env.Append(LINKFLAGS = '-g')        # debugging
+	cp_util_env.Append(CCFLAGS = '-g')          # debugging
+if not defenv['DEBUG'] and defenv['OPT']:
 	cp_util_env.Append(CCFLAGS = ['-O2'])             # optimize
 cp_util_env.Append(CCFLAGS = ['-Wall'])             # all warnings
 cp_util_env.Append(CCFLAGS = ['-fno-strict-aliasing']) # not safe for strict aliasing
@@ -149,6 +161,9 @@
 ### test environment
 
 test_env = defenv.Clone()
+if defenv['DEBUG_SYMBOLS']:
+	test_env.Append(LINKFLAGS = '-g')           # debugging
+	test_env.Append(CCFLAGS = '-g')             # debugging
 conf = FlagsConfigure(test_env)
 conf.CheckCompileFlag('-m32')
 conf.CheckLinkFlag('-m32')