Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 20 Nov 2002 23:53:45 -0600
From:      Dan Nelson <dnelson@allantgroup.com>
To:        Brian Reichert <reichert@numachi.com>
Cc:        hackers@FreeBSD.ORG
Subject:   Re: seeking clarification of makefile rules 'safe' with -j
Message-ID:  <20021121055345.GA65788@dan.emsphone.com>
In-Reply-To: <20021121000216.H82833@numachi.com>
References:  <20021121000216.H82833@numachi.com>

next in thread | previous in thread | raw e-mail | index | archive | help
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




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20021121055345.GA65788>