-
Notifications
You must be signed in to change notification settings - Fork 6
/
setenv.cmd
executable file
·129 lines (98 loc) · 3.05 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
/* Set environment variables */
parse arg cfg
parse source os addr src
if cfg = '' then signal usage
/* Build the full path to the config file */
if pos('/', translate(cfg, '/', '\')) == 0 then do
l = lastpos('/', translate(src, '/', '\'))
if l > 0 then cfg = delstr(src, l + 1) || cfg
end
if stream(cfg, 'c', 'query exists') = '' then signal usage
/* Read config file */
rc = stream(cfg, 'c', 'open read')
if rc \= 'READY:' then do
say 'Can''t open file ' || cfg || '!'
exit 1
end
do while lines(cfg) > 0
line = linein(cfg)
/* strip comments */
p = pos(';', line)
if p > 0 then line = delstr(line, p)
line = strip(line)
if line = '' then iterate
interpret line
end
call stream cfg, 'c', 'close'
env = 'ENVIRONMENT'
if pos(':', imgdir) == 2 then
imgdir = delstr(imgdir, 1, 2)
imgdir1 = translate(imgdir, '/', '\')
say os
if os == 'OS/2' then do
os = 'OS2'
wosdir = '\binp'
end; else
if os == 'WINDOWS' | os == 'WINNT' | os == 'WIN32' then do
wosdir = '\binnt'
end; else
if os == 'UNIX' | os == 'LINUX' then do
wosdir = '\binl'
end; else do
say 'Unsupported OS!'
exit 2
end
/* delete a driveletter from root */
if pos(':', root) = 2 then root = substr(root, 3)
if os == 'UNIX' | os == 'LINUX' then do
root = translate(root, '/', '\')
end
/* append '\' */
if lastpos('\', root) \= length(root) then root = root || '\'
tools = root || 'bin\tools'
path = value('PATH',, env)
path = watcom || wosdir || ';' || watcom || '\binw;' || tools || ';' || tkpath || '\bin;' || fppath || ';' || path
include = watcom || '\h;' || watcom || '\h\dos;' || watcom || '\h\win'
finclude = watcom || '\src\fortran'
edpath = watcom || '\eddat'
wipfc = watcom || '\wipfc'
if os == 'OS2' then do
help = value('HELP',, env)
help = watcom || wosdir || '\help;' || help
bookshelf = value('BOOKSHELF',, env)
bookshelf = watcom || wosdir || '\help;' || bookshelf
beginlibpath = watcom || wosdir || '\dll'
libos2 = watcom || '\lib386\os2'
end; else do
help = ''; bookshelf = '';
beginlibpath = ''; libos2 = '';
end
/* whether to use osFree or Watcom headers */
/* if headers == 'watcom' then
add_inc = watcom || '\h\os2'
else
add_inc = root || '\build\include\os2' */
lib = watcom || '\lib286;' || watcom || '\lib286\dos;' || watcom || '\lib286\win;' || libos2 || ';' || root || '\lib'
vars = 'WATCOM ROOT IMGDIR IMGDIR1 TOOLS PATH INCLUDE ',
'FINCLUDE EDPATH HELP BOOKSHELF BEGINLIBPATH ',
'LIBOS2 LIB OS SHELL REXX REXX_PATH MKISOFS SERVERENV WIPFC'
if verbose = 'yes' then
vars = vars || ' VERBOSE'
/* Set vars */
do i = 1 to words(vars)
var = word(vars, i)
val = value(var)
if os == 'UNIX' | os == 'LINUX'
then val = translate(val, '/:', '\;')
call value var, val, env
say var || '=' || val
end
if os == 'OS2' then 'set beginlibpath=' || beginlibpath
exit 0
/* ------------------------------------ */
usage:
say 'Usage:'
say
say 'setenv <config file>'
say
/* ------------------------------------ */