Date: Sun, 18 Jan 2004 06:40:15 -0800 (PST) From: Ruslan Ermilov <ru@freebsd.org> To: freebsd-bugs@FreeBSD.org Subject: Re: bin/61527: make -j2 changes $* Message-ID: <200401181440.i0IEeFmR091402@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
The following reply was made to PR bin/61527; it has been noted by GNATS. From: Ruslan Ermilov <ru@freebsd.org> To: Albert Hofkamp <a.t.hofkamp@tue.nl> Cc: freebsd-gnats-submit@freebsd.org Subject: Re: bin/61527: make -j2 changes $* Date: Sun, 18 Jan 2004 16:35:15 +0200 On Sun, Jan 18, 2004 at 06:03:41AM -0800, Albert Hofkamp wrote: > > with a make rule like > > foo/bar.o: foo/bar.cc > echo CC -o $*.o $< > > (and an existing foo/bar.cc > 'make' ouputs 'CC -o foo/bar.o foo/bar.cc' while > 'make -j2' outputs 'CC -o bar.o foo/bar.cc', ie the target misses the directory part in parallel make > The results will be even more surprising (at a glance) if you try this with ``make -r'' and ``make -r -j2''. This is because you're misusing the inference rules in sys.mk and ${.PREFIX} (aka $*) and ${.IMPSRC} (aka $<) macros which are defined only for inference rules. The corrected makefile would look like this: : foo/bar.o: foo/bar.cc : @echo CC -o $@ $> or better yet: : foo/bar.o: foo/bar.cc : @echo CC -o ${.TARGET} ${.ALLSRC} which gives the same results in all four make(1) invocations. But please be aware that ${.ALLSRC} is dangerous because once you create a .depend file, there might be a dependency of the form ``bar.o: bar.h'' in it, and bar.h will become part of ${.ALLSRC}. So the safe version would look like this: : foo/bar.o: foo/bar.cc : @echo CC -o ${.TARGET} foo/bar.cc If you need lot of such rules, you may start using the inference rule: : $ cat Makefile : .SUFFIXES: .cc .o : .cc.o: : @echo CC -o ${.TARGET} ${.IMPSRC} : $ make foo/bar.o : CC -o foo/bar.o foo/bar.cc : $ make -j2 foo/bar.o : CC -o foo/bar.o foo/bar.cc : $ make -r foo/bar.o : CC -o foo/bar.o foo/bar.cc : $ make -r -j2 foo/bar.o : CC -o foo/bar.o foo/bar.cc Cheers, -- Ruslan Ermilov FreeBSD committer ru@FreeBSD.org
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200401181440.i0IEeFmR091402>