From owner-cvs-all@FreeBSD.ORG Thu Apr 21 03:35:53 2005 Return-Path: Delivered-To: cvs-all@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 51BF916A4CE; Thu, 21 Apr 2005 03:35:53 +0000 (GMT) Received: from mailout2.pacific.net.au (mailout2.pacific.net.au [61.8.0.85]) by mx1.FreeBSD.org (Postfix) with ESMTP id 922FE43D2D; Thu, 21 Apr 2005 03:35:52 +0000 (GMT) (envelope-from bde@zeta.org.au) Received: from mailproxy1.pacific.net.au (mailproxy1.pacific.net.au [61.8.0.86])j3L3Zkml007102; Thu, 21 Apr 2005 13:35:46 +1000 Received: from katana.zip.com.au (katana.zip.com.au [61.8.7.246]) j3L3ZhIo028698; Thu, 21 Apr 2005 13:35:44 +1000 Date: Thu, 21 Apr 2005 13:35:44 +1000 (EST) From: Bruce Evans X-X-Sender: bde@delplex.bde.org To: "David O'Brien" In-Reply-To: <20050420161212.GA52582@dragon.NUXI.org> Message-ID: <20050421125501.W88810@delplex.bde.org> References: <200504182110.j3ILAc8J031298@repoman.freebsd.org> <20050419182938.GA27941@dragon.NUXI.org> <20050420161212.GA52582@dragon.NUXI.org> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed cc: cvs-src@FreeBSD.org cc: src-committers@FreeBSD.org cc: Ruslan Ermilov cc: cvs-all@FreeBSD.org cc: Warner Losh Subject: Re: cvs commit: src/sys/conf kmod.mk X-BeenThere: cvs-all@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: CVS commit messages for the entire tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 21 Apr 2005 03:35:53 -0000 On Wed, 20 Apr 2005, David O'Brien wrote: > On Wed, Apr 20, 2005 at 08:59:05AM +0300, Ruslan Ermilov wrote: >> This is easily fixable: >> >> make cleandepend >> make depend >> make > > Then why does 'make kernel-depend' do 'rm -f .depend'? It is because: (1) ${DEPENDFILE} is misspelled ".depend" (2) "rm -f depend; mv .newdep .depend" is safer, or just more familiar to its author, or gives better error handling than "mv -f .newdep .depend". The "rm -f" for kernel-depend has nothing to do with removing .depend before making dependencies or with the bug that initiated this thread. Dependencies have been written to .newdep and the rm -f is just a safety belt for moving the new dependencies to the usual place. Writing dependencies to .newdep instead of directly to .depend avoids various problems, probably including the one that initiated this thread. I think it was intended to only fix the cosmetic problems of losing the old .depend file and leaving a half-baked .depend file if the make depend step is aborted, but it fixes the problem that initiated this thread as a side effect. If everything used ${DEPENDFILE} correctly, then "${DEPENDFILE}=.newdep ${MAKE} _kernel-depend" should just work -- in particular, the old dependencies shouldn't get in the way. ernel-depend doesn't use ${DEPENDFILE}, but it ensures that the old dependencies don't get in the way by moving them out of the way. From kern.post.mk: % kernel-depend: % rm -f .olddep % if [ -f .depend ]; then mv .depend .olddep; fi Perhaps this should use mv -f instead of a separate rm -f. % ${MAKE} _kernel-depend Invoking a new make ensures that the old dependencies are not used (since they have been moved out of the way). % % # The argument list can be very long, so use make -V and xargs to % # pass it to mkdep. % _kernel-depend: assym.s vnode_if.h ${BEFORE_DEPEND} ${CFILES} \ % ${SYSTEM_CFILES} ${GEN_CFILES} ${SFILES} \ % ${MFILES:T:S/.m$/.h/} % if [ -f .olddep ]; then mv .olddep .depend; fi This step moves the old dependencies back, so that they will be there if the make is aborted. They are harmless now since make has already decided dependecies without the old ones being present. % rm -f .newdep If we used "${DEPENDFILE}=.newdep ${MAKE} _kernel-depend", then we would have to do this step in kernel-depend instead of here and we wouldn't have to move .depend out of the way there or move it back here. This is simpler. % ${MAKE} -V CFILES -V SYSTEM_CFILES -V GEN_CFILES | \ % MKDEP_CPP="${CC} -E" CC="${CC}" xargs mkdep -a -f .newdep ${CFLAGS} % ${MAKE} -V SFILES | \ % MKDEP_CPP="${CC} -E" xargs mkdep -a -f .newdep ${ASM_CFLAGS} Normal mkdep stuff except it it is too specialized to be handled by the general "make depend" rule. % rm -f .depend % mv .newdep .depend Move stuff back as explained above. % % kernel-cleandepend: % rm -f .depend A subtarget of the standard cleandepend target. cleandepend and its parts should not be part of depend or clean. > I'm sitting in the kernel directory, I expect the ways of building > modules to be as close to building the kernel (which is just a special > .ko) as possible. > > We've never documented that 'make cleandepend' is nearly a required step > for 'make depend' to be dependable. It is a bug that it is. The bug is apparently that kmod.mk or possibly bsd.dep.mk is missing the move-depend-file-out-of-the way code in the above. Bruce