2 .if !target(_DIRDEP_USE)
3 # we are the 1st makefile
6 .include "${SRCTOP}/share/mk/src.opts.mk"
9 # DEP_MACHINE is set before we get here, this may not be.
10 DEP_RELDIR ?= ${RELDIR}
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
20 M_dep_qual_fixes += C;($m),[^/.,]*$$;\1;
22 #.info M_dep_qual_fixes=${M_dep_qual_fixes}
24 # Cheat for including src.libnames.mk
26 # Pull in _INTERNALLIBS
27 .include <src.libnames.mk>
29 # Host libraries should mostly be excluded from the build so the
30 # host version in /usr/lib is used. Internal libraries need to be
31 # allowed to be built though since they are never installed.
33 .for lib in ${_INTERNALLIBS}
34 _need_host_libs+= ${LIB${lib:tu}DIR:S,^${OBJTOP}/,,}
37 N_host_libs:= ${cd ${SRCTOP} && echo lib/lib*:L:sh:${_need_host_libs:${M_ListToSkip}}:${M_ListToSkip}}
38 DIRDEPS_FILTER.host = \
51 ${DIRDEPS_FILTER.xtras:U}
54 # reset this each time
56 .if ${DEP_MACHINE:Npkgs*} != ""
57 DIRDEPS_FILTER.xtras+= Nusr.bin/clang/clang.host
60 .if ${DEP_MACHINE} != "host"
62 # this is how we can handle optional dependencies
63 .if ${DEP_RELDIR} == "lib/libc"
64 DIRDEPS += lib/libc_nonshared
65 .if ${MK_SSP:Uno} != "no"
66 DIRDEPS += gnu/lib/libssp/libssp_nonshared
69 DIRDEPS_FILTER.xtras+= Nlib/libc_nonshared
72 # some optional things
73 .if ${MK_CTF} == "yes" && ${DEP_RELDIR:Mcddl/usr.bin/ctf*} == ""
75 cddl/usr.bin/ctfconvert.host \
76 cddl/usr.bin/ctfmerge.host
79 # Add in proper libgcc (gnu or LLVM) if not building libcc and libc is needed.
80 # Add both gcc_s and gcc_eh as dependencies as the decision to build
81 # -static or not is not known here.
82 .if ${DEP_RELDIR:M*libgcc*} == "" && ${DIRDEPS:Mlib/libc}
83 .if ${MK_LLVM_LIBUNWIND} == "yes"
88 DIRDEPS+= gnu/lib/libgcc
92 # Bootstrap support. Give hints to DIRDEPS if there is no Makefile.depend*
93 # generated yet. This can be based on things such as SRC files and LIBADD.
94 # These hints will not factor into the final Makefile.depend as only what is
95 # used will be added in and handled via [local.]gendirdeps.mk. This is not
96 # done for MACHINE=host builds.
97 # XXX: Include this in local.autodep.mk as well for gendirdeps without filemon.
98 # Only do this for main build target
99 .if ${RELDIR} == ${DEP_RELDIR} && !defined(_RECURSING_PROGS)
100 .for _depfile in ${.MAKE.DEPENDFILE_PREFERENCE:T}
101 .if !defined(_have_depfile) && exists(${.CURDIR}/${_depfile})
105 .if !defined(_have_depfile)
106 # KMOD does not use any stdlibs.
108 # Gather PROGS dependencies first
113 .for _prog in ${PROGS}
115 .if !empty(LIBADD${s}${_prog})
116 _PROGS_LIBADD+= ${LIBADD${s}${_prog}}
118 .if !empty(DPADD${s}${_prog})
119 _PROGS_DPADD+= ${DPADD${s}${_prog}}
121 .if !empty(SRCS${s}${_prog})
122 _PROGS_SRCS+= ${SRCS${s}${_prog}}
124 .endfor # .for s in . _
125 # Add in assumed source (bsd.prog.mk)
126 .if !target(${_prog})
127 .if defined(PROG_CXX)
128 _PROGS_SRCS+= ${_prog}.cc
130 _PROGS_SRCS+= ${_prog}.c
132 .endif # !target(${_prog})
133 .endfor # .for _prog in ${PROGS}
134 .endif # !empty(PROGS)
135 _SRCS= ${SRCS} ${_PROGS_SRCS}
137 # Has C files. The C_DIRDEPS are shared with C++ files as well.
150 # libgcc is needed as well but is added later.
152 .if ${MK_GSSAPI} != "no"
153 C_DIRDEPS+= include/gssapi
156 .if !empty(_SRCS:M*.c)
157 DIRDEPS+= ${C_DIRDEPS}
160 .if !empty(_SRCS:M*.cc) || !empty(_SRCS:M*.C) || !empty(_SRCS:M*.cpp) || \
162 DIRDEPS+= ${C_DIRDEPS}
163 .if ${MK_CLANG} == "yes"
164 DIRDEPS+= lib/libc++ lib/libcxxrt
166 DIRDEPS+= gnu/lib/libstdc++ gnu/lib/libsupc++
168 # XXX: Clang and GCC always adds -lm currently, even when not needed.
171 .endif # !defined(KMOD)
173 .if !empty(_SRCS:M*.y)
174 DIRDEPS+= usr.bin/yacc.host
176 _DPADD= ${DPADD} ${_PROGS_DPADD}
178 # Taken from meta.autodep.mk (where it only does something with
179 # BUILD_AT_LEVEL0, which we don't use).
180 # This only works for DPADD with full OBJ/SRC paths, which is mostly just
183 ${_DPADD:O:u:M${OBJTOP}*:H:N.:tA:C,${OBJTOP}[^/]*/,,:N.:O:u} \
184 ${_DPADD:O:u:M${OBJROOT}*:N${OBJTOP}*:N${STAGE_ROOT}/*:H:S,${OBJROOT},,:C,^([^/]+)/(.*),\2.\1,:S,${HOST_TARGET}$,host,:N.*:O:u}
185 # Resolve the paths to RELDIRs
186 .if !empty(_DP_DIRDEPS)
187 DIRDEPS+= ${_DP_DIRDEPS:C,^,${SRCTOP}/,:tA:C,^${SRCTOP}/,,}
189 .endif # !empty(DPADD)
190 _ALL_LIBADD= ${LIBADD} ${_PROGS_LIBADD}
191 .if !empty(_ALL_LIBADD)
192 # Also handle LIBADD for non-internal libraries.
193 .for _lib in ${_ALL_LIBADD:O:u}
194 _lib${_lib}reldir= ${LIB${_lib:tu}DIR:C,${OBJTOP}/,,}
195 .if defined(LIB${_lib:tu}DIR) && ${DIRDEPS:M${_lib${_lib}reldir}} == "" && \
196 exists(${SRCTOP}/${_lib${_lib}reldir})
197 DIRDEPS+= ${_lib${_lib}reldir}
200 .endif # !empty(LIBADD)
201 .endif # no Makefile.depend*
202 .endif # ${RELDIR} == ${DEP_RELDIR}
204 .endif # ${DEP_MACHINE} != "host"
206 .if ${MK_STAGING} == "yes"
207 # we need targets/pseudo/stage to prep the stage tree
208 .if ${DEP_RELDIR} != "targets/pseudo/stage"
209 DIRDEPS += targets/pseudo/stage
213 DEP_MACHINE_ARCH = ${MACHINE_ARCH.${DEP_MACHINE}}
214 CSU_DIR.${DEP_MACHINE_ARCH} ?= csu/${DEP_MACHINE_ARCH}
215 CSU_DIR := ${CSU_DIR.${DEP_MACHINE_ARCH}}
216 BOOT_MACHINE_DIR:= ${BOOT_MACHINE_DIR.${DEP_MACHINE}}
217 KERNEL_NAME:= ${KERNEL_NAME.${DEP_MACHINE}}