cvs commit: src/sys/conf kmod.mk

Ruslan Ermilov ru at FreeBSD.org
Thu Apr 21 00:00:27 PDT 2005


On Thu, Apr 21, 2005 at 01:35:44PM +1000, Bruce Evans wrote:
> 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.
> 
Yes (we discussed this long ago).

> 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.
> 
make(1) is who reads .depend, hence the added complexity.

> kernel-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.
> 
No.  We want to remove .olddep even if .depend doesn't exist.

> % 	${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.
> 
Correct.

> % 	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.
> 
Speaking of kern.*.mk, I consider it a bug that "make depend" followed
by "make depend" rebuilds the .depend file.  We need to decide if we
want this behavior or not, and if we do, we should behave similarly
in other places too, i.e., bsd.dep.mk.

I proposed the following: with NO_CLEAN builds, default to always
regenerating .depend files (by moving the old .depend files out of
the way like is done in kern.post.mk), but provide a mean to skip
regenerating .depend files, NO_CLEANDEPEND.


Cheers,
-- 
Ruslan Ermilov
ru at FreeBSD.org
FreeBSD committer
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 187 bytes
Desc: not available
Url : http://lists.freebsd.org/pipermail/cvs-src/attachments/20050421/398006c3/attachment.bin


More information about the cvs-src mailing list