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
16 .for m in ${PSEUDO_MACHINE_LIST:Nhost*}
17 M_dep_qual_fixes += C;($m),[^/.,]*$$;\1;
19 #.info M_dep_qual_fixes=${M_dep_qual_fixes}
21 # Some things we never want to build for host
22 DIRDEPS_FILTER.host = \
31 .if ${.MAKE.OS} == "FreeBSD"
32 # Host libraries should mostly be excluded from the build so the
33 # host version in /usr/lib is used.
34 # Internal libraries need to be allowed to be built though
35 # since they are never installed.
37 # Cheat for including src.libnames.mk
39 # Pull in _INTERNALLIBS
40 .include <src.libnames.mk>
43 .for lib in ${_INTERNALLIBS}
44 _need_host_libs+= ${LIB${lib:tu}DIR:S,^${OBJTOP}/,,}
46 .if ${MK_host_egacy} == "yes"
47 _need_host_libs+= lib/libmd
50 N_host_libs:= ${cd ${SRCTOP} && echo lib/lib*:L:sh:${_need_host_libs:${M_ListToSkip}}:${M_ListToSkip}}
51 DIRDEPS_FILTER.host+= ${N_host_libs}
56 ${DIRDEPS_FILTER.xtras:U}
58 # Cleanup a buildworld's WORLDTMP so that any files generated from it
59 # or using it will rebuild with the DIRDEPS SYSROOT. Otherwise existing
60 # object .meta files may still reference those directories and not be
61 # rebuilt and lead to incorrect Makefile.depend files due to lack of
63 .if !defined(NO_CLEANUP_WORLDTMP) && exists(${OBJTOP}/tmp/_worldtmp)
64 cleanup_worldtmp: .PHONY .NOMETA
65 @echo "Cleaning leftover WORLDTMP from buildworld."
66 -rm -rf ${OBJTOP}/tmp/*
67 -chflags -R 0 ${OBJTOP}/tmp/*
69 beforedirdeps: cleanup_worldtmp
72 # pseudo option for building host tools on old or non-FreeBSD host
73 # allows us to leverage Makefile.depend.options with
74 # DIRDEPS_OPTIONS = host_egacy
75 # dirdeps-options.mk will qualify with ${DEP_MACHINE} (and others)
76 # before looking at the bare option.
77 MK_host_egacy.host= ${MK_host_egacy}
79 .endif # !target(_DIRDEP_USE)
81 # reset this each time
83 .if ${DEP_MACHINE:Npkgs*} != ""
84 DIRDEPS_FILTER.xtras+= Nusr.bin/clang/clang.host
87 .if ${DEP_MACHINE} != "host"
88 MK_host_egacy.${DEP_MACHINE}= no
90 # this is how we can handle optional dependencies
91 .if ${DEP_RELDIR} == "lib/libc"
92 DIRDEPS += lib/libc_nonshared
93 .if ${MK_SSP:Uno} != "no"
94 DIRDEPS += lib/libssp_nonshared
97 DIRDEPS_FILTER.xtras+= Nlib/libc_nonshared
100 # some optional things
101 .if ${MK_CTF} == "yes" && ${DEP_RELDIR:Mcddl/usr.bin/ctf*} == ""
103 cddl/usr.bin/ctfconvert.host \
104 cddl/usr.bin/ctfmerge.host
107 # Add in proper libgcc (gnu or LLVM) if not building libcc and libc is needed.
108 # Add both gcc_s and gcc_eh as dependencies as the decision to build
109 # -static or not is not known here.
110 .if ${DEP_RELDIR:M*libgcc*} == "" && ${DIRDEPS:U:Mlib/libc} != ""
116 # Bootstrap support. Give hints to DIRDEPS if there is no Makefile.depend*
117 # generated yet. This can be based on things such as SRC files and LIBADD.
118 # These hints will not factor into the final Makefile.depend as only what is
119 # used will be added in and handled via [local.]gendirdeps.mk. This is not
120 # done for MACHINE=host builds.
121 # XXX: Include this in local.autodep.mk as well for gendirdeps without filemon.
122 # Only do this for main build target
123 .if ${RELDIR} == ${DEP_RELDIR} && !defined(_RECURSING_PROGS)
124 .for _depfile in ${.MAKE.DEPENDFILE_PREFERENCE:T}
125 .if !defined(_have_depfile) && exists(${.CURDIR}/${_depfile})
129 .if !defined(_have_depfile)
130 # KMOD does not use any stdlibs.
132 # Gather PROGS dependencies first
137 .for _prog in ${PROGS}
139 .if !empty(LIBADD${s}${_prog})
140 _PROGS_LIBADD+= ${LIBADD${s}${_prog}}
142 .if !empty(DPADD${s}${_prog})
143 _PROGS_DPADD+= ${DPADD${s}${_prog}}
145 .if !empty(SRCS${s}${_prog})
146 _PROGS_SRCS+= ${SRCS${s}${_prog}}
148 .endfor # .for s in . _
149 # Add in assumed source (bsd.prog.mk)
150 .if !target(${_prog})
151 .if defined(PROG_CXX)
152 _PROGS_SRCS+= ${_prog}.cc
154 _PROGS_SRCS+= ${_prog}.c
156 .endif # !target(${_prog})
157 .endfor # .for _prog in ${PROGS}
158 .endif # !empty(PROGS)
159 _SRCS= ${SRCS} ${_PROGS_SRCS}
161 # Has C files. The C_DIRDEPS are shared with C++ files as well.
173 # libgcc is needed as well but is added later.
175 .if ${MK_GSSAPI} != "no"
176 C_DIRDEPS+= include/gssapi
179 .if !empty(_SRCS:M*.c)
180 DIRDEPS+= ${C_DIRDEPS}
183 .if !empty(_SRCS:M*.cc) || !empty(_SRCS:M*.C) || !empty(_SRCS:M*.cpp) || \
185 DIRDEPS+= ${C_DIRDEPS}
186 .if ${MK_CLANG} == "yes"
187 DIRDEPS+= lib/libc++ lib/libcxxrt
189 # XXX: Clang and GCC always adds -lm currently, even when not needed.
192 .endif # !defined(KMOD)
194 .if !empty(_SRCS:M*.y)
195 DIRDEPS+= usr.bin/yacc.host
197 _DPADD= ${DPADD} ${_PROGS_DPADD}
199 # This only works for DPADD with full OBJ/SRC paths, which is mostly just
202 ${_DPADD:O:u:M${OBJTOP}*:H:N.:tA:C,${OBJTOP}[^/]*/,,:N.:O:u} \
203 ${_DPADD:O:u:M${OBJROOT}*:N${OBJTOP}*:N${STAGE_ROOT}/*:H:S,${OBJROOT},,:C,^([^/]+)/(.*),\2.\1,:S,${HOST_TARGET}$,host,:N.*:O:u}
204 # Resolve the paths to RELDIRs
205 .if !empty(_DP_DIRDEPS)
206 DIRDEPS+= ${_DP_DIRDEPS:C,^,${SRCTOP}/,:tA:C,^${SRCTOP}/,,}
208 .endif # !empty(DPADD)
209 _ALL_LIBADD= ${LIBADD} ${_PROGS_LIBADD}
210 .if !empty(_ALL_LIBADD)
211 # Also handle LIBADD for non-internal libraries.
212 .for _lib in ${_ALL_LIBADD:O:u}
213 _lib${_lib}reldir= ${LIB${_lib:tu}DIR:C,${OBJTOP}/,,}
214 .if defined(LIB${_lib:tu}DIR) && ${DIRDEPS:M${_lib${_lib}reldir}} == "" && \
215 exists(${SRCTOP}/${_lib${_lib}reldir})
216 DIRDEPS+= ${_lib${_lib}reldir}
219 .endif # !empty(LIBADD)
220 .endif # no Makefile.depend*
221 .endif # ${RELDIR} == ${DEP_RELDIR}
223 .endif # ${DEP_MACHINE} != "host"
225 .if ${MK_STAGING} == "yes"
226 # we need targets/pseudo/stage to prep the stage tree
227 .if ${DEP_RELDIR:N.:N${SRCTOP}:N*pseudo/stage} != ""
228 DIRDEPS += targets/pseudo/stage
232 DEP_MACHINE_ARCH = ${MACHINE_ARCH.${DEP_MACHINE}}
233 DEP_MACHINE_CPUARCH = ${DEP_MACHINE_ARCH:${__TO_CPUARCH}}
234 CSU_DIR.${DEP_MACHINE_ARCH} ?= csu/${DEP_MACHINE_ARCH}
235 CSU_DIR := ${CSU_DIR.${DEP_MACHINE_ARCH}}
236 BOOT_MACHINE_DIR:= ${BOOT_MACHINE_DIR.${DEP_MACHINE}}
237 KERNEL_NAME:= ${KERNEL_NAME.${DEP_MACHINE}}
239 .-include <site.dirdeps.mk>