-
Notifications
You must be signed in to change notification settings - Fork 1
/
setenv.cmd
314 lines (251 loc) · 10.4 KB
/
setenv.cmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
/* $Id: setenv.cmd,v 1.2 2004/03/21 04:22:53 bird Exp $
*
* This script defines and setup the build environment for building JFS.
*
* You'll have to edit this to set the correct paths.
*
*/
/*
* Toolkit (4.5) main directory.
*/
sTKMain = 'f:\os2tk45';
/*
* Device Driver Kit (DDK) (v4.0+) base (important not main) directory.
*/
sDDKBase = 'f:\ddk\base';
/*
* IBM C/C++ Compiler and Tools Version 3.6.5 main directory.
*/
sCxxMain = 'f:\dev\vac365';
/*
* Microsoft C v6.0a main directory.
*/
sMSCMain = 'f:\ddktools\toolkits\msc60';
fRm = 0;
/**
* Set environment - don't change locally!
*
* Note: This is done in this inefficient was to allow this file to be
* invoked serveral times and still have the exactly same environment.
**/
call EnvSet fRm, 'tkmain', sTkMain;
call EnvSet fRm, 'ddkbase', sDDKBase;
call EnvSet fRm, 'cxxmain', sCxxMain;
call EnvSet fRm, 'mscmain', sMSCMain;
call EnvSet fRm, 'VACPP', sCxxMain;
call EnvSet fRm, 'UFILEVER', '"@#netlabs.org:1.00.1#@Utils OpenJFS. Compiled by Pavel Shtemenko"'
call EnvAddFront fRm, 'path', sMSCMain'\binp;'
call EnvAddFront fRm, 'path', sDDKBase'\tools;'
call EnvAddFront fRm, 'path', sCxxMain'\bin;'
call EnvAddFront fRm, 'path', sTkMain'\bin;'
call EnvAddFront fRm, 'dpath', sCxxMain'\help;'
call EnvAddFront fRm, 'dpath', sCxxMain'\local;'
call EnvAddFront fRm, 'dpath', sTkMain'\book;'
call EnvAddFront fRm, 'dpath', sTkMain'\msg;'
call EnvAddFront fRm, 'beginlibpath', sCxxMain'\runtime;'
call EnvAddFront fRm, 'beginlibpath', sCxxMain'\dll;'
call EnvAddFront fRm, 'beginlibpath', sTkMain'\dll;'
call EnvAddFront fRm, 'help', sTkMain'\help;'
call EnvAddFront fRm, 'bookshelf', sTkMain'\archived;'
call EnvAddFront fRm, 'bookshelf', sTkMain'\book;'
call EnvAddFront fRm, 'nlspath', sCxxMain'\msg\%N;'
call EnvAddFront fRm, 'nlspath', sTkMain'\msg\%N;'
call EnvAddEnd fRm, 'ulspath', sTkMain'\language;'
call EnvAddFront fRm, 'include', sDDKBase'\h;'
call EnvAddFront fRm, 'include', sCxxMain'\include;'
call EnvAddFront fRm, 'include', sTkMain'\H;'
call EnvAddFront fRm, 'include', sTkMain'\H\GL;'
call EnvAddFront fRm, 'include', sTkMain'\SPEECH\H;'
call EnvAddFront fRm, 'include', sTkMain'\H\RPC;'
call EnvAddFront fRm, 'include', sTkMain'\H\NETNB;'
call EnvAddFront fRm, 'include', sTkMain'\H\NETINET;'
call EnvAddFront fRm, 'include', sTkMain'\H\NET;'
call EnvAddFront fRm, 'include', sTkMain'\H\ARPA;'
call EnvAddEnd fRm, 'lib', sTkMain'\SAMPLES\MM\LIB;'
call EnvAddEnd fRm, 'lib', sTkMain'\SPEECH\LIB;'
call EnvAddFront fRm, 'lib', sCxxMain'\lib;'
call EnvAddFront fRm, 'lib', sDDKBase'\lib;'
call EnvAddFront fRm, 'lib', sTkMain'\lib;'
call EnvAddFront fRm, 'helpndx', 'EPMKWHLP.NDX;'
call EnvAddFront fRm, 'ipfc', sCxxMain'\ipfc;'
call EnvAddFront fRm, 'ipfc', sTkMain'\ipfc;'
call EnvSet fRm, 'LANG', 'en_us'
call EnvSet fRm, 'CPP_DBG_LANG', 'CPP'
call EnvSet fRm, 'CPREF', 'CP1.INF+CP2.INF+CP3.INF'
call EnvSet fRm, 'GPIREF', 'GPI1.INF+GPI2.INF+GPI3.INF+GPI4.INF'
call EnvSet fRm, 'MMREF', 'MMREF1.INF+MMREF2.INF+MMREF3.INF'
call EnvSet fRm, 'PMREF', 'PM1.INF+PM2.INF+PM3.INF+PM4.INF+PM5.INF'
call EnvSet fRm, 'WPSREF', 'WPS1.INF+WPS2.INF+WPS3.INF'
/*
call EnvSet fRm, 'CAT_MACHINE', 'COM1:57600'
call EnvSet fRm, 'CAT_HOST_BIN_PATH', TKMAIN'\BIN'
call EnvSet fRm, 'CAT_COMMUNICATION_TYPE', 'ASYNC_SIGBRK'
call EnvSet fRm, 'CAT_HOST_SOURCE_PATH',TKMAIN'\BIN;'
*/
exit(0);
/**
* Procedure section
**/
/**
* Add sToAdd in front of sEnvVar.
* Note: sToAdd now is allowed to be alist!
*
* Known features: Don't remove sToAdd from original value if sToAdd
* is at the end and don't end with a ';'.
*/
EnvAddFront: procedure
parse arg fRM, sEnvVar, sToAdd, sSeparator
/* sets default separator if not specified. */
if (sSeparator = '') then sSeparator = ';';
/* checks that sToAdd ends with an ';'. Adds one if not. */
if (substr(sToAdd, length(sToAdd), 1) <> sSeparator) then
sToAdd = sToAdd || sSeparator;
/* check and evt. remove ';' at start of sToAdd */
if (substr(sToAdd, 1, 1) = ';') then
sToAdd = substr(sToAdd, 2);
/* loop thru sToAdd */
rc = 0;
i = length(sToAdd);
do while i > 1 & rc = 0
j = lastpos(sSeparator, sToAdd, i-1);
rc = EnvAddFront2(fRM, sEnvVar, substr(sToAdd, j+1, i - j), sSeparator);
i = j;
end
return rc;
/**
* Add sToAdd in front of sEnvVar.
*
* Known features: Don't remove sToAdd from original value if sToAdd
* is at the end and don't end with a ';'.
*/
EnvAddFront2: procedure
parse arg fRM, sEnvVar, sToAdd, sSeparator
/* sets default separator if not specified. */
if (sSeparator = '') then sSeparator = ';';
/* checks that sToAdd ends with a separator. Adds one if not. */
if (substr(sToAdd, length(sToAdd), 1) <> sSeparator) then
sToAdd = sToAdd || sSeparator;
/* check and evt. remove the separator at start of sToAdd */
if (substr(sToAdd, 1, 1) = sSeparator) then
sToAdd = substr(sToAdd, 2);
/* Get original variable value */
sOrgEnvVar = EnvGet(sEnvVar);
/* Remove previously sToAdd if exists. (Changing sOrgEnvVar). */
i = pos(translate(sToAdd), translate(sOrgEnvVar));
if (i > 0) then
sOrgEnvVar = substr(sOrgEnvVar, 1, i-1) || substr(sOrgEnvVar, i + length(sToAdd));
/* set environment */
if (fRM) then
return EnvSet(0, sEnvVar, sOrgEnvVar);
return EnvSet(0, sEnvVar, sToAdd||sOrgEnvVar);
/**
* Add sToAdd as the end of sEnvVar.
* Note: sToAdd now is allowed to be alist!
*
* Known features: Don't remove sToAdd from original value if sToAdd
* is at the end and don't end with a ';'.
*/
EnvAddEnd: procedure
parse arg fRM, sEnvVar, sToAdd, sSeparator
/* sets default separator if not specified. */
if (sSeparator = '') then sSeparator = ';';
/* checks that sToAdd ends with a separator. Adds one if not. */
if (substr(sToAdd, length(sToAdd), 1) <> sSeparator) then
sToAdd = sToAdd || sSeparator;
/* check and evt. remove ';' at start of sToAdd */
if (substr(sToAdd, 1, 1) = sSeparator) then
sToAdd = substr(sToAdd, 2);
/* loop thru sToAdd */
rc = 0;
i = length(sToAdd);
do while i > 1 & rc = 0
j = lastpos(sSeparator, sToAdd, i-1);
rc = EnvAddEnd2(fRM, sEnvVar, substr(sToAdd, j+1, i - j), sSeparator);
i = j;
end
return rc;
/**
* Add sToAdd as the end of sEnvVar.
*
* Known features: Don't remove sToAdd from original value if sToAdd
* is at the end and don't end with a ';'.
*/
EnvAddEnd2: procedure
parse arg fRM, sEnvVar, sToAdd, sSeparator
/* sets default separator if not specified. */
if (sSeparator = '') then sSeparator = ';';
/* checks that sToAdd ends with a separator. Adds one if not. */
if (substr(sToAdd, length(sToAdd), 1) <> sSeparator) then
sToAdd = sToAdd || sSeparator;
/* check and evt. remove separator at start of sToAdd */
if (substr(sToAdd, 1, 1) = sSeparator) then
sToAdd = substr(sToAdd, 2);
/* Get original variable value */
sOrgEnvVar = EnvGet(sEnvVar);
if (sOrgEnvVar <> '') then
do
/* Remove previously sToAdd if exists. (Changing sOrgEnvVar). */
i = pos(translate(sToAdd), translate(sOrgEnvVar));
if (i > 0) then
sOrgEnvVar = substr(sOrgEnvVar, 1, i-1) || substr(sOrgEnvVar, i + length(sToAdd));
/* checks that sOrgEnvVar ends with a separator. Adds one if not. */
if (sOrgEnvVar = '') then
if (right(sOrgEnvVar,1) <> sSeparator) then
sOrgEnvVar = sOrgEnvVar || sSeparator;
end
/* set environment */
if (fRM) then return EnvSet(0, sEnvVar, sOrgEnvVar);
return EnvSet(0, sEnvVar, sOrgEnvVar||sToAdd);
/**
* Sets sEnvVar to sValue.
*/
EnvSet: procedure
parse arg fRM, sEnvVar, sValue
/* if we're to remove this, make valuestring empty! */
if (fRM) then
sValue = '';
sEnvVar = translate(sEnvVar);
/*
* Begin/EndLibpath fix:
* We'll have to set internal these using both commandline 'SET'
* and internal VALUE in order to export it and to be able to
* get it (with EnvGet) again.
*/
if ((sEnvVar = 'BEGINLIBPATH') | (sEnvVar = 'ENDLIBPATH')) then
do
if (length(sValue) >= 1024) then
say 'Warning: 'sEnvVar' is too long,' length(sValue)' char.';
return SysSetExtLibPath(sValue, substr(sEnvVar, 1, 1));
end
if (length(sValue) >= 1024) then
do
say 'Warning: 'sEnvVar' is too long,' length(sValue)' char.';
say ' This may make CMD.EXE unstable after a SET operation to print the environment.';
end
sRc = VALUE(sEnvVar, sValue, 'OS2ENVIRONMENT');
return 0;
/**
* Gets the value of sEnvVar.
*/
EnvGet: procedure
parse arg sEnvVar
if ((translate(sEnvVar) = 'BEGINLIBPATH') | (translate(sEnvVar) = 'ENDLIBPATH')) then
return SysQueryExtLibPath(substr(sEnvVar, 1, 1));
return value(sEnvVar,, 'OS2ENVIRONMENT');
/**
* Workaround for bug in CMD.EXE.
* It messes up when REXX have expanded the environment.
*/
FixCMDEnv: procedure
/* check for 4OS2 first */
Address CMD 'set 4os2test_env=%@eval[2 + 2]';
if (value('4os2test_env',, 'OS2ENVIRONMENT') = '4') then
return 0;
/* force environment expansion by setting a lot of variables and freeing them. */
do i = 1 to 100
Address CMD '@set dummyenvvar'||i'=abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
end
do i = 1 to 100
Address CMD '@set dummyenvvar'||i'=';
end
return 0;