* Added sfr space
[fw/sdcc] / src / SDCCmain.c
index ceeadef727d2aa53def68bec2ef60d5dfb9d8a03..5438a081d151522294a52f0706a12ddb647c4059 100644 (file)
@@ -128,32 +128,38 @@ static const char *_preCmd[] = {
     "-I" SDCC_INCLUDE_DIR, "$l", "$1", "$2", NULL
 };
 
+#if !OPT_DISABLE_MCS51
 extern PORT mcs51_port;
-extern PORT z80_port;
+#endif
+#if !OPT_DISABLE_GBZ80
 extern PORT gbz80_port;
+#endif
+#if !OPT_DISABLE_Z80
+extern PORT z80_port;
+#endif
+#if !OPT_DISABLE_AVR
 extern PORT avr_port;
+#endif
 
 PORT *port;
 
 static PORT *_ports[] = {
-    &mcs51_port,
-    &z80_port,
+#if !OPT_DISABLE_MCS51
+   &mcs51_port,
+#endif
+#if !OPT_DISABLE_GBZ80
     &gbz80_port,
-    &avr_port
+#endif
+#if !OPT_DISABLE_Z80
+    &z80_port,
+#endif
+#if !OPT_DISABLE_AVR
+    &avr_port,
+#endif
 };
 
 #define NUM_PORTS (sizeof(_ports)/sizeof(_ports[0]))
 
-extern ASM_PORT asxxxx_port;
-extern ASM_PORT rgbds_port;
-
-ASM_PORT *asm_port;
-
-static ASM_PORT *_asm_ports[] = {
-    &asxxxx_port,
-    &rgbds_port
-};
-
 /** Sets the port to the one given by the command line option.
     @param             The name minus the option (eg 'mcs51')
     @return            0 on success.
@@ -993,7 +999,6 @@ int   parseCmdLine ( int argc, char **argv )
            fprintf(cdbFile,"M:%s\n",moduleName);
        }
     }
-    port->finaliseOptions();
     return 0;
 }
 
@@ -1267,7 +1272,6 @@ static int preProcess (char **envp)
 
 static void _findPort(int argc, char **argv)
 {
-    asm_port = _asm_ports[0];
     argc--;
     while (argc) {
        if (!strncmp(*argv, "-m", 2)) {
@@ -1297,17 +1301,19 @@ int main ( int argc, char **argv , char **envp)
     /* Initalise the port. */
     if (port->init)
        port->init();
-    
-    initMem();
+
     setDefaultOptions();
     parseCmdLine(argc,argv);
 
+    initMem();
+
+    port->finaliseOptions();
+
     /* if no input then printUsage & exit */
     if ((!options.c1mode && !srcFileName && !nrelFiles) || (options.c1mode && !srcFileName && !options.out_name)) {
        printUsage();
        exit(0);
     }
-
        
     if (srcFileName)
        preProcess(envp) ;
@@ -1325,7 +1331,7 @@ int main ( int argc, char **argv , char **envp)
            if (!options.c1mode)
                assemble(envp);
        } else {
-           exit(-1);
+           return 1;
         }
        
     }
@@ -1347,6 +1353,7 @@ int main ( int argc, char **argv , char **envp)
         unlink(preOutName);
         free(preOutName);
     }
+
     return 0;
     
 }