DS800C400 fun, improved ROM interface and tinibios
[fw/sdcc] / src / SDCCmain.c
index cb5029eaa5b220a23028a014bdf504319f6a38ea..bda73ad70187bff57ee89ea517fdc64ac9792a1a 100644 (file)
    what you give them.   Help stamp out software-hoarding!
 -------------------------------------------------------------------------*/
 
+#ifdef _WIN32
+#include <io.h>
+#else
+#include <unistd.h>
+#endif
+
 #include <signal.h>
 #include "common.h"
 #include <ctype.h>
@@ -117,6 +123,7 @@ char buffer[PATH_MAX * 2];
 #define OPTION_ICODE_IN_ASM    "--i-code-in-asm"
 #define OPTION_PRINT_SEARCH_DIRS "--print-search-dirs"
 #define OPTION_MSVC_ERROR_STYLE "--vc"
+#define OPTION_USE_STDOUT "--use-stdout"
 
 static const OPTION
 optionsTable[] = {
@@ -217,6 +224,7 @@ optionsTable[] = {
     { 0,    OPTION_ICODE_IN_ASM,    &options.iCodeInAsm, "include i-code as comments in the asm file"},
     { 0,    OPTION_PRINT_SEARCH_DIRS, &options.printSearchDirs, "display the directories in the compiler's search path"},
     { 0,    OPTION_MSVC_ERROR_STYLE, &options.vc_err_style, "messages are compatible with Micro$oft visual studio"},
+    { 0,    OPTION_USE_STDOUT, &options.use_stdout, "send errors to stdout instead of stderr"},
     /* End of options */
 #if 0 /* 10jun03 !OPT_DISABLE_PIC16 */
     { 0,    "--no-movff",          &options.no_movff, "disable generating MOVFF opcode in PIC16 port"},
@@ -1269,6 +1277,8 @@ parseCmdLine (int argc, char **argv)
        werror (E_FILE_OPEN_ERR, scratchFileName);
     }
   MSVC_style(options.vc_err_style);
+  if(options.use_stdout) dup2(STDOUT_FILENO, STDERR_FILENO);
+
   return 0;
 }
 
@@ -1339,6 +1349,12 @@ linkEdit (char **envp)
   if ( (options.stack_loc) && (options.stack_loc<0x100) ) {
        WRITE_SEG_LOC ("SSEG", options.stack_loc);
   }
+  
+  /* If the port has any special linker area declarations, get 'em */
+  if (port->extraAreas.genExtraAreaLinkOptions)
+  {
+       port->extraAreas.genExtraAreaLinkOptions(lnkfile);
+  }
 
   /* add the extra linker options */
   fputStrSet(lnkfile, linkOptionsSet);
@@ -1475,11 +1491,11 @@ linkEdit (char **envp)
        /* VR 030517 - gplink needs linker options to set the linker script,*/
        buildCmdLine (buffer2, port->linker.cmd, dstFileName, scratchFileName, NULL, linkOptionsSet);
 
-       buildCmdLine2 (buffer, buffer2, sizeof(buffer));
+       buildCmdLine2 (buffer, sizeof(buffer), buffer2);
     }
   else
     {
-      buildCmdLine2 (buffer, port->linker.mcmd, sizeof(buffer));
+      buildCmdLine2 (buffer, sizeof(buffer), port->linker.mcmd);
     }
 
 /*  if (options.verbose)fprintf(stderr, "linker command line: %s\n", buffer); */
@@ -1566,7 +1582,7 @@ assemble (char **envp)
                      options.debug ? port->assembler.debug_opts : port->assembler.plain_opts,
                      asmOptionsSet);
     } else {
-       buildCmdLine2 (buffer, port->assembler.mcmd, sizeof(buffer));
+       buildCmdLine2 (buffer, sizeof(buffer), port->assembler.mcmd);
     }
 
     if (my_system (buffer)) {
@@ -1672,7 +1688,7 @@ preProcess (char **envp)
       if (options.verbose)
        printf ("sdcc: Calling preprocessor...\n");
 
-      buildCmdLine2 (buffer, _preCmd, sizeof(buffer));
+      buildCmdLine2 (buffer, sizeof(buffer), _preCmd);
 
       if (preProcOnly) {
         if (my_system (buffer)) {
@@ -1726,6 +1742,7 @@ setBinPaths(const char *argv0)
 }
 
 /* Set system include path */
+static void
 setIncludePath(void)
 {
   char *p;