DIRDEPS_BUILD: Let PROGS bootstrapping work.

- Support (DP|LIB)ADD_${PROG}.
- Support SRCS[._]${PROG}.
- Don't bootstrap DIRDEPS while recursing.

Sponsored by:	EMC / Isilon Storage Division
This commit is contained in:
Bryan Drewery 2016-03-09 22:44:48 +00:00
parent 988f26f9ff
commit 9593179053
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=296584

View File

@ -90,7 +90,8 @@ DIRDEPS += \
# used will be added in and handled via [local.]gendirdeps.mk. This is not
# done for MACHINE=host builds.
# XXX: Include this in local.autodep.mk as well for gendirdeps without filemon.
.if ${RELDIR} == ${DEP_RELDIR} # Only do this for main build target
# Only do this for main build target
.if ${RELDIR} == ${DEP_RELDIR} && !defined(_RECURSING_PROGS)
.for _depfile in ${.MAKE.DEPENDFILE_PREFERENCE:T}
.if !defined(_have_depfile) && exists(${.CURDIR}/${_depfile})
_have_depfile=
@ -99,6 +100,35 @@ _have_depfile=
.if !defined(_have_depfile)
# KMOD does not use any stdlibs.
.if !defined(KMOD)
# Gather PROGS dependencies first
.if !empty(PROGS)
_PROGS_LIBADD=
_PROGS_DPADD=
_PROGS_SRCS=
.for _prog in ${PROGS}
.for s in . _
.if !empty(LIBADD${s}${_prog})
_PROGS_LIBADD+= ${LIBADD${s}${_prog}}
.endif
.if !empty(DPADD${s}${_prog})
_PROGS_DPADD+= ${DPADD${s}${_prog}}
.endif
.if !empty(SRCS${s}${_prog})
_PROGS_SRCS+= ${SRCS${s}${_prog}}
.endif
.endfor # .for s in . _
# Add in assumed source (bsd.prog.mk)
.if !target(${_prog})
.if defined(PROG_CXX)
_PROGS_SRCS+= ${_prog}.cc
.else
_PROGS_SRCS+= ${_prog}.c
.endif
.endif # !target(${_prog})
.endfor # .for _prog in ${PROGS}
.endif # !empty(PROGS)
_SRCS= ${SRCS} ${_PROGS_SRCS}
# Has C files. The C_DIRDEPS are shared with C++ files as well.
C_DIRDEPS= \
gnu/lib/csu \
@ -118,12 +148,12 @@ C_DIRDEPS= \
C_DIRDEPS+= include/gssapi
.endif
.if !empty(SRCS:M*.c)
.if !empty(_SRCS:M*.c)
DIRDEPS+= ${C_DIRDEPS}
.endif
# Has C++ files
.if !empty(SRCS:M*.cc) || !empty(SRCS:M*.C) || !empty(SRCS:M*.cpp) || \
!empty(SRCS:M*.cxx)
.if !empty(_SRCS:M*.cc) || !empty(_SRCS:M*.C) || !empty(_SRCS:M*.cpp) || \
!empty(_SRCS:M*.cxx)
DIRDEPS+= ${C_DIRDEPS}
.if ${MK_CLANG} == "yes"
DIRDEPS+= lib/libc++ lib/libcxxrt
@ -135,28 +165,15 @@ DIRDEPS+= lib/msun
.endif # CXX
.endif # !defined(KMOD)
# Has yacc files.
.if !empty(SRCS:M*.y)
.if !empty(_SRCS:M*.y)
DIRDEPS+= usr.bin/yacc.host
.endif
# Gather PROGS dependencies
.if !empty(PROGS)
_PROGS_LIBADD=
_PROGS_DPADD=
.for _prog in ${PROGS}
.if !empty(LIBADD.${_prog})
_PROGS_LIBADD+= ${LIBADD.${_prog}}
.endif
.if !empty(DPADD.${_prog})
_PROGS_DPADD+= ${DPADD.${_prog}}
.endif
.endfor
.endif # !empty(PROGS)
.if !empty(DPADD)
_DPADD= ${DPADD} ${_PROGS_DPADD}
.if !empty(_DPADD)
# Taken from meta.autodep.mk (where it only does something with
# BUILD_AT_LEVEL0, which we don't use).
# This only works for DPADD with full OBJ/SRC paths, which is mostly just
# _INTERNALLIBS.
_DPADD= ${DPADD} ${_PROGS_DPADD}
_DP_DIRDEPS= \
${_DPADD:O:u:M${OBJTOP}*:H:N.:tA:C,${OBJTOP}[^/]*/,,:N.:O:u} \
${_DPADD:O:u:M${OBJROOT}*:N${OBJTOP}*:N${STAGE_ROOT}/*:H:S,${OBJROOT},,:C,^([^/]+)/(.*),\2.\1,:S,${HOST_TARGET}$,host,:N.*:O:u}
@ -165,9 +182,9 @@ _DP_DIRDEPS= \
DIRDEPS+= ${_DP_DIRDEPS:C,^,${SRCTOP}/,:tA:C,^${SRCTOP}/,,}
.endif
.endif # !empty(DPADD)
.if !empty(LIBADD)
# Also handle LIBADD for non-internal libraries.
_ALL_LIBADD= ${LIBADD} ${_PROGS_LIBADD}
.if !empty(_ALL_LIBADD)
# Also handle LIBADD for non-internal libraries.
.for _lib in ${_ALL_LIBADD:O:u}
_lib${_lib}reldir= ${LIB${_lib:tu}DIR:C,${OBJTOP}/,,}
.if defined(LIB${_lib:tu}DIR) && ${DIRDEPS:M${_lib${_lib}reldir}} == "" && \