1 .if !target(_DIRDEP_USE)
2 # we are the 1st makefile
5 .include "${SRCTOP}/share/mk/src.opts.mk"
8 # making universe is special
9 .if defined(UNIVERSE_GUARD)
10 # these should be done by now
11 DIRDEPS_FILTER+= N*.host
14 # pseudo machines get no qualification
15 .for m in ${PSEUDO_MACHINE_LIST:Nhost*}
16 M_dep_qual_fixes += C;($m),[^/.,]*$$;\1;
18 #.info M_dep_qual_fixes=${M_dep_qual_fixes}
20 # Some things we never want to build for host
21 DIRDEPS_FILTER.host = \
30 .if ${.MAKE.OS} == "FreeBSD"
31 # Host libraries should mostly be excluded from the build so the
32 # host version in /usr/lib is used.
33 # Internal libraries need to be allowed to be built though
34 # since they are never installed.
36 # Cheat for including src.libnames.mk
38 # Pull in _INTERNALLIBS
39 .include <src.libnames.mk>
42 .for lib in ${_INTERNALLIBS}
43 _need_host_libs+= ${LIB${lib:tu}DIR:S,^${OBJTOP}/,,}
45 .if ${MK_host_egacy} == "yes"
46 _need_host_libs+= lib/libmd
49 N_host_libs:= ${cd ${SRCTOP} && echo lib/lib*:L:sh:${_need_host_libs:${M_ListToSkip}}:${M_ListToSkip}}
50 DIRDEPS_FILTER.host+= ${N_host_libs}
55 ${DIRDEPS_FILTER.xtras:U}
57 # Cleanup a buildworld's WORLDTMP so that any files generated from it
58 # or using it will rebuild with the DIRDEPS SYSROOT. Otherwise existing
59 # object .meta files may still reference those directories and not be
60 # rebuilt and lead to incorrect Makefile.depend files due to lack of
62 .if !defined(NO_CLEANUP_WORLDTMP) && exists(${OBJTOP}/tmp/_worldtmp)
63 cleanup_worldtmp: .PHONY .NOMETA
64 @echo "Cleaning leftover WORLDTMP from buildworld."
65 -rm -rf ${OBJTOP}/tmp/*
66 -chflags -R 0 ${OBJTOP}/tmp/*
68 beforedirdeps: cleanup_worldtmp
71 # pseudo option for building host tools on old or non-FreeBSD host
72 # allows us to leverage Makefile.depend.options with
73 # DIRDEPS_OPTIONS = host_egacy
74 # dirdeps-options.mk will qualify with ${DEP_MACHINE} (and others)
75 # before looking at the bare option.
76 MK_host_egacy.host= ${MK_host_egacy}
78 .endif # !target(_DIRDEP_USE)
80 # reset this each time
82 .if ${DEP_MACHINE:Npkgs*} != ""
83 DIRDEPS_FILTER.xtras+= Nusr.bin/clang/clang.host
86 .if ${DEP_MACHINE:Nhost*} == ""
87 .if ${MK_host_egacy} == "yes" && ${DEP_RELDIR:Ntools/build:Ntargets/*:N*/stage} != ""
88 DIRDEPS += tools/build
91 MK_host_egacy.${DEP_MACHINE}= no
93 # this is how we can handle optional dependencies
94 .if ${DEP_RELDIR} == "lib/libc"
95 DIRDEPS += lib/libc_nonshared
96 .if ${MK_SSP:Uno} != "no"
97 DIRDEPS += lib/libssp_nonshared
100 DIRDEPS_FILTER.xtras+= Nlib/libc_nonshared
103 # some optional things
104 .if ${MK_CTF} == "yes" && ${DEP_RELDIR:Mcddl/usr.bin/ctf*} == ""
106 cddl/usr.bin/ctfconvert.host \
107 cddl/usr.bin/ctfmerge.host
110 # Add in proper libgcc (gnu or LLVM) if not building libcc and libc is needed.
111 # Add both gcc_s and gcc_eh as dependencies as the decision to build
112 # -static or not is not known here.
113 .if ${DEP_RELDIR:M*libgcc*} == "" && ${DIRDEPS:U:Mlib/libc} != ""
119 # Bootstrap support. Give hints to DIRDEPS if there is no Makefile.depend*
120 # generated yet. This can be based on things such as SRC files and LIBADD.
121 # These hints will not factor into the final Makefile.depend as only what is
122 # used will be added in and handled via [local.]gendirdeps.mk. This is not
123 # done for MACHINE=host builds.
124 # XXX: Include this in local.autodep.mk as well for gendirdeps without filemon.
125 # Only do this for main build target
126 .if ${RELDIR} == ${DEP_RELDIR} && !defined(_RECURSING_PROGS)
127 .for _depfile in ${.MAKE.DEPENDFILE_PREFERENCE:T}
128 .if !defined(_have_depfile) && exists(${.CURDIR}/${_depfile})
132 .if !defined(_have_depfile)
133 # KMOD does not use any stdlibs.
135 # Gather PROGS dependencies first
140 .for _prog in ${PROGS}
142 .if !empty(LIBADD${s}${_prog})
143 _PROGS_LIBADD+= ${LIBADD${s}${_prog}}
145 .if !empty(DPADD${s}${_prog})
146 _PROGS_DPADD+= ${DPADD${s}${_prog}}
148 .if !empty(SRCS${s}${_prog})
149 _PROGS_SRCS+= ${SRCS${s}${_prog}}
151 .endfor # .for s in . _
152 # Add in assumed source (bsd.prog.mk)
153 .if !target(${_prog})
154 .if defined(PROG_CXX)
155 _PROGS_SRCS+= ${_prog}.cc
157 _PROGS_SRCS+= ${_prog}.c
159 .endif # !target(${_prog})
160 .endfor # .for _prog in ${PROGS}
161 .endif # !empty(PROGS)
162 _SRCS= ${SRCS} ${_PROGS_SRCS}
164 # Has C files. The C_DIRDEPS are shared with C++ files as well.
176 # libgcc is needed as well but is added later.
178 .if ${MK_GSSAPI} != "no"
179 C_DIRDEPS+= include/gssapi
182 .if !empty(_SRCS:M*.c)
183 DIRDEPS+= ${C_DIRDEPS}
186 .if !empty(_SRCS:M*.cc) || !empty(_SRCS:M*.C) || !empty(_SRCS:M*.cpp) || \
188 DIRDEPS+= ${C_DIRDEPS}
189 .if ${MK_CLANG} == "yes"
190 DIRDEPS+= lib/libc++ lib/libcxxrt
192 # XXX: Clang and GCC always adds -lm currently, even when not needed.
195 .endif # !defined(KMOD)
197 .if !empty(_SRCS:M*.y)
198 DIRDEPS+= usr.bin/yacc.host
200 _DPADD= ${DPADD} ${_PROGS_DPADD}
202 # This only works for DPADD with full OBJ/SRC paths, which is mostly just
205 ${_DPADD:O:u:M${OBJTOP}*:H:N.:tA:C,${OBJTOP}[^/]*/,,:N.:O:u} \
206 ${_DPADD:O:u:M${OBJROOT}*:N${OBJTOP}*:N${STAGE_ROOT}/*:H:S,${OBJROOT},,:C,^([^/]+)/(.*),\2.\1,:S,${HOST_TARGET}$,host,:N.*:O:u}
207 # Resolve the paths to RELDIRs
208 .if !empty(_DP_DIRDEPS)
209 DIRDEPS+= ${_DP_DIRDEPS:C,^,${SRCTOP}/,:tA:C,^${SRCTOP}/,,}
211 .endif # !empty(DPADD)
212 _ALL_LIBADD= ${LIBADD} ${_PROGS_LIBADD}
213 .if !empty(_ALL_LIBADD)
214 # Also handle LIBADD for non-internal libraries.
215 .for _lib in ${_ALL_LIBADD:O:u}
216 _lib${_lib}reldir= ${LIB${_lib:tu}DIR:C,${OBJTOP}/,,}
217 .if defined(LIB${_lib:tu}DIR) && ${DIRDEPS:M${_lib${_lib}reldir}} == "" && \
218 exists(${SRCTOP}/${_lib${_lib}reldir})
219 DIRDEPS+= ${_lib${_lib}reldir}
222 .endif # !empty(LIBADD)
223 .endif # no Makefile.depend*
224 .endif # ${RELDIR} == ${DEP_RELDIR}
226 .endif # ${DEP_MACHINE} != "host"
228 .if ${MK_STAGING} == "yes"
229 # we need targets/pseudo/stage to prep the stage tree
230 .if ${DEP_RELDIR:N.:N${SRCTOP}:N*pseudo/stage} != ""
231 DIRDEPS += targets/pseudo/stage
235 DEP_MACHINE_ARCH = ${MACHINE_ARCH.${DEP_MACHINE}}
236 DEP_MACHINE_CPUARCH = ${DEP_MACHINE_ARCH:${__TO_CPUARCH}}
237 CSU_DIR.${DEP_MACHINE_ARCH} ?= csu/${DEP_MACHINE_ARCH}
238 CSU_DIR := ${CSU_DIR.${DEP_MACHINE_ARCH}}
239 BOOT_MACHINE_DIR:= ${BOOT_MACHINE_DIR.${DEP_MACHINE}}
240 KERNEL_NAME:= ${KERNEL_NAME.${DEP_MACHINE}}
242 .-include <site.dirdeps.mk>