How common is :: in makefiles

Guy Harris guy at auspex.auspex.com
Tue Mar 12 08:33:01 AEST 1991


>The :: has another (undocumented) effect. Try this --
>
>    all:	x y
>
>    x:
>	    touch x
>    y::
>	    touch y
>
>First time through you get touch x and touch y, as you'd expect.
>Second time through you only get touch y; the :: is a sort of
>do-it-always rule.
>
>Perhaps someone with access to makefile source could tell us what
>:: is _supposed_ to mean.

Well, if by "makefile source" you mean "make source", they can just tell
you want it means in that particular version of "make"; that may not be
what it means in some other version, nor is it necessarily what it was
*supposed* to mean - there may be a bug in that version, or it may not
have been intended to mean anything.

The System V Release 3.x (dunno what "x" is; we may have moved in the
S5R3.1 or S5R3.2 updates) "make" documentation (not the manual page, the
stuff in the Programmer's Guide), says (yes, the double-colon stuff *is*
documented there):

	   A dependency line may have either a single or double colon.
	A target name may appear on more than one dependency line, but
	all of those lines must be of the same (single or double colon)
	type.  For the more common single-colon case, a command sequence
	may be associated with at most one dependency line.  If the
	target is out of date with any of the dependents on any of the
	lines and a command sequence is specified (even a null one
	following a semicolon or tab), it is executed; otherwise, a
	default rule may be invoked.  In the double-colon case, a
	command sequence may be associated with more than one dependency
	line.  If the target is out of date with any of the files on a
	particular line, the associated commands are executed.  A
	built-in rule may also be executed.

As I read it, it says nothing about double-colon being a "do this
always" mechanism - it doesn't talk about what happens if there aren't
any dependencies on the dependency line.  The V7-vintage "make" in
4.3BSD, the S5R2-derived "make" in "/usr/old/make" in SunOS 4.0.3, and
the Sun-developed "make" in "/usr/bin/make" in SunOS 4.0.3, all show the
behavior you describe; whether this is intentional or just an unintended
consequence of the implementation, I don't know.  (The Sun one may be
"intentional" to the extent that the implementation mirrors the AT&T
ones, or that the behavior was intended to mirror the AT&T one.)



More information about the Comp.unix.programmer mailing list