2015-06-13 19:20:56 +00:00
|
|
|
# $FreeBSD$
|
2013-10-12 23:42:55 +00:00
|
|
|
.if !target(_DIRDEP_USE)
|
|
|
|
# we are the 1st makefile
|
|
|
|
|
2014-08-19 06:50:54 +00:00
|
|
|
.if !defined(MK_CLANG)
|
2014-05-10 00:25:21 +00:00
|
|
|
.include "${SRCTOP}/share/mk/src.opts.mk"
|
2014-05-05 18:18:23 +00:00
|
|
|
.endif
|
|
|
|
|
2014-11-30 18:45:46 +00:00
|
|
|
# making universe is special
|
|
|
|
.if defined(UNIVERSE_GUARD)
|
|
|
|
# these should be done by now
|
|
|
|
DIRDEPS_FILTER+= N*.host
|
|
|
|
.endif
|
|
|
|
|
2013-10-12 23:42:55 +00:00
|
|
|
# pseudo machines get no qualification
|
|
|
|
.for m in host common
|
|
|
|
M_dep_qual_fixes += C;($m),[^/.,]*$$;\1;
|
|
|
|
.endfor
|
|
|
|
#.info M_dep_qual_fixes=${M_dep_qual_fixes}
|
2015-11-25 19:44:51 +00:00
|
|
|
|
|
|
|
# Cheat for including src.libnames.mk
|
|
|
|
__<bsd.init.mk>__:
|
|
|
|
# Pull in _INTERNALLIBS
|
|
|
|
.include <src.libnames.mk>
|
|
|
|
|
|
|
|
# Host libraries should mostly be excluded from the build so the
|
|
|
|
# host version in /usr/lib is used. Internal libraries need to be
|
|
|
|
# allowed to be built though since they are never installed.
|
|
|
|
_need_host_libs=
|
|
|
|
.for lib in ${_INTERNALLIBS}
|
2015-11-26 01:47:56 +00:00
|
|
|
_need_host_libs+= ${LIB${lib:tu}DIR:S,^${OBJTOP}/,,}
|
2015-11-25 19:44:51 +00:00
|
|
|
.endfor
|
2014-05-16 15:00:04 +00:00
|
|
|
|
2014-05-05 19:35:32 +00:00
|
|
|
N_host_libs:= ${cd ${SRCTOP} && echo lib/lib*:L:sh:${_need_host_libs:${M_ListToSkip}}:${M_ListToSkip}}
|
2013-10-12 23:42:55 +00:00
|
|
|
DIRDEPS_FILTER.host = \
|
2014-05-05 19:35:32 +00:00
|
|
|
${N_host_libs} \
|
2013-10-12 23:42:55 +00:00
|
|
|
Ninclude* \
|
|
|
|
Nlib/csu* \
|
2018-08-02 21:33:45 +00:00
|
|
|
Nlib/libc \
|
2013-10-12 23:42:55 +00:00
|
|
|
Nlib/[mn]* \
|
|
|
|
Ngnu/lib/lib[a-r]* \
|
2016-05-04 03:13:48 +00:00
|
|
|
Nsecure/lib* \
|
2015-05-26 21:44:15 +00:00
|
|
|
Nusr.bin/xinstall* \
|
2013-10-12 23:42:55 +00:00
|
|
|
|
|
|
|
|
2014-05-16 15:00:04 +00:00
|
|
|
DIRDEPS_FILTER+= \
|
2015-06-14 03:28:25 +00:00
|
|
|
Nbin/cat.host \
|
2014-05-16 15:00:04 +00:00
|
|
|
${DIRDEPS_FILTER.xtras:U}
|
2017-11-02 20:45:04 +00:00
|
|
|
|
|
|
|
# Cleanup a buildworld's WORLDTMP so that any files generated from it
|
|
|
|
# or using it will rebuild with the DIRDEPS SYSROOT. Otherwise existing
|
|
|
|
# object .meta files may still reference those directories and not be
|
|
|
|
# rebuilt and lead to incorrect Makefile.depend files due to lack of
|
|
|
|
# .dirdep files.
|
|
|
|
.if !defined(NO_CLEANUP_WORLDTMP) && exists(${OBJTOP}/tmp/_worldtmp)
|
|
|
|
cleanup_worldtmp: .PHONY .NOMETA
|
|
|
|
@echo "Cleaning leftover WORLDTMP from buildworld."
|
|
|
|
-rm -rf ${OBJTOP}/tmp/*
|
|
|
|
-chflags -R 0 ${OBJTOP}/tmp/*
|
|
|
|
rm -rf ${OBJTOP}/tmp
|
|
|
|
beforedirdeps: cleanup_worldtmp
|
|
|
|
.endif
|
2014-05-16 15:00:04 +00:00
|
|
|
.endif
|
|
|
|
|
|
|
|
# reset this each time
|
|
|
|
DIRDEPS_FILTER.xtras=
|
|
|
|
.if ${DEP_MACHINE:Npkgs*} != ""
|
|
|
|
DIRDEPS_FILTER.xtras+= Nusr.bin/clang/clang.host
|
2013-10-12 23:42:55 +00:00
|
|
|
.endif
|
2012-08-22 19:25:57 +00:00
|
|
|
|
2013-03-17 03:06:49 +00:00
|
|
|
.if ${DEP_MACHINE} != "host"
|
|
|
|
|
2012-08-22 19:25:57 +00:00
|
|
|
# this is how we can handle optional dependencies
|
2014-05-16 15:00:04 +00:00
|
|
|
.if ${DEP_RELDIR} == "lib/libc"
|
|
|
|
DIRDEPS += lib/libc_nonshared
|
|
|
|
.if ${MK_SSP:Uno} != "no"
|
2020-01-04 20:19:25 +00:00
|
|
|
DIRDEPS += lib/libssp_nonshared
|
2012-08-22 19:25:57 +00:00
|
|
|
.endif
|
2014-05-16 15:00:04 +00:00
|
|
|
.else
|
|
|
|
DIRDEPS_FILTER.xtras+= Nlib/libc_nonshared
|
|
|
|
.endif
|
2013-03-06 18:35:57 +00:00
|
|
|
|
2013-10-12 23:42:55 +00:00
|
|
|
# some optional things
|
2014-05-16 15:00:04 +00:00
|
|
|
.if ${MK_CTF} == "yes" && ${DEP_RELDIR:Mcddl/usr.bin/ctf*} == ""
|
2013-10-12 23:42:55 +00:00
|
|
|
DIRDEPS += \
|
|
|
|
cddl/usr.bin/ctfconvert.host \
|
|
|
|
cddl/usr.bin/ctfmerge.host
|
|
|
|
.endif
|
|
|
|
|
2017-10-31 00:03:36 +00:00
|
|
|
# Add in proper libgcc (gnu or LLVM) if not building libcc and libc is needed.
|
|
|
|
# Add both gcc_s and gcc_eh as dependencies as the decision to build
|
|
|
|
# -static or not is not known here.
|
2018-08-02 21:33:45 +00:00
|
|
|
.if ${DEP_RELDIR:M*libgcc*} == "" && ${DIRDEPS:U:Mlib/libc} != ""
|
2017-10-31 00:03:36 +00:00
|
|
|
DIRDEPS+= \
|
|
|
|
lib/libgcc_eh \
|
|
|
|
lib/libgcc_s
|
|
|
|
.endif
|
|
|
|
|
2015-12-01 05:29:30 +00:00
|
|
|
# Bootstrap support. Give hints to DIRDEPS if there is no Makefile.depend*
|
|
|
|
# generated yet. This can be based on things such as SRC files and LIBADD.
|
|
|
|
# These hints will not factor into the final Makefile.depend as only what is
|
|
|
|
# used will be added in and handled via [local.]gendirdeps.mk. This is not
|
|
|
|
# done for MACHINE=host builds.
|
|
|
|
# XXX: Include this in local.autodep.mk as well for gendirdeps without filemon.
|
2016-03-09 22:44:48 +00:00
|
|
|
# Only do this for main build target
|
|
|
|
.if ${RELDIR} == ${DEP_RELDIR} && !defined(_RECURSING_PROGS)
|
2015-12-01 05:29:30 +00:00
|
|
|
.for _depfile in ${.MAKE.DEPENDFILE_PREFERENCE:T}
|
|
|
|
.if !defined(_have_depfile) && exists(${.CURDIR}/${_depfile})
|
|
|
|
_have_depfile=
|
2013-03-17 03:06:49 +00:00
|
|
|
.endif
|
2015-12-01 05:29:30 +00:00
|
|
|
.endfor
|
|
|
|
.if !defined(_have_depfile)
|
2015-12-11 22:55:41 +00:00
|
|
|
# KMOD does not use any stdlibs.
|
|
|
|
.if !defined(KMOD)
|
2016-03-09 22:44:48 +00:00
|
|
|
# Gather PROGS dependencies first
|
|
|
|
.if !empty(PROGS)
|
|
|
|
_PROGS_LIBADD=
|
|
|
|
_PROGS_DPADD=
|
|
|
|
_PROGS_SRCS=
|
|
|
|
.for _prog in ${PROGS}
|
|
|
|
.for s in . _
|
|
|
|
.if !empty(LIBADD${s}${_prog})
|
|
|
|
_PROGS_LIBADD+= ${LIBADD${s}${_prog}}
|
|
|
|
.endif
|
|
|
|
.if !empty(DPADD${s}${_prog})
|
|
|
|
_PROGS_DPADD+= ${DPADD${s}${_prog}}
|
|
|
|
.endif
|
|
|
|
.if !empty(SRCS${s}${_prog})
|
|
|
|
_PROGS_SRCS+= ${SRCS${s}${_prog}}
|
|
|
|
.endif
|
|
|
|
.endfor # .for s in . _
|
|
|
|
# Add in assumed source (bsd.prog.mk)
|
|
|
|
.if !target(${_prog})
|
|
|
|
.if defined(PROG_CXX)
|
|
|
|
_PROGS_SRCS+= ${_prog}.cc
|
|
|
|
.else
|
|
|
|
_PROGS_SRCS+= ${_prog}.c
|
|
|
|
.endif
|
|
|
|
.endif # !target(${_prog})
|
|
|
|
.endfor # .for _prog in ${PROGS}
|
|
|
|
.endif # !empty(PROGS)
|
|
|
|
_SRCS= ${SRCS} ${_PROGS_SRCS}
|
|
|
|
|
2015-12-01 05:29:30 +00:00
|
|
|
# Has C files. The C_DIRDEPS are shared with C++ files as well.
|
|
|
|
C_DIRDEPS= \
|
|
|
|
include \
|
2016-03-04 22:37:21 +00:00
|
|
|
include/arpa \
|
|
|
|
include/protocols \
|
|
|
|
include/rpc \
|
|
|
|
include/rpcsvc \
|
2015-12-01 05:29:30 +00:00
|
|
|
include/xlocale \
|
|
|
|
lib/${CSU_DIR} \
|
|
|
|
lib/libc \
|
|
|
|
lib/libcompiler_rt \
|
|
|
|
|
2017-10-31 00:03:36 +00:00
|
|
|
# libgcc is needed as well but is added later.
|
2016-03-04 22:37:21 +00:00
|
|
|
|
|
|
|
.if ${MK_GSSAPI} != "no"
|
|
|
|
C_DIRDEPS+= include/gssapi
|
|
|
|
.endif
|
|
|
|
|
2016-03-09 22:44:48 +00:00
|
|
|
.if !empty(_SRCS:M*.c)
|
2015-12-01 05:29:30 +00:00
|
|
|
DIRDEPS+= ${C_DIRDEPS}
|
|
|
|
.endif
|
|
|
|
# Has C++ files
|
2016-03-09 22:44:48 +00:00
|
|
|
.if !empty(_SRCS:M*.cc) || !empty(_SRCS:M*.C) || !empty(_SRCS:M*.cpp) || \
|
|
|
|
!empty(_SRCS:M*.cxx)
|
2015-12-01 05:29:30 +00:00
|
|
|
DIRDEPS+= ${C_DIRDEPS}
|
|
|
|
.if ${MK_CLANG} == "yes"
|
|
|
|
DIRDEPS+= lib/libc++ lib/libcxxrt
|
|
|
|
.endif
|
|
|
|
# XXX: Clang and GCC always adds -lm currently, even when not needed.
|
|
|
|
DIRDEPS+= lib/msun
|
2015-12-11 22:55:41 +00:00
|
|
|
.endif # CXX
|
|
|
|
.endif # !defined(KMOD)
|
2015-12-01 05:29:30 +00:00
|
|
|
# Has yacc files.
|
2016-03-09 22:44:48 +00:00
|
|
|
.if !empty(_SRCS:M*.y)
|
2015-12-01 05:29:30 +00:00
|
|
|
DIRDEPS+= usr.bin/yacc.host
|
|
|
|
.endif
|
2016-03-09 22:44:48 +00:00
|
|
|
_DPADD= ${DPADD} ${_PROGS_DPADD}
|
|
|
|
.if !empty(_DPADD)
|
2015-12-01 05:29:30 +00:00
|
|
|
# This only works for DPADD with full OBJ/SRC paths, which is mostly just
|
|
|
|
# _INTERNALLIBS.
|
2015-12-15 02:27:31 +00:00
|
|
|
_DP_DIRDEPS= \
|
2015-12-15 02:51:05 +00:00
|
|
|
${_DPADD:O:u:M${OBJTOP}*:H:N.:tA:C,${OBJTOP}[^/]*/,,:N.:O:u} \
|
|
|
|
${_DPADD:O:u:M${OBJROOT}*:N${OBJTOP}*:N${STAGE_ROOT}/*:H:S,${OBJROOT},,:C,^([^/]+)/(.*),\2.\1,:S,${HOST_TARGET}$,host,:N.*:O:u}
|
2015-12-04 03:17:04 +00:00
|
|
|
# Resolve the paths to RELDIRs
|
2015-12-15 02:46:14 +00:00
|
|
|
.if !empty(_DP_DIRDEPS)
|
2015-12-04 03:17:04 +00:00
|
|
|
DIRDEPS+= ${_DP_DIRDEPS:C,^,${SRCTOP}/,:tA:C,^${SRCTOP}/,,}
|
2015-12-01 05:29:30 +00:00
|
|
|
.endif
|
2015-12-15 02:46:14 +00:00
|
|
|
.endif # !empty(DPADD)
|
2015-12-15 02:51:05 +00:00
|
|
|
_ALL_LIBADD= ${LIBADD} ${_PROGS_LIBADD}
|
2016-03-09 22:44:48 +00:00
|
|
|
.if !empty(_ALL_LIBADD)
|
|
|
|
# Also handle LIBADD for non-internal libraries.
|
2015-12-15 02:51:05 +00:00
|
|
|
.for _lib in ${_ALL_LIBADD:O:u}
|
2015-12-01 05:29:30 +00:00
|
|
|
_lib${_lib}reldir= ${LIB${_lib:tu}DIR:C,${OBJTOP}/,,}
|
|
|
|
.if defined(LIB${_lib:tu}DIR) && ${DIRDEPS:M${_lib${_lib}reldir}} == "" && \
|
|
|
|
exists(${SRCTOP}/${_lib${_lib}reldir})
|
|
|
|
DIRDEPS+= ${_lib${_lib}reldir}
|
|
|
|
.endif
|
|
|
|
.endfor
|
|
|
|
.endif # !empty(LIBADD)
|
|
|
|
.endif # no Makefile.depend*
|
|
|
|
.endif # ${RELDIR} == ${DEP_RELDIR}
|
|
|
|
|
|
|
|
.endif # ${DEP_MACHINE} != "host"
|
2013-03-17 03:06:49 +00:00
|
|
|
|
2015-05-26 21:44:15 +00:00
|
|
|
.if ${MK_STAGING} == "yes"
|
2014-11-30 18:45:46 +00:00
|
|
|
# we need targets/pseudo/stage to prep the stage tree
|
|
|
|
.if ${DEP_RELDIR} != "targets/pseudo/stage"
|
|
|
|
DIRDEPS += targets/pseudo/stage
|
2013-03-06 18:35:57 +00:00
|
|
|
.endif
|
2015-05-26 21:44:15 +00:00
|
|
|
.endif
|
2013-03-12 17:21:03 +00:00
|
|
|
|
2013-10-12 23:42:55 +00:00
|
|
|
DEP_MACHINE_ARCH = ${MACHINE_ARCH.${DEP_MACHINE}}
|
2013-05-11 00:51:59 +00:00
|
|
|
CSU_DIR.${DEP_MACHINE_ARCH} ?= csu/${DEP_MACHINE_ARCH}
|
|
|
|
CSU_DIR := ${CSU_DIR.${DEP_MACHINE_ARCH}}
|
2013-10-12 23:42:55 +00:00
|
|
|
BOOT_MACHINE_DIR:= ${BOOT_MACHINE_DIR.${DEP_MACHINE}}
|
|
|
|
KERNEL_NAME:= ${KERNEL_NAME.${DEP_MACHINE}}
|