+ if (strcmp (argv[i], OPTION_CODE_SIZE) == 0)
+ {
+ options.code_size = getIntArg(OPTION_IRAM_SIZE, argv, &i, argc);
+ continue;
+ }
+
+ if (strcmp (argv[i], OPTION_DATA_LOC) == 0)
+ {
+ options.data_loc = getIntArg(OPTION_DATA_LOC, argv, &i, argc);
+ continue;
+ }
+
+ if (strcmp (argv[i], OPTION_IDATA_LOC) == 0)
+ {
+ options.idata_loc = getIntArg(OPTION_IDATA_LOC, argv, &i, argc);
+ continue;
+ }
+
+ if (strcmp (argv[i], OPTION_CODE_LOC) == 0)
+ {
+ options.code_loc = getIntArg(OPTION_CODE_LOC, argv, &i, argc);
+ continue;
+ }
+
+ if (strcmp (argv[i], OPTION_NO_GCSE) == 0)
+ {
+ optimize.global_cse = 0;
+ continue;
+ }
+
+ if (strcmp (argv[i], OPTION_NO_LOOP_INV) == 0)
+ {
+ optimize.loopInvariant = 0;
+ continue;
+ }
+
+ if (strcmp (argv[i], OPTION_NO_LABEL_OPT) == 0)
+ {
+ optimize.label4 = 0;
+ continue;
+ }
+
+ if (strcmp (argv[i], OPTION_NO_LOOP_IND) == 0)
+ {
+ optimize.loopInduction = 0;
+ continue;
+ }
+
+ if (strcmp (argv[i], OPTION_OPT_CODE_SPEED) == 0)
+ {
+ optimize.codeSpeed = 1;
+ optimize.codeSize = 0;
+ continue;
+ }
+
+ if (strcmp (argv[i], OPTION_OPT_CODE_SIZE) == 0)
+ {
+ optimize.codeSpeed = 0;
+ optimize.codeSize = 1;
+ continue;
+ }
+
+ if (strcmp (argv[i], OPTION_LESS_PEDANTIC) == 0)
+ {
+ options.lessPedantic = 1;
+ setErrorLogLevel(ERROR_LEVEL_WARNING);
+ continue;
+ }
+
+ if (strcmp (argv[i], OPTION_DISABLE_WARNING) == 0)
+ {
+ int w = getIntArg(OPTION_DISABLE_WARNING, argv, &i, argc);
+ if (w < MAX_ERROR_WARNING)
+ {
+ setWarningDisabled(w);
+ }
+ continue;
+ }
+
+ if (strcmp (&argv[i][1], OPTION_SHORT_IS_8BITS) == 0)
+ {
+ options.shortis8bits=1;
+ continue;
+ }
+
+ if (strcmp (argv[i], OPTION_TINI_LIBID) == 0)
+ {
+ options.tini_libid = getIntArg(OPTION_TINI_LIBID, argv, &i, argc);
+ continue;
+ }
+
+ if (!port->parseOption (&argc, argv, &i))
+ {
+ werror (W_UNKNOWN_OPTION, argv[i]);
+ continue;
+ }
+ else
+ {
+ continue;
+ }
+ }
+
+ /* if preceded by '-' then option */
+ if (*argv[i] == '-')
+ {
+ switch (argv[i][1])
+ {
+ case 'h':
+ verifyShortOption(argv[i]);
+
+ printUsage ();
+ exit (0);
+ break;
+
+ case 'm':
+ /* Used to select the port. But this has already been done. */
+ break;
+
+ case 'p':
+ /* Used to select the processor in port. But this has
+ * already been done. */
+ break;
+
+ case 'c':
+ verifyShortOption(argv[i]);
+
+ options.cc_only = 1;
+ break;
+
+ case 'L':
+ addSet(&libPathsSet, Safe_strdup(getStringArg("-L", argv, &i, argc)));
+ break;
+
+ case 'l':
+ addSet(&libFilesSet, Safe_strdup(getStringArg("-l", argv, &i, argc)));
+ break;
+
+ case 'o':
+ {
+ char *p;
+
+ /* copy the file name into the buffer */
+ strncpyz(buffer, getStringArg("-o", argv, &i, argc),
+ sizeof(buffer));
+ /* point to last character */
+ p = buffer + strlen (buffer) - 1;
+ if (*p == DIR_SEPARATOR_CHAR)
+ {
+ /* only output path specified */
+ dstPath = Safe_strdup (buffer);
+ fullDstFileName = NULL;
+ }
+ else
+ {
+ fullDstFileName = Safe_strdup (buffer);
+
+ /* get rid of the "."-extension */
+
+ /* is there a dot at all? */
+ if (strrchr (buffer, '.') &&
+ /* is the dot in the filename, not in the path? */
+ (strrchr (buffer, DIR_SEPARATOR_CHAR) < strrchr (buffer, '.')))
+ *strrchr (buffer, '.') = '\0';
+
+ dstFileName = Safe_strdup (buffer);
+
+ /* strip module name to get path */
+ p = strrchr (buffer, DIR_SEPARATOR_CHAR);
+ if (p)
+ {
+ /* path with trailing / */
+ p[1] = '\0';
+ dstPath = Safe_strdup (buffer);
+ }
+ }
+ break;
+ }
+
+ case 'W':
+ /* pre-processer options */
+ if (argv[i][2] == 'p')
+ {
+ setParseWithComma(&preArgvSet, getStringArg("-Wp", argv, &i, argc));
+ }
+ /* linker options */
+ else if (argv[i][2] == 'l')
+ {
+ setParseWithComma(&linkOptionsSet, getStringArg("-Wl", argv, &i, argc));
+ }
+ /* assembler options */
+ else if (argv[i][2] == 'a')
+ {
+ setParseWithComma(&asmOptionsSet, getStringArg("-Wa", argv, &i, argc));
+ }
+ else
+ {
+ werror (W_UNKNOWN_OPTION, argv[i]);
+ }
+ break;
+
+ case 'v':
+ verifyShortOption(argv[i]);
+
+ printVersionInfo ();
+ exit (0);
+ break;
+
+ /* preprocessor options */
+ case 'M':
+ {
+ preProcOnly = 1;
+ if (argv[i][2] == 'M')
+ addSet(&preArgvSet, Safe_strdup("-MM"));
+ else
+ addSet(&preArgvSet, Safe_strdup("-M"));
+ break;
+ }
+ case 'C':
+ {
+ addSet(&preArgvSet, Safe_strdup("-C"));
+ break;
+ }
+
+ case 'd':
+ case 'D':
+ case 'I':
+ case 'A':
+ case 'U':
+ {
+ char sOpt = argv[i][1];
+ char *rest;
+
+ if (argv[i][2] == ' ' || argv[i][2] == '\0')
+ {
+ i++;
+ if (i >= argc)
+ {
+ /* No argument. */
+ werror(E_ARGUMENT_MISSING, argv[i-1]);
+ break;
+ }
+ else
+ {
+ rest = argv[i];
+ }
+ }
+ else
+ rest = &argv[i][2];
+
+ if (sOpt == 'Y')
+ sOpt = 'I';
+
+ SNPRINTF (buffer, sizeof(buffer),
+ ((sOpt == 'I') ? "-%c\"%s\"": "-%c%s"), sOpt, rest);
+ addSet(&preArgvSet, Safe_strdup(buffer));
+ if(sOpt == 'I') {
+ addSet(&includeDirsSet, Safe_strdup(rest));
+ addSet(&userIncDirsSet, Safe_strdup(rest));
+ }
+ }
+ break;
+
+ default:
+ if (!port->parseOption (&argc, argv, &i))
+ werror (W_UNKNOWN_OPTION, argv[i]);
+ }
+ continue;
+ }
+
+ if (!port->parseOption (&argc, argv, &i))
+ {
+ /* no option must be a filename */
+ if (options.c1mode)
+ {
+ werror (W_NO_FILE_ARG_IN_C1, argv[i]);
+ }
+ else
+ {
+ processFile (argv[i]);
+ }
+ }
+ }
+
+ /* some sanity checks in c1 mode */
+ if (options.c1mode)
+ {
+ const char *s;
+
+ if (fullSrcFileName)
+ {
+ fclose (srcFile);
+ werror (W_NO_FILE_ARG_IN_C1, fullSrcFileName);
+ }
+ fullSrcFileName = NULL;
+ for (s = setFirstItem(relFilesSet); s != NULL; s = setNextItem(relFilesSet))
+ {
+ werror (W_NO_FILE_ARG_IN_C1, s);
+ }
+ for (s = setFirstItem(libFilesSet); s != NULL; s = setNextItem(libFilesSet))
+ {
+ werror (W_NO_FILE_ARG_IN_C1, s);
+ }
+ deleteSet(&relFilesSet);
+ deleteSet(&libFilesSet);
+
+ if (options.cc_only || noAssemble || preProcOnly)
+ {
+ werror (W_ILLEGAL_OPT_COMBINATION);
+ }
+ options.cc_only = noAssemble = preProcOnly = 0;
+ if (!dstFileName)
+ {
+ werror (E_NEED_OPT_O_IN_C1);
+ exit (1);
+ }
+ }
+ /* if no dstFileName given with -o, we've to find one: */
+ if (!dstFileName)
+ {
+ const char *s;
+
+ /* use the modulename from the C-source */
+ if (fullSrcFileName)
+ {
+ size_t bufSize = strlen (dstPath) + strlen (moduleNameBase) + 1;
+
+ dstFileName = Safe_alloc (bufSize);
+ strncpyz (dstFileName, dstPath, bufSize);
+ strncatz (dstFileName, moduleNameBase, bufSize);
+ }
+ /* use the modulename from the first object file */
+ else if ((s = peekSet(relFilesSet)) != NULL)
+ {
+ char *objectName;
+ size_t bufSize;
+
+ strncpyz (buffer, s, sizeof(buffer));
+ /* remove extension (it must be .rel) */
+ *strrchr (buffer, '.') = '\0';
+ /* remove path */
+ objectName = strrchr (buffer, DIR_SEPARATOR_CHAR);
+ if (objectName)
+ {
+ ++objectName;
+ }
+ else
+ {
+ objectName = buffer;
+ }
+ bufSize = strlen (dstPath) + strlen (objectName) + 1;
+ dstFileName = Safe_alloc (bufSize);
+ strncpyz (dstFileName, dstPath, bufSize);
+ strncatz (dstFileName, objectName, bufSize);
+ }
+ /* else no module given: help text is displayed */
+ }
+
+ /* set int, long and float reentrancy based on stack-auto */
+ if (options.stackAuto)
+ {
+ options.intlong_rent++;
+ options.float_rent++;
+ }
+
+ /* set up external stack location if not explicitly specified */
+ if (!options.xstack_loc)
+ options.xstack_loc = options.xdata_loc;
+
+ /* if debug option is set then open the cdbFile */
+ if (options.debug && fullSrcFileName)
+ {
+ SNPRINTF (scratchFileName, sizeof(scratchFileName),
+ "%s.adb", dstFileName); /*JCF: Nov 30, 2002*/
+ if(debugFile->openFile(scratchFileName))
+ debugFile->writeModule(moduleName);
+ else
+ werror (E_FILE_OPEN_ERR, scratchFileName);
+ }
+ MSVC_style(options.vc_err_style);
+ if(options.use_stdout) dup2(STDOUT_FILENO, STDERR_FILENO);
+
+ return 0;
+}