DataMuseum.dk

Presents historical artifacts from the history of:

Rational R1000/400 Tapes

This is an automatic "excavation" of a thematic subset of
artifacts from Datamuseum.dk's BitArchive.

See our Wiki for more about Rational R1000/400 Tapes

Excavated with: AutoArchaeologist - Free & Open Source Software.


top - download
Index: ┃ T d

⟦9b38052f7⟧ TextFile

    Length: 6209 (0x1841)
    Types: TextFile
    Names: »dep-make.awk«

Derivation

└─⟦85b835f43⟧ Bits:30000549 8mm tape, Rational 1000, Xlib rev 6.00
    └─ ⟦0c20f784e⟧ »DATA« 
        └─⟦1abbe589f⟧ 
            └─⟦dfeb830e8⟧ 
                └─ ⟦this⟧ »rev6-0-0/tools/config/dep-make.awk« 

TextFile

# dep-make.awk
#
# Used to create Makefile.dep from the contents of the $(WORKINGSTEM).obK
# database.  We are fed the .obK file as input.
#
# We have these variables set by the command line:
#
#	OFile - This is where we write our output.
#
# Each input line is of the form:
#
#	<Ada unit> <file> <GENERIC/BODY/SPEC/TARGET/SEPARATE> <lib> <deps>

#---The input file may be empty.  Allow for that.

BEGIN {
	Depends[" futz "] = "futz futz.ada BODY futz.o";
}

#---Concatenate all continuation lines together.

/^\@/ {
	Cont = Cont " " substr( $0, 2, length($0)-1 );
	next;
}

#---Read all normal lines and place them into the various arrays.

{
	AdaUnit = $1;
	AdaFile = $2;
	AdaType = $3;
	AdaLib  = $4

#---Extract the Path, the File, and the Extension from the AdaFile.

	Ext = AdaFile;
	while (i = index( Ext, "/" )) {
		Path = Path substr( Ext, 1, i );
		Ext  = substr( Ext, i+1 );
	}
	i = index( Ext, "." );
	if (i == 0) {
		File = Ext;
		Ext  = ""
	} else {
		File = substr( Ext, 1, i-1 );
		Ext  = substr( Ext, i+1 );
	}
	while (i = index( Ext, "." )) {
		File = File "." substr( Ext, 1, i-1 );
		Ext = substr( Ext, i+1 );
	}

#---Determine the name of the final output file of a compilation.

	AdaOutput = AdaLib "/" File "." substr( AdaType, 1, 1 );

#---Record all of our information in the various arrays.

	if (AdaType == "GENERIC") {
		UnitSpecType[AdaUnit] = AdaType;
	} else if (AdaType == "TARGET") {
		AdaFile = AdaFile AdaUnit;
	}
	if (AdaType == "SPEC" || AdaType == "GENERIC") {
		A = UnitSpecOutput[AdaUnit];
		if (A != "" && split( A, B, " " ) && B[1] != AdaFile) {
			print "Two units (Specs) have the same name:", AdaUnit;
			print "File1:", B[1];
			print "File2:", AdaFile;
			exit 1;
		}
		UnitSpecOutput[AdaUnit] = AdaFile " " AdaOutput;
	} else if (AdaType == "BODY") {
		A = UnitBodyOutput[AdaUnit];
		if (A != "" && split( A, B, " " ) && B[1] != AdaFile) {
			print "Two units (Bodies) have the same name:",AdaUnit;
			print "File1:", B[1];
			print "File2:", AdaFile;
			exit 1;
		}
		UnitBodyOutput[AdaUnit] = AdaFile " " AdaOutput;
	} else if (AdaType == "SEPARATE") {
		AdaSep = $5;
		UnitSeparateOutput[AdaSep] = Separate[AdaSep] " " AdaOutput;
	} else if (AdaType != "TARGET") {
		print "Unknown AdaType =", AdaType "?";
		exit 1;
	}
	Depends[AdaFile] = $0 Cont " " AdaOutput;
	Cont = "";
	Types[AdaFile]   = AdaType;
	Outputs[AdaFile] = AdaOutput;
	Units[AdaFile]   = AdaUnit;
	next;
}

#---Produce the Makefile here.

