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 # Bootstrap support. Give hints to DIRDEPS if there is no Makefile.depend*
80 # generated yet. This can be based on things such as SRC files and LIBADD.
81 # These hints will not factor into the final Makefile.depend as only what is
82 # used will be added in and handled via [local.]gendirdeps.mk. This is not
83 # done for MACHINE=host builds.
84 # XXX: Include this in local.autodep.mk as well for gendirdeps without filemon.
85 # Only do this for main build target
86 .if ${RELDIR} == ${DEP_RELDIR} && !defined(_RECURSING_PROGS)
87 .for _depfile in ${.MAKE.DEPENDFILE_PREFERENCE:T}
88 .if !defined(_have_depfile) && exists(${.CURDIR}/${_depfile})
92 .if !defined(_have_depfile)
93 # KMOD does not use any stdlibs.
95 # Gather PROGS dependencies first
100 .for _prog in ${PROGS}
102 .if !empty(LIBADD${s}${_prog})
103 _PROGS_LIBADD+= ${LIBADD${s}${_prog}}
105 .if !empty(DPADD${s}${_prog})
106 _PROGS_DPADD+= ${DPADD${s}${_prog}}
108 .if !empty(SRCS${s}${_prog})
109 _PROGS_SRCS+= ${SRCS${s}${_prog}}
111 .endfor # .for s in . _
112 # Add in assumed source (bsd.prog.mk)
113 .if !target(${_prog})
114 .if defined(PROG_CXX)
115 _PROGS_SRCS+= ${_prog}.cc
117 _PROGS_SRCS+= ${_prog}.c
119 .endif # !target(${_prog})
120 .endfor # .for _prog in ${PROGS}
121 .endif # !empty(PROGS)
122 _SRCS= ${SRCS} ${_PROGS_SRCS}
124 # Has C files. The C_DIRDEPS are shared with C++ files as well.
139 .if ${MK_GSSAPI} != "no"
140 C_DIRDEPS+= include/gssapi
143 .if !empty(_SRCS:M*.c)
144 DIRDEPS+= ${C_DIRDEPS}
147 .if !empty(_SRCS:M*.cc) || !empty(_SRCS:M*.C) || !empty(_SRCS:M*.cpp) || \
149 DIRDEPS+= ${C_DIRDEPS}
150 .if ${MK_CLANG} == "yes"
151 DIRDEPS+= lib/libc++ lib/libcxxrt
153 DIRDEPS+= gnu/lib/libstdc++ gnu/lib/libsupc++
155 # XXX: Clang and GCC always adds -lm currently, even when not needed.
158 .endif # !defined(KMOD)
160 .if !empty(_SRCS:M*.y)
161 DIRDEPS+= usr.bin/yacc.host
163 _DPADD= ${DPADD} ${_PROGS_DPADD}
165 # Taken from meta.autodep.mk (where it only does something with
166 # BUILD_AT_LEVEL0, which we don't use).
167 # This only works for DPADD with full OBJ/SRC paths, which is mostly just
170 ${_DPADD:O:u:M${OBJTOP}*:H:N.:tA:C,${OBJTOP}[^/]*/,,:N.:O:u} \
171 ${_DPADD:O:u:M${OBJROOT}*:N${OBJTOP}*:N${STAGE_ROOT}/*:H:S,${OBJROOT},,:C,^([^/]+)/(.*),\2.\1,:S,${HOST_TARGET}$,host,:N.*:O:u}
172 # Resolve the paths to RELDIRs
173 .if !empty(_DP_DIRDEPS)
174 DIRDEPS+= ${_DP_DIRDEPS:C,^,${SRCTOP}/,:tA:C,^${SRCTOP}/,,}
176 .endif # !empty(DPADD)
177 _ALL_LIBADD= ${LIBADD} ${_PROGS_LIBADD}
178 .if !empty(_ALL_LIBADD)
179 # Also handle LIBADD for non-internal libraries.
180 .for _lib in ${_ALL_LIBADD:O:u}
181 _lib${_lib}reldir= ${LIB${_lib:tu}DIR:C,${OBJTOP}/,,}
182 .if defined(LIB${_lib:tu}DIR) && ${DIRDEPS:M${_lib${_lib}reldir}} == "" && \
183 exists(${SRCTOP}/${_lib${_lib}reldir})
184 DIRDEPS+= ${_lib${_lib}reldir}
187 .endif # !empty(LIBADD)
188 .endif # no Makefile.depend*
189 .endif # ${RELDIR} == ${DEP_RELDIR}
191 .endif # ${DEP_MACHINE} != "host"
193 .if ${MK_STAGING} == "yes"
194 # we need targets/pseudo/stage to prep the stage tree
195 .if ${DEP_RELDIR} != "targets/pseudo/stage"
196 DIRDEPS += targets/pseudo/stage
200 DEP_MACHINE_ARCH = ${MACHINE_ARCH.${DEP_MACHINE}}
201 CSU_DIR.${DEP_MACHINE_ARCH} ?= csu/${DEP_MACHINE_ARCH}
202 CSU_DIR := ${CSU_DIR.${DEP_MACHINE_ARCH}}
203 BOOT_MACHINE_DIR:= ${BOOT_MACHINE_DIR.${DEP_MACHINE}}
204 KERNEL_NAME:= ${KERNEL_NAME.${DEP_MACHINE}}