home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 18 REXX
/
18-REXX.zip
/
NMAKER.ZIP
/
NMAKER.CMD
Wrap
OS/2 REXX Batch file
|
1991-07-09
|
7KB
|
176 lines
/* Rexx to read in all you .mak files in the directory and builds new files*/
/* in reverse format used by NMAKE. Read for program comments for more */
/* information. */
/* Copyright 1991 Joe McVerry Raleigh NC USA All rights reserved */
/* This program assumes there is one .LRF file for each .EXE file it finds */
/* in the mak files. The program will create one MAKEFILE for all exe's. */
/* And the program will create one .NMK file for each exe. You should */
/* rename these .nmk's to .mak's if you're going to use them. The program */
/* does not edit the original make commands except for the new dependencies*/
/* I do not guantee valid results due to dependencies of your original make */
/* files. Use this program and its resulting output at your own risk */
/* If you have any questions please feel free to call me at 919-846-2014 or*/
/* write me: Joe McVerry at 8004 Selfridge Ct. Raleigh NC 27615 */
"copy *.mak mak.all" /* copy all .mak files to a working file */
make_line_found = 0 /* set up line counter */
alls = "" /* executable file name string */
make_line_pos = 1 /* current position on line */
do while(lines(mak.all)) /* do until end of working file */
parse value linein("mak.all") with first_word ":" second_word
/* get first dependency */
if substr(second_word,1,1) = "\" & length(first_word) > 12 then do
/* found one with disk id in it */
first_word = first_word || ":" || second_word /* replace disk id */
second_word = ""
end
if first_word = "" then do /* ignore blank line */
end
else
if second_word = "" then do /* looks like a make command line */
if skip = 0 then do
make_line_pos = make_line_pos + 1
make_line.make_line_found.make_line_pos = first_word
end
end
else do /* must be a make target-dependent line */
skip = 0
do key_cnt1 = 1 to make_line_found /* one one target description per file */
if first_word = key.key_cnt1 then do /* so find out if we have done already */
skip = 1 /* exit boolean */
say first_word "is already processed, we won't process again."
end
end
name = ""
extension = ""
parse upper value first_word with name "." extension
if name = "ALL" then do /* doing a nmake file skip ALL target */
skip = 1 /* exit boolean */
end
if skip = 0 then do /* let's do this line */
make_lines.make_line_found = make_line_pos
make_line_pos = 0
make_line_found = make_line_found + 1
if extension = "EXE" then do /* is the target an executable */
alls = alls||name||".EXE " /* yes, get its LRF file for its true*/
namelrf = name||".lrf" /* dependencies */
done = 0
objstr = ""
do while lines(namelrf) > 0 & done = 0
lrfin = linein(namelrf)
lrflen = length(lrfin)
if substr(lrfin,lrflen,1) \= "+" then done = 1 /* continues ? */
do while length(lrfin) > 0
parse upper value lrfin with objname "+" lrfin
objstr = objstr||objname||".OBJ "
end
end
say stream(namelrf,c,"close")
if objstr = "" then skip = 1
else make_line.make_line_found.make_line_pos = first_word":" objstr
end
else /* not an executable so use the depencies specified */
make_line.make_line_found.make_line_pos = first_word":" second_word
say first_word /* send it to the screen */
key.make_line_found = first_word
end
end
end
make_lines.make_line_found = make_line_pos
/* program priority by extention */
extension.1 = "EXE"
extension.2 = "DLL"
extension.3 = "LIB"
extension.4 = "OBJ"
extension.5 = "C"
extension.6 = "PAS"
extension.7 = "ASM"
extension.8 = "CBL"
extension.9 = "SQC"
extension.10 = "H"
extension.11 = "INC"
extension.cnt = 10
/* create a MAKEFILE */
"del MAKEFILE"
ALLS = "ALL: "||ALLS
mfile = "makefile"
call lineout mfile, ALLS
do extcnt = 1 to extension.cnt /* do it by extension priority order */
do line_pos = 1 to make_line_found
parse upper value key.line_pos with name "." extype
if extype = extension.extcnt then do
say key.line_pos /* send it to the screen */
call lineout mfile, " "
if make_lines.line_pos > 0 then
do line_cnt = 0 to make_lines.line_pos /* write out all dependences */
call lineout mfile, make_line.line_pos.line_cnt
end
end
end
end
say stream(mfile,c,"close")
/* make individual make files for EXE files*/
do make_pos = 1 to make_line_found /* all exe's are in first extenstion */
parse upper value key.make_pos with name "." extension
if extension \= "EXE" then iterate /* skip over non exe's */
mfile = name".nmk"
"del " mfile
do line_cnt = 0 to make_lines.make_pos
call lineout mfile, make_line.make_pos.line_cnt
end
call lineout mfile, " "
parse upper value make_line.make_pos.0 with name ":" dependencies
do quecnt = 1 to extension.cnt
depend_line.quecnt.cnt = 0
end
quecnt = 0
call find_dependencies make_pos dependencies
say name upper_loop /* display to screen current target */
do quecnt = 1 to extension.cnt
do extcnt = 1 to depend_line.quecnt.cnt
say key.extcnt
line_pos = depend_line.quecnt.extcnt
do line_cnt = 0 to make_lines.line_pos
say make_line.line_pos.line_cnt
call lineout mfile, make_line.line_pos.line_cnt
end
call lineout mfile, " "
end
end
say stream(mfile,c,"close")
end
exit
find_dependencies: procedure expose mfile make_line_found make_line. quecnt depend_line. extension.
parse arg make_line_foundpos dependents
parse value dependents with name dependents
foundit = 0 /* find counter */
do while name \= " "
do line_pos = 1 to make_line_found
parse upper value make_line.line_pos.0 with name2 ":" depends_on
if name = name2 then do
parse value name2 with name3 "." extension
do extype = 1 to extension.cnt until extension = extension.extype
end
if extype <= extension.cnt then do
foundit = foundit + 1
lookhere.foundit = line_pos
newpos = depend_line.extype.cnt + 1
depend_line.extype.newpos = line_pos
depend_line.extype.cnt = newpos
end
leave /* get out of do line_pos loop because we found it */
end
end
parse value dependents with name dependents
end
do findline = 1 to foundit
lookatline = lookhere.findline
parse upper value make_line.lookatline.0 with name ":" dependencies
call find_dependencies line_pos dependencies
end
return