From owner-freebsd-hackers Wed Nov 20 21:53:53 2002 Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 0F1EC37B401 for ; Wed, 20 Nov 2002 21:53:52 -0800 (PST) Received: from dan.emsphone.com (dan.emsphone.com [199.67.51.101]) by mx1.FreeBSD.org (Postfix) with ESMTP id 8C30543E88 for ; Wed, 20 Nov 2002 21:53:51 -0800 (PST) (envelope-from dan@dan.emsphone.com) Received: (from dan@localhost) by dan.emsphone.com (8.12.6/8.12.6) id gAL5rj6t035193; Wed, 20 Nov 2002 23:53:45 -0600 (CST) (envelope-from dan) Date: Wed, 20 Nov 2002 23:53:45 -0600 From: Dan Nelson To: Brian Reichert Cc: hackers@FreeBSD.ORG Subject: Re: seeking clarification of makefile rules 'safe' with -j Message-ID: <20021121055345.GA65788@dan.emsphone.com> References: <20021121000216.H82833@numachi.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20021121000216.H82833@numachi.com> X-OS: FreeBSD 5.0-CURRENT X-message-flag: Outlook Error User-Agent: Mutt/1.5.1i Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG In the last episode (Nov 21), Brian Reichert said: > I'm crunching out some complex 'make' rules , and am having a brain > fart as to what sorts of rules are safe to use with '-j'. > > As a matter of example, I'm looking at /usr/share/mk/sys.mk under > 4.5-RELEASE: > > # XXX not -j safe > .y.out: > ${YACC} ${YFLAGS} ${.IMPSRC} > ${CC} ${CFLAGS} ${LDFLAGS} y.tab.c ${LDLIBS} -ly -o ${.TARGET} > rm -f y.tab.c > > .l.out: > ${LEX} -t ${LFLAGS} ${.IMPSRC} > ${.PREFIX}.tmp.c > ${CC} ${CFLAGS} ${LDFLAGS} ${.PREFIX}.tmp.c ${LDLIBS} -ll -o ${.TARGET} > rm -f ${.PREFIX}.tmp.c .y.out uses a constant filename (y.tab.c) as an intermediate file. If make -j decided to compile two .y files in the same directory at the same time, one's going to get overwritten. .l.out avoids this by using ${.PREFIX}, which expands to the filename of the source file minus path and extension. .y.out could be made safe by making the first line ${YACC} ${YFLAGS} -o ${.PREFIX}.y.tmp.c ${.IMPSRC} and replacing y.tab.c. with ${.PREFIX}.y.tmp.c . For good measure, .l.out should probably be using ${.PREFIX}.l.tmp.c, just so you can tell which rule generated a particular tempfile. -- Dan Nelson dnelson@allantgroup.com To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message