1 .if !target(_DIRDEP_USE)
2 # we are the 1st makefile
5 .include "${SRCTOP}/share/mk/src.opts.mk"
8 # Machine-specific MK settings needed for Makefile.dirdeps.options usage
12 # making universe is special
13 .if defined(UNIVERSE_GUARD)
14 # these should be done by now
15 DIRDEPS_FILTER+= N*.host
18 # pseudo machines get no qualification
19 .for m in ${PSEUDO_MACHINE_LIST:Nhost*}
20 M_dep_qual_fixes += C;($m),[^/.,]*$$;\1;
22 #.info M_dep_qual_fixes=${M_dep_qual_fixes}
24 # Some things we never want to build for host
25 DIRDEPS_FILTER.host = \
36 .if ${.MAKE.OS} == "FreeBSD"
37 # Host libraries should mostly be excluded from the build so the
38 # host version in /usr/lib is used.
39 # Internal libraries need to be allowed to be built though
40 # since they are never installed.
42 # Cheat for including src.libnames.mk
44 # Pull in _INTERNALLIBS
45 .include <src.libnames.mk>
48 .for lib in ${_INTERNALLIBS}
49 _need_host_libs+= ${LIB${lib:tu}DIR:S,^${OBJTOP}/,,}
51 .if ${MK_host_egacy} == "yes"
52 _need_host_libs+= lib/libmd
55 N_host_libs:= ${cd ${SRCTOP} && echo lib/lib*:L:sh:${_need_host_libs:${M_ListToSkip}}:${M_ListToSkip}}
56 DIRDEPS_FILTER.host+= ${N_host_libs}
59 DIRDEPS_FILTER.host32 = ${DIRDEPS_FILTER.host}
63 ${DIRDEPS_FILTER.xtras:U}
65 # Cleanup a buildworld's WORLDTMP so that any files generated from it
66 # or using it will rebuild with the DIRDEPS SYSROOT. Otherwise existing
67 # object .meta files may still reference those directories and not be
68 # rebuilt and lead to incorrect Makefile.depend files due to lack of
70 .if !defined(NO_CLEANUP_WORLDTMP) && exists(${OBJTOP}/tmp/_worldtmp)
71 cleanup_worldtmp: .PHONY .NOMETA
72 @echo "Cleaning leftover WORLDTMP from buildworld."
73 -rm -rf ${OBJTOP}/tmp/*
74 -chflags -R 0 ${OBJTOP}/tmp/*
76 beforedirdeps: cleanup_worldtmp
79 # pseudo option for building host tools on old or non-FreeBSD host
80 # allows us to leverage Makefile.depend.options with
81 # DIRDEPS_OPTIONS = host_egacy
82 # dirdeps-options.mk will qualify with ${DEP_MACHINE} (and others)
83 # before looking at the bare option.
84 MK_host_egacy.host= ${MK_host_egacy}
86 .endif # !target(_DIRDEP_USE)
88 # reset this each time
90 .if ${DEP_MACHINE:Npkgs*} != ""
91 DIRDEPS_FILTER.xtras+= Nusr.bin/clang/clang.host
94 .if ${DEP_MACHINE:Nhost*} == ""
95 .if ${MK_host_egacy} == "yes" && ${DEP_RELDIR:Ntools/build:Ntargets/*:N*/stage} != ""
96 DIRDEPS += tools/build
99 MK_host_egacy.${DEP_MACHINE}= no
101 # this is how we can handle optional dependencies
102 .if ${DEP_RELDIR} == "lib/libc"
103 DIRDEPS += lib/libc_nonshared
104 .if ${MK_SSP:Uno} != "no"
105 DIRDEPS += lib/libssp_nonshared
108 DIRDEPS_FILTER.xtras+= Nlib/libc_nonshared
111 # some optional things
112 .if ${MK_CTF} == "yes" && ${DEP_RELDIR:Mcddl/usr.bin/ctf*} == ""
114 cddl/usr.bin/ctfconvert.host \
115 cddl/usr.bin/ctfmerge.host
118 .if ${DEP_MACHINE:Nhost*} != ""
119 # Add in proper libgcc (gnu or LLVM) if not building libcc and libc is needed.
120 # Add both gcc_s and gcc_eh as dependencies as the decision to build
121 # -static or not is not known here.
122 .if ${DEP_RELDIR:M*libgcc*} == "" && ${DIRDEPS:U:Mlib/libc} != ""
129 # Bootstrap support. Give hints to DIRDEPS if there is no Makefile.depend*
130 # generated yet. This can be based on things such as SRC files and LIBADD.
131 # These hints will not factor into the final Makefile.depend as only what is
132 # used will be added in and handled via [local.]gendirdeps.mk. This is not
133 # done for MACHINE=host builds.
134 # XXX: Include this in local.autodep.mk as well for gendirdeps without filemon.
135 # Only do this for main build target
136 .if ${RELDIR} == ${DEP_RELDIR} && !defined(_RECURSING_PROGS)
137 .for _depfile in ${.MAKE.DEPENDFILE_PREFERENCE:T}
138 .if !defined(_have_depfile) && exists(${.CURDIR}/${_depfile})
142 .if !defined(_have_depfile)
143 # KMOD does not use any stdlibs.
145 # Gather PROGS dependencies first
150 .for _prog in ${PROGS}
152 .if !empty(LIBADD${s}${_prog})
153 _PROGS_LIBADD+= ${LIBADD${s}${_prog}}
155 .if !empty(DPADD${s}${_prog})
156 _PROGS_DPADD+= ${DPADD${s}${_prog}}
158 .if !empty(SRCS${s}${_prog})
159 _PROGS_SRCS+= ${SRCS${s}${_prog}}
161 .endfor # .for s in . _
162 # Add in assumed source (bsd.prog.mk)
163 .if !target(${_prog})
164 .if defined(PROG_CXX)
165 _PROGS_SRCS+= ${_prog}.cc
167 _PROGS_SRCS+= ${_prog}.c
169 .endif # !target(${_prog})
170 .endfor # .for _prog in ${PROGS}
171 .endif # !empty(PROGS)
172 _SRCS= ${SRCS} ${_PROGS_SRCS}
174 # Has C files. The C_DIRDEPS are shared with C++ files as well.
186 # libgcc is needed as well but is added later.
188 .if ${MK_GSSAPI} != "no"
189 C_DIRDEPS+= include/gssapi
192 .if !empty(_SRCS:M*.c)
193 DIRDEPS+= ${C_DIRDEPS}
196 .if !empty(_SRCS:M*.cc) || !empty(_SRCS:M*.C) || !empty(_SRCS:M*.cpp) || \
198 DIRDEPS+= ${C_DIRDEPS}
199 .if ${MK_CLANG} == "yes"
200 DIRDEPS+= lib/libc++ lib/libcxxrt
202 # XXX: Clang and GCC always adds -lm currently, even when not needed.
205 .endif # !defined(KMOD)
207 .if !empty(_SRCS:M*.y)
208 DIRDEPS+= usr.bin/yacc.host
210 _DPADD= ${DPADD} ${_PROGS_DPADD}
212 # This only works for DPADD with full OBJ/SRC paths, which is mostly just
215 ${_DPADD:O:u:M${OBJTOP}*:H:N.:tA:C,${OBJTOP}[^/]*/,,:N.:O:u} \
216 ${_DPADD:O:u:M${OBJROOT}*:N${OBJTOP}*:N${STAGE_ROOT}/*:H:S,${OBJROOT},,:C,^([^/]+)/(.*),\2.\1,:S,${HOST_TARGET}$,host,:N.*:O:u}
217 # Resolve the paths to RELDIRs
218 .if !empty(_DP_DIRDEPS)
219 DIRDEPS+= ${_DP_DIRDEPS:C,^,${SRCTOP}/,:tA:C,^${SRCTOP}/,,}
221 .endif # !empty(DPADD)
222 _ALL_LIBADD= ${LIBADD} ${_PROGS_LIBADD}
223 .if !empty(_ALL_LIBADD)
224 # Also handle LIBADD for non-internal libraries.
225 .for _lib in ${_ALL_LIBADD:O:u}
226 _lib${_lib}reldir= ${LIB${_lib:tu}DIR:C,${OBJTOP}/,,}
227 .if defined(LIB${_lib:tu}DIR) && ${DIRDEPS:M${_lib${_lib}reldir}} == "" && \
228 exists(${SRCTOP}/${_lib${_lib}reldir})
229 DIRDEPS+= ${_lib${_lib}reldir}
232 .endif # !empty(LIBADD)
233 .endif # no Makefile.depend*
234 .endif # ${RELDIR} == ${DEP_RELDIR}
236 .endif # ${DEP_MACHINE} != "host"
238 .if ${MK_STAGING} == "yes"
239 # we need targets/pseudo/stage to prep the stage tree
240 .if ${DEP_RELDIR:N.:N${SRCTOP}:N*pseudo/stage} != ""
241 DIRDEPS += targets/pseudo/stage
245 DEP_MACHINE_ARCH = ${MACHINE_ARCH.${DEP_MACHINE}}
246 DEP_MACHINE_CPUARCH = ${DEP_MACHINE_ARCH:${__TO_CPUARCH}}
247 CSU_DIR.${DEP_MACHINE_ARCH} ?= csu/${DEP_MACHINE_ARCH}
248 CSU_DIR := ${CSU_DIR.${DEP_MACHINE_ARCH}}
249 BOOT_MACHINE_DIR:= ${BOOT_MACHINE_DIR.${DEP_MACHINE}}
250 KERNEL_NAME:= ${KERNEL_NAME.${DEP_MACHINE}}
252 .-include <site.dirdeps.mk>