Fix building host tools for host

Several makefile depend on tools built for host.
At least when using DIRDEPS_BUILD we can build these for the
pseudo machine "host" to facilitate building on older host versions.

Ideally we would build these tools in their own directories to avoid
building more than needed.

For now, setting an appropriate default for BTOOLSPATH will suffice

Reviewed by:	stevek
Sponsored by:	Juniper Networks, Inc.
Differential Revision:	https://reviews.freebsd.org/D39708
This commit is contained in:
Simon J. Gerraty 2023-04-20 10:05:43 -07:00
parent de4da6cd04
commit 8fe4f8f7a7
6 changed files with 37 additions and 7 deletions

View File

@ -118,15 +118,18 @@ NLSSRCFILES_${catalog:C/.*://}!= cd ${NLSSRCDIR_${catalog:C/.*://}}; echo charse
csh.1: tcsh.man
cat ${.ALLSRC} > ${.TARGET}
.if ${MACHINE} == "host" || ${MK_DIRDEPS_BUILD} == "no"
build-tools: gethost
tc.defs.c: gethost
DEPENDOBJS+= gethost
gethost: gethost.c sh.err.h tc.const.h sh.h ${BUILD_TOOLS_META}
@rm -f ${.TARGET}
${CC:N${CCACHE_BIN}} -o gethost ${LDFLAGS} ${CFLAGS:C/-DHAVE_ICONV//} \
${TCSHDIR}/gethost.c
.endif
tc.defs.c: gethost ${TCSHDIR}/host.defs
tc.defs.c: ${TCSHDIR}/host.defs
@rm -f ${.TARGET}
@echo "/* Do not edit this file, make creates it */" > ${.TARGET}
${BTOOLSPATH:U.}/gethost ${TCSHDIR}/host.defs >> ${.TARGET}

View File

@ -39,15 +39,18 @@ CFLAGS+=-DSHELL -I. -I${.CURDIR}
CLEANFILES+= mknodes mksyntax
CLEANFILES+= ${GENSRCS} ${GENHDRS}
.if ${MACHINE} == "host" || ${MK_DIRDEPS_BUILD} == "no"
build-tools: mknodes mksyntax
DEPENDOBJS+= mknodes mksyntax
mknodes mksyntax: ${BUILD_TOOLS_META}
.endif
.ORDER: builtins.c builtins.h
builtins.h: .NOMETA
builtins.c builtins.h: mkbuiltins builtins.def
sh ${.CURDIR}/mkbuiltins ${.CURDIR}
DEPENDOBJS+= mknodes mksyntax
mknodes mksyntax: ${BUILD_TOOLS_META}
.ORDER: nodes.c nodes.h
nodes.h: .NOMETA

View File

@ -270,6 +270,11 @@ keys.list: MKkeys_list.sh Caps Caps-ncurses
AWK=${AWK} sh ${NCURSES_DIR}/ncurses/tinfo/MKkeys_list.sh \
${NCURSES_DIR}/include/Caps ${NCURSES_DIR}/include/Caps-ncurses | LC_ALL=C sort > keys.list
.if ${MK_DIRDEPS_BUILD} == "yes" && ${MACHINE} != "host"
# we need to override the default
BTOOLSPATH= ${HOST_OBJTOP}/${RELDIR:S,w$,,}
.endif
.if ${MACHINE} == "host" || ${MK_DIRDEPS_BUILD} == "no"
# Build tools
DEPENDOBJS+= make_hash make_keys
build-tools: make_hash make_keys
@ -280,6 +285,14 @@ make_keys: make_keys.c names.c ncurses_def.h ${HEADERS} ${BUILD_TOOLS_META}
make_hash: make_hash.c hashsize.h ncurses_def.h ${HEADERS} ${BUILD_TOOLS_META}
${CC:N${CCACHE_BIN}} -o $@ ${CFLAGS} -DMAIN_PROGRAM \
${NCURSES_DIR}/ncurses/tinfo/make_hash.c
.endif
.if ${MK_DIRDEPS_BUILD} == "yes" && ${MACHINE} != "host"
make_keys: ${BTOOLSPATH}/make_keys
${LN:Uln} -sf ${.ALLSRC} ${.TARGET}
make_hash: ${BTOOLSPATH}/make_hash
${LN:Uln} -sf ${.ALLSRC} ${.TARGET}
.endif
# ./configure generated
MKterm.h.awk: MKterm.h.awk.in

View File

@ -210,12 +210,19 @@ TOOLSDIR?= ${HOST_OBJTOP}/tools
.elif defined(STAGE_HOST_OBJTOP)
TOOLSDIR?= ${STAGE_HOST_OBJTOP}
.endif
.if ${MK_DIRDEPS_BUILD} == "yes" && ${MACHINE} != "host"
# ideally tools needed by makefiles like sh,csh,tinfo
# would be built in their own directories but for now
# this works well enough.
BTOOLSPATH= ${HOST_OBJTOP}/${RELDIR}
.else
# Only define if it exists in case user didn't run bootstrap-tools. Otherwise
# the tool will be built during the build. Building it assumes it is
# TARGET==MACHINE.
.if exists(${HOST_OBJTOP}/tools${.CURDIR})
BTOOLSPATH= ${HOST_OBJTOP}/tools${.CURDIR}
.endif
.endif
# Don't use the bootstrap tools logic on itself.
.if ${.TARGETS:Mbootstrap-tools} == "" && \

View File

@ -14,16 +14,18 @@ CLEANFILES+= ${SCRMAPS_MK} ${SCRMAPS}
FILES= ${SCRMAPS}
FILESDIR= ${SHAREDIR}/syscons/scrnmaps
.if ${MACHINE} == "host" || ${MK_DIRDEPS_BUILD} == "no"
DEPENDOBJS+= ${SCRMAPS_MK}
build-tools: ${SCRMAPS_MK}
${SCRMAPS_MK}: ${.TARGET:R} mkscrfil.c ${BUILD_TOOLS_META}
${CC:N${CCACHE_BIN}} ${CFLAGS} -I${.CURDIR} -DFIL=\"${.TARGET:R}\" \
${LDFLAGS} -o ${.TARGET} ${.CURDIR}/mkscrfil.c
.endif
${SCRMAPS}: ${.TARGET:R}.mk
${BTOOLSPATH:U.}/${.TARGET:R}.mk ${.TARGET:R}.tmp
uuencode ${.TARGET:R}.tmp ${.TARGET:R} > ${.TARGET}
rm -f ${.TARGET:R}.tmp
${SCRMAPS_MK}: ${.TARGET:R} mkscrfil.c ${BUILD_TOOLS_META}
${CC:N${CCACHE_BIN}} ${CFLAGS} -I${.CURDIR} -DFIL=\"${.TARGET:R}\" \
${LDFLAGS} -o ${.TARGET} ${.CURDIR}/mkscrfil.c
.include <bsd.prog.mk>

View File

@ -25,9 +25,11 @@ awkgram.tab.h: awkgram.h
proctab.c: maketab awkgram.tab.h
${BTOOLSPATH:U.}/maketab awkgram.tab.h > proctab.c
.if ${MACHINE} == "host" || ${MK_DIRDEPS_BUILD} == "no"
DEPENDOBJS+= maketab
build-tools: maketab
maketab: awkgram.tab.h ${BUILD_TOOLS_META}
.endif
HAS_TESTS=
SUBDIR.${MK_TESTS}+= tests