update dev300-m57
[ooovba.git] / dmake / imacs.c
blob04feb097552cea02587a00b2763bccf32f90b0d8
1 /* RCS $Id: imacs.c,v 1.9 2008-03-05 18:29:01 kz Exp $
2 --
3 -- SYNOPSIS
4 -- Define default internal macros.
5 --
6 -- DESCRIPTION
7 -- This file adds to the internal macro tables the set of default
8 -- internal macros, and for those that are accessible internally via
9 -- variables creates these variables, and initializes them to point
10 -- at the default values of these macros.
12 -- AUTHOR
13 -- Dennis Vadura, dvadura@dmake.wticorp.com
15 -- WWW
16 -- http://dmake.wticorp.com/
18 -- COPYRIGHT
19 -- Copyright (c) 1996,1997 by WTI Corp. All rights reserved.
20 --
21 -- This program is NOT free software; you can redistribute it and/or
22 -- modify it under the terms of the Software License Agreement Provided
23 -- in the file <distribution-root>/readme/license.txt.
25 -- LOG
26 -- Use cvs log to obtain detailed change logs.
29 #include "extern.h"
31 static void _set_int_var ANSI((char *, char *, int, int *));
32 static void _set_string_var ANSI((char *, char *, int, char **));
33 static void _set_bit_var ANSI((char *, char *, int));
36 PUBLIC void
37 Make_rules()/*
38 ==============
39 Parse the strings stored in Rule_tab (from ruletab.c). */
41 Parse(NIL(FILE));
45 #define M_FLAG M_DEFAULT | M_EXPANDED
48 ** Add to the macro table all of the internal macro variables plus
49 ** create secondary variables which will give access to their values
50 ** easily, both when needed and when the macro value is modified.
51 ** The latter is accomplished by providing a flag in the macro and a field
52 ** which gives a pointer to the value if it is a char or string macro value
53 ** and a mask representing the bit of the global flag register that is affected
54 ** by this macro's value.
56 PUBLIC void
57 Create_macro_vars()
59 static char* switchar;
60 static char* version;
61 char swchar[2];
62 char buf[20];
64 swchar[0] = Get_switch_char(), swchar[1] = '\0';
65 _set_string_var("SWITCHAR", swchar, M_PRECIOUS, &switchar);
66 if (*swchar == '/')
67 DirSepStr = "\\";
68 else
69 #if (_MPW)
70 DirSepStr = ":";
71 #elif defined( __EMX__)
72 /* Use '\' for OS/2 port. */
73 DirSepStr = "\\";
74 #else
75 DirSepStr = "/";
76 #endif
77 _set_string_var("DIRSEPSTR", DirSepStr, M_DEFAULT,&DirSepStr);
78 _set_string_var("DIRBRKSTR", DirBrkStr, M_DEFAULT, &DirBrkStr);
79 swchar[0] = DEF_ESCAPE_CHAR, swchar[1] = '\0';
80 _set_string_var(".ESCAPE_PREFIX", swchar, M_FLAG, &Escape_char);
82 /* Each one the following attributes corresponds to a bit of
83 * Glob_attr. */
84 _set_bit_var(".SILENT", "", A_SILENT );
85 _set_bit_var(".IGNORE", "", A_IGNORE );
86 _set_bit_var(".PRECIOUS", "", A_PRECIOUS);
87 _set_bit_var(".EPILOG", "", A_EPILOG );
88 _set_bit_var(".PROLOG", "", A_PROLOG );
89 _set_bit_var(".NOINFER", "", A_NOINFER );
90 _set_bit_var(".SEQUENTIAL","",A_SEQ );
91 _set_bit_var(".USESHELL", "", A_SHELL );
92 /* .SWAP (MSDOS) and .WINPATH (cygwin) share the same bit. */
93 _set_bit_var(".SWAP", "", A_SWAP );
94 _set_bit_var(".WINPATH", "", A_WINPATH );
95 _set_bit_var(".MKSARGS", "", A_MKSARGS );
96 _set_bit_var(".IGNOREGROUP","",A_IGNOREGROUP);
98 Glob_attr = A_DEFAULT; /* set all flags to NULL */
100 _set_string_var("SHELL", "", M_DEFAULT, &Shell );
101 _set_string_var("SHELLFLAGS", " ", M_DEFAULT, &Shell_flags );
102 _set_string_var("SHELLCMDQUOTE","", M_DEFAULT, &Shell_quote );
103 _set_string_var("GROUPSHELL", "", M_DEFAULT, &GShell );
104 _set_string_var("GROUPFLAGS", " ", M_DEFAULT, &GShell_flags);
105 _set_string_var("SHELLMETAS", "", M_DEFAULT, &Shell_metas );
106 _set_string_var("GROUPSUFFIX", "", M_DEFAULT, &Grp_suff );
107 _set_string_var("AUGMAKE",NIL(char), M_DEFAULT, &Augmake );
108 _set_string_var("OOODMAKEMODE", "", M_DEFAULT, &OOoDmMode );
109 _set_string_var(".KEEP_STATE", "", M_DEFAULT, &Keep_state );
110 _set_string_var(".NOTABS", "", M_MULTI, &Notabs );
111 _set_string_var(".DIRCACHE", "y", M_DEFAULT, &UseDirCache );
113 #if CASE_INSENSITIVE_FS
114 #define DIRCACHERESPCASEDEFAULT ""
115 #else
116 #define DIRCACHERESPCASEDEFAULT "y"
117 #endif
118 _set_string_var(".DIRCACHERESPCASE", DIRCACHERESPCASEDEFAULT, M_DEFAULT, &DcacheRespCase);
120 _set_string_var("MAKEDIR",Get_current_dir(),M_PRECIOUS|M_NOEXPORT,
121 &Makedir_macval);
122 Makedir = DmStrDup(Makedir_macval); /* Later done by Def_macro(). */
123 _set_string_var("MAKEVERSION", VERSION, M_PRECIOUS, &version);
124 _set_string_var("PWD", Makedir, M_PRECIOUS|M_NOEXPORT, &Pwd_macval);
125 Pwd = DmStrDup(Pwd_macval); /* Later done by Def_macro(). */
126 _set_string_var("TMD", ".", M_PRECIOUS|M_NOEXPORT, &Tmd_macval);
127 Tmd = DmStrDup(Tmd_macval); /* Later done by _set_tmd(). */
129 Def_macro("NULL", "", M_PRECIOUS|M_NOEXPORT|M_FLAG);
131 /* Initialize a macro that contains a space. As leading and trailing
132 * spaces are stripped by Def_macro a little cheating is necessary. */
133 _set_string_var("SPACECHAR", "x", M_PRECIOUS|M_NOEXPORT|M_FLAG, &Spacechar );
134 Spacechar[0] = ' ';
136 _set_int_var( "MAXLINELENGTH", "0", M_DEFAULT|M_NOEXPORT, &Buffer_size );
137 _set_int_var( "PREP", "0", M_DEFAULT, &Prep );
138 (void) Def_macro("MAXLINELENGTH", "1024", M_FLAG | M_DEFAULT);
140 /* MAXPROCESSLIMIT is overwritten by the ruletab.c settings. Set its
141 * initial value high so that it allows MAXPROCESS to be changed
142 * from the command line. */
143 _set_int_var( "MAXPROCESSLIMIT", "100", M_DEFAULT|M_NOEXPORT,&Max_proclmt );
144 #if defined(USE_CREATEPROCESS)
145 /* Set the OS early enough. */
146 Max_proclmt = MAXIMUM_WAIT_OBJECTS;
147 #endif
148 _set_int_var( "MAXPROCESS", "1", M_DEFAULT|M_NOEXPORT, &Max_proc );
149 sprintf(buf,"%d",NAME_MAX);
150 _set_int_var( "NAMEMAX", buf, M_DEFAULT|M_NOEXPORT, &NameMax);
155 ** Define an integer variable value, and set up the macro.
157 static void
158 _set_int_var(name, val, flag, var)
159 char *name;
160 char *val;
161 int flag;
162 int *var;
164 HASHPTR hp;
166 hp = Def_macro(name, val, M_FLAG | flag);
167 hp->ht_flag |= M_VAR_INT | M_MULTI | M_INIT;
168 hp->MV_IVAR = var;
169 *var = atoi(val);
174 ** Define a string variables value, and set up the macro.
176 static void
177 _set_string_var(name, val, flag, var)
178 char *name;
179 char *val;
180 int flag;
181 char **var;
183 HASHPTR hp;
185 hp = Def_macro(name, val, M_FLAG | flag);
186 hp->ht_flag |= M_VAR_STRING | M_MULTI | M_INIT;
187 hp->MV_SVAR = var;
188 *var = hp->ht_value;
192 /* Define a bit variable value, and set up the macro. Each of the bits
193 * corresponds to an attribute bit of Glob_attr. */
194 static void
195 _set_bit_var(name, val, mask)
196 char *name;
197 char *val;
198 int mask;
200 HASHPTR hp;
202 hp = Def_macro(name, val, M_FLAG);
203 hp->ht_flag |= M_VAR_BIT | M_MULTI | M_INIT;
204 hp->MV_MASK = mask;
205 hp->MV_BVAR = &Glob_attr;