home *** CD-ROM | disk | FTP | other *** search
/ Club Amiga de Montreal - CAM / CAM_CD_1.iso / files / 240.lha / CC / sources / options.c < prev    next >
Encoding:
C/C++ Source or Header  |  1989-05-07  |  2.2 KB  |  116 lines

  1. /*
  2.  * compiler options processing
  3.  * March 1989, Miles Bader
  4.  */
  5.  
  6. #include "common.h"
  7. #include "options.h"
  8.  
  9. long globalOpts[MAXOPTS/BITSPERLONG];
  10.  
  11. struct option {
  12.     char *name;
  13.     int opt;
  14.     int *set;
  15. };
  16.  
  17. /* pre-processor compatibility modes */
  18. int ppOptSet[]={OPT_TRAD, OPT_ANSI, OPT_CPP, 0};
  19.  
  20. /* cpu-types */
  21. int cpuOptSet[]={OPT_68K, OPT_020, OPT_030, 0};
  22.  
  23. /* types of floating point support */
  24. int floatOptSet[]={OPT_FFP, OPT_IEEE, OPT_881, 0};
  25.  
  26. struct option optionlist[]={
  27. /*   name        mask        excludes    */
  28.  
  29.     /* parsing */
  30.     {"ansi",        OPT_ANSI,    ppOptSet},
  31.     {"c++",        OPT_CPP,    ppOptSet},
  32.     {"traditional",    OPT_TRAD,    ppOptSet},
  33.  
  34.     /* code gen */
  35.     {"abs-code",    OPT_ABSCODE},
  36.     {"abs-data",    OPT_ABSDATA},
  37.  
  38.     {"reg-args",    OPT_REGARGS},
  39.     {"reload-a4",    OPT_RELOADA4},
  40.     {"short-ints",    OPT_SHORTINTS},
  41.     {"long-align",    OPT_LONGALIGN},
  42.     {"stack-check",    OPT_STACKCHECK},
  43.  
  44.     {"pure-strings",    OPT_PURESTRINGS},
  45.  
  46.     {"68k",        OPT_68K,    cpuOptSet},
  47.     {"020",        OPT_020,    cpuOptSet},
  48.     {"030",        OPT_030,    cpuOptSet},
  49.  
  50.     {"881",        OPT_881,    floatOptSet},
  51.     {"ffp",        OPT_FFP,    floatOptSet},
  52.     {"ieee",        OPT_IEEE,    floatOptSet},
  53.  
  54.     /* linking */
  55.     {"detach",        OPT_DETACH},
  56.     {"resident",    OPT_RESIDENT},
  57.     {"tiny-main",    OPT_TINYMAIN},
  58.     {"catch",        OPT_CATCH},
  59.  
  60.     {"optimize",    OPT_OPTIMIZE},
  61.     {"link",        OPT_LINK},
  62.     {"compile",        OPT_COMPILE},
  63.     {"assemble",    OPT_ASSEMBLE},
  64.     {"debug",        OPT_DEBUG},
  65.  
  66.     {"echo",        OPT_ECHO},
  67.     {"filter",        OPT_FILTER},
  68.     {"exec",        OPT_EXEC},
  69.  
  70.     {"big-lc1",        OPT_BIGLC1},
  71.  
  72.     NULL
  73. };
  74.  
  75. void options_SetByName(optname)
  76. char *optname;
  77. {
  78.     struct option *opt;
  79.     int not=FALSE;
  80.  
  81.     if(strncmp(optname,"no-",3)==0){
  82.     optname+=3;
  83.     not=TRUE;
  84.     }
  85.  
  86.     for(opt=optionlist; opt->name!=NULL; opt++)
  87.     if(strcmp(optname,opt->name)==0){
  88.         if(not){
  89.         if(opt->set!=NULL)
  90.             fatal("%s is not a boolean option",opt);
  91.         else
  92.             options_Clear(opt->opt);
  93.         }else{
  94.         if(opt->set!=NULL){
  95.             int *clear;
  96.             for(clear=opt->set; *clear!=0; clear++)
  97.                 options_Clear(*clear);
  98.         }
  99.         
  100.         options_Set(opt->opt);
  101.         }
  102.  
  103.         break;
  104.     }
  105.  
  106.     if(opt->name==NULL)
  107.     fatal("unknown option: %s",optname);
  108. }
  109.  
  110. void options_Init()
  111. {
  112.     int i;
  113.     for(i=0; i<(MAXOPTS/BITSPERLONG); i++)
  114.     globalOpts[i]=0;
  115. }
  116.