#include "common.h"
#include <ctype.h>
+
+#if NATIVE_WIN32
+#include <process.h>
+#else
#include "spawn.h"
+#endif
/* This is a bit messy. We cant include unistd.h as it defines
'link' which we also use.
#define OPTION_SMALL_MODEL "-model-small"
#define OPTION_FLAT24_MODEL "-model-flat24"
#define OPTION_STACK_AUTO "-stack-auto"
+#define OPTION_STACK_10BIT "-stack-10bit"
#define OPTION_XSTACK "-xstack"
#define OPTION_GENERIC "-generic"
#define OPTION_NO_GCSE "-nogcse"
"-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,
+#if !OPT_DISABLE_MCS51
+ &mcs51_port,
+#endif
+#if !OPT_DISABLE_GBZ80
+ &gbz80_port,
+#endif
+#if !OPT_DISABLE_Z80
&z80_port,
- &gbz80_port
+#endif
+#if !OPT_DISABLE_AVR
+ &avr_port,
+#endif
};
#define NUM_PORTS (sizeof(_ports)/sizeof(_ports[0]))
}
}
/* Error - didnt find */
- return 1;
+ werror(E_UNKNOWN_TARGET,name);
+ exit(1);
}
static void _buildCmdLine(char *into, char **args, const char **cmds,
if (strcmp(&argv[i][1],OPTION_FLAT24_MODEL) == 0) {
options.model = MODEL_FLAT24;
continue;
- }
+ }
+
+ if (strcmp(&argv[i][1],OPTION_STACK_10BIT) == 0) {
+ options.stack10bit = 1;
+ continue;
+ }
if (strcmp(&argv[i][1],OPTION_STACK_AUTO) == 0) {
options.stackAuto = 1;
fprintf(cdbFile,"M:%s\n",moduleName);
}
}
- port->finaliseOptions();
return 0;
}
char *try_dir[]= {SRCDIR "/bin",PREFIX "/bin", NULL};
int my_system (const char *cmd, char **cmd_argv)
{
-
char *dir, *got= NULL; int i= 0;
- while (!got && try_dir[i]) {
- dir= (char*)malloc(strlen(try_dir[i])+strlen(cmd)+10);
- strcpy(dir, try_dir[i]); strcat(dir, "/"); strcat(dir, cmd);
- if (access(dir, X_OK) == 0)
- got= strdup(dir);
- free(dir);
- i++;
+
+ while (!got && try_dir[i])
+ {
+ dir= (char*)malloc(strlen(try_dir[i])+strlen(cmd)+10);
+ strcpy(dir, try_dir[i]);
+ strcat(dir, "/");
+ strcat(dir, cmd);
+
+#if NATIVE_WIN32
+ strcat(dir, ".exe");
+
+ /* Mung slashes into backslashes to keep WIndoze happy. */
+ {
+ char *r;
+ r = dir;
+
+ while (*r)
+ {
+ if (*r == '/')
+ {
+ *r = '\\';
+ }
+ r++;
+ }
+ }
+#endif
+
+ if (access(dir, X_OK) == 0)
+ {
+ got= strdup(dir);
+ }
+ free(dir);
+ i++;
}
#if FEATURE_VERBOSE_EXEC
if (verboseExec) {
/* set the macro for stack autos */
if ( options.stackAuto )
_addToList(preArgv, "-DSDCC_STACK_AUTO");
+
+ /* set the macro for stack autos */
+ if ( options.stack10bit )
+ _addToList(preArgv, "-DSDCC_STACK_TENBIT");
/* set the macro for large model */
switch(options.model)
/* Initalise the port. */
if (port->init)
port->init();
-
+
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();
if (srcFileName) {
initSymt();
- initMem();
initiCode();
initCSupport ();
initPeepHole();
glue();
if (!options.c1mode)
assemble(envp);
- }
+ } else {
+ exit(-1);
+ }
}
fclose(yyin);
if (preOutName && !options.c1mode) {
- unlink(preOutName);
- free(preOutName);
+ unlink(preOutName);
+ free(preOutName);
}
return 0;