mirror of
https://github.com/freebsd/freebsd-src
synced 2024-09-29 21:26:51 +00:00
Simplify building host tools during DIRDEPS_BUILD
The whole point of the DIRDEPS_BUILD is to avoid tree walks and basically build everything in a single pass. We use the pseudo MACHINE "host" to represent the build host. When the build host is not FreeBSD or is an older version of FreeBSD it may need some help to build host-tools. The directory tools/build does this - building libegacy. local.sys.mk: create a pseudo option MK_host_egacy to indicate if tools/build needs to be built for "host". local.dirdeps.mk: set MK_host_egacy.host to ${MK_host_egacy} all other DEP_MACHINES will get "no" This allows a Makefile.depend.options in makefs etc to cause tools/build to be built for host but only if necessary. local.init.mk: use ISYSTEM as arg to -isystem so that it can be overridden. The default remains ${STAGE_INCLUDEDIR} src.init.mk: if MACHINE is host and we are not FreeBSD set some MK_ flags the same as tools/build/mk/Makefile.boot.pre and include src.init.${.MAKE.OS:tl}.mk if it exists. For older versions of FreeBSD add libegacy when building PROGs for "host" Also instead of -isystem${STAGE_INCLUDEDIR} we want -I${STAGE_INCLUDEDIR} and -isystem/usr/include so we override ISYSTEM. This means any headers we stage for "host" will take precedence over system headers but #include_next will DTRT. src.init.linux.mk: add -I${SRCTOP}/tools/build/cross-build/include/linux and generally deal with building host tools on Linux. Eg. static linking does not work so set NO_SHARED= no Override some HAVE_ flags. src.sys.env.mk: on linux awk throws an warning about # in newvers.sh just send stderr to /dev/null Reviewed by: jrtc27, arichardson Sponsored by: Juniper Networks, Inc. Differential Revision: https://reviews.freebsd.org/D39744
This commit is contained in:
parent
dbce131b8f
commit
8561d0b2ec
|
@ -60,7 +60,15 @@ cleanup_worldtmp: .PHONY .NOMETA
|
|||
rm -rf ${OBJTOP}/tmp
|
||||
beforedirdeps: cleanup_worldtmp
|
||||
.endif
|
||||
.endif
|
||||
|
||||
# pseudo option for building host tools on old or non-FreeBSD host
|
||||
# allows us to leverage Makefile.depend.options with
|
||||
# DIRDEPS_OPTIONS = host_egacy
|
||||
# dirdeps-options.mk will qualify with ${DEP_MACHINE} (and others)
|
||||
# before looking at the bare option.
|
||||
MK_host_egacy.host= ${MK_host_egacy}
|
||||
|
||||
.endif # !target(_DIRDEP_USE)
|
||||
|
||||
# reset this each time
|
||||
DIRDEPS_FILTER.xtras=
|
||||
|
@ -69,6 +77,7 @@ DIRDEPS_FILTER.xtras+= Nusr.bin/clang/clang.host
|
|||
.endif
|
||||
|
||||
.if ${DEP_MACHINE} != "host"
|
||||
MK_host_egacy.${DEP_MACHINE}= no
|
||||
|
||||
# this is how we can handle optional dependencies
|
||||
.if ${DEP_RELDIR} == "lib/libc"
|
||||
|
|
|
@ -19,7 +19,10 @@ CFLAGS_LAST+= --sysroot=${SYSROOT}
|
|||
CXXFLAGS_LAST+= --sysroot=${SYSROOT}
|
||||
LDADD+= --sysroot=${SYSROOT}
|
||||
.elif ${MK_STAGING} == "yes"
|
||||
CFLAGS+= -isystem ${STAGE_INCLUDEDIR}
|
||||
ISYSTEM?= ${STAGE_INCLUDEDIR}
|
||||
# no space after -isystem makes it easier to
|
||||
# grep the flag out of command lines (in meta files) to see its value.
|
||||
CFLAGS+= -isystem${ISYSTEM}
|
||||
# XXX: May be needed for GCC to build with libc++ rather than libstdc++. See Makefile.inc1
|
||||
#CXXFLAGS+= -std=gnu++11
|
||||
#LDADD+= -L${STAGE_LIBDIR}/libc++
|
||||
|
|
|
@ -79,6 +79,14 @@ JOB_MAX:= ${jm:R}
|
|||
.endif
|
||||
.endif
|
||||
|
||||
.if ${MK_DIRDEPS_BUILD} == "yes"
|
||||
.if ${.MAKE.OS} != "FreeBSD" || ${_HOST_OSREL:R} < ${OS_REVISION:R}
|
||||
# a pseudo option to indicate we need libegacy for host
|
||||
MK_host_egacy= yes
|
||||
.endif
|
||||
.endif
|
||||
MK_host_egacy?= no
|
||||
|
||||
.if ${.MAKE.MODE:Mmeta*} != ""
|
||||
# we can afford to use cookies to prevent some targets
|
||||
# re-running needlessly but only when using filemon.
|
||||
|
|
15
share/mk/src.init.linux.mk
Normal file
15
share/mk/src.init.linux.mk
Normal file
|
@ -0,0 +1,15 @@
|
|||
# We want to build some host tools (eg makefs, mkimg) for Linux
|
||||
# This only gets included during DIRDEPS_BUILD when MACHINE is "host"
|
||||
|
||||
CFLAGS+= -I${SRCTOP}/tools/build/cross-build/include/linux
|
||||
|
||||
WARNS= 0
|
||||
|
||||
.ifdef PROG
|
||||
LOCAL_LIBRARIES+= bsd egacy
|
||||
LIBADD+= egacy m
|
||||
.endif
|
||||
|
||||
# Bring in the full GNU namespace
|
||||
CFLAGS+= -D_GNU_SOURCE
|
||||
|
|
@ -8,4 +8,35 @@ buildenv: .PHONY
|
|||
${_+_}@env BUILDENV_DIR=${.CURDIR} ${MAKE} -C ${SRCTOP} buildenv
|
||||
.endif
|
||||
|
||||
.if ${MACHINE:Nhost*} == ""
|
||||
.if ${.MAKE.OS} != "FreeBSD"
|
||||
# these won't work anyway - see tools/build/mk/Makefile.boot.pre
|
||||
MK_DEBUG_FILES= no
|
||||
MK_MAN= no
|
||||
MK_PIE= no
|
||||
MK_RETPOLINE= no
|
||||
NO_SHARED= no
|
||||
MK_TESTS= no
|
||||
|
||||
.-include <src.init.${.MAKE.OS:tl}.mk>
|
||||
|
||||
CFLAGS+= \
|
||||
-DHAVE_NBTOOL_CONFIG_H=1 \
|
||||
-I${SRCTOP}/tools/build/cross-build/include/common \
|
||||
|
||||
.endif
|
||||
|
||||
.if ${MK_host_egacy} == "yes"
|
||||
.ifdef PROG
|
||||
LOCAL_LIBRARIES+= egacy
|
||||
LIBADD+= egacy
|
||||
.endif
|
||||
.endif
|
||||
|
||||
.if ${MK_STAGING} == "yes"
|
||||
ISYSTEM= /usr/include
|
||||
CFLAGS+= -I${STAGE_INCLUDEDIR}
|
||||
.endif
|
||||
.endif
|
||||
|
||||
.endif # !target(__<src.init.mk>__)
|
||||
|
|
Loading…
Reference in a new issue