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