#define OPTION_VERSION "-version"
#define OPTION_STKAFTRDATA "-stack-after-data"
#define OPTION_PREPROC_ONLY "-preprocessonly"
+#define OPTION_C1_MODE "-c1mode"
#define OPTION_HELP "-help"
#define OPTION_CALLEE_SAVES "-callee-saves"
#define OPTION_NOREGPARMS "-noregparms"
}
/* otherwise depending on the file type */
- if (strcmp(fext,".c") == 0 || strcmp(fext,".C") == 0) {
+ if (strcmp(fext,".c") == 0 || strcmp(fext,".C") == 0 || options.c1mode) {
/* source file name : not if we already have a
source file */
if (srcFileName) {
}
+static void _processC1Arg(char *s)
+{
+ if (srcFileName) {
+ if (options.out_name) {
+ werror(W_TOO_MANY_SRC,s);
+ return;
+ }
+ options.out_name = strdup(s);
+ }
+ else {
+ processFile(s);
+ }
+}
+
static void _addToList(const char **list, const char *str)
{
/* This is the bad way to do things :) */
continue;
}
+ if (strcmp(&argv[i][1],OPTION_C1_MODE) == 0) {
+ options.c1mode = 1;
+ continue;
+ }
+
if (strcmp(&argv[i][1],OPTION_DUMP_ALL) == 0) {
options.dump_rassgn =
/* these are undocumented options */
/* if preceded by '/' then turn off certain optmizations, used
for debugging only these are also the legacy options from
- version 1.xx will be removed gradually */
- if ( *argv[i] == '/') {
+ version 1.xx will be removed gradually.
+ It may be an absolute filename.
+ */
+ if ( *argv[i] == '/' && strlen(argv[i]) < 3) {
switch (argv[i][1]) {
case 'p':
if (!port->parseOption(&argc, argv, &i)) {
/* no option must be a filename */
- processFile(argv[i]);
+ if (options.c1mode)
+ _processC1Arg(argv[i]);
+ else
+ processFile(argv[i]);
}
}
preOutName = NULL;
- /* if using external stack define the macro */
- if ( options.useXstack )
- _addToList(preArgv, "-DSDCC_USE_XSTACK");
-
- /* set the macro for stack autos */
- if ( options.stackAuto )
- _addToList(preArgv, "-DSDCC_STACK_AUTO");
+ if (!options.c1mode) {
+ /* if using external stack define the macro */
+ if ( options.useXstack )
+ _addToList(preArgv, "-DSDCC_USE_XSTACK");
+
+ /* set the macro for stack autos */
+ if ( options.stackAuto )
+ _addToList(preArgv, "-DSDCC_STACK_AUTO");
- /* set the macro for large model */
- switch(options.model)
- {
- case MODEL_LARGE:
- _addToList(preArgv, "-DSDCC_MODEL_LARGE");
- break;
- case MODEL_SMALL:
- _addToList(preArgv, "-DSDCC_MODEL_SMALL");
- break;
- case MODEL_FLAT24:
- _addToList(preArgv, "-DSDCC_MODEL_FLAT24");
- break;
- default:
- werror(W_UNKNOWN_MODEL, __FILE__, __LINE__);
- break;
- }
+ /* set the macro for large model */
+ switch(options.model)
+ {
+ case MODEL_LARGE:
+ _addToList(preArgv, "-DSDCC_MODEL_LARGE");
+ break;
+ case MODEL_SMALL:
+ _addToList(preArgv, "-DSDCC_MODEL_SMALL");
+ break;
+ case MODEL_FLAT24:
+ _addToList(preArgv, "-DSDCC_MODEL_FLAT24");
+ break;
+ default:
+ werror(W_UNKNOWN_MODEL, __FILE__, __LINE__);
+ break;
+ }
- /* add port (processor information to processor */
- sprintf(procDef,"-DSDCC_%s",port->target);
- _addToList(preArgv,procDef);
+ /* add port (processor information to processor */
+ sprintf(procDef,"-DSDCC_%s",port->target);
+ _addToList(preArgv,procDef);
- if (!preProcOnly)
- preOutName = strdup(tmpnam(NULL));
+ if (!preProcOnly)
+ preOutName = strdup(tmpnam(NULL));
- _buildCmdLine(buffer, argv, _preCmd, fullSrcFileName,
- preOutName, srcFileName, preArgv);
+ _buildCmdLine(buffer, argv, _preCmd, fullSrcFileName,
+ preOutName, srcFileName, preArgv);
- if (my_system(argv[0], argv)) {
- unlink (preOutName);
- perror("Cannot exec Preprocessor");
- exit(1);
- }
+ if (my_system(argv[0], argv)) {
+ unlink (preOutName);
+ perror("Cannot exec Preprocessor");
+ exit(1);
+ }
- if (preProcOnly)
- exit(0);
+ if (preProcOnly)
+ exit(0);
+ }
+ else {
+ preOutName = fullSrcFileName;
+ }
- yyin = fopen(preOutName,"r");
+ yyin = fopen(preOutName, "r");
if (yyin == NULL) {
perror("Preproc file not found\n");
exit(1);
parseCmdLine(argc,argv);
/* if no input then printUsage & exit */
- if (!srcFileName && !nrelFiles) {
+ if ((!options.c1mode && !srcFileName && !nrelFiles) || (options.c1mode && !srcFileName && !options.out_name)) {
printUsage();
exit(0);
}
if (!fatalError) {
glue();
- assemble(envp);
+ if (!options.c1mode)
+ assemble(envp);
}
}
if (!options.cc_only &&
!fatalError &&
!noAssemble &&
+ !options.c1mode &&
(srcFileName || nrelFiles))
linkEdit (envp);
if (yyin && yyin != stdin)
fclose(yyin);
- if (preOutName) {
+ if (preOutName && !options.c1mode) {
unlink(preOutName);
free(preOutName);
}