From owner-freebsd-stable Mon Nov 13 1:53:19 2000 Delivered-To: freebsd-stable@freebsd.org Received: from mailman.zeta.org.au (mailman.zeta.org.au [203.26.10.16]) by hub.freebsd.org (Postfix) with ESMTP id 7321637B479; Mon, 13 Nov 2000 01:53:10 -0800 (PST) Received: from bde.zeta.org.au (bde.zeta.org.au [203.2.228.102]) by mailman.zeta.org.au (8.8.7/8.8.7) with ESMTP id UAA19162; Mon, 13 Nov 2000 20:43:20 +1100 Date: Mon, 13 Nov 2000 20:44:15 +1100 (EST) From: Bruce Evans X-Sender: bde@besplex.bde.org To: Marcel Moolenaar Cc: Makoto MATSUSHITA , current@FreeBSD.ORG, stable@FreeBSD.ORG Subject: Re: "make modules" kicks the first module directory twice In-Reply-To: <3A0F9ED8.A56CA34E@cup.hp.com> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-freebsd-stable@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG On Sun, 12 Nov 2000, Marcel Moolenaar wrote: > Makoto MATSUSHITA wrote: > > > > % make -j 2 modules > > cd ../../modules && env MAKEOBJDIRPREFIX=/usr/src/sys/compile/GENERIC/modules KMODDIR=/boot/kernel make obj all > > ===> 3dfx > > ===> 3dfx > > Warning: Object directory not changed from original /usr/src/sys/modules/3dfx > > (... ok, break it ...) > > The problem is in the fact that the Makefile (the one in /sys/conf) > contains something like: > > ${MAKE} obj all > > and > > ${MAKE} obj depend > > The net effect is that these targets are built in parallel, which > obviously isn't right. The following solves the problem (i386 only): That's just one of the problems :-). "make obj all" is usually an error, but in Makefile.${MACHINE} it should be just a bad example, since the `obj' and `all' targets should be built sequentially and then the object directories will exist by the time make(1) recurses into them for the `all' target. This doesn't work right for the -j case. (In the above example, the targets are built concurrently and race each other. This is bad when the `all' target wins the race. The `obj' target runs faster, so it usually wins the race except in the first directory (3dfx)). More .ORDER statements in *.mk are required. > Index: Makefile.i386 > =================================================================== > RCS file: /home/ncvs/src/sys/conf/Makefile.i386,v > retrieving revision 1.212 > diff -u -r1.212 Makefile.i386 > --- Makefile.i386 2000/10/29 09:47:50 1.212 > +++ Makefile.i386 2000/11/13 07:49:00 > @@ -271,11 +271,13 @@ > > modules: > @mkdir -p ${.OBJDIR}/modules > - cd $S/modules && env ${MKMODULESENV} ${MAKE} obj all > + cd $S/modules && env ${MKMODULESENV} ${MAKE} obj && \ > + env ${MKMODULESENV} ${MAKE} all > > modules-depend: > @mkdir -p ${.OBJDIR}/modules > - cd $S/modules && env ${MKMODULESENV} ${MAKE} obj depend > + cd $S/modules && env ${MKMODULESENV} ${MAKE} obj $$ \ > + env ${MKMODULESENV} ${MAKE} depend > > modules-clean: > cd $S/modules && env ${MKMODULESENV} ${MAKE} clean > `&&' should never be used in shell commands in makefiles, although it may be only a bad example. This is because multiple commands are executed in the same shell in the -j case, and `&&' gives non-simple commands which may defeat the shell's -e setting. E.g., the command: cd /; set -e; cd /nonesuch && false; rm -rf * removes everything under "/", not everything under /nonesuch, despite checking that the cd to /nonesuch worked. Bruce To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-stable" in the body of the message