* support/cpp2/cppinit.c, support/cpp2/cpplib.h, support/cpp2/mkdeps.c,
authorborutr <borutr@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Sun, 27 Nov 2005 14:34:12 +0000 (14:34 +0000)
committerborutr <borutr@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Sun, 27 Nov 2005 14:34:12 +0000 (14:34 +0000)
  support/cpp2/mkdeps.h: added command line option
  -obj-ext=<extension> to SDCPP to define object file externion, used
  for generation of make dependencies (-M)
* src/SDCCmain.c: pass -obj-ext=<extension> to SDCPP

git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@3991 4a8a32a2-be11-0410-ad9d-d568d2c75423

ChangeLog
src/SDCCmain.c
support/cpp2/cppinit.c
support/cpp2/cpplib.h
support/cpp2/mkdeps.c
support/cpp2/mkdeps.h

index 34438a4e103fc659332edd04c2a32c9d8df2d798..50bd4d608ead583efe0292f9c8ab2707edccf2b3 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2005-11-27 Borut Razem <borut.razem AT siol.net>
+
+       *support/cpp2/, 
+
 2005-11-26 Borut Razem <borut.razem AT siol.net>
 
        * support/scripts/sdcc.nsi: added small-stack-auto libraries,
index c689064db67a15c95baf681f7b517b3ab61912d1..6c286a33cc8602212cc88fc71efa478093d8e7af 100644 (file)
@@ -413,7 +413,7 @@ _findPort (int argc, char **argv)
     }
 
   /* Use the first in the list */
-        port = _ports[0];
+  port = _ports[0];
 }
 
 /* search through the command line options for the processor */
@@ -1955,6 +1955,16 @@ preProcess (char **envp)
       const char *s;
       set *inclList = NULL;
 
+      if (NULL != port->linker.rel_ext)
+        {
+#define OBJ_EXT_STR     "-obj-ext="
+#define OBJ_EXT_LEN     ((sizeof OBJ_EXT_STR) - 1)
+          char *buf = Safe_alloc(strlen(port->linker.rel_ext) + (OBJ_EXT_LEN + 1));
+          strcpy(buf, OBJ_EXT_STR);
+          strcpy(&buf[OBJ_EXT_LEN], port->linker.rel_ext);
+          addSet(&preArgvSet, buf);
+        }
+
       /* if using external stack define the macro */
       if (options.useXstack)
         addSet(&preArgvSet, Safe_strdup("-DSDCC_USE_XSTACK"));
@@ -2025,7 +2035,6 @@ preProcess (char **envp)
 
       if (options.verbose)
         printf ("sdcc: Calling preprocessor...\n");
-
       buildCmdLine2 (buffer, sizeof(buffer), _preCmd);
 
       if (preProcOnly) {
@@ -2325,7 +2334,7 @@ main (int argc, char **argv, char **envp)
 #ifdef JAMIN_DS390
   if (strcmp(port->target, "mcs51") == 0) {
     printf("DS390 jammed in A\n");
-          _setPort ("ds390");
+    _setPort ("ds390");
     ds390_jammed = 1;
   }
 #endif
index 5cf8d60e14d3234ad75ea510f06bfc715e1a8821..38033e2d186fb48a9a20fbc19d816d54dcc88c0b 100644 (file)
@@ -943,7 +943,7 @@ cpp_start_read (pfile, fname)
 
   if (CPP_OPTION (pfile, print_deps))
     /* Set the default target (if there is none already).  */
-    deps_add_default_target (pfile->deps, fname);
+    deps_add_default_target (pfile, fname);
 
   /* Open the main input file.  This must be done early, so we have a
      buffer to stand on.  */
@@ -1116,6 +1116,8 @@ new_pending_directive (pend, text, handler)
   DEF_OPT("nostdinc",                 0,      OPT_nostdinc)                   \
   DEF_OPT("nostdinc++",               0,      OPT_nostdincplusplus)           \
   DEF_OPT("o",                        no_fil, OPT_o)                          \
+  /* SDCC specific */                                                         \
+  DEF_OPT("obj-ext=",                 no_arg, OPT_obj_ext)                    \
   DEF_OPT("pedantic",                 0,      OPT_pedantic)                   \
   DEF_OPT("pedantic-errors",          0,      OPT_pedantic_errors)            \
   DEF_OPT("remap",                    0,      OPT_remap)                      \
@@ -1664,7 +1666,11 @@ cpp_handle_option (pfile, argc, argv)
          else if (!strcmp (argv[i], "-Wno-system-headers"))
            CPP_OPTION (pfile, warn_system_headers) = 0;
          break;
-       }
+       /* SDCC specific */
+       case OPT_obj_ext:
+         CPP_OPTION (pfile, obj_ext) = arg;
+         break;
+       }
     }
   return i + 1;
 }
