From owner-freebsd-bugs@FreeBSD.ORG Sun Jan 18 06:40:27 2004 Return-Path: Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 6E89B16A4CE for ; Sun, 18 Jan 2004 06:40:27 -0800 (PST) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id 7E89C43D66 for ; Sun, 18 Jan 2004 06:40:15 -0800 (PST) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) i0IEeFFR091405 for ; Sun, 18 Jan 2004 06:40:15 -0800 (PST) (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.12.10/8.12.10/Submit) id i0IEeFmR091402; Sun, 18 Jan 2004 06:40:15 -0800 (PST) (envelope-from gnats) Date: Sun, 18 Jan 2004 06:40:15 -0800 (PST) Message-Id: <200401181440.i0IEeFmR091402@freefall.freebsd.org> To: freebsd-bugs@FreeBSD.org From: Ruslan Ermilov Subject: Re: bin/61527: make -j2 changes $* X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list Reply-To: Ruslan Ermilov List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 18 Jan 2004 14:40:27 -0000 The following reply was made to PR bin/61527; it has been noted by GNATS. From: Ruslan Ermilov To: Albert Hofkamp 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