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/lib[a-r]* \ 42 Nsecure/lib* \ 43 Nusr.bin/xinstall* \ 44 45 46DIRDEPS_FILTER+= \ 47 Nbin/cat.host \ 48 ${DIRDEPS_FILTER.xtras:U} 49 50# Cleanup a buildworld's WORLDTMP so that any files generated from it 51# or using it will rebuild with the DIRDEPS SYSROOT. Otherwise existing 52# object .meta files may still reference those directories and not be 53# rebuilt and lead to incorrect Makefile.depend files due to lack of 54# .dirdep files. 55.if !defined(NO_CLEANUP_WORLDTMP) && exists(${OBJTOP}/tmp/_worldtmp) 56cleanup_worldtmp: .PHONY .NOMETA 57 @echo "Cleaning leftover WORLDTMP from buildworld." 58 -rm -rf ${OBJTOP}/tmp/* 59 -chflags -R 0 ${OBJTOP}/tmp/* 60 rm -rf ${OBJTOP}/tmp 61beforedirdeps: cleanup_worldtmp 62.endif 63 64# pseudo option for building host tools on old or non-FreeBSD host 65# allows us to leverage Makefile.depend.options with 66# DIRDEPS_OPTIONS = host_egacy 67# dirdeps-options.mk will qualify with ${DEP_MACHINE} (and others) 68# before looking at the bare option. 69MK_host_egacy.host= ${MK_host_egacy} 70 71.endif # !target(_DIRDEP_USE) 72 73# reset this each time 74DIRDEPS_FILTER.xtras= 75.if ${DEP_MACHINE:Npkgs*} != "" 76DIRDEPS_FILTER.xtras+= Nusr.bin/clang/clang.host 77.endif 78 79.if ${DEP_MACHINE} != "host" 80MK_host_egacy.${DEP_MACHINE}= no 81 82# this is how we can handle optional dependencies 83.if ${DEP_RELDIR} == "lib/libc" 84DIRDEPS += lib/libc_nonshared 85.if ${MK_SSP:Uno} != "no" 86DIRDEPS += lib/libssp_nonshared 87.endif 88.else 89DIRDEPS_FILTER.xtras+= Nlib/libc_nonshared 90.endif 91 92# some optional things 93.if ${MK_CTF} == "yes" && ${DEP_RELDIR:Mcddl/usr.bin/ctf*} == "" 94DIRDEPS += \ 95 cddl/usr.bin/ctfconvert.host \ 96 cddl/usr.bin/ctfmerge.host 97.endif 98 99# Add in proper libgcc (gnu or LLVM) if not building libcc and libc is needed. 100# Add both gcc_s and gcc_eh as dependencies as the decision to build 101# -static or not is not known here. 102.if ${DEP_RELDIR:M*libgcc*} == "" && ${DIRDEPS:U:Mlib/libc} != "" 103DIRDEPS+= \ 104 lib/libgcc_eh \ 105 lib/libgcc_s 106.endif 107 108# Bootstrap support. Give hints to DIRDEPS if there is no Makefile.depend* 109# generated yet. This can be based on things such as SRC files and LIBADD. 110# These hints will not factor into the final Makefile.depend as only what is 111# used will be added in and handled via [local.]gendirdeps.mk. This is not 112# done for MACHINE=host builds. 113# XXX: Include this in local.autodep.mk as well for gendirdeps without filemon. 114# Only do this for main build target 115.if ${RELDIR} == ${DEP_RELDIR} && !defined(_RECURSING_PROGS) 116.for _depfile in ${.MAKE.DEPENDFILE_PREFERENCE:T} 117.if !defined(_have_depfile) && exists(${.CURDIR}/${_depfile}) 118_have_depfile= 119.endif 120.endfor 121.if !defined(_have_depfile) 122# KMOD does not use any stdlibs. 123.if !defined(KMOD) 124# Gather PROGS dependencies first 125.if !empty(PROGS) 126_PROGS_LIBADD= 127_PROGS_DPADD= 128_PROGS_SRCS= 129.for _prog in ${PROGS} 130.for s in . _ 131.if !empty(LIBADD${s}${_prog}) 132_PROGS_LIBADD+= ${LIBADD${s}${_prog}} 133.endif 134.if !empty(DPADD${s}${_prog}) 135_PROGS_DPADD+= ${DPADD${s}${_prog}} 136.endif 137.if !empty(SRCS${s}${_prog}) 138_PROGS_SRCS+= ${SRCS${s}${_prog}} 139.endif 140.endfor # .for s in . _ 141# Add in assumed source (bsd.prog.mk) 142.if !target(${_prog}) 143.if defined(PROG_CXX) 144_PROGS_SRCS+= ${_prog}.cc 145.else 146_PROGS_SRCS+= ${_prog}.c 147.endif 148.endif # !target(${_prog}) 149.endfor # .for _prog in ${PROGS} 150.endif # !empty(PROGS) 151_SRCS= ${SRCS} ${_PROGS_SRCS} 152 153# Has C files. The C_DIRDEPS are shared with C++ files as well. 154C_DIRDEPS= \ 155 include \ 156 include/arpa \ 157 include/protocols \ 158 include/rpc \ 159 include/rpcsvc \ 160 include/xlocale \ 161 lib/${CSU_DIR} \ 162 lib/libc \ 163 lib/libcompiler_rt \ 164 165# libgcc is needed as well but is added later. 166 167.if ${MK_GSSAPI} != "no" 168C_DIRDEPS+= include/gssapi 169.endif 170 171.if !empty(_SRCS:M*.c) 172DIRDEPS+= ${C_DIRDEPS} 173.endif 174# Has C++ files 175.if !empty(_SRCS:M*.cc) || !empty(_SRCS:M*.C) || !empty(_SRCS:M*.cpp) || \ 176 !empty(_SRCS:M*.cxx) 177DIRDEPS+= ${C_DIRDEPS} 178.if ${MK_CLANG} == "yes" 179DIRDEPS+= lib/libc++ lib/libcxxrt 180.endif 181# XXX: Clang and GCC always adds -lm currently, even when not needed. 182DIRDEPS+= lib/msun 183.endif # CXX 184.endif # !defined(KMOD) 185# Has yacc files. 186.if !empty(_SRCS:M*.y) 187DIRDEPS+= usr.bin/yacc.host 188.endif 189_DPADD= ${DPADD} ${_PROGS_DPADD} 190.if !empty(_DPADD) 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:N.:N${SRCTOP}:N*pseudo/stage} != "" 220DIRDEPS += targets/pseudo/stage 221.endif 222.endif 223 224DEP_MACHINE_ARCH = ${MACHINE_ARCH.${DEP_MACHINE}} 225DEP_MACHINE_CPUARCH = ${DEP_MACHINE_ARCH:${__TO_CPUARCH}} 226CSU_DIR.${DEP_MACHINE_ARCH} ?= csu/${DEP_MACHINE_ARCH} 227CSU_DIR := ${CSU_DIR.${DEP_MACHINE_ARCH}} 228BOOT_MACHINE_DIR:= ${BOOT_MACHINE_DIR.${DEP_MACHINE}} 229KERNEL_NAME:= ${KERNEL_NAME.${DEP_MACHINE}} 230 231.-include <site.dirdeps.mk> 232