From: borutr Date: Sun, 27 Nov 2005 14:34:12 +0000 (+0000) Subject: * support/cpp2/cppinit.c, support/cpp2/cpplib.h, support/cpp2/mkdeps.c, X-Git-Url: https://git.gag.com/?a=commitdiff_plain;h=969195f2f447edcd39741f5920bdf0ff98d8d574;p=fw%2Fsdcc * support/cpp2/cppinit.c, support/cpp2/cpplib.h, support/cpp2/mkdeps.c, support/cpp2/mkdeps.h: added command line option -obj-ext= to SDCPP to define object file externion, used for generation of make dependencies (-M) * src/SDCCmain.c: pass -obj-ext= to SDCPP git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@3991 4a8a32a2-be11-0410-ad9d-d568d2c75423 --- diff --git a/ChangeLog b/ChangeLog index 34438a4e..50bd4d60 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2005-11-27 Borut Razem + + *support/cpp2/, + 2005-11-26 Borut Razem * support/scripts/sdcc.nsi: added small-stack-auto libraries, diff --git a/src/SDCCmain.c b/src/SDCCmain.c index c689064d..6c286a33 100644 --- a/src/SDCCmain.c +++ b/src/SDCCmain.c @@ -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 diff --git a/support/cpp2/cppinit.c b/support/cpp2/cppinit.c index 5cf8d60e..38033e2d 100644 --- a/support/cpp2/cppinit.c +++ b/support/cpp2/cppinit.c @@ -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 Add a MAKE-quoted target\n\ -MT Add an unquoted target\n\ +"), stdout); + /* SDCC specific */ + fputs (_("\ + -obj-ext= Define object file externion, used for generation\n\ + of make dependencies\n\ "), stdout); fputs (_("\ -D Define a with string '1' as its value\n\ diff --git a/support/cpp2/cpplib.h b/support/cpp2/cpplib.h index e5f98238..55c4f501 100644 --- a/support/cpp2/cpplib.h +++ b/support/cpp2/cpplib.h @@ -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. */ diff --git a/support/cpp2/mkdeps.c b/support/cpp2/mkdeps.c index 70c78f5d..3d188b62 100644 --- a/support/cpp2/mkdeps.c +++ b/support/cpp2/mkdeps.c @@ -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); } } diff --git a/support/cpp2/mkdeps.h b/support/cpp2/mkdeps.h index fa79b865..ceee017b 100644 --- a/support/cpp2/mkdeps.h +++ b/support/cpp2/mkdeps.h @@ -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