cvs commit: src/sys/conf kmod.mk
Bruce Evans
bde at zeta.org.au
Wed Apr 20 20:35:53 PDT 2005
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
More information about the cvs-src
mailing list