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# making universe is special 10.if defined(UNIVERSE_GUARD) 11# these should be done by now 12DIRDEPS_FILTER+= N*.host 13.endif 14 15# pseudo machines get no qualification 16.for m in host common 17M_dep_qual_fixes += C;($m),[^/.,]*$$;\1; 18.endfor 19#.info M_dep_qual_fixes=${M_dep_qual_fixes} 20 21# Cheat for including src.libnames.mk 22__<bsd.init.mk>__: 23# Pull in _INTERNALLIBS 24.include <src.libnames.mk> 25 26# Host libraries should mostly be excluded from the build so the 27# host version in /usr/lib is used. Internal libraries need to be 28# allowed to be built though since they are never installed. 29_need_host_libs= 30.for lib in ${_INTERNALLIBS} 31_need_host_libs+= ${LIB${lib:tu}DIR:S,^${OBJTOP}/,,} 32.endfor 33 34N_host_libs:= ${cd ${SRCTOP} && echo lib/lib*:L:sh:${_need_host_libs:${M_ListToSkip}}:${M_ListToSkip}} 35DIRDEPS_FILTER.host = \ 36 ${N_host_libs} \ 37 Ninclude* \ 38 Nlib/csu* \ 39 Nlib/libc \ 40 Nlib/[mn]* \ 41 Ngnu/lib/csu* \ 42 Ngnu/lib/lib[a-r]* \ 43 Nsecure/lib* \ 44 Nusr.bin/xinstall* \ 45 46 47DIRDEPS_FILTER+= \ 48 Nbin/cat.host \ 49 ${DIRDEPS_FILTER.xtras:U} 50 51# Cleanup a buildworld's WORLDTMP so that any files generated from it 52# or using it will rebuild with the DIRDEPS SYSROOT. Otherwise existing 53# object .meta files may still reference those directories and not be 54# rebuilt and lead to incorrect Makefile.depend files due to lack of 55# .dirdep files. 56.if !defined(NO_CLEANUP_WORLDTMP) && exists(${OBJTOP}/tmp/_worldtmp) 57cleanup_worldtmp: .PHONY .NOMETA 58 @echo "Cleaning leftover WORLDTMP from buildworld." 59 -rm -rf ${OBJTOP}/tmp/* 60 -chflags -R 0 ${OBJTOP}/tmp/* 61 rm -rf ${OBJTOP}/tmp 62beforedirdeps: cleanup_worldtmp 63.endif 64.endif 65 66# reset this each time 67DIRDEPS_FILTER.xtras= 68.if ${DEP_MACHINE:Npkgs*} != "" 69DIRDEPS_FILTER.xtras+= Nusr.bin/clang/clang.host 70.endif 71 72.if ${DEP_MACHINE} != "host" 73 74# this is how we can handle optional dependencies 75.if ${DEP_RELDIR} == "lib/libc" 76DIRDEPS += lib/libc_nonshared 77.if ${MK_SSP:Uno} != "no" 78DIRDEPS += gnu/lib/libssp/libssp_nonshared 79.endif 80.else 81DIRDEPS_FILTER.xtras+= Nlib/libc_nonshared 82.endif 83 84# some optional things 85.if ${MK_CTF} == "yes" && ${DEP_RELDIR:Mcddl/usr.bin/ctf*} == "" 86DIRDEPS += \ 87 cddl/usr.bin/ctfconvert.host \ 88 cddl/usr.bin/ctfmerge.host 89.endif 90 91# Add in proper libgcc (gnu or LLVM) if not building libcc and libc is needed. 92# Add both gcc_s and gcc_eh as dependencies as the decision to build 93# -static or not is not known here. 94.if ${DEP_RELDIR:M*libgcc*} == "" && ${DIRDEPS:U:Mlib/libc} != "" 95.if ${MK_LLVM_LIBUNWIND} == "yes" 96DIRDEPS+= \ 97 lib/libgcc_eh \ 98 lib/libgcc_s 99.else 100DIRDEPS+= gnu/lib/libgcc 101.endif 102.endif 103 104# Bootstrap support. Give hints to DIRDEPS if there is no Makefile.depend* 105# generated yet. This can be based on things such as SRC files and LIBADD. 106# These hints will not factor into the final Makefile.depend as only what is 107# used will be added in and handled via [local.]gendirdeps.mk. This is not 108# done for MACHINE=host builds. 109# XXX: Include this in local.autodep.mk as well for gendirdeps without filemon. 110# Only do this for main build target 111.if ${RELDIR} == ${DEP_RELDIR} && !defined(_RECURSING_PROGS) 112.for _depfile in ${.MAKE.DEPENDFILE_PREFERENCE:T} 113.if !defined(_have_depfile) && exists(${.CURDIR}/${_depfile}) 114_have_depfile= 115.endif 116.endfor 117.if !defined(_have_depfile) 118# KMOD does not use any stdlibs. 119.if !defined(KMOD) 120# Gather PROGS dependencies first 121.if !empty(PROGS) 122_PROGS_LIBADD= 123_PROGS_DPADD= 124_PROGS_SRCS= 125.for _prog in ${PROGS} 126.for s in . _ 127.if !empty(LIBADD${s}${_prog}) 128_PROGS_LIBADD+= ${LIBADD${s}${_prog}} 129.endif 130.if !empty(DPADD${s}${_prog}) 131_PROGS_DPADD+= ${DPADD${s}${_prog}} 132.endif 133.if !empty(SRCS${s}${_prog}) 134_PROGS_SRCS+= ${SRCS${s}${_prog}} 135.endif 136.endfor # .for s in . _ 137# Add in assumed source (bsd.prog.mk) 138.if !target(${_prog}) 139.if defined(PROG_CXX) 140_PROGS_SRCS+= ${_prog}.cc 141.else 142_PROGS_SRCS+= ${_prog}.c 143.endif 144.endif # !target(${_prog}) 145.endfor # .for _prog in ${PROGS} 146.endif # !empty(PROGS) 147_SRCS= ${SRCS} ${_PROGS_SRCS} 148 149# Has C files. The C_DIRDEPS are shared with C++ files as well. 150C_DIRDEPS= \ 151 include \ 152 include/arpa \ 153 include/protocols \ 154 include/rpc \ 155 include/rpcsvc \ 156 include/xlocale \ 157 lib/${CSU_DIR} \ 158 lib/libc \ 159 lib/libcompiler_rt \ 160 161# libgcc is needed as well but is added later. 162 163.if ${MK_GSSAPI} != "no" 164C_DIRDEPS+= include/gssapi 165.endif 166 167.if !empty(_SRCS:M*.c) 168DIRDEPS+= ${C_DIRDEPS} 169.endif 170# Has C++ files 171.if !empty(_SRCS:M*.cc) || !empty(_SRCS:M*.C) || !empty(_SRCS:M*.cpp) || \ 172 !empty(_SRCS:M*.cxx) 173DIRDEPS+= ${C_DIRDEPS} 174.if ${MK_CLANG} == "yes" 175DIRDEPS+= lib/libc++ lib/libcxxrt 176.else 177DIRDEPS+= gnu/lib/libstdc++ gnu/lib/libsupc++ 178.endif 179# XXX: Clang and GCC always adds -lm currently, even when not needed. 180DIRDEPS+= lib/msun 181.endif # CXX 182.endif # !defined(KMOD) 183# Has yacc files. 184.if !empty(_SRCS:M*.y) 185DIRDEPS+= usr.bin/yacc.host 186.endif 187_DPADD= ${DPADD} ${_PROGS_DPADD} 188.if !empty(_DPADD) 189# Taken from meta.autodep.mk (where it only does something with 190# BUILD_AT_LEVEL0, which we don't use). 191# This only works for DPADD with full OBJ/SRC paths, which is mostly just 192# _INTERNALLIBS. 193_DP_DIRDEPS= \ 194 ${_DPADD:O:u:M${OBJTOP}*:H:N.:tA:C,${OBJTOP}[^/]*/,,:N.:O:u} \ 195 ${_DPADD:O:u:M${OBJROOT}*:N${OBJTOP}*:N${STAGE_ROOT}/*:H:S,${OBJROOT},,:C,^([^/]+)/(.*),\2.\1,:S,${HOST_TARGET}$,host,:N.*:O:u} 196# Resolve the paths to RELDIRs 197.if !empty(_DP_DIRDEPS) 198DIRDEPS+= ${_DP_DIRDEPS:C,^,${SRCTOP}/,:tA:C,^${SRCTOP}/,,} 199.endif 200.endif # !empty(DPADD) 201_ALL_LIBADD= ${LIBADD} ${_PROGS_LIBADD} 202.if !empty(_ALL_LIBADD) 203# Also handle LIBADD for non-internal libraries. 204.for _lib in ${_ALL_LIBADD:O:u} 205_lib${_lib}reldir= ${LIB${_lib:tu}DIR:C,${OBJTOP}/,,} 206.if defined(LIB${_lib:tu}DIR) && ${DIRDEPS:M${_lib${_lib}reldir}} == "" && \ 207 exists(${SRCTOP}/${_lib${_lib}reldir}) 208DIRDEPS+= ${_lib${_lib}reldir} 209.endif 210.endfor 211.endif # !empty(LIBADD) 212.endif # no Makefile.depend* 213.endif # ${RELDIR} == ${DEP_RELDIR} 214 215.endif # ${DEP_MACHINE} != "host" 216 217.if ${MK_STAGING} == "yes" 218# we need targets/pseudo/stage to prep the stage tree 219.if ${DEP_RELDIR} != "targets/pseudo/stage" 220DIRDEPS += targets/pseudo/stage 221.endif 222.endif 223 224# this one is too pervasive 225.if ${MK_BSD_CRTBEGIN} == "no" && ${DEP_RELDIR:N.:Ngnu/lib/csu:Ninclude*:Ntargets/*} != "" 226DIRDEPS+= gnu/lib/csu 227.endif 228 229DEP_MACHINE_ARCH = ${MACHINE_ARCH.${DEP_MACHINE}} 230CSU_DIR.${DEP_MACHINE_ARCH} ?= csu/${DEP_MACHINE_ARCH} 231CSU_DIR := ${CSU_DIR.${DEP_MACHINE_ARCH}} 232BOOT_MACHINE_DIR:= ${BOOT_MACHINE_DIR.${DEP_MACHINE}} 233KERNEL_NAME:= ${KERNEL_NAME.${DEP_MACHINE}} 234