- int i ;
- char cdbfnbuf[50];
-
- /* go thru all whole command line */
- for ( i = 1; i < argc; i++ ) {
- if ( i >= argc )
- break ;
-
- /* options */
- if (argv[i][0] == '-' && argv[i][1] == '-') {
-
- if (strcmp(&argv[i][1],OPTION_HELP) == 0) {
- printUsage();
- exit(0);
- }
-
- if (strcmp(&argv[i][1],OPTION_XREGS) == 0) {
- options.regExtend = 1;
- continue;
- }
-
- if (strcmp(&argv[i][1],OPTION_LARGE_MODEL) == 0) {
- _setModel(MODEL_LARGE, argv[i]);
- continue;
- }
-
- if (strcmp(&argv[i][1],OPTION_MEDIUM_MODEL) == 0) {
- _setModel(MODEL_MEDIUM, argv[i]);
- continue;
- }
-
- if (strcmp(&argv[i][1],OPTION_SMALL_MODEL) == 0) {
- _setModel(MODEL_SMALL, argv[i]);
- continue;
- }
-
- if (strcmp(&argv[i][1],OPTION_FLAT24_MODEL) == 0) {
- _setModel(MODEL_FLAT24, argv[i]);
- 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;
- continue;
- }
-
- if (strcmp(&argv[i][1],OPTION_DUMP_RAW) == 0) {
- options.dump_raw = 1;
- continue;
- }
-
- if (strcmp(&argv[i][1],OPTION_CYCLOMATIC) == 0) {
- options.cyclomatic = 1;
- continue;
- }
-
- if (strcmp(&argv[i][1],OPTION_DUMP_GCSE) == 0) {
- options.dump_gcse = 1;
- continue;
- }
-
- if (strcmp(&argv[i][1],OPTION_DUMP_LOOP) == 0) {
- options.dump_loop = 1;
- continue;
- }
-
- if (strcmp(&argv[i][1],OPTION_DUMP_KILL) == 0) {
- options.dump_kill = 1;
- continue;
- }
-
- if (strcmp(&argv[i][1],OPTION_INTLONG_RENT) == 0) {
- options.intlong_rent = 1;
- continue;
- }
-
- if (strcmp(&argv[i][1],OPTION_FLOAT_RENT) == 0) {
- options.float_rent = 1;
- continue;
- }
-
- if (strcmp(&argv[i][1],OPTION_DUMP_RANGE) == 0) {
- options.dump_range = 1;
- continue;
- }
-
- if (strcmp(&argv[i][1],OPTION_DUMP_PACK) == 0) {
- options.dump_pack = 1;
- continue;
- }
-
- if (strcmp(&argv[i][1],OPTION_DUMP_RASSGN) == 0) {
- options.dump_rassgn = 1;
- continue;
- }
-
- if (strcmp(&argv[i][1],OPTION_OUT_FMT_IHX) == 0) {
- options.out_fmt = 0;
- continue;
- }
-
- if (strcmp(&argv[i][1],OPTION_OUT_FMT_S19) == 0) {
- options.out_fmt = 1;
- continue;
- }
-
- if (strcmp(&argv[i][1],OPTION_NOOVERLAY) == 0) {
- options.noOverlay = 1;
- continue;
- }
-
- if (strcmp(&argv[i][1],OPTION_STKAFTRDATA) == 0) {
- options.stackOnData = 1;
- continue;
- }
-
- if (strcmp(&argv[i][1],OPTION_PREPROC_ONLY) == 0) {
- preProcOnly = 1;
- 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 =
- options.dump_pack =
- options.dump_range =
- options.dump_kill =
- options.dump_loop =
- options.dump_gcse =
- options.dump_raw = 1;
- continue;
- }
-
- if (strcmp(&argv[i][1],OPTION_COMP_ONLY) == 0) {
- options.cc_only = 1;
- continue;
- }
-
- if (strcmp(&argv[i][1],OPTION_GENERIC) == 0) {
- options.genericPtr = 1;
- continue;
- }
-
- if (strcmp(&argv[i][1],OPTION_NOPEEP) == 0) {
- options.nopeep = 1;
- continue;
- }
-
- if (strcmp(&argv[i][1],OPTION_ASMPEEP) == 0) {
- options.asmpeep = 1;
- continue;
- }
-
- if (strcmp(&argv[i][1],OPTION_DEBUG) == 0) {
- options.debug = 1;
- continue;
- }
-
- if (strcmp(&argv[i][1],OPTION_NOREGPARMS) == 0) {
- options.noregparms = 1;
- continue;
- }
-
- if (strcmp(&argv[i][1],OPTION_PEEP_FILE) == 0) {
- if (argv[i][1+strlen(OPTION_PEEP_FILE)])
- options.peep_file =
- &argv[i][1+strlen(OPTION_PEEP_FILE)];
- else
- options.peep_file = argv[++i];
- continue ;
- }
-
- if (strcmp(&argv[i][1],OPTION_LIB_PATH) == 0) {
- if (argv[i][1+strlen(OPTION_LIB_PATH)])
- libPaths[nlibPaths++] =
- &argv[i][1+strlen(OPTION_PEEP_FILE)];
- else
- libPaths[nlibPaths++] = argv[++i];
- continue ;
- }
-
- if (strcmp(&argv[i][1],OPTION_XSTACK_LOC) == 0) {
-
- if (argv[i][1+strlen(OPTION_XSTACK_LOC)])
- options.xstack_loc =
- (int) floatFromVal(constVal(&argv[i][1+strlen(OPTION_XSTACK_LOC)]));
- else
- options.xstack_loc =
- (int) floatFromVal(constVal(argv[++i]));
- continue ;
- }
-
- if (strcmp(&argv[i][1],OPTION_XSTACK) == 0) {
- options.useXstack = 1;
- continue;
- }
-
- if (strcmp(&argv[i][1],OPTION_MAINRETURN) == 0) {
- options.mainreturn = 1;
- continue;
- }
-
- if (strcmp(&argv[i][1],OPTION_CALLEE_SAVES) == 0) {
- if (argv[i][1+strlen(OPTION_CALLEE_SAVES)])
- parseWithComma(options.calleeSaves
- ,&argv[i][1+strlen(OPTION_CALLEE_SAVES)]);
- else
- parseWithComma(options.calleeSaves,argv[++i]);
- continue;
- }
-
- if (strcmp(&argv[i][1],OPTION_STACK_LOC) == 0) {
-
- if (argv[i][1+strlen(OPTION_STACK_LOC)])
- options.stack_loc =
- (int) floatFromVal(constVal(&argv[i][1+strlen(OPTION_STACK_LOC)]));
- else
- options.stack_loc =
- (int) floatFromVal(constVal(argv[++i]));
- continue;
- }
-
- if (strcmp(&argv[i][1],OPTION_XRAM_LOC) == 0) {
-
- if (argv[i][1+strlen(OPTION_XRAM_LOC)])
- options.xdata_loc =
- (unsigned int) floatFromVal(constVal(&argv[i][1+strlen(OPTION_XRAM_LOC)]));
- else
- options.xdata_loc =
- (unsigned int) floatFromVal(constVal(argv[++i]));
- continue;
- }
-
- if (strcmp(&argv[i][1],OPTION_IRAM_SIZE) == 0) {
-
- if (argv[i][1+strlen(OPTION_IRAM_SIZE)])
- options.iram_size =
- (int) floatFromVal(constVal(&argv[i][1+strlen(OPTION_IRAM_SIZE)]));
- else
- options.iram_size =
- (int) floatFromVal(constVal(argv[++i]));
- continue;
- }
-
- if (strcmp(&argv[i][1],OPTION_VERSION) == 0) {
- printVersionInfo();
- exit(0);
- continue;
- }
-
- if (strcmp(&argv[i][1],OPTION_DATA_LOC) == 0) {
-
- if (argv[i][1+strlen(OPTION_DATA_LOC)])
- options.data_loc =
- (int) floatFromVal(constVal(&argv[i][1+strlen(OPTION_DATA_LOC)]));
- else
- options.data_loc =
- (int) floatFromVal(constVal(argv[++i]));
- continue;
- }
-
- if (strcmp(&argv[i][1],OPTION_IDATA_LOC) == 0) {
-
- if (argv[i][1+strlen(OPTION_IDATA_LOC)])
- options.idata_loc =
- (int) floatFromVal(constVal(&argv[i][1+strlen(OPTION_IDATA_LOC)]));
- else
- options.idata_loc =
- (int) floatFromVal(constVal(argv[++i]));
- continue;
- }
-
- if (strcmp(&argv[i][1],OPTION_CODE_LOC) == 0) {
-
- if (argv[i][1+strlen(OPTION_CODE_LOC)])
- options.code_loc =
- (int) floatFromVal(constVal(&argv[i][1+strlen(OPTION_CODE_LOC)]));
- else
- options.code_loc =
- (int) floatFromVal(constVal(argv[++i]));
- continue;
- }
-
-
- if (strcmp(&argv[i][1],OPTION_NO_JTBOUND) == 0) {
- optimize.noJTabBoundary = 1;
- continue;
- }
-
- if (strcmp(&argv[i][1],OPTION_NO_GCSE) == 0) {
- optimize.global_cse = 0;
- continue;
- }
-
- if (strcmp(&argv[i][1],OPTION_NO_LOOP_INV) == 0) {
- optimize.loopInvariant = 0;
- continue;
- }
-
- if (strcmp(&argv[i][1],OPTION_NO_LOOP_IND) == 0) {
- optimize.loopInduction = 0;
- continue;
- }
-
- if (strcmp(&argv[i][1],OPTION_NO_LOOPREV) == 0) {
- optimize.noLoopReverse = 1;
- continue;
- }
-
- if (!port->parseOption(&argc, argv, &i))
- {
- werror(W_UNKNOWN_OPTION,argv[i]);
- }
- else
- {
- continue;
- }
- }
-
- /* 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.
- It may be an absolute filename.
- */
- if ( *argv[i] == '/' && strlen(argv[i]) < 3) {
- switch (argv[i][1]) {
-
- case 'p':
- optimize.ptrArithmetic=0;
- break;
-
- case 'L':
- switch (argv[i][2]) {
- case '\0':
- optimize.label1 =
- optimize.label2 =
- optimize.label3 =
- optimize.label4 = 0 ;
- break;
- case '1':
- optimize.label1 = 0;
- break;
- case '2':
- optimize.label2 = 0;
- break;
- case '3':
- optimize.label3 = 0;
- break;
- case '4':
- optimize.label4 = 0;
- break;
- }
- break;
-
- case 'l' :
- switch (argv[i][2]) {
- case 'i' :
- optimize.loopInvariant = 0;
- break;
- case 'n' :
- optimize.loopInduction = 0;
- break;
-
-
- }
- break ;
- case 'g' :
- optimize.global_cse = 0;
- break;
-
- }
- continue ;
- }
-
- /* if preceded by '-' then option */
- if ( *argv[i] == '-' ) {
- switch (argv[i][1]) {
- case 'h' :
- printUsage();
- exit(0);
- break;
-
- case 'E':
- preProcOnly = 1;
- break;
-
- case 'm':
- /* Used to select the port */
- if (_setPort(argv[i] + 2)) {
- werror(W_UNSUPP_OPTION,"-m","Unrecognised processor");
- }
- break;
-
- case 'a' :
- werror(W_UNSUPP_OPTION,"-a","use --stack-auto instead");
- break ;
-
- case 'g' :
- werror(W_UNSUPP_OPTION,"-g","use --generic instead");
- break;
-
- case 'X' : /* use external stack */
- werror(W_UNSUPP_OPTION,"-X","use --xstack-loc instead");
- break ;
-
- case 'x' :
- werror(W_UNSUPP_OPTION,"-x","use --xstack instead");
- break;
-
- case 'p' : /* stack pointer intial value */
- case 'P' :
- werror(W_UNSUPP_OPTION,"-p","use --stack-loc instead");
- break ;
-
- case 'i' :
- werror(W_UNSUPP_OPTION,"-i","use --idata-loc instead");
- break ;
-
- case 'r' :
- werror(W_UNSUPP_OPTION,"-r","use --xdata-loc instead");
- break ;
-
- case 's' :
- werror(W_UNSUPP_OPTION,"-s","use --code-loc instead");
- break ;
-
- case 'c':
- options.cc_only = 1;
- break;
-
- case 'Y':
- werror(W_UNSUPP_OPTION,"-Y","use -I instead");
- break;
-
- case 'L' :
- if (argv[i][2])
- libPaths[nlibPaths++] = &argv[i][2];
- else
- libPaths[nlibPaths++] = argv[++i];
- break;
-
- case 'W':
- /* linker options */
- if (argv[i][2] == 'l') {
- if (argv[i][3])
- parseWithComma(linkOptions,&argv[i][3]);
- else
- parseWithComma(linkOptions,argv[++i]);
- } else {
- /* assembler options */
- if (argv[i][2] == 'a') {
- if (argv[i][3])
- parseWithComma((char **)asmOptions,&argv[i][3]);
- else
- parseWithComma((char **)asmOptions,argv[++i]);
-
- } else {
- werror(W_UNKNOWN_OPTION,argv[i]);
- }
- }
- break;
- case 'S':
- noAssemble = 1;
- break;
-
- case 'v':
-#if FEATURE_VERBOSE_EXEC
- verboseExec = TRUE;
-#else
- printVersionInfo();
- exit(0);
-#endif
- break;
-
- /* preprocessor options */
- case 'M':
- {
- preProcOnly=1;
- _addToList(preArgv, "-M");
- break;
- }
- case 'C':
- {
- _addToList(preArgv, "-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++ ;
- rest = argv[i] ;
- }
- else
- rest = &argv[i][2] ;
-
- if ( argv[i][1] == 'Y' )
- argv[i][1] = 'I';
-
- sprintf(buffer, "-%c%s", sOpt, rest);
- _addToList(preArgv, buffer);
- }
- 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)
- _processC1Arg(argv[i]);
- else
- processFile(argv[i]);
- }
- }
-
- /* set up external stack location if not explicitly specified */
- if ( !options.xstack_loc )
- options.xstack_loc = options.xdata_loc ;
-
- /* if debug option is set the open the cdbFile */
- if (/* options.debug && */ srcFileName) {
- sprintf(cdbfnbuf,"%s.cdb",srcFileName);
- if ((cdbFile = fopen(cdbfnbuf,"w")) == NULL)
- werror(E_FILE_OPEN_ERR,cdbfnbuf);
- else {
- /* add a module record */
- fprintf(cdbFile,"M:%s\n",moduleName);
- }
+ int i;
+
+ /* go thru all whole command line */
+ for (i = 1; i < argc; i++)
+ {
+ if (i >= argc)
+ break;
+
+ if (tryHandleUnsupportedOpt(argv, &i) == TRUE)
+ {
+ continue;
+ }
+
+ if (tryHandleSimpleOpt(argv, &i) == TRUE)
+ {
+ continue;
+ }
+
+ /* options */
+ if (argv[i][0] == '-' && argv[i][1] == '-')
+ {
+ if (strcmp (argv[i], OPTION_HELP) == 0)
+ {
+ printUsage ();
+ exit (0);
+ }
+
+ if (strcmp (argv[i], OPTION_STACK_8BIT) == 0)
+ {
+ options.stack10bit = 0;
+ continue;
+ }
+
+ if (strcmp (argv[i], OPTION_OUT_FMT_IHX) == 0)
+ {
+ options.out_fmt = 0;
+ continue;
+ }
+
+ if (strcmp (argv[i], OPTION_OUT_FMT_S19) == 0)
+ {
+ options.out_fmt = 1;
+ continue;
+ }
+
+ if (strcmp (argv[i], OPTION_LARGE_MODEL) == 0)
+ {
+ _setModel (MODEL_LARGE, argv[i]);
+ continue;
+ }
+
+ if (strcmp (argv[i], OPTION_MEDIUM_MODEL) == 0)
+ {
+ _setModel (MODEL_MEDIUM, argv[i]);
+ continue;
+ }
+
+ if (strcmp (argv[i], OPTION_SMALL_MODEL) == 0)
+ {
+ _setModel (MODEL_SMALL, argv[i]);
+ continue;
+ }
+
+ if (strcmp (argv[i], OPTION_FLAT24_MODEL) == 0)
+ {
+ _setModel (MODEL_FLAT24, argv[i]);
+ continue;
+ }
+
+ if (strcmp (argv[i], OPTION_DUMP_ALL) == 0)
+ {
+ options.dump_rassgn =
+ options.dump_pack =
+ options.dump_range =
+ options.dump_kill =
+ options.dump_loop =
+ options.dump_gcse =
+ options.dump_raw = 1;
+ continue;
+ }
+
+ if (strcmp (argv[i], OPTION_PEEP_FILE) == 0)
+ {
+ options.peep_file = getStringArg(OPTION_PEEP_FILE, argv, &i, argc);
+ continue;
+ }
+
+ if (strcmp (argv[i], OPTION_LIB_PATH) == 0)
+ {
+ addSet(&libPathsSet, Safe_strdup(getStringArg(OPTION_LIB_PATH, argv, &i, argc)));
+ continue;
+ }
+
+ if (strcmp (argv[i], OPTION_VERSION) == 0)
+ {
+ printVersionInfo ();
+ exit (0);
+ continue;
+ }
+
+ if (strcmp (argv[i], OPTION_CALLEE_SAVES) == 0)
+ {
+ setParseWithComma(&options.calleeSavesSet, getStringArg(OPTION_CALLEE_SAVES, argv, &i, argc));
+ continue;
+ }
+
+ if (strcmp (argv[i], OPTION_XSTACK_LOC) == 0)
+ {
+ options.xstack_loc = getIntArg(OPTION_XSTACK_LOC, argv, &i, argc);
+ continue;
+ }
+
+ if (strcmp (argv[i], OPTION_STACK_LOC) == 0)
+ {
+ options.stack_loc = getIntArg(OPTION_STACK_LOC, argv, &i, argc);
+ continue;
+ }
+
+ if (strcmp (argv[i], OPTION_STACK_SIZE) == 0)
+ {
+ options.stack_size = getIntArg(OPTION_STACK_SIZE, argv, &i, argc);
+ continue;
+ }
+
+ if (strcmp (argv[i], OPTION_XRAM_LOC) == 0)
+ {
+ options.xdata_loc = getIntArg(OPTION_XRAM_LOC, argv, &i, argc);
+ continue;
+ }
+
+ if (strcmp (argv[i], OPTION_IRAM_SIZE) == 0)
+ {
+ options.iram_size = getIntArg(OPTION_IRAM_SIZE, argv, &i, argc);
+ continue;
+ }
+
+ if (strcmp (argv[i], OPTION_XRAM_SIZE) == 0)
+ {
+ options.xram_size = getIntArg(OPTION_XRAM_SIZE, argv, &i, argc);
+ options.xram_size_set = TRUE;
+ continue;
+ }
+
+ if (strcmp (argv[i], OPTION_CODE_SIZE) == 0)
+ {
+ options.code_size = getIntArg(OPTION_CODE_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 (strcmp (argv[i], OPTION_STD_C89) == 0)
+ {
+ options.std_c99 = 0;
+ options.std_sdcc = 0;
+ continue;
+ }
+
+ if (strcmp (argv[i], OPTION_STD_C99) == 0)
+ {
+ options.std_c99 = 1;
+ options.std_sdcc = 0;
+ continue;
+ }
+
+ if (strcmp (argv[i], OPTION_STD_SDCC89) == 0)
+ {
+ options.std_c99 = 0;
+ options.std_sdcc = 1;
+ continue;
+ }
+
+ if (strcmp (argv[i], OPTION_STD_SDCC99) == 0)
+ {
+ options.std_c99 = 1;
+ options.std_sdcc = 1;
+ continue;
+ }
+
+ if (strcmp (argv[i], OPTION_CODE_SEG) == 0)
+ {
+ options.code_seg = getStringArg(OPTION_CODE_SEG, argv, &i, argc);
+ continue;
+ }
+
+ if (strcmp (argv[i], OPTION_CONST_SEG) == 0)
+ {
+ options.const_seg = getStringArg(OPTION_CONST_SEG, 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]);
+ }
+ }