On Tue, 13 Aug 2002, Poul-Henning Kamp wrote: > The final make in this script fails, I don't think it should. > > #!/bin/sh > set -ex > rm -rf /usr/src/sys/i386/compile/GENERIC > cd /usr/src/sys/i386/conf > config GENERIC > cd ../compile/GENERIC > make depend > _.m.0.d 2>&1 > make > _.m.1 2>&1 > make clean > _.m.2.c 2>&1 > make > echo "SUCCESS" > > The error is included below. If I run "make depend" it works, but that > should not be needed after a "make clean". Some dependencies must > be missing somewhere.
"make" after "make clean" was broken by excessively zealous cleanups in conf/files (rev.1.348 if I grep correctly). Dependencies related to *.m used to be generated by verbose rules in conf/files but the verbose rules were replaced by low quality rules generated by config plus too-simple rules in Makefile.${ARCH} (now in kern.post.mk). Example of a low quality explicit rule generated by config: % device_if.o: $S/kern/device_if.m % ${NORMAL_M} ${NORMAL_M} expands to an awk step to go from .m to .c and a cc step to go from .c to .o. make(1) is not told about the intermediate .c file so it can't handle the .c to .o conversion automagically. NORMAL_M also has style bugs (it unsorts the NORMAL_* definitions and uses $<). Too-simple rules in kern.post.mk: % .if !exists(.depend) % ${SYSTEM_OBJS}: vnode_if.h ${BEFORE_DEPEND:M*.h} ${MFILES:T:S/.m$/.h/} % .endif % % .for mfile in ${MFILES} % ${mfile:T:S/.m$/.h/}: ${mfile} % ${AWK} -f $S/tools/makeobjops.awk ${mfile} -h % .endfor When .depend doesn't exist, the first group of lines above implements the hack of making all objects depend on all headers (including ones generated from .m files) so that "make depend" works when .depend doesn't exist. When .depend exists, the dependencies in it are used instead of this hack, but the low quality .m.o rule helps give incomplete dependencies in .depend. The usual cause of failure is that mkdep is not run on device_if.c, and since device_if.c is normally compiled before anything else that uses device_if.h, compiling it fails because device_if.h has not been created at that point. config puts all relevant .m files in MFILES and the second group of lines gives the rule to go from .m to .h. Fixes: (1) Quick fix: delete .depend. I've often done this. (2) Tell mkdep about all the generated files so that dependencies work in the normal way. The following patch seems to work. It doesn't fix the bogus rules generated by config, but adds a .m.c one so that device_if.c can be generated before mkdep is run. It also fixes some old style bugs (extra env processes). %%% Index: kern.post.mk =================================================================== RCS file: /home/ncvs/src/sys/conf/kern.post.mk,v retrieving revision 1.25 diff -u -2 -r1.25 kern.post.mk --- kern.post.mk 1 Aug 2002 03:13:10 -0000 1.25 +++ kern.post.mk 13 Aug 2002 16:15:06 -0000 @@ -43,4 +42,8 @@ .for mfile in ${MFILES} +# XXX the low quality .m.o rules gnerated by config are normally used +# instead of the .m.c rules here. +${mfile:T:S/.m$/.c/}: ${mfile} + ${AWK} -f $S/tools/makeobjops.awk ${mfile} -c ${mfile:T:S/.m$/.h/}: ${mfile} ${AWK} -f $S/tools/makeobjops.awk ${mfile} -h @@ -91,15 +94,20 @@ ${MAKE} _kernel-depend -# The argument list can be very long, use make -V and xargs to +# XXX this belongs elsewhere (inside GEN_CFILES if possible). +GEN_M_CFILES= ${MFILES:T:S/.m$/.c/} + +# 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} \ - ${SYSTEM_SFILES} ${MFILES:T:S/.m$/.h/} + ${CFILES} ${SYSTEM_CFILES} ${GEN_CFILES} ${GEN_M_CFILES} \ + ${SFILES} ${SYSTEM_SFILES} ${MFILES:T:S/.m$/.h/} if [ -f .olddep ]; then mv .olddep .depend; fi rm -f .newdep - ${MAKE} -V CFILES -V SYSTEM_CFILES -V GEN_CFILES | xargs \ - env MKDEP_CPP="${CC} -E" CC="${CC}" mkdep -a -f .newdep ${CFLAGS} - ${MAKE} -V SFILES -V SYSTEM_SFILES | xargs \ - env MKDEP_CPP="${CC} -E" mkdep -a -f .newdep ${ASM_CFLAGS} + ${MAKE} -V CFILES -V SYSTEM_CFILES -V GEN_CFILES -V GEN_M_CFILES | \ + MKDEP_CPP="${CC} -E" CC="${CC}" xargs \ + mkdep -a -f .newdep ${CFLAGS} + ${MAKE} -V SFILES -V SYSTEM_SFILES | \ + MKDEP_CPP="${CC} -E" xargs \ + mkdep -a -f .newdep ${ASM_CFLAGS} rm -f .depend mv .newdep .depend %%% Bruce To Unsubscribe: send mail to [EMAIL PROTECTED] with "unsubscribe freebsd-current" in the body of the message