Index: sources/src/gen_code.cc
===================================================================
--- sources/src/gen_code.cc	(revision 17)
+++ sources/src/gen_code.cc	(revision 27)
@@ -34,7 +34,7 @@
  * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  */
-#ifndef _WIN32
+#if defined(__linux__)
 #include <linux/limits.h>
-#else
+#elif defined(WIN32)
 #include <windows.h>
 #endif
@@ -45,21 +45,24 @@
 #include<fstream>
 
-#include"internal.h"
-#include"gen_code.h"
-#include"sc_module.h"
-#include"sc_ver.h"
-#include"process_dependency.h"
-
-#ifdef CHECK_FSM_RULES
-#define fsm_check_flag "-DCHECK_FSM_RULES"
+#include "internal.h"
+#include "gen_code.h"
+#include "sc_module.h"
+#include "sc_ver.h"
+#include "process_dependency.h"
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#ifdef CONFIG_CHECK_FSM_RULES
+#include "fsm_rules.h"
+#define fsm_check_flag "-DCONFIG_CHECK_FSM_RULES"
 #else
 #define fsm_check_flag
 #endif
 
-#define casc_cflags CFLAGS " " fsm_check_flag
-
-#if defined(darwin)
-#define macosx
-#endif
+#define casc_cflags GENERATED_MODULE_CFLAGS " " fsm_check_flag
+
+// Enable CPP call, this is useful for typeinfo-enabled classes
+#define CPP_CALL
 
 using namespace std;
@@ -91,5 +94,5 @@
 	  	<< m.module->name() << "->" << m.name << "()\\n\");\n";
   o << " p.integer = " << func << ";\n";
-#if CPP_CALL
+#ifdef CPP_CALL
   o << " (((sc_module*)(" << m.module << "))->*(p.pmf)) (); /* " 
 		<< m.module->name () << "->" << m.name << "() */\n";
@@ -143,5 +146,5 @@
   }
 
-#ifdef DEBUG
+#ifdef CONFIG_DEBUG
   cerr << "opened temporary filename : " << temp << "\n";
 #endif
@@ -268,7 +271,7 @@
 
   o << "// generated by " << sc_version () << endl
-		<< "#include<casc.h>\n\n"
-		<< "#include<cstdio>\n\n"
-//		<< "#include<iostream>\n\n"
+		<< "#include <casc.h>\n\n"
+		<< "#include <cstdio>\n\n"
+//		<< "#include <iostream>\n\n"
 		<< "namespace sc_core {\n"
     << " typedef void (sc_module::*SC_ENTRY_FUNC)();\n"
@@ -329,7 +332,7 @@
 
   o << "// generated by " << sc_version () << endl
-		<< "#include<casc.h>\n\n"
-		<< "#include<cstdio>\n\n"
-//		<< "#include<iostream>\n\n"
+		<< "#include <casc.h>\n\n"
+		<< "#include <cstdio>\n\n"
+//		<< "#include <iostream>\n\n"
 		<< "namespace sc_core {\n"
     << " typedef void (sc_module::*SC_ENTRY_FUNC)();\n"
@@ -377,5 +380,5 @@
 //  const char *target_arch = getenv ("TARGET_ARCH");
 	const char *default_compiler =
-#if CPP_CALL
+#ifdef CPP_CALL
 		"g++";
 #else
@@ -418,33 +421,21 @@
   /* COMPILE */
   /* ******* */
