EGG_DEBUGBUILD added by mario-goulart on Mon Oct 21 15:29:22 2013

diff --git a/chicken-hatch.scm b/chicken-hatch.scm
index 59dceb3..c96863d 100755
--- a/chicken-hatch.scm
+++ b/chicken-hatch.scm
@@ -159,8 +159,14 @@ Options:
 
 (write-egg-file "setup"
 #<#EOF
-(compile -d0 -O2 -J -s #(write-string (string->symbol egg-name.scm)))
-(compile -d0 -O2 -s #(write-string (string->symbol egg-name.import.scm)))
+(define csc-args
+  (cons '-S
+        (if (get-environment-variable "EGG_DEBUGBUILD")
+            '(-O0 -d2)
+            '(-O3 -d0))))
+
+(compile ,@csc-args -J -s #(write-string (string->symbol egg-name.scm)))
+(compile ,@csc-args -s #(write-string (string->symbol egg-name.import.scm)))
 
 (install-extension
  '#(write-string egg-symbol)