gamiddleton@watmath.waterloo.edu (Guy Middleton) (03/31/89)
We just got mk, and I tried running this mkfile: PROGS = host addr hostaddr all:V: $PROGS $PROGS: $CC -o $target $target.c I expected this to happen: cc -o host host.c cc -o addr addr.c cc -o hostaddr hostaddr.c Instead, I got this: cc -o host addr hostaddr host addr hostaddr.c I got what I expected when the "all:V: $PROGS" line was removed. Why does it work this way? Am I missing something obvious? -Guy Middleton, University of Waterloo gamiddleton@watmath.waterloo.edu
andrew@alice.UUCP (Andrew Hume) (04/02/89)
In article <24726@watmath.waterloo.edu>, gamiddleton@watmath.waterloo.edu (Guy Middleton) writes: > We just got mk, and I tried running this mkfile: > > PROGS = host addr hostaddr > > all:V: $PROGS > > $PROGS: > $CC -o $target $target.c > > I expected this to happen: > > cc -o host host.c > cc -o addr addr.c > cc -o hostaddr hostaddr.c > > Instead, I got this: > > cc -o host addr hostaddr host addr hostaddr.c > > I got what I expected when the "all:V: $PROGS" line was removed. > > Why does it work this way? Am I missing something obvious? well, what you said was that host addr hostaddr can all be made from no prerequisites from one recipe. i suspect you wanted to say all:V: $PROGS %: %.c $CC -o $stem $stem.c or more pedantically, $CC $CFLAGS -o $stem $stem.c the reason it worked the way you expected when the all line was removed was that each of $PROGS was made individually (by default mk makes targets of first nonmetarule), and the $CC recipe got a single value for target. when the all line was there, mk said AHA! i can make all three things at once with just one invocation of the recipe and set $target='host addr hostaddr'. feel free to mail me at research!andrew or andrew@research.att.com.