-#if defined(macosx)
-    sprintf(compil_str, 
-				"(cd %s ; %s %s -DSCHEDULING_BY_CASC -I%s/include -fno-common -dynamic -o %s -c %s)",
-        temporary_dir,
-			 	compiler, 
-				casc_cflags, 
-				systemc_dir, 
-				target_name,
-				source_name);
-//    sprintf(compil_str,""); 
-#elif defined(linux)
-    sprintf(compil_str, 
-				"(cd %s ; libtool --mode=compile %s %s -DSCHEDULING_BY_CASC -I%s/include -shared -o %s -c %s)",
-        temporary_dir,
-			 	compiler, 
-				casc_cflags, 
-				systemc_dir, 
-				target_name,
-				source_name);
+  const char *commandline_template =
+#if defined(CONFIG_OS_DARWIN)
+	  "(cd %s ;"                     " %s %s -DSCHEDULING_BY_CASC -I%s/include -fno-common -dynamic -o %s -c %s)"
+#elif defined(CONFIG_OS_LINUX)
+	  "(cd %s ; libtool --mode=compile %s %s -DSCHEDULING_BY_CASC -I%s/include -shared -o %s -c %s)"
 #else
-    sprintf(compil_str, 
-				"(cd %s ; %s %s -DSCHEDULING_BY_CASC -I%s/include -dynamiclib -o %s -c %s)",
-        temporary_dir,
-			 	compiler, 
-				casc_cflags, 
-				systemc_dir, 
-				target_name,
-				source_name);
-#endif
+	  "(cd %s ;"                     " %s %s -DSCHEDULING_BY_CASC -I%s/include -dynamiclib -o %s -c %s)"
+#endif
+	  ;
+  sprintf(compil_str, 
+		  commandline_template,
+		  temporary_dir,
+		  compiler, 
+		  casc_cflags, 
+		  systemc_dir, 
+		  target_name,
+		  source_name);
 
   if (dump_stage) 
@@ -461,5 +452,5 @@
   sprintf (target_name, "%s.so", base_name);
 
-#if defined(linux)
+#ifdef CONFIG_OS_LINUX
   sprintf (source_name, "%s.lo", base_name);
   sprintf(compil_str, "(cd %s ; pwd ; libtool --mode=link %s %s -shared -rdynamic -o %s %s)", /* -L. -L%s/lib-%s */ 
@@ -560,5 +551,5 @@
   for (i = 0; i < n; ++i)
   {
-#if 0 //defined(DEBUG)
+#if 0 //defined(CONFIG_DEBUG)
     sc_module *m = (sc_module*)(fc.instance[i]);
     cerr << m->name () << endl;
@@ -575,18 +566,18 @@
 void static_simulate_1_cycle (void) 
 {
-#ifdef CHECK_FSM_RULES
+#ifdef CONFIG_CHECK_FSM_RULES
 	casc_fsm_step = TRANSITION;
 #endif
   call_functions (pf[0]); // transition
   update     ();
-#ifdef CHECK_FSM_RULES
+#ifdef CONFIG_CHECK_FSM_RULES
 	casc_fsm_step = GEN_MOORE;
 #endif
   call_functions (pf[1]); // moore generation
-#ifdef CHECK_FSM_RULES
+#ifdef CONFIG_CHECK_FSM_RULES
 	casc_fsm_step = GEN_MEALY;
 #endif
   call_functions (pf[2]); // mealy generation
-#ifdef CHECK_FSM_RULES
+#ifdef CONFIG_CHECK_FSM_RULES
 	casc_fsm_step = STIMULI;
 #endif
@@ -634,5 +625,5 @@
 void quasistatic_simulate_1_cycle (void) 
 {
-#ifdef CHECK_FSM_RULES
+#ifdef CONFIG_CHECK_FSM_RULES
 	casc_fsm_step = TRANSITION;
 #endif
@@ -644,5 +635,5 @@
   }
   update     ();
-#ifdef CHECK_FSM_RULES
+#ifdef CONFIG_CHECK_FSM_RULES
 	casc_fsm_step = GEN_MOORE;
 #endif
@@ -652,9 +643,9 @@
     Call (m);
   }
-#ifdef CHECK_FSM_RULES
+#ifdef CONFIG_CHECK_FSM_RULES
 	casc_fsm_step = GEN_MEALY;
 #endif
   quasistatic_mealy_generation ();
-#ifdef CHECK_FSM_RULES
+#ifdef CONFIG_CHECK_FSM_RULES
 	casc_fsm_step = STIMULI;
 #endif
