]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - share/mk/local.dirdeps.mk
Don't propagate MAKEOBJDIRPREFIX changes to environment.
[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 # 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"
84 DIRDEPS+= \
85         lib/libgcc_eh \
86         lib/libgcc_s
87 .else
88 DIRDEPS+= gnu/lib/libgcc
89 .endif
90 .endif
91
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})
102 _have_depfile=
103 .endif
104 .endfor
105 .if !defined(_have_depfile)
106 # KMOD does not use any stdlibs.
107 .if !defined(KMOD)
108 # Gather PROGS dependencies first
109 .if !empty(PROGS)
110 _PROGS_LIBADD=
111 _PROGS_DPADD=
112 _PROGS_SRCS=
113 .for _prog in ${PROGS}
114 .for s in . _
115 .if !empty(LIBADD${s}${_prog})
116 _PROGS_LIBADD+= ${LIBADD${s}${_prog}}
117 .endif
118 .if !empty(DPADD${s}${_prog})
119 _PROGS_DPADD+=  ${DPADD${s}${_prog}}
120 .endif
121 .if !empty(SRCS${s}${_prog})
122 _PROGS_SRCS+=   ${SRCS${s}${_prog}}
123 .endif
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
129 .else
130 _PROGS_SRCS+=   ${_prog}.c
131 .endif
132 .endif  # !target(${_prog})
133 .endfor # .for _prog in ${PROGS}
134 .endif  # !empty(PROGS)
135 _SRCS= ${SRCS} ${_PROGS_SRCS}
136
137 # Has C files. The C_DIRDEPS are shared with C++ files as well.
138 C_DIRDEPS= \
139         gnu/lib/csu \
140         include \
141         include/arpa \
142         include/protocols \
143         include/rpc  \
144         include/rpcsvc \
145         include/xlocale \
146         lib/${CSU_DIR} \
147         lib/libc \
148         lib/libcompiler_rt \
149
150 # libgcc is needed as well but is added later.
151
152 .if ${MK_GSSAPI} != "no"
153 C_DIRDEPS+=  include/gssapi
154 .endif
155
156 .if !empty(_SRCS:M*.c)
157 DIRDEPS+= ${C_DIRDEPS}
158 .endif
159 # Has C++ files
160 .if !empty(_SRCS:M*.cc) || !empty(_SRCS:M*.C) || !empty(_SRCS:M*.cpp) || \
161     !empty(_SRCS:M*.cxx)
162 DIRDEPS+= ${C_DIRDEPS}
163 .if ${MK_CLANG} == "yes"
164 DIRDEPS+= lib/libc++ lib/libcxxrt
165 .else
166 DIRDEPS+= gnu/lib/libstdc++ gnu/lib/libsupc++
167 .endif
168 # XXX: Clang and GCC always adds -lm currently, even when not needed.
169 DIRDEPS+= lib/msun
170 .endif  # CXX
171 .endif  # !defined(KMOD)
172 # Has yacc files.
173 .if !empty(_SRCS:M*.y)
174 DIRDEPS+=       usr.bin/yacc.host
175 .endif
176 _DPADD= ${DPADD} ${_PROGS_DPADD}
177 .if !empty(_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
181 # _INTERNALLIBS.
182 _DP_DIRDEPS= \
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}/,,}
188 .endif
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}
198 .endif
199 .endfor
200 .endif  # !empty(LIBADD)
201 .endif  # no Makefile.depend*
202 .endif  # ${RELDIR} == ${DEP_RELDIR}
203
204 .endif  # ${DEP_MACHINE} != "host"
205
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
210 .endif
211 .endif
212
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}}