END {

#---Process each of the dependency lines from the .obK file.

    for (i in Depends) {
	ELibs = ExternalLib;
	if (i == " futz ") { continue; }

#---Extract the basic information from the line we stored before.

	AdaDep = split( Depends[i], A, " " );
	AdaUnit = A[1];
	AdaFile = A[2];
	AdaType = A[3];
	AdaLib  = A[4];
	AdaOutput = A[AdaDep];

#---If this is a "target" line then each of the 4..ArgDep-1 entries is
#   the name of an Ada source file.  Convert the name of the source file into
#   the name of an AdaUnit.  Then use the AdaUnit name to lookup the name
#   of the 'Spec and 'Body AdaOutput files.  Finally we lookup IS SEPARATE
#   units in the UnitSeparateOutput array.

	if (AdaType == "TARGET") {
	    AdaOutput = AdaUnit;
	    Deps = AdaOutput ":" ;
	    for (j = 4; j < AdaDep; j++) {
		AdaUnit = Units[A[j]];
		if (AdaUnit == "") {
			C = "File " A[j] " for target " AdaOutput;
			print C " has no entry?";
			exit 1;
		}

#---Look up the AdaOutput files for the 'Spec and the 'Body.

#		Module = "";
#		if (split( UnitSpecOutput[AdaUnit], B, " " ) >= 2) {
#			Module = " " B[2];
#		}
#		if (split( UnitBodyOutput[AdaUnit], B, " " ) >= 2) {
#			Module = Module " " B[2];
#		}
		Module = " " Outputs[A[j]];

#---See if the output line has reached 79 characters yet.  We want the output
#   to be readable.

		C = Deps Module;
		if (length(C) > 79) {
			print Deps			> OFile;
			C = AdaOutput ":" Module;
		}
		Deps = C;

#---Look up any IS SEPARATE's that may exist for the 'Body.

		if (Types[A[j]] == "BODY") {
			Module = UnitSeparateOutput[AdaUnit];
			C = Deps Module;
			if (length(C) > 79) {
				print Deps		> OFile;
				C = AdaOutput ":" Module;
			}
		}
		Deps = C;
	    }
	    print Deps						> OFile;
	    print "	$(RM)", AdaOutput			> OFile;
	    print "	$(MAKE) $(MFLAGS) load." AdaOutput	> OFile;
	    continue;
	}

#---If this is a SEPARATE module line then the 4'th entry is the name of a
#   parent Ada Body.  Look that up and use the associated AdaOutput name as a
#   dependency for this module.

	if (AdaType == "SEPARATE") {
		if (ELibs != "") {
			print AdaOutput ": " ELibs	> OFile;
			ELibs = "";
		}
		Deps = AdaOutput ":";
		AdaUnit = A[5];
		if (split( UnitBodyOutput[AdaUnit], B, " " ) >= 2) {
			Module = " " B[2];
		}
		print Deps Module			> OFile;
		j = 6;
	} else {
		j = 4;
	}

#---This must be a normal module line so each of the 4..ArgDep-1 entries is
#   the name of an Ada Unit.  Look that up and use the associated AdaOutput
#   name as a dependency for this module.  If that Spec is-an/has exported
#   generic(s) then add the body of that unit to the dependency list.  This
#   takes care of macro-expanded generics.

	if (ELibs != "") {
		print AdaOutput ": " ELibs			> OFile;
		ELibs = "";
	}
	Deps = AdaOutput ": " AdaFile ;
	if (AdaType == "BODY") {
		if (split( UnitSpecOutput[AdaUnit], B, " " ) >= 2) {
			Deps = Deps " " B[2];
		}
	}
	for ( ; j < AdaDep; j++) {
		AdaUnit = A[j];
		Module = "";
		if (split( UnitSpecOutput[AdaUnit], B, " " ) >= 2) {
			Module = " " B[2];
		}
		if (UnitSpecType[AdaUnit] == "GENERIC") {
			if (split( UnitBodyOutput[AdaUnit], B, " " ) >= 2) {
				Module = Module " " B[2];
			}
		}

#---See if the output line has reached 79 characters yet.  We want the output
#   to be readable.

		C = Deps Module;
		if (length(C) > 79) {
			print Deps			> OFile;
			C = AdaOutput ":" Module;
		}
		Deps = C;
	}

#---Finish off with two commands for this target.  One compiles the unit and
#   the other creates and empty "flag" file that we use to "remember" that this
#   compilation has completed.

	print Deps					> OFile;
	print "	$(COMMAND)", AdaFile			> OFile;
	print "	@rm -f", AdaOutput			> OFile
	print "	@cat /dev/null >", AdaOutput		> OFile
    }
}