2 .if !target(_DIRDEP_USE)
3 # we are the 1st makefile
6 .include "${SRCTOP}/share/mk/src.opts.mk"
9 # making universe is special
10 .if defined(UNIVERSE_GUARD)
11 # these should be done by now
12 DIRDEPS_FILTER+= N*.host
15 # pseudo machines get no qualification
17 M_dep_qual_fixes += C;($m),[^/.,]*$$;\1;
19 #.info M_dep_qual_fixes=${M_dep_qual_fixes}
21 # Cheat for including src.libnames.mk
23 # Pull in _INTERNALLIBS
24 .include <src.libnames.mk>
26 # Host libraries should mostly be excluded from the build so the
27 # host version in /usr/lib is used. Internal libraries need to be
28 # allowed to be built though since they are never installed.
30 .for lib in ${_INTERNALLIBS}
31 _need_host_libs+= ${LIB${lib:tu}DIR:S,^${OBJTOP}/,,}
34 N_host_libs:= ${cd ${SRCTOP} && echo lib/lib*:L:sh:${_need_host_libs:${M_ListToSkip}}:${M_ListToSkip}}
35 DIRDEPS_FILTER.host = \
48 ${DIRDEPS_FILTER.xtras:U}
50 # Cleanup a buildworld's WORLDTMP so that any files generated from it
51 # or using it will rebuild with the DIRDEPS SYSROOT. Otherwise existing
52 # object .meta files may still reference those directories and not be
53 # rebuilt and lead to incorrect Makefile.depend files due to lack of
55 .if !defined(NO_CLEANUP_WORLDTMP) && exists(${OBJTOP}/tmp/_worldtmp)
56 cleanup_worldtmp: .PHONY .NOMETA
57 @echo "Cleaning leftover WORLDTMP from buildworld."
58 -rm -rf ${OBJTOP}/tmp/*
59 -chflags -R 0 ${OBJTOP}/tmp/*
61 beforedirdeps: cleanup_worldtmp
65 # reset this each time
67 .if ${DEP_MACHINE:Npkgs*} != ""
68 DIRDEPS_FILTER.xtras+= Nusr.bin/clang/clang.host
71 .if ${DEP_MACHINE} != "host"
73 # this is how we can handle optional dependencies
74 .if ${DEP_RELDIR} == "lib/libc"
75 DIRDEPS += lib/libc_nonshared
76 .if ${MK_SSP:Uno} != "no"
77 DIRDEPS += lib/libssp_nonshared
80 DIRDEPS_FILTER.xtras+= Nlib/libc_nonshared
83 # some optional things
84 .if ${MK_CTF} == "yes" && ${DEP_RELDIR:Mcddl/usr.bin/ctf*} == ""
86 cddl/usr.bin/ctfconvert.host \
87 cddl/usr.bin/ctfmerge.host
90 # Add in proper libgcc (gnu or LLVM) if not building libcc and libc is needed.
91 # Add both gcc_s and gcc_eh as dependencies as the decision to build
92 # -static or not is not known here.
93 .if ${DEP_RELDIR:M*libgcc*} == "" && ${DIRDEPS:U:Mlib/libc} != ""
99 # Bootstrap support. Give hints to DIRDEPS if there is no Makefile.depend*
100 # generated yet. This can be based on things such as SRC files and LIBADD.
101 # These hints will not factor into the final Makefile.depend as only what is
102 # used will be added in and handled via [local.]gendirdeps.mk. This is not
103 # done for MACHINE=host builds.
104 # XXX: Include this in local.autodep.mk as well for gendirdeps without filemon.
105 # Only do this for main build target
106 .if ${RELDIR} == ${DEP_RELDIR} && !defined(_RECURSING_PROGS)
107 .for _depfile in ${.MAKE.DEPENDFILE_PREFERENCE:T}
108 .if !defined(_have_depfile) && exists(${.CURDIR}/${_depfile})
112 .if !defined(_have_depfile)
113 # KMOD does not use any stdlibs.
115 # Gather PROGS dependencies first
120 .for _prog in ${PROGS}
122 .if !empty(LIBADD${s}${_prog})
123 _PROGS_LIBADD+= ${LIBADD${s}${_prog}}
125 .if !empty(DPADD${s}${_prog})
126 _PROGS_DPADD+= ${DPADD${s}${_prog}}
128 .if !empty(SRCS${s}${_prog})
129 _PROGS_SRCS+= ${SRCS${s}${_prog}}
131 .endfor # .for s in . _
132 # Add in assumed source (bsd.prog.mk)
133 .if !target(${_prog})
134 .if defined(PROG_CXX)
135 _PROGS_SRCS+= ${_prog}.cc
137 _PROGS_SRCS+= ${_prog}.c
139 .endif # !target(${_prog})
140 .endfor # .for _prog in ${PROGS}
141 .endif # !empty(PROGS)
142 _SRCS= ${SRCS} ${_PROGS_SRCS}
144 # Has C files. The C_DIRDEPS are shared with C++ files as well.
156 # libgcc is needed as well but is added later.
158 .if ${MK_GSSAPI} != "no"
159 C_DIRDEPS+= include/gssapi
162 .if !empty(_SRCS:M*.c)
163 DIRDEPS+= ${C_DIRDEPS}
166 .if !empty(_SRCS:M*.cc) || !empty(_SRCS:M*.C) || !empty(_SRCS:M*.cpp) || \
168 DIRDEPS+= ${C_DIRDEPS}
169 .if ${MK_CLANG} == "yes"
170 DIRDEPS+= lib/libc++ lib/libcxxrt
172 # XXX: Clang and GCC always adds -lm currently, even when not needed.
175 .endif # !defined(KMOD)
177 .if !empty(_SRCS:M*.y)
178 DIRDEPS+= usr.bin/yacc.host
180 _DPADD= ${DPADD} ${_PROGS_DPADD}
182 # This only works for DPADD with full OBJ/SRC paths, which is mostly just
185 ${_DPADD:O:u:M${OBJTOP}*:H:N.:tA:C,${OBJTOP}[^/]*/,,:N.:O:u} \
186 ${_DPADD:O:u:M${OBJROOT}*:N${OBJTOP}*:N${STAGE_ROOT}/*:H:S,${OBJROOT},,:C,^([^/]+)/(.*),\2.\1,:S,${HOST_TARGET}$,host,:N.*:O:u}
187 # Resolve the paths to RELDIRs
188 .if !empty(_DP_DIRDEPS)
189 DIRDEPS+= ${_DP_DIRDEPS:C,^,${SRCTOP}/,:tA:C,^${SRCTOP}/,,}
191 .endif # !empty(DPADD)
192 _ALL_LIBADD= ${LIBADD} ${_PROGS_LIBADD}
193 .if !empty(_ALL_LIBADD)
194 # Also handle LIBADD for non-internal libraries.
195 .for _lib in ${_ALL_LIBADD:O:u}
196 _lib${_lib}reldir= ${LIB${_lib:tu}DIR:C,${OBJTOP}/,,}
197 .if defined(LIB${_lib:tu}DIR) && ${DIRDEPS:M${_lib${_lib}reldir}} == "" && \
198 exists(${SRCTOP}/${_lib${_lib}reldir})
199 DIRDEPS+= ${_lib${_lib}reldir}
202 .endif # !empty(LIBADD)
203 .endif # no Makefile.depend*
204 .endif # ${RELDIR} == ${DEP_RELDIR}
206 .endif # ${DEP_MACHINE} != "host"
208 .if ${MK_STAGING} == "yes"
209 # we need targets/pseudo/stage to prep the stage tree
210 .if ${DEP_RELDIR:N.:N${SRCTOP}:N*pseudo/stage} != ""
211 DIRDEPS += targets/pseudo/stage
215 DEP_MACHINE_ARCH = ${MACHINE_ARCH.${DEP_MACHINE}}
216 DEP_MACHINE_CPUARCH = ${DEP_MACHINE_ARCH:${__TO_CPUARCH}}
217 CSU_DIR.${DEP_MACHINE_ARCH} ?= csu/${DEP_MACHINE_ARCH}
218 CSU_DIR := ${CSU_DIR.${DEP_MACHINE_ARCH}}
219 BOOT_MACHINE_DIR:= ${BOOT_MACHINE_DIR.${DEP_MACHINE}}
220 KERNEL_NAME:= ${KERNEL_NAME.${DEP_MACHINE}}
222 .-include <site.dirdeps.mk>