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# 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} != "host" 88MK_host_egacy.${DEP_MACHINE}= no 89 90# this is how we can handle optional dependencies 91.if ${DEP_RELDIR} == "lib/libc" 92DIRDEPS += lib/libc_nonshared 93.if ${MK_SSP:Uno} != "no" 94DIRDEPS += lib/libssp_nonshared 95.endif 96.else 97DIRDEPS_FILTER.xtras+= Nlib/libc_nonshared 98.endif 99 100# some optional things 101.if ${MK_CTF} == "yes" && ${DEP_RELDIR:Mcddl/usr.bin/ctf*} == "" 102DIRDEPS += \ 103 cddl/usr.bin/ctfconvert.host \ 104 cddl/usr.bin/ctfmerge.host 105.endif 106 107# Add in proper libgcc (gnu or LLVM) if not building libcc and libc is needed. 108# Add both gcc_s and gcc_eh as dependencies as the decision to build 109# -static or not is not known here. 110.if ${DEP_RELDIR:M*libgcc*} == "" && ${DIRDEPS:U:Mlib/libc} != "" 111DIRDEPS+= \ 112 lib/libgcc_eh \ 113 lib/libgcc_s 114.endif 115 116# Bootstrap support. Give hints to DIRDEPS if there is no Makefile.depend* 117# generated yet. This can be based on things such as SRC files and LIBADD. 118# These hints will not factor into the final Makefile.depend as only what is 119# used will be added in and handled via [local.]gendirdeps.mk. This is not 120# done for MACHINE=host builds. 121# XXX: Include this in local.autodep.mk as well for gendirdeps without filemon. 122# Only do this for main build target 123.if ${RELDIR} == ${DEP_RELDIR} && !defined(_RECURSING_PROGS) 124.for _depfile in ${.MAKE.DEPENDFILE_PREFERENCE:T} 125.if !defined(_have_depfile) && exists(${.CURDIR}/${_depfile}) 126_have_depfile= 127.endif 128.endfor 129.if !defined(_have_depfile) 130# KMOD does not use any stdlibs. 131.if !defined(KMOD) 132# Gather PROGS dependencies first 133.if !empty(PROGS) 134_PROGS_LIBADD= 135_PROGS_DPADD= 136_PROGS_SRCS= 137.for _prog in ${PROGS} 138.for s in . _ 139.if !empty(LIBADD${s}${_prog}) 140_PROGS_LIBADD+= ${LIBADD${s}${_prog}} 141.endif 142.if !empty(DPADD${s}${_prog}) 143_PROGS_DPADD+= ${DPADD${s}${_prog}} 144.endif 145.if !empty(SRCS${s}${_prog}) 146_PROGS_SRCS+= ${SRCS${s}${_prog}} 147.endif 148.endfor # .for s in . _ 149# Add in assumed source (bsd.prog.mk) 150.if !target(${_prog}) 151.if defined(PROG_CXX) 152_PROGS_SRCS+= ${_prog}.cc 153.else 154_PROGS_SRCS+= ${_prog}.c 155.endif 156.endif # !target(${_prog}) 157.endfor # .for _prog in ${PROGS} 158.endif # !empty(PROGS) 159_SRCS= ${SRCS} ${_PROGS_SRCS} 160 161# Has C files. The C_DIRDEPS are shared with C++ files as well. 162C_DIRDEPS= \ 163 include \ 164 include/arpa \ 165 include/protocols \ 166 include/rpc \ 167 include/rpcsvc \ 168 include/xlocale \ 169 lib/${CSU_DIR} \ 170 lib/libc \ 171 lib/libcompiler_rt \ 172 173# libgcc is needed as well but is added later. 174 175.if ${MK_GSSAPI} != "no" 176C_DIRDEPS+= include/gssapi 177.endif 178 179.if !empty(_SRCS:M*.c) 180DIRDEPS+= ${C_DIRDEPS} 181.endif 182# Has C++ files 183.if !empty(_SRCS:M*.cc) || !empty(_SRCS:M*.C) || !empty(_SRCS:M*.cpp) || \ 184 !empty(_SRCS:M*.cxx) 185DIRDEPS+= ${C_DIRDEPS} 186.if ${MK_CLANG} == "yes" 187DIRDEPS+= lib/libc++ lib/libcxxrt 188.endif 189# XXX: Clang and GCC always adds -lm currently, even when not needed. 190DIRDEPS+= lib/msun 191.endif # CXX 192.endif # !defined(KMOD) 193# Has yacc files. 194.if !empty(_SRCS:M*.y) 195DIRDEPS+= usr.bin/yacc.host 196.endif 197_DPADD= ${DPADD} ${_PROGS_DPADD} 198.if !empty(_DPADD) 199# This only works for DPADD with full OBJ/SRC paths, which is mostly just 200# _INTERNALLIBS. 201_DP_DIRDEPS= \ 202 ${_DPADD:O:u:M${OBJTOP}*:H:N.:tA:C,${OBJTOP}[^/]*/,,:N.:O:u} \ 203 ${_DPADD:O:u:M${OBJROOT}*:N${OBJTOP}*:N${STAGE_ROOT}/*:H:S,${OBJROOT},,:C,^([^/]+)/(.*),\2.\1,:S,${HOST_TARGET}$,host,:N.*:O:u} 204# Resolve the paths to RELDIRs 205.if !empty(_DP_DIRDEPS) 206DIRDEPS+= ${_DP_DIRDEPS:C,^,${SRCTOP}/,:tA:C,^${SRCTOP}/,,} 207.endif 208.endif # !empty(DPADD) 209_ALL_LIBADD= ${LIBADD} ${_PROGS_LIBADD} 210.if !empty(_ALL_LIBADD) 211# Also handle LIBADD for non-internal libraries. 212.for _lib in ${_ALL_LIBADD:O:u} 213_lib${_lib}reldir= ${LIB${_lib:tu}DIR:C,${OBJTOP}/,,} 214.if defined(LIB${_lib:tu}DIR) && ${DIRDEPS:M${_lib${_lib}reldir}} == "" && \ 215 exists(${SRCTOP}/${_lib${_lib}reldir}) 216DIRDEPS+= ${_lib${_lib}reldir} 217.endif 218.endfor 219.endif # !empty(LIBADD) 220.endif # no Makefile.depend* 221.endif # ${RELDIR} == ${DEP_RELDIR} 222 223.endif # ${DEP_MACHINE} != "host" 224 225.if ${MK_STAGING} == "yes" 226# we need targets/pseudo/stage to prep the stage tree 227.if ${DEP_RELDIR:N.:N${SRCTOP}:N*pseudo/stage} != "" 228DIRDEPS += targets/pseudo/stage 229.endif 230.endif 231 232DEP_MACHINE_ARCH = ${MACHINE_ARCH.${DEP_MACHINE}} 233DEP_MACHINE_CPUARCH = ${DEP_MACHINE_ARCH:${__TO_CPUARCH}} 234CSU_DIR.${DEP_MACHINE_ARCH} ?= csu/${DEP_MACHINE_ARCH} 235CSU_DIR := ${CSU_DIR.${DEP_MACHINE_ARCH}} 236BOOT_MACHINE_DIR:= ${BOOT_MACHINE_DIR.${DEP_MACHINE}} 237KERNEL_NAME:= ${KERNEL_NAME.${DEP_MACHINE}} 238 239.-include <site.dirdeps.mk> 240