tynor@gitpyr.gatech.EDU (Steve Tynor) (01/08/87)
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= Here's a Modula2 program to generate a MAKFILE for a collection of Modula2 modules. It was written in TDI Modula2 (on the Atari ST) but should easily port to other compilers. Happy Making. =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= No problem is so formidable that you can't just walk away from it. Steve Tynor Georgia Instutute of Technology ...{akgua, allegra, amd, harpo, hplabs, ihnp4, masscomp, ut-ngp, rlgvax, sb1, uf-cgrl, unmvax, ut-sally} !gatech!gitpyr!tynor ---------------------------------------------------------------------- #! /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: # readme # makefile # makefore.def # makelibr.def # makepars.def # makefore.mod # makelibr.mod # makemake.mod # makepars.mod # maketoke.mod # This archive created: Wed Jan 7 23:35:08 1987 # By: Steve Tynor (Georgia Institute of Technology) export PATH; PATH=/bin:/usr/bin:$PATH echo shar: "extracting 'readme'" '(2949 characters)' if test -f 'readme' then echo shar: "will not over-write existing file 'readme'" else sed 's/^ X//' << \SHAR_EOF > 'readme' XMODULE MakeMake; 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 (* X * MAKEMAKE. Create a MAKEFILE for a MODULA-2 program. X * Usage: X * MAKEMAKE "main-module-modulename" X * X * Even though module dependencies are explicit in MODULA-2, it can still X * be quite a chore to figure them out and create a MAKEFILE. This program X * reads the text file associated with the module name given on the command X * line and recursively checks dependencies for all imported files. It then X * creates a MAKEFILE suitable for use with the Unix MAKE utility. If a X * file is not found and is not a recognized library module, then the X * MAKEFILE will include a comment: X * ## File NOT Found ## X * on the right hand side of the dependency. X * X * This program was written on the Atari ST using TDI Modula-2. X * X * BUGS: X * the CommandLine module dies when a null command line is seen. X * Unfortunately, I no longer have the source to the module, so I can't X * fix it. This bug also seems to consider a command line consisting of X * a single character as a reason for dieing. X * X * Suggestions for porting to another compiler: X * X * 1) module CommandLine is non-standard. It exports 2 procedures: X * PROCEDURE GetArgument ( num : CARDINAL; X * VAR filename : ARRAY OF CHAR); X * PROCEDURE NumberOfArguments() : CARDINAL; X * they do just what their names imply. (ie. like C's argv, argc) X * X * 2) the IMPLEMENTATION MODULE MakeLibraries will have to be edited to X * reflect the standard library that your compiler knows about. List X * any modules that you don't want included in your MAKEFILE. Library X * modules are listed in the MAKEFILE, but are commented out. X * X * 3) the procedure ModulenameToFilename in MakeParse will have to be X * modified so that it creates the correct filename for your machine. X * X * 4) if your MAKE program has default MODULA-2 rules, set the constant X * MAKEHasModulaRules (in this module) to TRUE. This will prevent X * MAKEMAKE from producing remake lines. X * X * 5) the procedure WriteFilename takes a parameter: extension. Trace X * all the calls to this function and make sure the proper extentions X * are used. in TDI Modula, '.DEF' = definition module text X * '.MOD' = implementation module text X * '.SYM' = symbol file (compiled DEF) X * '.LNK' = symbol file (compiled MOD) X *) X X X SHAR_EOF if test 2949 -ne "`wc -c < 'readme'`" then echo shar: "error transmitting 'readme'" '(should have been 2949 characters)' fi fi echo shar: "extracting 'makefile'" '(936 characters)' if test -f 'makefile' then echo shar: "will not over-write existing file 'makefile'" else sed 's/^ X//' << \SHAR_EOF > 'makefile' X XMAKEMAKE.PRG : MakeLibr.LNK MakeToke.LNK MakePars.LNK MakeFore.LNK \ X CommandL.LNK MAKEMAKE.LNK X C:\BIN\LNK.PRG MAKEMAKE.LNK XMAKEMAKE.LNK : MAKEMAKE.MOD MakePars.SYM MakeFore.SYM CommandL.SYM X #libs: Strings.SYM Streams.SYM ASCII.SYM InOut.SYM X C:\BIN\MOD.PRG MAKEMAKE.MOD XMakeLibr.LNK : MakeLibr.MOD MakeLibr.SYM X #libs: Strings.SYM X C:\BIN\MOD.PRG MakeLibr.MOD XMakeLibr.SYM : MakeLibr.DEF X C:\BIN\MOD.PRG MakeLibr.DEF XMakeToke.LNK : MakeToke.MOD MakeToke.SYM X #libs: Streams.SYM X C:\BIN\MOD.PRG MakeToke.MOD XMakeToke.SYM : MakeToke.DEF X C:\BIN\MOD.PRG MakeToke.DEF XMakePars.LNK : MakePars.MOD MakePars.SYM MakeLibr.SYM MakeFore.SYM \ X MakeToke.SYM X #libs: Strings.SYM X C:\BIN\MOD.PRG MakePars.MOD XMakePars.SYM : MakePars.DEF X C:\BIN\MOD.PRG MakePars.DEF XMakeFore.LNK : MakeFore.MOD MakeFore.SYM X #libs: Storage.SYM Strings.SYM X C:\BIN\MOD.PRG MakeFore.MOD XMakeFore.SYM : MakeFore.DEF X C:\BIN\MOD.PRG MakeFore.DEF SHAR_EOF if test 936 -ne "`wc -c < 'makefile'`" then echo shar: "error transmitting 'makefile'" '(should have been 936 characters)' fi fi echo shar: "extracting 'makefore.def'" '(1433 characters)' if test -f 'makefore.def' then echo shar: "will not over-write existing file 'makefore.def'" else sed 's/^ X//' << \SHAR_EOF > 'makefore.def' XDEFINITION MODULE MakeForest; 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 XTYPE X String = ARRAY [0 .. 100] OF CHAR; X X FileDefinitionList = POINTER TO FileDefinitionRec; X ImportList = POINTER TO ImportRec; X X FileDefinitionRec = RECORD X filename : String; X library : BOOLEAN; (* this file is a library module *) X next : FileDefinitionList; X imports : ImportList; (* points to linked list of imported files *) X END; (* RECORD *) X X ImportRec = RECORD X file : FileDefinitionList; X next : ImportList; X END; (* RECORD *) X XVAR X FileForestEnd, X FileForest : FileDefinitionList; X X (*----------------------------------------------------------------------*) X PROCEDURE AddImport (VAR fileDefinition : FileDefinitionList; X VAR fname : ARRAY OF CHAR); X X (*----------------------------------------------------------------------*) X PROCEDURE AddFile (VAR fname : ARRAY OF CHAR; X VAR fileDefinition : FileDefinitionList ) : BOOLEAN; X (* returns TRUE if file added, FALSE if the file was already there *) X XEND MakeForest. SHAR_EOF if test 1433 -ne "`wc -c < 'makefore.def'`" then echo shar: "error transmitting 'makefore.def'" '(should have been 1433 characters)' fi fi echo shar: "extracting 'makelibr.def'" '(469 characters)' if test -f 'makelibr.def' then echo shar: "will not over-write existing file 'makelibr.def'" else sed 's/^ X//' << \SHAR_EOF > 'makelibr.def' XDEFINITION MODULE MakeLibraries; 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 PROCEDURE IsALibraryModule (VAR modulename : ARRAY OF CHAR) : BOOLEAN; X XEND MakeLibraries. SHAR_EOF if test 469 -ne "`wc -c < 'makelibr.def'`" then echo shar: "error transmitting 'makelibr.def'" '(should have been 469 characters)' fi fi echo shar: "extracting 'makepars.def'" '(669 characters)' if test -f 'makepars.def' then echo shar: "will not over-write existing file 'makepars.def'" else sed 's/^ X//' << \SHAR_EOF > 'makepars.def' XDEFINITION MODULE MakeParse; 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 XTYPE X FileType = (def, mod, main); X X (*----------------------------------------------------------------------*) X PROCEDURE ParseModule (VAR modulename : ARRAY OF CHAR; X type : FileType; X VAR filename : ARRAY OF CHAR); X XEND MakeParse. SHAR_EOF if test 669 -ne "`wc -c < 'makepars.def'`" then echo shar: "error transmitting 'makepars.def'" '(should have been 669 characters)' fi fi echo shar: "extracting 'makefore.mod'" '(2161 characters)' if test -f 'makefore.mod' then echo shar: "will not over-write existing file 'makefore.mod'" else sed 's/^ X//' << \SHAR_EOF > 'makefore.mod' XIMPLEMENTATION MODULE MakeForest; 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 XIMPORT Strings; XFROM Storage IMPORT ALLOCATE; X X (*----------------------------------------------------------------------*) X PROCEDURE FindFile (VAR fname : ARRAY OF CHAR; X VAR fileDefinition : FileDefinitionList); X VAR X found : BOOLEAN; X BEGIN X fileDefinition := FileForest; X found := FALSE; X WHILE (fileDefinition <> NIL) AND (NOT found) DO X found := Strings.Compare (fname, fileDefinition^.filename) X = Strings.Equal; X IF NOT found THEN X fileDefinition := fileDefinition^.next; X END; (* IF *) X END; (* WHILE *) X END FindFile; X X X (*----------------------------------------------------------------------*) X PROCEDURE AddFile (VAR fname : ARRAY OF CHAR; X VAR fileDefinition : FileDefinitionList) : BOOLEAN; X BEGIN X FindFile (fname, fileDefinition); X IF fileDefinition = NIL THEN X NEW (fileDefinition); X Strings.Assign (fileDefinition^.filename, fname); X fileDefinition^.next := FileForest; X fileDefinition^.imports := NIL; X IF FileForest = NIL THEN X FileForestEnd := fileDefinition; X END; (* IF *) X FileForest := fileDefinition; X RETURN TRUE; X ELSE X RETURN FALSE; X END; (* IF *) X END AddFile; X X X (*----------------------------------------------------------------------*) X PROCEDURE AddImport (VAR fileDefinition : FileDefinitionList; X VAR fname : ARRAY OF CHAR ); X VAR X iPtr : ImportList; X BEGIN X NEW (iPtr); X iPtr^.next := fileDefinition^.imports; X fileDefinition^.imports := iPtr; X IF AddFile (fname, iPtr^.file) THEN END; X END AddImport; X X XBEGIN X FileForest := NIL; X FileForestEnd := NIL; XEND MakeForest. SHAR_EOF if test 2161 -ne "`wc -c < 'makefore.mod'`" then echo shar: "error transmitting 'makefore.mod'" '(should have been 2161 characters)' fi fi echo shar: "extracting 'makelibr.mod'" '(3115 characters)' if test -f 'makelibr.mod' then echo shar: "will not over-write existing file 'makelibr.mod'" else sed 's/^ X//' << \SHAR_EOF > 'makelibr.mod' XIMPLEMENTATION MODULE MakeLibraries; 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 (* NOTE: this module is implementation specific. Substitute the library X * modules supplied by your compiler. X *) XIMPORT Strings; X XCONST X NumLibraryModules = 41; X XVAR X LibraryModule : ARRAY [1 .. NumLibraryModules] OF X ARRAY [0 .. 20] 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 Strings.Compare (modulename, LibraryModule[mid]) OF X Strings.Equal : X RETURN TRUE; X | Strings.Less : 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 (* TDI supplied libraries: *) X LibraryModule [ 1] := 'AESApplications'; X LibraryModule [ 2] := 'AESEvents'; X LibraryModule [ 3] := 'AESForms'; X LibraryModule [ 4] := 'AESGraphics'; X LibraryModule [ 5] := 'AESMenus'; X LibraryModule [ 6] := 'AESObjects'; X LibraryModule [ 7] := 'AESResources'; X LibraryModule [ 8] := 'AESScraps'; X LibraryModule [ 9] := 'AESShells'; X LibraryModule [10] := 'AESWindows'; X LibraryModule [11] := 'ASCII'; X LibraryModule [12] := 'BIOS'; X LibraryModule [13] := 'Conversions'; X LibraryModule [14] := 'Display'; X LibraryModule [15] := 'FileSystem'; X LibraryModule [16] := 'GEMAESbase'; X LibraryModule [17] := 'GEMDOS'; X LibraryModule [18] := 'GEMError'; X LibraryModule [19] := 'GEMVDIbase'; X LibraryModule [20] := 'GEMX'; X LibraryModule [21] := 'InOut'; X LibraryModule [22] := 'Keyboard'; X LibraryModule [23] := 'LongInOut'; X LibraryModule [24] := 'M2Conversions'; X LibraryModule [25] := 'MathLib0'; X LibraryModule [26] := 'RealInOut'; X (* note : Strings.Compare thinks 'SY' < 'St'. (it just compares ASCII X * values...) So this is not exactly alphabetical... just sorted X * as Strings.Compare would... X *) X LibraryModule [27] := 'SYSTEM'; X LibraryModule [28] := 'Storage'; X LibraryModule [29] := 'Streams'; X LibraryModule [30] := 'Strings'; X LibraryModule [31] := 'TermBase'; X LibraryModule [32] := 'Terminal'; X LibraryModule [33] := 'TextIO'; X LibraryModule [34] := 'VDIAttribs'; X LibraryModule [35] := 'VDIControls'; X LibraryModule [36] := 'VDIEscapes'; X LibraryModule [37] := 'VDIInputs'; X LibraryModule [38] := 'VDIInquires'; X LibraryModule [39] := 'VDIOutputs'; X LibraryModule [40] := 'VDIRasters'; X LibraryModule [41] := 'XBIOS'; X XEND MakeLibraries. SHAR_EOF if test 3115 -ne "`wc -c < 'makelibr.mod'`" then echo shar: "error transmitting 'makelibr.mod'" '(should have been 3115 characters)' fi fi echo shar: "extracting 'makemake.mod'" '(9455 characters)' if test -f 'makemake.mod' then echo shar: "will not over-write existing file 'makemake.mod'" else sed 's/^ X//' << \SHAR_EOF > 'makemake.mod' XMODULE MakeMake; 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 (* X * MAKEMAKE. Create a MAKEFILE for a MODULA-2 program. X * Usage: X * MAKEMAKE "main-module-modulename" X * X * Even though module dependencies are explicit in MODULA-2, it can still X * be quite a chore to figure them out and create a MAKEFILE. This program X * reads the text file associated with the module name given on the command X * line and recursively checks dependencies for all imported files. It then X * creates a MAKEFILE suitable for use with the Unix MAKE utility. If a X * file is not found and is not a recognized library module, then the X * MAKEFILE will include a comment: X * ## File NOT Found ## X * on the right hand side of the dependency. X * X * X * This program was written on the Atari ST using TDI Modula-2. X * X * BUGS: X * the CommandLine module dies when a null command line is seen. X * Unfortunately, I no longer have the source to the module, so I can't X * fix it. This bug also seems to consider a command line consisting of X * a single character as a reason for dieing. X * X * Suggestions for porting to another compiler: X * X * 1) module CommandLine is non-standard. It exports 2 procedures: X * PROCEDURE GetArgument ( num : CARDINAL; X * VAR filename : ARRAY OF CHAR); X * PROCEDURE NumberOfArguments() : CARDINAL; X * they do just what their names imply. (ie. like C's argv, argc) X * X * 2) the IMPLEMENTATION MODULE MakeLibraries will have to be edited to X * reflect the standard library that your compiler knows about. List X * any modules that you don't want included in your MAKEFILE. Library X * modules are listed in the MAKEFILE, but are commented out. X * X * 3) the procedure ModulenameToFilename in MakeParse will have to be X * modified so that it creates the correct filename for your machine. X * X * 4) if your MAKE program has default MODULA-2 rules, set the constant X * MAKEHasModulaRules (in this module) to TRUE. This will prevent X * MAKEMAKE from producing remake lines. X * X * 5) the procedure WriteFilename takes a parameter: extension. Trace X * all the calls to this function and make sure the proper extentions X * are used. in TDI Modula, '.DEF' = definition module text X * '.MOD' = implementation module text X * '.SYM' = symbol file (compiled DEF) X * '.LNK' = symbol file (compiled MOD) X *) X XIMPORT InOut; XIMPORT CommandLine; XIMPORT MakeForest; XIMPORT MakeParse; XIMPORT ASCII; XIMPORT Streams; XIMPORT Strings; X XCONST X MAKEHasModulaRules = FALSE; X CompilerPathname = 'C:\BIN\MOD.PRG '; X LinkerPathname = 'C:\BIN\LNK.PRG '; X XVAR X outputStream : Streams.Stream; X X (*----------------------------------------------------------------------*) X PROCEDURE CloseOutput; X VAR X reply : INTEGER; X BEGIN X Streams.CloseStream (outputStream, reply); X END CloseOutput; X X (*----------------------------------------------------------------------*) X PROCEDURE OpenOutput (VAR filename : ARRAY OF CHAR) : BOOLEAN; X VAR X reply : INTEGER; X BEGIN X Streams.OpenStream (outputStream, filename, Streams.READWRITE, reply); X RETURN reply = 0; X END OpenOutput; X X X (*----------------------------------------------------------------------*) X PROCEDURE Write (ch : CHAR); X BEGIN X Streams.Write8Bit (outputStream, ch); X END Write; X X X (*----------------------------------------------------------------------*) X PROCEDURE WriteString (VAR str : ARRAY OF CHAR); X VAR X c : CARDINAL; X BEGIN X c := 0; X WHILE (c <= HIGH(str)) AND (str[c] <> 0C) DO X Write(str[c]); X INC(c); X END; (* WHILE *) X END WriteString; X X X (*----------------------------------------------------------------------*) X PROCEDURE WriteLn; X BEGIN X Write ( ASCII.CR ); X Write ( ASCII.LF ); X END WriteLn; X X X (*----------------------------------------------------------------------*) X PROCEDURE WriteMakefile; X X (*--------------------------------------------------------------------*) X PROCEDURE WriteFileDependency (file : MakeForest.FileDefinitionList; X VAR lhsExtention : ARRAY OF CHAR); X VAR X c : CARDINAL; X iptr : MakeForest.ImportList; X BEGIN X IF file <> NIL THEN X IF file^.filename[0] = '#' THEN X RETURN; X END; (* IF *) X WriteFilename (file^.filename, lhsExtention); X Write (ASCII.HT); X WriteString (': '); X WriteString (file^.filename); X (* if this is a .LNK file, then don't forget the .SYM file: *) X (* but don't do it for the main module! *) X IF (file <> MakeForest.FileForestEnd) AND X (Strings.Compare (lhsExtention, '.LNK') = Strings.Equal) THEN X Write (' '); X WriteFilename (file^.filename, '.SYM'); X c := 3; X ELSE X c := 2; X END; (* IF *) X iptr := file^.imports; X WHILE iptr <> NIL DO X IF NOT iptr^.file^.library THEN X IF c > 4 THEN X WriteString (' \'); X WriteLn; X WriteString (' '); X c := 0; X END; (* IF *) X Write (' '); X WriteFilename (iptr^.file^.filename, '.SYM'); X INC (c); X END; (* IF *) X iptr := iptr^.next; X END; (* WHILE *) X X iptr := file^.imports; X c := 5; (* <-- force a WriteLn *) X WHILE iptr <> NIL DO X IF iptr^.file^.library THEN X IF c > 4 THEN X WriteLn; X WriteString (' #libs: '); X c := 0; X END; (* IF *) X Write (' '); X WriteFilename (iptr^.file^.filename, '.SYM'); X INC (c); X END; (* IF *) X iptr := iptr^.next; X END; (* WHILE *) X X WriteLn; X IF NOT MAKEHasModulaRules THEN X Write (ASCII.HT); X WriteString (CompilerPathname); X WriteString (file^.filename); X WriteLn; X END; (* IF *) X END; (* IF *) X END WriteFileDependency; X X (*--------------------------------------------------------------------*) X PROCEDURE WriteAllLnkFiles; X VAR X c, dummy : CARDINAL; X ptr : MakeForest.FileDefinitionList; X BEGIN X ptr := MakeForest.FileForest; X c := 2; X REPEAT X IF Strings.Pos (ptr^.filename, '.MOD', 0, dummy) THEN X IF NOT ptr^.library THEN X WriteFilename (ptr^.filename, '.LNK'); X Write (' '); X IF c > 4 THEN X WriteString (' \'); X WriteLn; X WriteString (' '); X c := 0; X END; (* IF *) X INC (c); X END; (* IF *) X END; (* IF *) X ptr := ptr^.next; X UNTIL ptr = NIL; X WriteLn; X END WriteAllLnkFiles; X X (*--------------------------------------------------------------------*) X PROCEDURE WriteFilename (VAR filename, extention : ARRAY OF CHAR); X VAR X c : CARDINAL; X BEGIN X c := 0; X REPEAT X Write (filename[c]); X INC(c); X UNTIL (c > HIGH (filename)) OR (filename[c] = '.'); X WriteString (extention); X END WriteFilename; X X (*--------------------------------------------------------------------*) X PROCEDURE WritePRGDependency (file : MakeForest.FileDefinitionList); X BEGIN X WriteLn; X WriteFilename (file^.filename, '.PRG'); X Write (ASCII.HT); WriteString (': '); X WriteAllLnkFiles; X IF NOT MAKEHasModulaRules THEN X Write (ASCII.HT); WriteString (LinkerPathname); X WriteFilename (file^.filename, '.LNK'); X WriteLn; X END; (* IF *) X END WritePRGDependency; X X VAR X ptr : MakeForest.FileDefinitionList; X c : CARDINAL; X BEGIN X IF OpenOutput ('MAKEFILE') THEN X (* print out the .PRG dependency first.... *) X WritePRGDependency (MakeForest.FileForestEnd); X WriteFileDependency (MakeForest.FileForestEnd, '.LNK'); X ptr := MakeForest.FileForest; X WHILE ptr <> MakeForest.FileForestEnd DO X IF NOT ptr^.library THEN X IF Strings.Pos (ptr^.filename, '.MOD', 0, c) THEN X WriteFileDependency (ptr, '.LNK'); X ELSE X WriteFileDependency (ptr, '.SYM'); X END; (* IF *) X END; (* IF *) X ptr := ptr^.next; X END; (* WHILE *) X ELSE X InOut.WriteString ('Error opening MAKEFILE'); X InOut.WriteLn; X END; (* IF *) X CloseOutput; X END WriteMakefile; X XVAR X modulename, X filename : ARRAY [0 .. 132] OF CHAR; X XBEGIN X IF CommandLine.NumberOfArguments() < 1 THEN X InOut.WriteString ("Usage: MAKEMAKE main-module-modulename"); X InOut.WriteLn; X ELSE X CommandLine.GetArgument (1, filename); X MakeParse.ParseModule (filename, MakeParse.main, filename); X WriteMakefile; X END; (* IF *) XEND MakeMake. SHAR_EOF if test 9455 -ne "`wc -c < 'makemake.mod'`" then echo shar: "error transmitting 'makemake.mod'" '(should have been 9455 characters)' fi fi echo shar: "extracting 'makepars.mod'" '(5161 characters)' if test -f 'makepars.mod' then echo shar: "will not over-write existing file 'makepars.mod'" else sed 's/^ X//' << \SHAR_EOF > 'makepars.mod' XIMPLEMENTATION MODULE MakeParse; 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 XIMPORT MakeToken; XIMPORT MakeForest; XIMPORT Strings; XIMPORT MakeLibraries; X 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 : CARDINAL; X BEGIN X c := 0; X WHILE (c < HIGH (modulename)) AND (c < 8) 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 (*----------------------------------------------------------------------*) 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 := (Strings.Compare (token, 'CONST') = Strings.Equal) OR X (Strings.Compare (token, 'TYPE') = Strings.Equal) OR X (Strings.Compare (token, 'VAR') = Strings.Equal) OR X (Strings.Compare (token, 'MODULE') = Strings.Equal); X RETURN temp OR X (Strings.Compare (token, 'PROCEDURE') = Strings.Equal) OR X (Strings.Compare (token, 'BEGIN') = Strings.Equal) OR X (Strings.Compare (token, 'END') = Strings.Equal); X END TerminatingToken; X X X (*----------------------------------------------------------------------*) X PROCEDURE ParseFROM ( fileDef : MakeForest.FileDefinitionList; X VAR eof : BOOLEAN ); X VAR X modulename, filename : ARRAY [0 .. 100] OF CHAR; X BEGIN X MakeToken.NextToken (modulename, eof); X ParseModule (modulename, def, filename); X MakeForest.AddImport (fileDef, filename); X MakeToken.SkipTillSemicolon (eof); X X ParseModule (modulename, mod, filename); X END ParseFROM; X X (*----------------------------------------------------------------------*) X PROCEDURE ParseIMPORT ( fileDef : MakeForest.FileDefinitionList; X VAR eof : BOOLEAN ); X VAR X modulename, filename : ARRAY [0 .. 100] OF CHAR; X BEGIN X MakeToken.NextToken (modulename, eof); X WHILE modulename[0] <> ';' DO X ParseModule (modulename, def, filename); X MakeForest.AddImport (fileDef, filename); X X ParseModule (modulename, mod, filename); X MakeToken.NextToken (modulename, eof); X END; (* WHILE *) X END ParseIMPORT; X X (*----------------------------------------------------------------------*) X PROCEDURE ParseModule (VAR modulename : ARRAY OF CHAR; X type : FileType; X VAR filename : ARRAY OF CHAR); X VAR X token : ARRAY [0 .. 132] OF CHAR; X fileDef : MakeForest.FileDefinitionList; X success, X eof : BOOLEAN; X X BEGIN X ModulenameToFilename (modulename, type, filename); X X IF MakeForest.AddFile (filename, fileDef) THEN X MakeToken.OpenFile (filename, success); X X IF NOT success THEN X IF MakeLibraries.IsALibraryModule (modulename) THEN X fileDef^.library := TRUE; X ELSE X MakeForest.AddImport (fileDef, "## SOURCE FILE NOT FOUND ##"); X END; (* IF *) X ELSE X MakeToken.NextToken (token, eof); X IF (type = def) AND NOT X (Strings.Compare (token, 'DEFINITION') = Strings.Equal) THEN X MakeForest.AddImport (fileDef, X "## Expected a 'DEFINITION' module ##"); X ELSIF (type = mod) AND NOT X (Strings.Compare (token, 'IMPLEMENTATION') = Strings.Equal) THEN X MakeForest.AddImport (fileDef, X "## Expected an 'IMPLEMENTATION' module ##"); X ELSIF (type = main) AND NOT X (Strings.Compare (token, 'MODULE') = Strings.Equal) THEN X MakeForest.AddImport (fileDef, X "## Expected a 'MODULE' module ##"); X END; (* IF / ELSE / ENDIF *) X MakeToken.SkipTillSemicolon (eof); X token := ';'; X WHILE (NOT eof) AND (NOT TerminatingToken(token)) DO X IF Strings.Compare (token, 'FROM') = Strings.Equal THEN X ParseFROM (fileDef, eof); X ELSIF Strings.Compare (token, 'IMPORT') = Strings.Equal THEN X ParseIMPORT (fileDef, eof); X END; (* IF *) X MakeToken.NextToken (token, eof); X END; (* WHILE *) X END; (* IF file opened *) X MakeToken.CloseFile; X END; (* IF we need to check this one *) X X END ParseModule; X XEND MakeParse. SHAR_EOF if test 5161 -ne "`wc -c < 'makepars.mod'`" then echo shar: "error transmitting 'makepars.mod'" '(should have been 5161 characters)' fi fi echo shar: "extracting 'maketoke.mod'" '(5757 characters)' if test -f 'maketoke.mod' then echo shar: "will not over-write existing file 'maketoke.mod'" else sed 's/^ X//' << \SHAR_EOF > 'maketoke.mod' XIMPLEMENTATION MODULE MakeToken; 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 XIMPORT Streams; X XVAR X currentCh : CHAR; X currentStream : Streams.Stream; X X (*======================================================================*) X MODULE StreamStack; X IMPORT Streams; X EXPORT Pop, Push; X X CONST X StackSize = 20; X VAR X StrStack : ARRAY [1 .. StackSize] OF Streams.Stream; X CharStack : ARRAY [1 .. StackSize] OF CHAR; X StackPtr : CARDINAL; X X (*--------------------------------------------------------------------*) X PROCEDURE Push (str : Streams.Stream; 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 : Streams.Stream; 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 StreamStack; X (*======================================================================*) X X X (*----------------------------------------------------------------------*) X PROCEDURE OpenFile (VAR filename : ARRAY OF CHAR; X VAR success : BOOLEAN); X VAR X result : INTEGER; X BEGIN X Push (currentStream, currentCh); X Streams.OpenStream(currentStream, filename, Streams.READ, result); X currentCh := ' '; X success := result = 0; X END OpenFile; X X (*----------------------------------------------------------------------*) X PROCEDURE CloseFile; X VAR X result : INTEGER; X BEGIN X Streams.CloseStream(currentStream, result); X Pop (currentStream, 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 : CARDINAL; X BEGIN X c := 0; X IF currentCh = ';' THEN X token[0] := ';'; X token[1] := 0C; X eof := Streams.EOS(currentStream); X Streams.Read8Bit(currentStream, currentCh); X RETURN; X END; (* IF *) X WHILE SeparatingChar (currentCh) DO X Streams.Read8Bit(currentStream, currentCh); X IF currentCh = ';' THEN X token[0] := ';'; X token[1] := 0C; X eof := Streams.EOS(currentStream); X Streams.Read8Bit(currentStream, currentCh); X RETURN; X ELSIF currentCh = '(' THEN X token[c] := currentCh; X Streams.Read8Bit(currentStream, 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 Streams.Read8Bit(currentStream, 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 Streams.Read8Bit(currentStream, currentCh); X UNTIL Streams.EOS(currentStream) OR X (c > HIGH (token)) OR X SeparatingChar (currentCh); X token[c] := 0C; X eof := Streams.EOS (currentStream); X END NextToken; X X X (*----------------------------------------------------------------------*) X PROCEDURE SkipTillSemicolon (VAR eof : BOOLEAN); X VAR X ch : CHAR; X BEGIN X REPEAT X IF (NOT Streams.EOS(currentStream)) AND (currentCh = '(') THEN X Streams.Read8Bit(currentStream, currentCh); X IF (NOT Streams.EOS (currentStream)) AND (currentCh = '*') THEN X SkipComment; X END; (* IF *) X ELSE X Streams.Read8Bit(currentStream, currentCh); X END; (* IF *) X UNTIL Streams.EOS (currentStream) 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 Streams.Read8Bit(currentStream, currentCh); X done := FALSE; X REPEAT X IF (NOT Streams.EOS(currentStream)) AND (currentCh = '*') THEN X Streams.Read8Bit(currentStream, currentCh); X IF (NOT Streams.EOS(currentStream)) AND (currentCh = ')') THEN X DEC(level); X done := level = 0; X END; (* IF *) X ELSIF (NOT Streams.EOS(currentStream)) AND (currentCh = '(') THEN X Streams.Read8Bit(currentStream, currentCh); X IF (NOT Streams.EOS (currentStream)) AND (currentCh = '*') THEN X INC(level); X END; (* IF *) X ELSE X Streams.Read8Bit(currentStream, currentCh); X END; (* IF *) X UNTIL Streams.EOS(currentStream) OR done; X END SkipComment; X XBEGIN X currentCh := ' '; XEND MakeToken. SHAR_EOF if test 5757 -ne "`wc -c < 'maketoke.mod'`" then echo shar: "error transmitting 'maketoke.mod'" '(should have been 5757 characters)' fi fi exit 0 # End of shell archive