]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - share/mk/local.dirdeps.mk
Merge branch 'releng/11.3' into releng-CDN/11.3
[FreeBSD/FreeBSD.git] / share / mk / local.dirdeps.mk
1 # $FreeBSD$
2 .if !target(_DIRDEP_USE)
3 # we are the 1st makefile
4
5 .if !defined(MK_CLANG)
6 .include "${SRCTOP}/share/mk/src.opts.mk"
7 .endif
8
9 # DEP_MACHINE is set before we get here, this may not be.
10 DEP_RELDIR ?= ${RELDIR}
11
12 # making universe is special
13 .if defined(UNIVERSE_GUARD)
14 # these should be done by now
15 DIRDEPS_FILTER+= N*.host
16 .endif
17
18 # pseudo machines get no qualification
19 .for m in host common
20 M_dep_qual_fixes += C;($m),[^/.,]*$$;\1;
21 .endfor
22 #.info M_dep_qual_fixes=${M_dep_qual_fixes}
23
24 # Cheat for including src.libnames.mk
25 __<bsd.init.mk>__:
26 # Pull in _INTERNALLIBS
27 .include <src.libnames.mk>
28
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.
32 _need_host_libs=
33 .for lib in ${_INTERNALLIBS}
34 _need_host_libs+= ${LIB${lib:tu}DIR:S,^${OBJTOP}/,,}
35 .endfor
36
37 N_host_libs:= ${cd ${SRCTOP} && echo lib/lib*:L:sh:${_need_host_libs:${M_ListToSkip}}:${M_ListToSkip}}
38 DIRDEPS_FILTER.host = \
39         ${N_host_libs} \
40         Ninclude* \
41         Nlib/csu* \
42         Nlib/[mn]* \
43         Ngnu/lib/csu* \
44         Ngnu/lib/lib[a-r]* \
45         Nsecure/lib* \
46         Nusr.bin/xinstall* \
47
48
49 DIRDEPS_FILTER+= \
50         Nbin/cat.host \
51         ${DIRDEPS_FILTER.xtras:U}
52 .endif
53
54 # reset this each time
55 DIRDEPS_FILTER.xtras=
56 .if ${DEP_MACHINE:Npkgs*} != ""
57 DIRDEPS_FILTER.xtras+= Nusr.bin/clang/clang.host
58 .endif
59
60 .if ${DEP_MACHINE} != "host"
61
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
67 .endif
68 .else
69 DIRDEPS_FILTER.xtras+= Nlib/libc_nonshared
70 .endif
71
72 # some optional things
73 .if ${MK_CTF} == "yes" && ${DEP_RELDIR:Mcddl/usr.bin/ctf*} == ""
74 DIRDEPS += \
75         cddl/usr.bin/ctfconvert.host \
76         cddl/usr.bin/ctfmerge.host
77 .endif
78
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})
89 _have_depfile=
90 .endif
91 .endfor
92 .if !defined(_have_depfile)
93 # KMOD does not use any stdlibs.
94 .if !defined(KMOD)
95 # Gather PROGS dependencies first
96 .if !empty(PROGS)
97 _PROGS_LIBADD=
98 _PROGS_DPADD=
99 _PROGS_SRCS=
100 .for _prog in ${PROGS}
101 .for s in . _
102 .if !empty(LIBADD${s}${_prog})
103 _PROGS_LIBADD+= ${LIBADD${s}${_prog}}
104 .endif
105 .if !empty(DPADD${s}${_prog})
106 _PROGS_DPADD+=  ${DPADD${s}${_prog}}
107 .endif
108 .if !empty(SRCS${s}${_prog})
109 _PROGS_SRCS+=   ${SRCS${s}${_prog}}
110 .endif
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
116 .else
117 _PROGS_SRCS+=   ${_prog}.c
118 .endif
119 .endif  # !target(${_prog})
120 .endfor # .for _prog in ${PROGS}
121 .endif  # !empty(PROGS)
122 _SRCS= ${SRCS} ${_PROGS_SRCS}
123
124 # Has C files. The C_DIRDEPS are shared with C++ files as well.
125 C_DIRDEPS= \
126         gnu/lib/csu \
127         gnu/lib/libgcc \
128         include \
129         include/arpa \
130         include/protocols \
131         include/rpc  \
132         include/rpcsvc \
133         include/xlocale \
134         lib/${CSU_DIR} \
135         lib/libc \
136         lib/libcompiler_rt \
137
138
139 .if ${MK_GSSAPI} != "no"
140 C_DIRDEPS+=  include/gssapi
141 .endif
142
143 .if !empty(_SRCS:M*.c)
144 DIRDEPS+= ${C_DIRDEPS}
145 .endif
146 # Has C++ files
147 .if !empty(_SRCS:M*.cc) || !empty(_SRCS:M*.C) || !empty(_SRCS:M*.cpp) || \
148     !empty(_SRCS:M*.cxx)
149 DIRDEPS+= ${C_DIRDEPS}
150 .if ${MK_CLANG} == "yes"
151 DIRDEPS+= lib/libc++ lib/libcxxrt
152 .else
153 DIRDEPS+= gnu/lib/libstdc++ gnu/lib/libsupc++
154 .endif
155 # XXX: Clang and GCC always adds -lm currently, even when not needed.
156 DIRDEPS+= lib/msun
157 .endif  # CXX
158 .endif  # !defined(KMOD)
159 # Has yacc files.
160 .if !empty(_SRCS:M*.y)
161 DIRDEPS+=       usr.bin/yacc.host
162 .endif
163 _DPADD= ${DPADD} ${_PROGS_DPADD}
164 .if !empty(_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
168 # _INTERNALLIBS.
169 _DP_DIRDEPS= \
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}/,,}
175 .endif
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}
185 .endif
186 .endfor
187 .endif  # !empty(LIBADD)
188 .endif  # no Makefile.depend*
189 .endif  # ${RELDIR} == ${DEP_RELDIR}
190
191 .endif  # ${DEP_MACHINE} != "host"
192
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
197 .endif
198 .endif
199
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}}