[net.unix-wizards] Question on Make

barto (04/11/83)

	I was having some problems with MAKE(1) on my 780 Vax
	running 4.1BSD.  I looked in the code and found the
	statement in doname.c:
		if (p1==srchname(".DEFAULT")) {
	yet I can find NO documentation on .DEFAULT in any of
	the manuals.

	The question is, What is .DEFAULT used for.  I found
	that I could insert a command to extract SCCS files
	using a .DEFAULT rule.  What else is .DEFAULT used for?

	All help gratefully ACK prior to reciept.

	barto
	(david barto)
	uucp : {ucbvax || decvax || philabs}!sdcsvax!bmcg!barto
	arpa : sdcsvax!bmcg!barto@nosc

dhb (04/19/83)

I was about to flame you on reading manuals when I decided to double
check the manuals and realized that you are right, .DEFAULT is not
documented.

Basically, it is used to define a *DEFAULT* transformation if make
cannot figure out how to make the specified target from the indicated
dependencies.  For example, consider the following:

	.DEFAULT:
		cp $*.joe $*.sam

	file1.sam: file1.joe

This could also have been accomplished by defining .joe and .sam as
valid suffixes and then defining the transformation from .joe to
.sam.  Transformations are not sufficient however, if you also use
filename prefixes, which the current make (4.1bsd or earlier) will
not recognize.   My understanding is that this ability is being
added to a new release of make (system V maybe?).

	Dave Brierley, ...!decvax!brunix!rayssd!dhb

pgf (04/21/83)

	I beg to differ on the subject of .DEFAULT, and make a query of
	my own.

	The comment was made that the set of rules:

		.DEFAULT:
			cp $*.joe $*.sam

		file1.sam: file1.joe

	could be used to create file1.sam from file1.joe.  This is not the
	case.  The .DEFAULT rule is used to create a file which cannot
	be found, and for which no explicit or implicit rule exists.  Thus
	the .DEFAULT rule would be used to create file1.joe if it did not
	exist in the current directory.  The dependency listed above for
	file1.sam and file1.joe simply has a null rule associated with it.
	Make says to itself "I guess I must not have to do anything to get
	file1.sam from file1.joe-- either the user doesn't care or he knows
	more about what he wants than I do."  

	The .DEFAULT rule can be used to force a get(1) from another directory
	if you don't keep your s.source.c files in your working directory.


		source.o: source.c

		.DEFAULT:
			get $(SRCDIR)/s.$<

	The .c.o rule will create source.o after (possibly) the .DEFAULT
	rule is used to create source.c.
	What I can't figure out how to do is similar to that, but I want
	to have the SCCS files (in $(SRCDIR)) be the *only* copy of
	the source around.  What I want to write is:

		source.o: $(SRCDIR)/s.source.c

	but somehow prepending $(SRCDIR) to the dependent causes make to lose
	the .c~.o relationship between them, and it won't use that rule.
	Specifying the rule explicitly for each source file would work, but
	seems silly for 300 source files.

	Any help would be greatly appreciated.
				Paul Fox, BTL Holmdel (201)949-6412
				  (houxm!pgf)