2 * This script serves as a helper cmd file for imake. Install this in
3 * the path just like imake itself.
5 * $XFree86: xc/config/imake/imakesvc.cmd,v 3.10.2.1 1997/07/19 04:59:10 dawes Exp $
9 CALL RxFuncAdd 'SysFileDelete', 'RexxUtil', 'SysFileDelete'
10 CALL RxFuncAdd 'SysFileTree', 'RexxUtil', 'SysFileTree'
11 CALL RxFuncAdd 'SysRmDir', 'RexxUtil', 'SysRmDir'
12 CALL RxFuncAdd 'SysMkDir', 'RexxUtil', 'SysMkDir'
19 /* imakesvc 1 u/n dir ruledir top current */
24 currentdir = WORD(all,6)
25 IF instflg = 'u' THEN DO
26 root = VALUE('X11ROOT',,'OS2ENVIRONMENT')
28 SAY 'Fatal error: no X11ROOT environment variable found!'
32 IF POS(':',ruledir) = 0 THEN
33 ruledir1 = root||ruledir
37 useinst = '-DUseInstalled'
40 /* in n mode, we must add a prefix ../ for MakeMakeSubdirs */
41 ruledir1 = '../'||ruledir
42 topdir1 = '../'||topdir
49 dir = fixbadprefix(WORD(all,3))
51 dirfwd=TRANSLATE(dir,'/','\')
52 RC = SysFileDelete('Makefile.bak')
53 IF exists('Makefile') THEN REN Makefile Makefile.bak
54 /* There is a difficulty in the Imakefiles. Some builds refer
55 * to directories that are in a different subtree. We need to adjust
56 * the CURDIR and TOPDIR and -I paths
58 IF SUBSTR(dirfwd,1,2)='..' THEN DO
59 /* must recalculate passed topdir, currentdir, and ruledir */
60 ndist = nlevels(topdir)
61 ncurdir = './'striplevel(dirfwd,ndist-1)
62 ntopdir = maketop(nlevels(ncurdir))
63 nruledir = ntopdir||'/config/cf'
66 /* this is simple it is relative to this dir */
67 pfx = downlevels(dirfwd)
69 IF instflg = 'n' THEN DO /*sm120296*/
70 nruledir = pfx||ruledir
73 ncurdir = currentdir /* use to be pfx || currentdir */
75 imakecmd useinst '-I'nruledir' -DTOPDIR='ntopdir' -DCURDIR='ncurdir'/'dirfwd
76 'x11make MAKE=x11make SHELL= Makefiles'
80 /* imakesvc 2 buildincdir buildinctop currentdir file */
85 d = DIRECTORY(WORD(all,2))
86 rc = SysFileDelete(fil)
87 dir = TRANSLATE(bid'/'cid'/'fil,'\','/')
88 COPY dir .' >nul 2>&1 '
92 /* imakesvc 3 subdir updir file */
96 d = DIRECTORY(WORD(all,3))
97 rc = SysFileDelete(fil)
98 dir = TRANSLATE(sdi'/'fil,'\','/')
99 COPY dir' . >nul 2>&1'
100 d = DIRECTORY(curdir)
103 /* imakesvc 4 [-r] files... */
106 IF rec = '-r' THEN fp = 3
108 DO i=fp TO WORDS(all)
109 CALL discard rec,TRANSLATE(WORD(all,i),'\','/')
113 /* imakesvc 5 file */
114 file = TRANSLATE(WORD(all,2),'\','/')
115 RC = SysFileDelete(file'.bak')
116 if exists(file) THEN 'REN 'file file||'.bak'
119 /* imakesvc 6 file */
120 file = TRANSLATE(WORD(all,2),'\','/')
121 CALL SysFileDelete(file||'.bak')
122 if exists(file) THEN 'REN 'file file||'.bak'
125 /* imakesvc 7 from to */
126 from = TRANSLATE(WORD(all,2),'\','/')
127 to = TRANSLATE(WORD(all,3),'\','/')
128 CALL SysFileDelete(to)
129 COPY from to' >nul 2>&1'
133 SAY SUBWORD(TRANSLATE(all,' ','222c'x),2)
136 /* imakesvc 9 dst.c incl.h src.c */
137 dst = TRANSLATE(WORD(all,2),'\','/')
138 src = TRANSLATE(WORD(all,4),'\','/')
139 CALL SysFileDelete(dst)
140 CALL LINEOUT dst,'#include "'WORD(all,3)'"'
141 CALL LINEOUT dst,'#include "'src'"'
145 /* imakesvc 10 srcfile destdir destfile suffix */
146 src = stripsuffix(WORD(all,2))
147 destdir = TRANSLATE(WORD(all,3),'\','/')
148 dest = stripsuffix(WORD(all,4))
150 tgt = destdir'\'dest'.'suffix
151 /* if you have no col.exe get one from 4.4BSD */
152 'groff -e -t -man -Tascii 'src'.man | col -b >'tgt
155 /* imakesvc 11 dirtomake */
156 dirtomake = TRANSLATE(WORD(all,2),'\','/')
157 rc = SysMkDir(dirtomake)
160 /* imakesvc 12 srcfile destdir destfile */
161 src = stripsuffix(WORD(all,2))
162 destdir = TRANSLATE(WORD(all,3),'\','/')
163 dest = stripsuffix(WORD(all,4))
164 tgt = destdir'\'dest'.gz'
165 /* if you have no col.exe get one from 4.4BSD */
166 'groff -e -t -man -Tascii 'src'.man | col -b | gzip -n >'tgt
169 /* imakesvc 13 indir fromfile tofile */
170 ind = TRANSLATE(WORD(all,2),'\','/')
171 frm = TRANSLATE(WORD(all,3),'\','/')
172 tof = ind'\'WORD(all,4)
173 IF \(exists(ind)) THEN MKDIR ind
174 rc = SysFileDelete(tof)
185 newpos = POS('/',ARG(1),oldpos)
186 IF newpos = 0 THEN LEAVE
193 /* returns 1, if file exists */
195 'DIR "'arg(1)'" >nul 2>&1'
196 IF rc = 0 THEN return 1
202 IF rec = '-r' THEN DO
205 CALL SysFileTree files, 'deld', 'DO'
206 IF deld.0 > 0 THEN DO
208 CALL DIRECTORY deld.m
215 CALL SysFileTree files, 'delf', 'FO'
217 DEL '"'delf.k'"' '>nul 2>&1'
222 DEL '"'files'"' '>nul 2>&1'
226 /* somehow make or cmd manages to convert a relative path ..\..\. to ..... */
230 DO WHILE SUBSTR(str,count,2) = '..'
232 str = INSERT('\',str,count)
243 str = DELSTR(str,1,p)
252 newpos = POS('/',str,oldpos)
253 IF newpos = 0 THEN LEAVE
273 RETURN LEFT(str,spos-1)