jnp@daimi.UUCP (J|rgen N|rgaard) (01/17/88)
[MAKEMAKE - Create a MAKEFILE for a MODULA-2 program] Here is a small utility to be used with MacMETH MODULA 2. It is a (not extensively debugged) make-like facility. It is intended for use with the compiler's cmd-1 option. In order to be used it needs some modifications of StringLib0 which are also posted now. Please mail me if you find bugs, inconvinient things etc. Have Fun !!! It is based on a make-file creator for Atari ST/TDI-MODULA by Steve Tynor. Regards J|rgen N|rgaard, jnp@daimi.dk --- #! /bin/sh # This is a shell archive, meaning: # 1. Remove everything above the #! /bin/sh line. # 2. Save the resulting text in a file. # 3. Execute the file with /bin/sh (not csh) to create the files: # Make.CMD # MakeFileInfo.DEF # MakeForest.DEF # MakeLibraries.DEF # MakeParser.DEF # MakeToken.DEF # Make.MOD # MakeFileInfo.MOD # MakeForest.MOD # MakeLibraries.MOD # MakeParser.MOD # MakeToken.MOD # This archive created: Fri Oct 23 12:29:08 1987 export PATH; PATH=/bin:$PATH echo shar: extracting "'Make.CMD'" '(316 characters)' if test -f 'Make.CMD' then echo shar: will not over-write existing file "'Make.CMD'" else sed 's/^X//' << \SHAR_EOF > 'Make.CMD' X:Project:MakeFileInfo.DEF X:Project:MakeForest.DEF X:Project:MakeToken.DEF X:Project:MakeLibraries.DEF X:Project:MakeParser.DEF X:Project:MakeFileInfo.MOD X:Project:MakeForest.MOD X:Project:MakeFileInfo.MOD X:Project:MakeForest.MOD X:Project:MakeToken.MOD X:Project:MakeLibraries.MOD X:Project:MakeParser.MOD X:Project:Make.MOD SHAR_EOF if test 316 -ne "`wc -c < 'Make.CMD'`" then echo shar: error transmitting "'Make.CMD'" '(should have been 316 characters)' fi fi # end of overwriting check echo shar: extracting "'MakeFileInfo.DEF'" '(885 characters)' if test -f 'MakeFileInfo.DEF' then echo shar: will not over-write existing file "'MakeFileInfo.DEF'" else sed 's/^X//' << \SHAR_EOF > 'MakeFileInfo.DEF' XDEFINITION MODULE MakeFileInfo; X (* X * MAKEMAKE. Create a MAKEFILE for a MODULA-2 program. X * X * Written by Steve Tynor, 30 September 1986. X * UUCP : tynor@gitpyr X * USNAIL: 2550 Akers Mill Rd. T-2, Atlanta GA. 30339 X * X * Permission is granted to distribute, copy and change this program as long X * as this notice remains... X --- X * X * Make. X * Modified and extended for MacMETH by : X * J?rgen N?rgaard, 23 october 1987. X * UUCP : jnp@daimi.dk X * MAIL : Dybb?lvej 29, v?r. 2+3, 8240 Risskov, DENMARK X * X * Essentially only the parser remains from the original. X * Extensions are a dependency-tree and a make-like facility. X * X *) X XPROCEDURE ModifiedTime(VAR name : ARRAY OF CHAR; X VAR success : BOOLEAN; X VAR time : LONGINT); X XEND MakeFileInfo. SHAR_EOF if test 885 -ne "`wc -c < 'MakeFileInfo.DEF'`" then echo shar: error transmitting "'MakeFileInfo.DEF'" '(should have been 885 characters)' fi fi # end of overwriting check echo shar: extracting "'MakeForest.DEF'" '(2070 characters)' if test -f 'MakeForest.DEF' then echo shar: will not over-write existing file "'MakeForest.DEF'" else sed 's/^X//' << \SHAR_EOF > 'MakeForest.DEF' XDEFINITION MODULE MakeForest; X (* X * MAKEMAKE. Create a MAKEFILE for a MODULA-2 program. X * X * Written by Steve Tynor, 30 September 1986. X * UUCP : tynor@gitpyr X * USNAIL: 2550 Akers Mill Rd. T-2, Atlanta GA. 30339 X * X * Permission is granted to distribute, copy and change this program as long X * as this notice remains... X --- X * X * Make. X * Modified and extended for MacMETH by : X * J?rgen N?rgaard, 23 october 1987. X * UUCP : jnp@daimi.dk X * MAIL : Dybb?lvej 29, v?r. 2+3, 8240 Risskov, DENMARK X * X * Essentially only the parser remains from the original. X * Extensions are a dependency-tree and a make-like facility. X * X *) X XIMPORT System; XIMPORT FileSystem; X XTYPE X NameString = ARRAY[0..60] OF CHAR; (* Total filename length is 64 - '.EXT' *) X DepList = POINTER TO DepListEntity; X DepTree = DepList; X EntityPtr = POINTER TO DepEntity; X DepEntity = RECORD X moduleName : NameString; X defName, X impName : System.Path; X seen, X checked, X library : BOOLEAN; X date : LONGINT; X DEFDepends, X MODDepends : DepTree; X END; X X DepListEntity = RECORD X next : DepList; X actual : EntityPtr; X END; X XVAR X root : DepTree; X X (*----------------------------------------------------------------------*) X PROCEDURE AddModule (VAR name : NameString; X VAR dp : DepTree; X VAR de : EntityPtr) : BOOLEAN; X (* returns TRUE if file added, FALSE if the file was already there, and a X POINTER to a new entity *) X (*----------------------------------------------------------------------*) X X PROCEDURE RemoveTree(VAR dp : DepTree); X X (*----------------------------------------------------------------------*) X PROCEDURE Make(dp : DepTree; VAR fd : FileSystem.File); X XEND MakeForest. SHAR_EOF if test 2070 -ne "`wc -c < 'MakeForest.DEF'`" then echo shar: error transmitting "'MakeForest.DEF'" '(should have been 2070 characters)' fi fi # end of overwriting check echo shar: extracting "'MakeLibraries.DEF'" '(813 characters)' if test -f 'MakeLibraries.DEF' then echo shar: will not over-write existing file "'MakeLibraries.DEF'" else sed 's/^X//' << \SHAR_EOF > 'MakeLibraries.DEF' XDEFINITION MODULE MakeLibraries; X (* X * MAKEMAKE. Create a MAKEFILE for a MODULA-2 program. X * X * Written by Steve Tynor, 30 September 1986. X * UUCP : tynor@gitpyr X * USNAIL: 2550 Akers Mill Rd. T-2, Atlanta GA. 30339 X * X * Permission is granted to distribute, copy and change this program as long X * as this notice remains... X --- X * X * Make. X * Modified and extended for MacMETH by : X * J?rgen N?rgaard, 23 october 1987. X * UUCP : jnp@daimi.dk X * MAIL : Dybb?lvej 29, v?r. 2+3, 8240 Risskov, DENMARK X * X * Essentially only the parser remains from the original. X * Extensions are a dependency-tree and a make-like facility. X * X *) X XPROCEDURE IsALibraryModule (VAR modulename : ARRAY OF CHAR) : BOOLEAN; X XEND MakeLibraries. SHAR_EOF if test 813 -ne "`wc -c < 'MakeLibraries.DEF'`" then echo shar: error transmitting "'MakeLibraries.DEF'" '(should have been 813 characters)' fi fi # end of overwriting check echo shar: extracting "'MakeParser.DEF'" '(1177 characters)' if test -f 'MakeParser.DEF' then echo shar: will not over-write existing file "'MakeParser.DEF'" else sed 's/^X//' << \SHAR_EOF > 'MakeParser.DEF' XDEFINITION MODULE MakeParser; X X (* X * MAKEMAKE. Create a MAKEFILE for a MODULA-2 program. X * X * Written by Steve Tynor, 30 September 1986. X * UUCP : tynor@gitpyr X * USNAIL: 2550 Akers Mill Rd. T-2, Atlanta GA. 30339 X * X * Permission is granted to distribute, copy and change this program as long X * as this notice remains... X --- X * X * Make. X * Modified and extended for MacMETH by : X * J?rgen N?rgaard, 23 october 1987. X * UUCP : jnp@daimi.dk X * MAIL : Dybb?lvej 29, v?r. 2+3, 8240 Risskov, DENMARK X * X * Essentially only the parser remains from the original. X * Extensions are a dependency-tree and a make-like facility. X * X *) X XIMPORT System; XIMPORT MakeForest; X XTYPE X FileType = (def, mod, main); X X (*----------------------------------------------------------------------*) X PROCEDURE ParseModule (VAR modulename : MakeForest.NameString; X type : FileType; X VAR de : MakeForest.EntityPtr; X VAR filename : System.Path; X VAR succeded : BOOLEAN); X XEND MakeParser. SHAR_EOF if test 1177 -ne "`wc -c < 'MakeParser.DEF'`" then echo shar: error transmitting "'MakeParser.DEF'" '(should have been 1177 characters)' fi fi # end of overwriting check echo shar: extracting "'MakeToken.DEF'" '(1096 characters)' if test -f 'MakeToken.DEF' then echo shar: will not over-write existing file "'MakeToken.DEF'" else sed 's/^X//' << \SHAR_EOF > 'MakeToken.DEF' XDEFINITION MODULE MakeToken; X (* X * MAKEMAKE. Create a MAKEFILE for a MODULA-2 program. X * X * Written by Steve Tynor, 30 September 1986. X * UUCP : tynor@gitpyr X * USNAIL: 2550 Akers Mill Rd. T-2, Atlanta GA. 30339 X * X * Permission is granted to distribute, copy and change this program as long X * as this notice remains... X --- X * X * Make. X * Modified and extended for MacMETH by : X * J?rgen N?rgaard, 23 october 1987. X * UUCP : jnp@daimi.dk X * MAIL : Dybb?lvej 29, v?r. 2+3, 8240 Risskov, DENMARK X * X * Essentially only the parser remains from the original. X * Extensions are a dependency-tree and a make-like facility. X * X *) X XIMPORT System; X X PROCEDURE OpenFile (VAR filename : System.Path; X VAR success : BOOLEAN); X X PROCEDURE CloseFile; X X PROCEDURE NextToken (VAR token : ARRAY OF CHAR; X VAR eof : BOOLEAN); X X PROCEDURE SkipTillSemicolon (VAR eof : BOOLEAN); X X PROCEDURE SkipComment; X XEND MakeToken. SHAR_EOF if test 1096 -ne "`wc -c < 'MakeToken.DEF'`" then echo shar: error transmitting "'MakeToken.DEF'" '(should have been 1096 characters)' fi fi # end of overwriting check echo shar: extracting "'Make.MOD'" '(2343 characters)' if test -f 'Make.MOD' then echo shar: will not over-write existing file "'Make.MOD'" else sed 's/^X//' << \SHAR_EOF > 'Make.MOD' XMODULE Make; X X (* X * MAKEMAKE. Create a MAKEFILE for a MODULA-2 program. X * X * Written by Steve Tynor, 30 September 1986. X * UUCP : tynor@gitpyr X * USNAIL: 2550 Akers Mill Rd. T-2, Atlanta GA. 30339 X * X * Permission is granted to distribute, copy and change this program as long X * as this notice remains... X --- X * X * Make. X * Modified and extended for MacMETH by : X * J?rgen N?rgaard, 23 october 1987. X * UUCP : jnp@daimi.dk X * MAIL : Dybb?lvej 29, v?r. 2+3, 8240 Risskov, DENMARK X * X * Essentially only the parser remains from the original. X * Extensions are a dependency-tree and a make-like facility. X * X *) X X (* Usage : X * Enter the name of the module, X * "name" (assumed to have extension .MOD) to make. X * Output (if successful) name.CMD file for the compiler-utility 'cmd-1' X *) X XIMPORT System, InOut, StringLib0, FileSystem, MakeForest, MakeParser; X XVAR X modulename : MakeForest.NameString; X filename : System.Path; X thisEntity : MakeForest.EntityPtr; X makeFile : FileSystem.File; X success : BOOLEAN; X i : INTEGER; X XBEGIN X InOut.WriteString ("Make which MODULE ? "); X InOut.ReadString(modulename); X WHILE (InOut.termCH # 3C) DO (* Not terminated *) X InOut.WriteLn; X MakeForest.RemoveTree(MakeForest.root); X IF MakeForest.AddModule(modulename, MakeForest.root, thisEntity) THEN X MakeParser.ParseModule (modulename, MakeParser.main, X thisEntity, filename, success); X IF success THEN X i := StringLib0.Length(filename) - 1; X filename[i - 3] := '.'; filename[i - 2] := 'C'; X filename[i - 1] := 'M'; filename[i] := 'D'; X FileSystem.Lookup(makeFile, filename, TRUE); X IF NOT (makeFile.res = FileSystem.done) THEN X InOut.WriteString('Could not open .CMD-file'); X ELSE X MakeForest.Make(MakeForest.root, makeFile); X FileSystem.Close(makeFile); X InOut.WriteString('+ '); X InOut.WriteString(filename); X END; X ELSE X InOut.WriteString('Missing file'); X END; X ELSE X InOut.WriteString('Serious error! (in "MakeForest")'); X END; X InOut.WriteLn; X InOut.WriteString ("Make which MODULE ? "); X InOut.ReadString(modulename); X END; XEND Make. SHAR_EOF if test 2343 -ne "`wc -c < 'Make.MOD'`" then echo shar: error transmitting "'Make.MOD'" '(should have been 2343 characters)' fi fi # end of overwriting check echo shar: extracting "'MakeFileInfo.MOD'" '(4935 characters)' if test -f 'MakeFileInfo.MOD' then echo shar: will not over-write existing file "'MakeFileInfo.MOD'" else sed 's/^X//' << \SHAR_EOF > 'MakeFileInfo.MOD' XIMPLEMENTATION MODULE MakeFileInfo; X (* X * MAKEMAKE. Create a MAKEFILE for a MODULA-2 program. X * X * Written by Steve Tynor, 30 September 1986. X * UUCP : tynor@gitpyr X * USNAIL: 2550 Akers Mill Rd. T-2, Atlanta GA. 30339 X * X * Permission is granted to distribute, copy and change this program as long X * as this notice remains... X --- X * X * Make. X * Modified and extended for MacMETH by : X * J?rgen N?rgaard, 23 october 1987. X * UUCP : jnp@daimi.dk X * MAIL : Dybb?lvej 29, v?r. 2+3, 8240 Risskov, DENMARK X * X * Essentially only the parser remains from the original. X * Extensions are a dependency-tree and a make-like facility. X * X *) X XIMPORT SYSTEM, StringLib0; X XTYPE X Ptr = SYSTEM.ADDRESS; X ProcPtr = Ptr; X Byte = CHAR; X Str255 = ARRAY [0..255] OF CHAR; X StringPtr = POINTER TO Str255; X OSErr = INTEGER; X VHSelect =(v,h); X VHSelectR = [v..h]; X Point = X RECORD X CASE :INTEGER OF X 0: v: INTEGER; X h: INTEGER X | 1: vh: ARRAY VHSelectR OF INTEGER X END X END; X OSType = ARRAY [1..4] OF CHAR; X FInfo = X RECORD X fdType: OSType; X fdCreator: OSType; X fdFlags: BITSET; X fdLocation: Point; X fdFldr: INTEGER X END; X (* some general types *) X QElemPtr = POINTER TO QElem; X QHdrPtr = POINTER TO QHdr; X QHdr = X RECORD X qFlags: BITSET; X qHead: QElemPtr; X qTail: QElemPtr X END; X (* FileManager *) X X ParamBlkType = (ioParam, fileParam, volumeParam, cntrlParam); X ParmBlkPtr = POINTER TO ParamBlockRec; X ParamBlockRec = X RECORD X qLink: QElemPtr; X qType: INTEGER; X ioTrap: INTEGER; X ioCmdAddr: Ptr; X ioCompletion: ProcPtr; X ioResult: OSErr; X ioNamePtr: StringPtr; X ioVRefNum: INTEGER; X CASE :ParamBlkType OF X ioParam: X ioRefNum: INTEGER; X ioVersNum: Byte; (* change *) X ioPermssn: Byte; (* change *) X ioMisc: Ptr; X ioBuffer: Ptr; X ioReqCount: LONGINT; X ioActCount: LONGINT; X ioPosMode: INTEGER; X ioPosOffset: LONGINT; X | fileParam: X ioFRefNum: INTEGER; X ioFVersNum: Byte; (* change *) X filler1: Byte; (* change *) X ioFDirIndex: INTEGER; X ioFlAttrib: Byte; (* change *) X ioFlVersNum: Byte; (* change *) X ioFlFndrInfo: FInfo; X ioFlNum: LONGINT; X ioFlStBlk: INTEGER; X ioFlLgLen: LONGINT; X ioFlPyLen: LONGINT; X ioFlRStBlk: INTEGER; X ioFlRLgLen: LONGINT; X ioFlRPyLen: LONGINT; X ioFlCrDat: LONGINT; X ioFlMdDat: LONGINT; X X | volumeParam: X filler2: LONGINT; X ioVolIndex: INTEGER; X ioVCrDate: LONGINT; X ioVLsBkUp: LONGINT; X ioVAtrb: BITSET; X ioVNmFls: INTEGER; X ioVDirSt: INTEGER; X ioVBlLn: INTEGER; X ioVNmAlBlks: INTEGER; X ioVAlBlkSiz: LONGINT; X ioVClpSiz: LONGINT; X ioAlBlSt: INTEGER; X ioVNxtFNum: LONGINT; X ioVFrBlk: INTEGER; X | cntrlParam: X ioCRefNum: INTEGER; X csCode: INTEGER; X csParam: ARRAY [0..10] OF INTEGER X END X END; X X X PROCEDURE PBGetFInfo(paramBlock: ParmBlkPtr; aSync: BOOLEAN): OSErr; X CONST X A0 = 8; X D0 = 0; X sync = 0A000H; X async = 0A400H; X BEGIN X SYSTEM.SETREG(A0,paramBlock); X IF aSync THEN SYSTEM.INLINE(async+0CH) ELSE SYSTEM.INLINE(sync+0CH) END; X RETURN paramBlock^.ioResult X END PBGetFInfo; X X VAR X block : ParamBlockRec; X PROCEDURE ModifiedTime(VAR name : ARRAY OF CHAR; X VAR success : BOOLEAN; X VAR time : LONGINT); X VAR X i,j : INTEGER; X err : OSErr; X BEGIN X i := StringLib0.Length(name); X FOR j:= i TO 1 BY -1 DO X name[j] := name[j - 1]; X END; X name[0] := SYSTEM.VAL(CHAR, i); X block.ioNamePtr := SYSTEM.ADR(name); X block.ioCompletion := NIL; (* See below *) X block.ioVRefNum := 0; (* Default volume *) X block.ioFDirIndex := 0; (* Use name *) X block.ioVersNum := 0C; (* Not used, has to be zero *) X block.ioVersNum := 0C; (* Not used, has to be zero *) X err := PBGetFInfo(SYSTEM.ADR(block), FALSE); X time := block.ioFlMdDat; X success := (err = 0); X IF NOT ((err = 0) OR (err = -43)) THEN (* Other Error *) HALT; END; X END ModifiedTime; X X XBEGIN XEND MakeFileInfo. SHAR_EOF if test 4935 -ne "`wc -c < 'MakeFileInfo.MOD'`" then echo shar: error transmitting "'MakeFileInfo.MOD'" '(should have been 4935 characters)' fi fi # end of overwriting check echo shar: extracting "'MakeForest.MOD'" '(8981 characters)' if test -f 'MakeForest.MOD' then echo shar: will not over-write existing file "'MakeForest.MOD'" else sed 's/^X//' << \SHAR_EOF > 'MakeForest.MOD' XIMPLEMENTATION MODULE MakeForest; X (* X * MAKEMAKE. Create a MAKEFILE for a MODULA-2 program. X * X * Written by Steve Tynor, 30 September 1986. X * UUCP : tynor@gitpyr X * USNAIL: 2550 Akers Mill Rd. T-2, Atlanta GA. 30339 X * X * Permission is granted to distribute, copy and change this program as long X * as this notice remains... X --- X * X * Make. X * Modified and extended for MacMETH by : X * J?rgen N?rgaard, 23 october 1987. X * UUCP : jnp@daimi.dk X * MAIL : Dybb?lvej 29, v?r. 2+3, 8240 Risskov, DENMARK X * X * Essentially only the parser remains from the original. X * Extensions are a dependency-tree and a make-like facility. X * X *) X X (* Note : Statements etc. parenthesised by 'Begin Debug/End Debug' comments X * are for debug use only X *) X XIMPORT SYSTEM, System, FileSystem, MakeFileInfo, StringLib0, InOut; X X(* Begin Debug *) (* XPROCEDURE WriteLong(l : LONGINT); X VAR X a, k : CARDINAL; X digits : ARRAY[0..10] OF CHAR; X negative, X special : BOOLEAN; XBEGIN X negative := (l < 0D); X special := (l = MIN(LONGINT) ); X IF special THEN l:= -(l+1D); X ELSIF negative THEN l:= -l; END; X k := 0; X REPEAT X a := l MOD 10D; X l := l DIV 10D; X digits[k] := CHR(SYSTEM.VAL(CARDINAL, ORD('0')) + a); X INC(k); X UNTIL l = 0D; X IF special THEN digits[k] := '-'; digits[0] := '8'; X ELSIF negative THEN digits[k] := '-'; ELSE digits[k] := ' '; END; X INC(k); X REPEAT DEC(k); InOut.Write(digits[k]); UNTIL k = 0; XEND WriteLong; X*)(* End Debug *) X X (*----------------------------------------------------------------------*) X PROCEDURE FindName (dp : DepTree; X VAR name : ARRAY OF CHAR; X VAR entity : EntityPtr) : BOOLEAN; X VAR X l : DepList; X resD, X resM : BOOLEAN; X entityD, X entityM : EntityPtr; X BEGIN X IF dp = NIL THEN X entity := NIL; X RETURN FALSE; X ELSE X l := dp; X WHILE l # NIL DO X IF StringLib0.Equal(name, l^.actual^.moduleName) THEN X entity := l^.actual; X RETURN TRUE; X ELSE X IF NOT l^.actual^.seen THEN X l^.actual^.seen := TRUE; X resD := FindName(l^.actual^.DEFDepends, name, entityD); X resM := FindName(l^.actual^.MODDepends, name, entityM); X l^.actual^.seen := FALSE; X ELSE X resD := FALSE; X resM := FALSE; X END; X IF resD THEN X entity := entityD; X RETURN TRUE; X ELSIF resM THEN X entity := entityM; X RETURN TRUE; X ELSE X l := l^.next; X END; X END; X END; X entity := NIL; X RETURN FALSE; X END; X END FindName; X X (*----------------------------------------------------------------------*) X PROCEDURE AddModule (VAR name : NameString; X VAR dp : DepTree; X VAR de : EntityPtr) : BOOLEAN; X (* returns TRUE if file added, FALSE if the file was already there, and a X POINTER to a new entity *) X VAR X res : BOOLEAN; X entity : EntityPtr; X l : DepList; X BEGIN X res := FindName(root, name, entity); X IF dp = NIL THEN X System.Allocate(dp, SYSTEM.TSIZE(DepListEntity)); X dp^.next := NIL; X l := dp; X ELSE X l := dp; X WHILE l^.next # NIL DO l := l^.next END; X System.Allocate(l^.next, SYSTEM.TSIZE(DepListEntity)); X l := l^.next; X l^.next := NIL; X END; X IF res THEN X l^.actual := entity; X de := NIL; X RETURN FALSE; X ELSE X System.Allocate(l^.actual, SYSTEM.TSIZE(DepEntity)); X de := l^.actual; X WITH de^ DO X moduleName := name; X defName := ""; X impName := ""; X seen := FALSE; X checked := FALSE; X library := FALSE; X date := 0D; X DEFDepends := NIL; X MODDepends := NIL; X END; X RETURN TRUE; X END; X END AddModule; X X PROCEDURE RemoveTree(VAR dp : DepTree); X VAR temp : DepTree; X BEGIN X WHILE dp # NIL DO X RemoveTree(dp^.actual^.DEFDepends); X RemoveTree(dp^.actual^.MODDepends); X temp := dp^.next; X System.Deallocate(dp^.actual); X System.Deallocate(dp); X dp := temp; X END; X END RemoveTree; X X PROCEDURE Make(dp : DepTree; VAR fd : FileSystem.File); X CONST X Genesis = MIN(LONGINT); (* older than any file *) X Eternity = MAX(LONGINT); (* newer than any file *) X X TYPE X Extension = ARRAY[0..2] OF CHAR; X X PROCEDURE Max(l1, l2 : LONGINT) : LONGINT; X BEGIN X IF l1 > l2 THEN RETURN l1 ELSE RETURN l2 END; X END Max; X X PROCEDURE FileTime(name : System.Path; ext : Extension) : LONGINT; X VAR X i : INTEGER; X time : LONGINT; X done : BOOLEAN; X BEGIN X i := StringLib0.Length(name) - 1; X name[i - 2] := ext[0]; X name[i - 1] := ext[1]; X name[i ] := ext[2]; X MakeFileInfo.ModifiedTime(name, done, time); X IF NOT done THEN time := Genesis; END; (* File not found; make it. X Assumed to be .SBM or .OBM *) X RETURN time; X END FileTime; X X PROCEDURE WriteFileName(VAR name : System.Path); X VAR X i, top : INTEGER; X BEGIN X top := StringLib0.Length(name) - 1; X FOR i:= 0 TO top DO X FileSystem.WriteChar(fd, name[i]); X END; X FileSystem.WriteChar(fd, InOut.EOL); X END WriteFileName; X X PROCEDURE MakeDEFs(dp : DepTree) : LONGINT; X PROCEDURE Check(ep : EntityPtr; VAR time : LONGINT); X VAR X dateDEF, X dateSBM : LONGINT; X BEGIN X dateDEF := FileTime(ep^.defName, 'DEF'); X dateSBM := FileTime(ep^.defName, 'SBM'); X(* Begin Debug *)(* XWriteLong(time); InOut.Write(' '); WriteLong(dateDEF); InOut.WriteLn; XWriteLong(dateDEF); InOut.Write(' '); WriteLong(dateSBM); InOut.WriteLn; X*)(* End Debug *) X IF (time >= dateDEF) OR (dateDEF >= dateSBM) THEN X(* Begin Debug *)(* XInOut.WriteString("Marked Changed"); InOut.WriteLn; X*)(* End Debug *) X WriteFileName(ep^.defName); X ep^.date := Eternity; (* Mark changed *) X ELSE X ep^.date := dateSBM; X END; X time := ep^.date; X END Check; X X VAR X res, maximum : LONGINT; X BEGIN X res := Genesis; X maximum := Genesis; X WHILE dp # NIL DO X WITH dp^.actual^ DO X IF NOT checked THEN X checked := TRUE; X IF NOT library THEN X res := MakeDEFs(MODDepends); (* Dummy, just do it *) X res := MakeDEFs(DEFDepends); X(* Begin Debug *)(* XInOut.WriteString('DEF Checking '); XInOut.WriteString(moduleName); InOut.WriteLn; X*)(* End Debug *) X Check(dp^.actual, res); X ELSE X date := Genesis; X res := date; X END; X ELSE X res := date; X END; X END; X maximum := Max(maximum, res); X dp := dp^.next; X END; X RETURN maximum; X END MakeDEFs; X X PROCEDURE MakeMODs(dp : DepTree) : LONGINT; X VAR X maximum : LONGINT; X dateDEF, X dateMOD, X dateOBM : LONGINT; X BEGIN X dateDEF := Genesis; X maximum := Genesis; X WHILE dp # NIL DO X WITH dp^.actual^ DO X IF NOT library THEN X dateMOD := FileTime(impName, 'MOD'); X dateOBM := FileTime(impName, 'OBM'); X dateDEF := MakeMODs(MODDepends); X(* Begin Debug *)(* XInOut.WriteString('MOD Checking '); XInOut.WriteString(moduleName); XInOut.WriteLn; XWriteLong(dateDEF); InOut.Write(' '); WriteLong(dateOBM); InOut.WriteLn; XWriteLong(dateMOD); InOut.Write(' '); WriteLong(dateOBM); InOut.WriteLn; X*)(* End Debug *) X IF (dateDEF >= dateOBM) OR (dateMOD >= dateOBM) THEN X(* Begin Debug *)(* XInOut.WriteString("Marked Changed"); InOut.WriteLn; X*)(* End Debug *) X WriteFileName(impName); X END; X maximum := Max(maximum, date); X END; X END; X dp := dp^.next; X END; X RETURN maximum; X END MakeMODs; X X VAR X dateDEF, X dateMOD, X dateOBM : LONGINT; X BEGIN X dateDEF := MakeDEFs(dp^.actual^.MODDepends); (* Dummy; just do it *) X dateDEF := MakeMODs(dp^.actual^.MODDepends); X dateMOD := FileTime(dp^.actual^.impName, 'MOD'); X dateOBM := FileTime(dp^.actual^.impName, 'OBM'); X(* Begin Debug *)(* XInOut.WriteString("Checking "); XInOut.WriteString(dp^.actual^.moduleName); InOut.WriteLn; XWriteLong(dateDEF); InOut.Write(' '); WriteLong(dateOBM); InOut.WriteLn; XWriteLong(dateMOD); InOut.Write(' '); WriteLong(dateOBM); InOut.WriteLn; X*)(* End Debug *) X IF (dateDEF >= dateOBM) OR (dateMOD >= dateOBM) THEN X(* Begin Debug *)(* XInOut.WriteString("Marked Changed"); InOut.WriteLn; X*)(* End Debug *) X WriteFileName(dp^.actual^.impName); X END; X END Make; X XBEGIN X root := NIL; XEND MakeForest. SHAR_EOF if test 8981 -ne "`wc -c < 'MakeForest.MOD'`" then echo shar: error transmitting "'MakeForest.MOD'" '(should have been 8981 characters)' fi fi # end of overwriting check echo shar: extracting "'MakeLibraries.MOD'" '(2421 characters)' if test -f 'MakeLibraries.MOD' then echo shar: will not over-write existing file "'MakeLibraries.MOD'" else sed 's/^X//' << \SHAR_EOF > 'MakeLibraries.MOD' XIMPLEMENTATION MODULE MakeLibraries; X (* X * MAKEMAKE. Create a MAKEFILE for a MODULA-2 program. X * X * Written by Steve Tynor, 30 September 1986. X * UUCP : tynor@gitpyr X * USNAIL: 2550 Akers Mill Rd. T-2, Atlanta GA. 30339 X * X * Permission is granted to distribute, copy and change this program as long X * as this notice remains... X --- X * X * Make. X * Modified and extended for MacMETH by : X * J?rgen N?rgaard, 23 october 1987. X * UUCP : jnp@daimi.dk X * MAIL : Dybb?lvej 29, v?r. 2+3, 8240 Risskov, DENMARK X * X * Essentially only the parser remains from the original. X * Extensions are a dependency-tree and a make-like facility. X * X *) X X (* NOTE: this module is implementation specific. Substitute the library X * modules supplied by your compiler. X *) XIMPORT StringLib0; X XCONST X NumLibraryModules = 18; X XVAR X LibraryModule : ARRAY [1 .. NumLibraryModules] OF ARRAY[0..31] OF CHAR; X X (*-----------------------------------------------------------------------*) X PROCEDURE IsALibraryModule (VAR modulename : ARRAY OF CHAR) : BOOLEAN; X (* binary search... *) X VAR X low, mid, high : CARDINAL; X BEGIN X low := 1; X high := NumLibraryModules; X WHILE low <= high DO X mid := low + (high - low) DIV 2; X CASE StringLib0.Compare (modulename, LibraryModule[mid]) OF X StringLib0.EqualTo : X RETURN TRUE; X | StringLib0.LessThan : X high := mid - 1; X ELSE X low := mid + 1; X END; (* CASE *) X END; (* WHILE *) X RETURN FALSE; X END IsALibraryModule; X XBEGIN X (* NOTE: we're doing a binary search, so these must be in sorted order: *) X X (* MacMETH supplied libraries: *) X LibraryModule [ 1] := 'CursorMouse'; X LibraryModule [ 2] := 'EventBase'; X LibraryModule [ 3] := 'FileSystem'; X LibraryModule [ 4] := 'GraphicWindows'; X LibraryModule [ 5] := 'InOut'; X LibraryModule [ 6] := 'LongMathLib'; X LibraryModule [ 7] := 'LongRealInOut'; X LibraryModule [ 8] := 'MathLib'; X LibraryModule [ 9] := 'Menu'; X LibraryModule [10] := 'Printer'; X LibraryModule [11] := 'RealInOut'; X LibraryModule [12] := 'SYSTEM'; X LibraryModule [13] := 'System'; X LibraryModule [14] := 'Terminal'; X LibraryModule [15] := 'TerminalIn'; X LibraryModule [16] := 'TerminalOut'; X LibraryModule [17] := 'TextWindows'; X LibraryModule [18] := 'Windows'; X XEND MakeLibraries. SHAR_EOF if test 2421 -ne "`wc -c < 'MakeLibraries.MOD'`" then echo shar: error transmitting "'MakeLibraries.MOD'" '(should have been 2421 characters)' fi fi # end of overwriting check echo shar: extracting "'MakeParser.MOD'" '(6153 characters)' if test -f 'MakeParser.MOD' then echo shar: will not over-write existing file "'MakeParser.MOD'" else sed 's/^X//' << \SHAR_EOF > 'MakeParser.MOD' XIMPLEMENTATION MODULE MakeParser; X X (* X * MAKEMAKE. Create a MAKEFILE for a MODULA-2 program. X * X * Written by Steve Tynor, 30 September 1986. X * UUCP : tynor@gitpyr X * USNAIL: 2550 Akers Mill Rd. T-2, Atlanta GA. 30339 X * X * Permission is granted to distribute, copy and change this program as long X * as this notice remains... X --- X * X * Make. X * Modified and extended for MacMETH by : X * J?rgen N?rgaard, 23 october 1987. X * UUCP : jnp@daimi.dk X * MAIL : Dybb?lvej 29, v?r. 2+3, 8240 Risskov, DENMARK X * X * Essentially only the parser remains from the original. X * Extensions are a dependency-tree and a make-like facility. X * X *) X XIMPORT System; XIMPORT StringLib0; XIMPORT MakeForest; XIMPORT MakeToken; XIMPORT MakeLibraries; X XIMPORT InOut; X (*----------------------------------------------------------------------*) X PROCEDURE ModulenameToFilename (VAR modulename : ARRAY OF CHAR; X defOrMod : FileType; X VAR fname : ARRAY OF CHAR); X CONST X EOS = 0C; X VAR X c : INTEGER; X BEGIN X c := 0; X WHILE (c < HIGH(modulename)) AND (c <= (HIGH(fname) - 4)) X AND (modulename[c] <> EOS) DO X fname[c] := modulename[c]; X INC (c); X END; (* WHILE *) X fname[c] := '.'; X IF defOrMod = def THEN X fname[c+1] := 'D'; fname[c+2] := 'E'; fname[c+3] := 'F'; X fname[c+4] := EOS; X ELSE X fname[c+1] := 'M'; fname[c+2] := 'O'; fname[c+3] := 'D'; X fname[c+4] := EOS; X END; (* IF *) X END ModulenameToFilename; X X (*----------------------------------------------------------------------*) X PROCEDURE TerminatingToken(VAR token : ARRAY OF CHAR) : BOOLEAN; X VAR X temp : BOOLEAN; X BEGIN X (* had to split up due to compiler limitation... *) X temp := StringLib0.Equal (token, 'CONST') OR X StringLib0.Equal (token, 'TYPE') OR X StringLib0.Equal (token, 'VAR') OR X StringLib0.Equal (token, 'MODULE'); X RETURN temp OR X StringLib0.Equal (token, 'PROCEDURE') OR X StringLib0.Equal (token, 'BEGIN') OR X StringLib0.Equal (token, 'END'); X END TerminatingToken; X X (*----------------------------------------------------------------------*) X PROCEDURE ParseFROM ( VAR dp : MakeForest.DepTree; X VAR eof : BOOLEAN; X VAR filename : System.Path; X VAR succeded : BOOLEAN); X VAR X modulename : MakeForest.NameString; X de : MakeForest.EntityPtr; X BEGIN X MakeToken.NextToken (modulename, eof); X IF MakeForest.AddModule(modulename, dp, de) THEN X ParseModule (modulename, def, de, filename, succeded); X ParseModule (modulename, mod, de, filename, succeded); X END; X MakeToken.SkipTillSemicolon (eof); X END ParseFROM; X X (*----------------------------------------------------------------------*) X PROCEDURE ParseIMPORT ( VAR dp : MakeForest.DepTree; X VAR eof : BOOLEAN; X VAR filename : System.Path; X VAR succeded : BOOLEAN); X VAR X modulename : MakeForest.NameString; X de : MakeForest.EntityPtr; X BEGIN X MakeToken.NextToken (modulename, eof); X WHILE (modulename[0] <> ';') AND succeded DO X IF MakeForest.AddModule(modulename, dp, de) THEN X ParseModule (modulename, def, de, filename, succeded); X ParseModule (modulename, mod, de, filename, succeded); X END; X MakeToken.NextToken (modulename, eof); X END; (* WHILE *) X END ParseIMPORT; X X (*----------------------------------------------------------------------*) X PROCEDURE ParseModule (VAR modulename : MakeForest.NameString; X type : FileType; X VAR de : MakeForest.EntityPtr; X VAR filename : System.Path; X VAR succeded : BOOLEAN); X VAR X token : ARRAY [0 .. 132] OF CHAR; X success, X eof : BOOLEAN; X tempName : System.Path; X BEGIN X ModulenameToFilename (modulename, type, filename); X succeded := TRUE; X IF MakeLibraries.IsALibraryModule (modulename) THEN X de^.library := TRUE; X InOut.WriteString(modulename); X InOut.WriteString(' (Library)'); X InOut.WriteLn; X ELSE X MakeToken.OpenFile (filename, success); X IF type = def THEN X de^.defName := filename; X ELSE X de^.impName := filename; X END; X InOut.WriteString('- '); X InOut.WriteString(filename); X IF NOT success THEN X InOut.WriteString(', File Not Found'); InOut.WriteLn; X succeded := FALSE; X ELSE X MakeToken.NextToken (token, eof); X IF (type = def) AND NOT StringLib0.Equal(token, 'DEFINITION') THEN X InOut.WriteString('Expected a "DEFINITION"-MODULE'); X ELSIF (type = mod) AND NOT StringLib0.Equal(token, 'IMPLEMENTATION') THEN X InOut.WriteString('Expected a "IMPLEMENTATION"-MODULE'); X ELSIF (type = main) AND NOT StringLib0.Equal(token, 'MODULE') THEN X InOut.WriteString('Expected a "MODULE"-MODULE'); X END; (* IF / ELSE / ENDIF *) X InOut.WriteLn; X MakeToken.SkipTillSemicolon (eof); X token := ';'; X WHILE (NOT eof) AND (NOT TerminatingToken(token)) DO X IF StringLib0.Equal (token, 'FROM') THEN X IF type = def THEN X ParseFROM (de^.DEFDepends, eof, tempName, succeded); X ELSE X ParseFROM (de^.MODDepends, eof, tempName, succeded); X END; X ELSIF StringLib0.Equal (token, 'IMPORT') THEN X IF type = def THEN X ParseIMPORT (de^.DEFDepends, eof, tempName, succeded); X ELSE X ParseIMPORT (de^.MODDepends, eof, tempName, succeded); X END; X END; (* IF *) X MakeToken.NextToken (token, eof); X END; (* WHILE *) X END; (* IF file opened *) X MakeToken.CloseFile; X END;(* IF ELSE we need to check this one *) X END ParseModule; XEND MakeParser. SHAR_EOF if test 6153 -ne "`wc -c < 'MakeParser.MOD'`" then echo shar: error transmitting "'MakeParser.MOD'" '(should have been 6153 characters)' fi fi # end of overwriting check echo shar: extracting "'MakeToken.MOD'" '(6221 characters)' if test -f 'MakeToken.MOD' then echo shar: will not over-write existing file "'MakeToken.MOD'" else sed 's/^X//' << \SHAR_EOF > 'MakeToken.MOD' XIMPLEMENTATION MODULE MakeToken; X (* X * MAKEMAKE. Create a MAKEFILE for a MODULA-2 program. X * X * Written by Steve Tynor, 30 September 1986. X * UUCP : tynor@gitpyr X * USNAIL: 2550 Akers Mill Rd. T-2, Atlanta GA. 30339 X * X * Permission is granted to distribute, copy and change this program as long X * as this notice remains... X --- X * X * Make. X * Modified and extended for MacMETH by : X * J?rgen N?rgaard, 23 october 1987. X * UUCP : jnp@daimi.dk X * MAIL : Dybb?lvej 29, v?r. 2+3, 8240 Risskov, DENMARK X * X * Essentially only the parser remains from the original. X * Extensions are a dependency-tree and a make-like facility. X * X *) X XIMPORT System; XIMPORT FileSystem; X XVAR X currentCh : CHAR; X currentFile : FileSystem.File; X X (*======================================================================*) X MODULE FileStack; X IMPORT FileSystem; X EXPORT Pop, Push; X X CONST X StackSize = 25; X VAR X StrStack : ARRAY [1 .. StackSize] OF FileSystem.File; X CharStack : ARRAY [1 .. StackSize] OF CHAR; X StackPtr : CARDINAL; X X (*--------------------------------------------------------------------*) X PROCEDURE Push (str : FileSystem.File; ch : CHAR); X BEGIN X IF StackPtr + 1 <= StackSize THEN X INC (StackPtr); X StrStack [StackPtr] := str; X CharStack[StackPtr] := ch; X END; (* IF *) X END Push; X X (*--------------------------------------------------------------------*) X PROCEDURE Pop (VAR str : FileSystem.File; VAR ch : CHAR); X BEGIN X IF StackPtr > 0 THEN X str := StrStack [StackPtr]; X ch := CharStack[StackPtr]; X DEC (StackPtr); X END; (* IF *) X END Pop; X X BEGIN X StackPtr := 0; X END FileStack; X (*======================================================================*) X X X (*----------------------------------------------------------------------*) X PROCEDURE OpenFile (VAR filename : System.Path; X VAR success : BOOLEAN); X VAR X path, name : System.Path; X whichPath : INTEGER; X BEGIN X Push (currentFile, currentCh); X whichPath := 0; X REPEAT X INC(whichPath); X System.FindPath(path, filename, whichPath); X System.AddPath(path, filename, name); X FileSystem.Lookup(currentFile, name, FALSE); X success := currentFile.res = FileSystem.done; X UNTIL success OR (whichPath = 0); X IF success THEN filename := name END; X currentCh := ' '; X END OpenFile; X X (*----------------------------------------------------------------------*) X PROCEDURE CloseFile; X BEGIN X FileSystem.Close(currentFile); X Pop (currentFile, currentCh); X END CloseFile; X X X (*----------------------------------------------------------------------*) X PROCEDURE SeparatingChar (ch : CHAR) : BOOLEAN; X (* we're just worried about a subset of the real separating chars... *) X BEGIN X RETURN NOT (((ORD(ch) >= ORD('a')) AND (ORD(ch) <= ORD('z'))) OR X ((ORD(ch) >= ORD('A')) AND (ORD(ch) <= ORD('Z'))) OR X ((ORD(ch) >= ORD('0')) AND (ORD(ch) <= ORD('9')))); X END SeparatingChar; X X X (*----------------------------------------------------------------------*) X PROCEDURE NextToken (VAR token : ARRAY OF CHAR; X VAR eof : BOOLEAN); X VAR X c : INTEGER; X BEGIN X c := 0; X IF currentCh = ';' THEN X token[0] := ';'; X token[1] := 0C; X eof := currentFile.eof; X FileSystem.ReadChar(currentFile, currentCh); X RETURN; X END; (* IF *) X WHILE SeparatingChar (currentCh) DO X FileSystem.ReadChar(currentFile, currentCh); X IF currentCh = ';' THEN X token[0] := ';'; X token[1] := 0C; X eof := currentFile.eof; X FileSystem.ReadChar(currentFile, currentCh); X RETURN; X ELSIF currentCh = '(' THEN X token[c] := currentCh; X FileSystem.ReadChar(currentFile, currentCh); X IF currentCh = '*' THEN X SkipComment; X ELSE X token[0] := '('; X token[1] := currentCh; X c := 2; X END; (* IF *) X END; (* IF *) X END; (* WHILE *) X REPEAT X IF currentCh = '(' THEN X token[c] := currentCh; X FileSystem.ReadChar(currentFile, currentCh); X IF currentCh = '*' THEN X IF c > 0 THEN X token[c+1] := 0C; X SkipComment; X RETURN; X ELSE X SkipComment; X END; (* IF *) X END; (* IF *) X END; (* IF *) X token[c] := currentCh; X INC (c); X FileSystem.ReadChar(currentFile, currentCh); X UNTIL currentFile.eof OR X (c > HIGH (token)) OR X SeparatingChar (currentCh); X token[c] := 0C; X eof := currentFile.eof; X END NextToken; X X X (*----------------------------------------------------------------------*) X PROCEDURE SkipTillSemicolon (VAR eof : BOOLEAN); X VAR X ch : CHAR; X BEGIN X REPEAT X IF (NOT currentFile.eof) AND (currentCh = '(') THEN X FileSystem.ReadChar(currentFile, currentCh); X IF (NOT currentFile.eof) AND (currentCh = '*') THEN X SkipComment; X END; (* IF *) X ELSE X FileSystem.ReadChar(currentFile, currentCh); X END; (* IF *) X UNTIL currentFile.eof OR (currentCh = ';'); X END SkipTillSemicolon; X X X (*----------------------------------------------------------------------*) X PROCEDURE SkipComment; X VAR X level : CARDINAL; X done : BOOLEAN; X BEGIN X level := 1; X FileSystem.ReadChar(currentFile, currentCh); X done := FALSE; X REPEAT X IF (NOT currentFile.eof) AND (currentCh = '*') THEN X FileSystem.ReadChar(currentFile, currentCh); X IF (NOT currentFile.eof) AND (currentCh = ')') THEN X DEC(level); X done := level = 0; X END; (* IF *) X ELSIF (NOT currentFile.eof) AND (currentCh = '(') THEN X FileSystem.ReadChar(currentFile, currentCh); X IF (NOT currentFile.eof) AND (currentCh = '*') THEN X INC(level); X END; (* IF *) X ELSE X FileSystem.ReadChar(currentFile, currentCh); X END; (* IF *) X UNTIL currentFile.eof OR done; X END SkipComment; X XBEGIN X currentCh := ' '; XEND MakeToken. SHAR_EOF if test 6221 -ne "`wc -c < 'MakeToken.MOD'`" then echo shar: error transmitting "'MakeToken.MOD'" '(should have been 6221 characters)' fi fi # end of overwriting check # End of shell archive exit 0 ---