@@ -1868,9 +1874,14 @@ Switches:\n\
   -MG                       Treat missing header file as generated files\n\
 "), stdout);
   fputs (_("\
-  -MP                      Generate phony targets for all headers\n\
+  -MP                       Generate phony targets for all headers\n\
   -MQ <target>              Add a MAKE-quoted target\n\
   -MT <target>              Add an unquoted target\n\
+"), stdout);
+  /* SDCC specific */
+  fputs (_("\
+  -obj-ext=<extension>      Define object file externion, used for generation\n\
+                            of make dependencies\n\
 "), stdout);
   fputs (_("\
   -D<macro>                 Define a <macro> with string '1' as its value\n\
index e5f9823893a90fc496858c4358cace27a3ca1aba..55c4f50103bbf31e3d0b96b5392cac0e0d4d35bc 100644 (file)
@@ -396,6 +396,10 @@ struct cpp_options
   /* SDCC _asm specific
      switch _asm block preprocessing on / off */
   unsigned char preproc_asm;
+
+  /* SDCC specific
+     object file exetnsion */
+  const char *obj_ext;
 };
 
 /* This structure is passed to the call back when changing file.  */
index 70c78f5d6a332c524e4b4966804782f2294d57d4..3d188b62ae6697d7cf6ea586dbad30a7664fc20e 100644 (file)
@@ -23,6 +23,8 @@ Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 #include "config.h"
 #include "system.h"
 #include "mkdeps.h"
+#include "cpplib.h"
+#include "cpphash.h"
 
 /* Keep this structure local to this file, so clients don't find it
    easy to start making assumptions.  */
@@ -176,33 +178,49 @@ deps_add_target (d, t, quote)
    string as the default target in interpreted as stdin.  The string
    is quoted for MAKE.  */
 void
-deps_add_default_target (d, tgt)
-     struct deps *d;
-     const char *tgt;
+deps_add_default_target (pfile, tgt)
+    cpp_reader *pfile;
+    const char *tgt;
 {
   /* Only if we have no targets.  */
-  if (d->ntargets)
+  if (pfile->deps->ntargets)
     return;
 
   if (tgt[0] == '\0')
-    deps_add_target (d, "-", 1);
+    deps_add_target (pfile->deps, "-", 1);
   else
     {
 #ifndef TARGET_OBJECT_SUFFIX
 # define TARGET_OBJECT_SUFFIX ".o"
 #endif
       char *start = lbasename (tgt);
-      char *o = (char *) alloca (strlen (start) + strlen (TARGET_OBJECT_SUFFIX) + 1);
+      char *o;
       char *suffix;
 
+      if (NULL == CPP_OPTION (pfile, obj_ext))
+        {
+        printf("obj_ext = --NULL--\n");
+        CPP_OPTION (pfile, obj_ext) = TARGET_OBJECT_SUFFIX;
+        }
+      else if (CPP_OPTION (pfile, obj_ext)[0] != '.')
+        {
+          char *t = (char *) alloca (strlen (CPP_OPTION (pfile, obj_ext)) + 2);
+          t[0] = '.';
+          strcpy (&t[1], CPP_OPTION (pfile, obj_ext));
+          CPP_OPTION (pfile, obj_ext) = t;
+          printf("obj_ext = %s\n", CPP_OPTION (pfile, obj_ext));
+        }
+
+      o = (char *) alloca (strlen (start) + strlen (CPP_OPTION (pfile, obj_ext)) + 1);
+
       strcpy (o, start);
-      
+
       suffix = strrchr (o, '.');
       if (!suffix)
         suffix = o + strlen (o);
-      strcpy (suffix, TARGET_OBJECT_SUFFIX);
-      
-      deps_add_target (d, o, 1);
+      strcpy (suffix, CPP_OPTION (pfile, obj_ext));
+
+      deps_add_target (pfile->deps, o, 1);
     }
 }
 
index fa79b86591b5ca0f9a133234e90809b51f332648..ceee017b3065b0319eef2fb652bcea9afa597cff 100644 (file)
@@ -27,6 +27,7 @@ Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
    It's quite straightforward, but should be treated as opaque.  */
 
 struct deps;
+struct cpp_reader;
 
 /* Create a deps buffer.  */
 extern struct deps *deps_init  PARAMS ((void));
@@ -40,7 +41,7 @@ extern void deps_add_target   PARAMS ((struct deps *, const char *, int));
 
 /* Sets the default target if none has been given already.  An empty
    string as the default target in interpreted as stdin.  */
-extern void deps_add_default_target PARAMS ((struct deps *, const char *));
+extern void deps_add_default_target PARAMS ((struct cpp_reader *, const char *));
 
 /* Add a dependency (appears on the right side of the colon) to the
    deps list.  Dependencies will be printed in the order that they