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