FAST_DEPEND: Rework how guessed dependencies are handled.

Rather than depend on .depend not existing, check the actual
.depend.OBJ file that will be used for that object.  If it doesn't
exist then use the guessed dependencies.

FAST_DEPEND may never have a .depend file.  Not having one means all of the
previous logic would over-depend all object files on all headers which is not
what we wanted.  It also means that if a .depend is generated before a build
is done for _EXTRADEPEND (such as for PROG or LIB) then all of these
dependencies would not be used since the .depend wasn't generated from mkdep
and the real .depend.* files are not generated until the build.

Sponsored by:	EMC / Isilon Storage Division
This commit is contained in:
Bryan Drewery 2016-02-24 17:19:05 +00:00
parent cc66670114
commit d7beff082b
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=295985
5 changed files with 62 additions and 33 deletions

View File

@ -94,19 +94,21 @@ _SKIP_READ_DEPEND= 1
.if defined(SRCS)
CLEANFILES?=
.if ${MK_FAST_DEPEND} == "yes" || !exists(${.OBJDIR}/${DEPENDFILE})
.for _S in ${SRCS:N*.[dhly]}
${_S:R}.o: ${_S}
.endfor
OBJS_DEPEND_GUESS.${_S:R}.o= ${_S}
.if ${MK_FAST_DEPEND} == "no" && !exists(${.OBJDIR}/${DEPENDFILE})
${_S:R}.o: ${OBJS_DEPEND_GUESS.${_S:R}.o}
.endif
.endfor
# Lexical analyzers
.for _LSRC in ${SRCS:M*.l:N*/*}
.for _LC in ${_LSRC:R}.c
${_LC}: ${_LSRC}
${LEX} ${LFLAGS} -o${.TARGET} ${.ALLSRC}
.if ${MK_FAST_DEPEND} == "yes" || !exists(${.OBJDIR}/${DEPENDFILE})
${_LC:R}.o: ${_LC}
OBJS_DEPEND_GUESS.${_LC:R}.o= ${_LC}
.if ${MK_FAST_DEPEND} == "no" && !exists(${.OBJDIR}/${DEPENDFILE})
${_LC:R}.o: ${OBJS_DEPEND_GUESS.${_LC:R}.o}
.endif
SRCS:= ${SRCS:S/${_LSRC}/${_LC}/}
CLEANFILES+= ${_LC}
@ -136,8 +138,9 @@ CLEANFILES+= ${_YH}
${_YC}: ${_YSRC}
${YACC} ${YFLAGS} -o ${_YC} ${.ALLSRC}
.endif
.if ${MK_FAST_DEPEND} == "yes" || !exists(${.OBJDIR}/${DEPENDFILE})
${_YC:R}.o: ${_YC}
OBJS_DEPEND_GUESS.${_YC:R}.o= ${_YC}
.if ${MK_FAST_DEPEND} == "no" && !exists(${.OBJDIR}/${DEPENDFILE})
${_YC:R}.o: ${OBJS_DEPEND_GUESS.${_YC:R}.o}
.endif
.endfor
.endfor
@ -195,7 +198,7 @@ DEPENDFILES_OBJS= ${DEPENDOBJS:O:u:${DEPEND_FILTER}:C/^/${DEPENDFILE}./}
.for __depend_obj in ${DEPENDFILES_OBJS}
.sinclude "${__depend_obj}"
.endfor
.endif
.endif # !defined(_SKIP_READ_DEPEND)
.endif # ${MK_FAST_DEPEND} == "yes"
.endif # defined(SRCS)
@ -208,6 +211,18 @@ beforedepend:
afterdepend: beforedepend
.endif
# Guess some dependencies for when no ${DEPENDFILE}.OBJ is generated yet.
# Done here to support meta mode as well which does not always need
# the CFLAGS modifications or .depend.* included.
.if ${MK_FAST_DEPEND} == "yes"
.for __obj in ${DEPENDOBJS:O:u}
.if !exists(${.OBJDIR}/${DEPENDFILE}.${__obj})
${__obj}: ${OBJS_DEPEND_GUESS}
${__obj}: ${OBJS_DEPEND_GUESS.${__obj}}
.endif
.endfor
.endif
.if !target(depend)
.if defined(SRCS)
depend: beforedepend ${DEPENDFILE} afterdepend

View File

@ -415,28 +415,31 @@ lint: ${SRCS:M*.c}
.include <bsd.man.mk>
.endif
.include <bsd.dep.mk>
.if ${MK_FAST_DEPEND} == "yes" || !exists(${.OBJDIR}/${DEPENDFILE})
.if defined(LIB) && !empty(LIB)
.if !exists(${.OBJDIR}/${DEPENDFILE})
${OBJS} ${STATICOBJS} ${POBJS}: ${SRCS:M*.h}
OBJS_DEPEND_GUESS+= ${SRCS:M*.h}
.if ${MK_FAST_DEPEND} == "no" && !exists(${.OBJDIR}/${DEPENDFILE})
${OBJS} ${STATICOBJS} ${POBJS}: ${OBJS_DEPEND_GUESS}
.endif
.for _S in ${SRCS:N*.[hly]}
${_S:R}.po: ${_S}
OBJS_DEPEND_GUESS.${_S:R}.po= ${_S}
.if ${MK_FAST_DEPEND} == "no" && !exists(${.OBJDIR}/${DEPENDFILE})
${_S:R}.po: ${OBJS_DEPEND_GUESS.${_S:R}.po}
.endif
.endfor
.endif
.if defined(SHLIB_NAME) || \
defined(INSTALL_PIC_ARCHIVE) && defined(LIB) && !empty(LIB)
.if !exists(${.OBJDIR}/${DEPENDFILE})
${SOBJS}: ${SRCS:M*.h}
.if ${MK_FAST_DEPEND} == "no" && !exists(${.OBJDIR}/${DEPENDFILE})
${SOBJS}: ${OBJS_DEPEND_GUESS}
.endif
.for _S in ${SRCS:N*.[hly]}
${_S:R}.So: ${_S}
OBJS_DEPEND_GUESS.${_S:R}.So= ${_S}
.if ${MK_FAST_DEPEND} == "no" && !exists(${.OBJDIR}/${DEPENDFILE})
${_S:R}.So: ${OBJS_DEPEND_GUESS.${_S:R}.So}
.endif
.endfor
.endif
.endif
.include <bsd.dep.mk>
.include <bsd.obj.mk>
.include <bsd.sys.mk>

View File

@ -275,12 +275,13 @@ lint: ${SRCS:M*.c}
.include <bsd.man.mk>
.endif
.include <bsd.dep.mk>
.if defined(PROG) && !exists(${.OBJDIR}/${DEPENDFILE})
${OBJS}: ${SRCS:M*.h}
.if defined(PROG)
OBJS_DEPEND_GUESS+= ${SRCS:M*.h}
.if ${MK_FAST_DEPEND} == "no" && !exists(${.OBJDIR}/${DEPENDFILE})
${OBJS}: ${OBJS_DEPEND_GUESS}
.endif
.endif
.include <bsd.dep.mk>
.include <bsd.obj.mk>
.include <bsd.sys.mk>

View File

@ -143,8 +143,10 @@ ${FULLKERNEL}: ${SYSTEM_DEP} vers.o
.endif
${SYSTEM_LD_TAIL}
.if !exists(${.OBJDIR}/.depend)
${SYSTEM_OBJS}: assym.s vnode_if.h ${BEFORE_DEPEND:M*.h} ${MFILES:T:S/.m$/.h/}
OBJS_DEPEND_GUESS+= assym.s vnode_if.h ${BEFORE_DEPEND:M*.h} \
${MFILES:T:S/.m$/.h/}
.if ${MK_FAST_DEPEND} == "no" && !exists(${.OBJDIR}/.depend)
${SYSTEM_OBJS}: ${OBJS_DEPEND_GUESS}
.endif
LNFILES= ${CFILES:T:S/.c$/.ln/}
@ -239,10 +241,18 @@ CFLAGS+= ${DEPEND_CFLAGS}
DEPENDOBJS+= ${SYSTEM_OBJS} genassym.o
DEPENDFILES_OBJS= ${DEPENDOBJS:O:u:C/^/.depend./}
.if !defined(_SKIP_READ_DEPEND)
.for __depend_obj in ${DEPENDFILES_OBJS}
.sinclude "${__depend_obj}"
.endfor
.for __obj in ${DEPENDOBJS}
.if exists(${.OBJDIR}/.depend.${__obj})
.include ".depend.${__obj}"
.else
# Guess some dependencies for when no .depend.OBJ is generated yet.
.if ${SYSTEM_OBJS:M${__obj}}
${__obj}: ${OBJS_DEPEND_GUESS}
.endif
${__obj}: ${OBJS_DEPEND_GUESS.${__obj}}
.endif
.endfor
.endif # !defined(_SKIP_READ_DEPEND)
.endif # ${MK_FAST_DEPEND} == "yes"
.NOPATH: .depend ${DEPENDFILES_OBJS}

View File

@ -450,16 +450,16 @@ lint: ${SRCS}
${OBJS}: opt_global.h
.endif
.include <bsd.dep.mk>
CLEANDEPENDFILES+= ${_ILINKS}
# .depend needs include links so we remove them only together.
cleanilinks:
rm -f ${_ILINKS}
.if !exists(${.OBJDIR}/${DEPENDFILE})
${OBJS}: ${SRCS:M*.h}
OBJS_DEPEND_GUESS+= ${SRCS:M*.h}
.if ${MK_FAST_DEPEND} == "no" && !exists(${.OBJDIR}/${DEPENDFILE})
${OBJS}: ${OBJS_DEPEND_GUESS}
.endif
.include <bsd.dep.mk>
.include <bsd.obj.mk>
.include "kern.mk"