home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / INFO / C / DMAKE37S.ZIP / DMAKE / IMACS.C < prev    next >
Encoding:
C/C++ Source or Header  |  1991-05-06  |  5.4 KB  |  171 lines

  1. /* RCS      -- $Header: /u2/dvadura/src/generic/dmake/src/RCS/imacs.c,v 1.1 91/05/06 15:23:16 dvadura Exp $
  2. -- SYNOPSIS -- define default internal macros.
  3. -- 
  4. -- DESCRIPTION
  5. --    This file adds to the internal macro tables the set of default
  6. --    internal macros, and for those that are accessible internally via
  7. --    variables creates these variables, and initializes them to point
  8. --    at the default values of these macros.
  9. --
  10. -- AUTHOR
  11. --      Dennis Vadura, dvadura@watdragon.uwaterloo.ca
  12. --      CS DEPT, University of Waterloo, Waterloo, Ont., Canada
  13. --
  14. -- COPYRIGHT
  15. --      Copyright (c) 1990 by Dennis Vadura.  All rights reserved.
  16. -- 
  17. --      This program is free software; you can redistribute it and/or
  18. --      modify it under the terms of the GNU General Public License
  19. --      (version 1), as published by the Free Software Foundation, and
  20. --      found in the file 'LICENSE' included with this distribution.
  21. -- 
  22. --      This program is distributed in the hope that it will be useful,
  23. --      but WITHOUT ANY WARRANTY; without even the implied warrant of
  24. --      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  25. --      GNU General Public License for more details.
  26. -- 
  27. --      You should have received a copy of the GNU General Public License
  28. --      along with this program;  if not, write to the Free Software
  29. --      Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  30. --
  31. -- LOG
  32. --     $Log:    imacs.c,v $
  33.  * Revision 1.1  91/05/06  15:23:16  dvadura
  34.  * dmake Release Version 3.7
  35.  * 
  36. */
  37.  
  38. #include "extern.h"
  39.  
  40. static    void    _set_int_var ANSI((char *, char *, int, int *));
  41. static    void    _set_string_var ANSI((char *, char *, int, char **));
  42. static    void    _set_bit_var ANSI((char *, char *, int));
  43.  
  44. /*
  45. ** Arrange to parse the strings stored in Rules[]
  46. */
  47. PUBLIC void
  48. Make_rules()
  49. {
  50.    Parse(NIL(FILE));
  51. }
  52.  
  53.  
  54. #define M_FLAG   M_DEFAULT | M_EXPANDED
  55.  
  56. /*
  57. ** Add to the macro table all of the internal macro variables plus
  58. ** create secondary variables which will give access to their values
  59. ** easily, both when needed and when the macro value is modified.
  60. ** The latter is accomplished by providing a flag in the macro and a field
  61. ** which gives a pointer to the value if it is a char or string macro value
  62. ** and a mask representing the bit of the global flag register that is affected
  63. ** by this macro's value.
  64. */
  65. PUBLIC void
  66. Create_macro_vars()
  67. {
  68.    static char* switchar;
  69.    char   swchar[2];
  70.  
  71.    swchar[0] = Get_switch_char(), swchar[1] = '\0';
  72.    _set_string_var("SWITCHAR", swchar, M_PRECIOUS, &switchar);
  73.    _set_string_var("DIRSEPSTR", "/", M_PRECIOUS, &DirSepStr);
  74.    _set_string_var("DIRBRKSTR", DirBrkStr, M_PRECIOUS, &DirBrkStr);
  75.  
  76.    _set_bit_var(".SILENT",   "", A_SILENT  );
  77.    _set_bit_var(".IGNORE",   "", A_IGNORE  );
  78.    _set_bit_var(".PRECIOUS", "", A_PRECIOUS);
  79.    _set_bit_var(".EPILOG",   "", A_EPILOG  );
  80.    _set_bit_var(".PROLOG",   "", A_PROLOG  );
  81.    _set_bit_var(".NOINFER",  "", A_NOINFER );
  82.    _set_bit_var(".SEQUENTIAL","",A_SEQ     );
  83.    _set_bit_var(".USESHELL", "", A_SHELL   );
  84.    _set_bit_var(".SWAP",     "", A_SWAP    );
  85.    _set_bit_var(".MKSARGS",  "", A_MKSARGS );
  86.  
  87.    Glob_attr = A_DEFAULT;        /* set all flags to NULL   */
  88.  
  89.    _set_string_var("SHELL",        "",  M_DEFAULT, &Shell       );
  90.    _set_string_var("SHELLFLAGS",   " ", M_DEFAULT, &Shell_flags );
  91.    _set_string_var("GROUPSHELL",   "",  M_DEFAULT, &GShell      );
  92.    _set_string_var("GROUPFLAGS",   " ", M_DEFAULT, &GShell_flags);
  93.    _set_string_var("SHELLMETAS",   "",  M_DEFAULT, &Shell_metas );
  94.    _set_string_var("GROUPSUFFIX",  "",  M_DEFAULT, &Grp_suff    );
  95.    _set_string_var("PREP",         "0", M_DEFAULT, &Prep        );
  96.    _set_string_var("AUGMAKE",NIL(char), M_DEFAULT, &Augmake     );
  97.    _set_string_var(".SETDIR",      "",  M_DEFAULT, &Start_dir   );
  98.    _set_string_var(".KEEP_STATE",  "",  M_DEFAULT, &Keep_state  );
  99.  
  100.    _set_string_var("MAKEDIR", Get_current_dir(), M_PRECIOUS|M_NOEXPORT,
  101.          &Makedir);
  102.    _set_string_var("PWD",  Makedir,  M_DEFAULT|M_NOEXPORT, &Pwd);
  103.    _set_string_var("TMD",  "",       M_DEFAULT|M_NOEXPORT, &Tmd);
  104.  
  105.    Def_macro("NULL", "", M_PRECIOUS|M_NOEXPORT|M_FLAG);
  106.  
  107.    _set_int_var( "MAXLINELENGTH", "0", M_DEFAULT|M_NOEXPORT, &Buffer_size );
  108.    (void) Def_macro("MAXLINELENGTH", "0", M_FLAG | M_DEFAULT);
  109.  
  110.    /* set MAXPROCESSLIMIT high initially so that it allows MAXPROCESS to
  111.     * change from command line. */
  112.    _set_int_var( "MAXPROCESSLIMIT", "100", M_DEFAULT|M_NOEXPORT, &Max_proclmt );
  113.    _set_int_var( "MAXPROCESS", "1", M_DEFAULT|M_NOEXPORT, &Max_proc );
  114. }
  115.  
  116.  
  117. /*
  118. ** Define an integer variable value, and set up the macro.
  119. */
  120. static void
  121. _set_int_var(name, val, flag, var)
  122. char *name;
  123. char *val;
  124. int  flag;
  125. int  *var;
  126. {
  127.    HASHPTR hp;
  128.  
  129.    hp = Def_macro(name, val, M_FLAG | flag);
  130.    hp->ht_flag |= M_VAR_INT | M_MULTI;
  131.    hp->MV_IVAR  = var;
  132.    *var         = atoi(val);
  133. }
  134.  
  135.  
  136. /*
  137. ** Define a string variables value, and set up the macro.
  138. */
  139. static void
  140. _set_string_var(name, val, flag, var)
  141. char *name;
  142. char *val;
  143. int  flag;
  144. char **var;
  145. {
  146.    HASHPTR hp;
  147.  
  148.    hp = Def_macro(name, val, M_FLAG | flag);
  149.    hp->ht_flag |= M_VAR_STRING | M_MULTI;
  150.    hp->MV_SVAR  = var;
  151.    *var         = hp->ht_value;
  152. }
  153.  
  154.  
  155. /*
  156. ** Define a bit variable value, and set up the macro.
  157. */
  158. static void
  159. _set_bit_var(name, val, mask)
  160. char *name;
  161. char *val;
  162. int  mask;
  163. {
  164.    HASHPTR hp;
  165.  
  166.    hp           = Def_macro(name, val, M_FLAG);
  167.    hp->ht_flag |= M_VAR_BIT | M_MULTI;
  168.    hp->MV_MASK  = mask;
  169.    hp->MV_BVAR  = &Glob_attr;
  170. }
  171.