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

View File

@ -39,15 +39,18 @@ CFLAGS+=-DSHELL -I. -I${.CURDIR}
CLEANFILES+= mknodes mksyntax CLEANFILES+= mknodes mksyntax
CLEANFILES+= ${GENSRCS} ${GENHDRS} CLEANFILES+= ${GENSRCS} ${GENHDRS}
.if ${MACHINE} == "host" || ${MK_DIRDEPS_BUILD} == "no"
build-tools: mknodes mksyntax build-tools: mknodes mksyntax
DEPENDOBJS+= mknodes mksyntax
mknodes mksyntax: ${BUILD_TOOLS_META}
.endif
.ORDER: builtins.c builtins.h .ORDER: builtins.c builtins.h
builtins.h: .NOMETA builtins.h: .NOMETA
builtins.c builtins.h: mkbuiltins builtins.def builtins.c builtins.h: mkbuiltins builtins.def
sh ${.CURDIR}/mkbuiltins ${.CURDIR} sh ${.CURDIR}/mkbuiltins ${.CURDIR}
DEPENDOBJS+= mknodes mksyntax
mknodes mksyntax: ${BUILD_TOOLS_META}
.ORDER: nodes.c nodes.h .ORDER: nodes.c nodes.h
nodes.h: .NOMETA 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 \ 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 ${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 # Build tools
DEPENDOBJS+= make_hash make_keys DEPENDOBJS+= make_hash make_keys
build-tools: 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} make_hash: make_hash.c hashsize.h ncurses_def.h ${HEADERS} ${BUILD_TOOLS_META}
${CC:N${CCACHE_BIN}} -o $@ ${CFLAGS} -DMAIN_PROGRAM \ ${CC:N${CCACHE_BIN}} -o $@ ${CFLAGS} -DMAIN_PROGRAM \
${NCURSES_DIR}/ncurses/tinfo/make_hash.c ${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 # ./configure generated
MKterm.h.awk: MKterm.h.awk.in MKterm.h.awk: MKterm.h.awk.in

View File

@ -210,12 +210,19 @@ TOOLSDIR?= ${HOST_OBJTOP}/tools
.elif defined(STAGE_HOST_OBJTOP) .elif defined(STAGE_HOST_OBJTOP)
TOOLSDIR?= ${STAGE_HOST_OBJTOP} TOOLSDIR?= ${STAGE_HOST_OBJTOP}
.endif .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 # 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 # the tool will be built during the build. Building it assumes it is
# TARGET==MACHINE. # TARGET==MACHINE.
.if exists(${HOST_OBJTOP}/tools${.CURDIR}) .if exists(${HOST_OBJTOP}/tools${.CURDIR})
BTOOLSPATH= ${HOST_OBJTOP}/tools${.CURDIR} BTOOLSPATH= ${HOST_OBJTOP}/tools${.CURDIR}
.endif .endif
.endif
# Don't use the bootstrap tools logic on itself. # Don't use the bootstrap tools logic on itself.
.if ${.TARGETS:Mbootstrap-tools} == "" && \ .if ${.TARGETS:Mbootstrap-tools} == "" && \

View File

@ -14,16 +14,18 @@ CLEANFILES+= ${SCRMAPS_MK} ${SCRMAPS}
FILES= ${SCRMAPS} FILES= ${SCRMAPS}
FILESDIR= ${SHAREDIR}/syscons/scrnmaps FILESDIR= ${SHAREDIR}/syscons/scrnmaps
.if ${MACHINE} == "host" || ${MK_DIRDEPS_BUILD} == "no"
DEPENDOBJS+= ${SCRMAPS_MK} DEPENDOBJS+= ${SCRMAPS_MK}
build-tools: ${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 ${SCRMAPS}: ${.TARGET:R}.mk
${BTOOLSPATH:U.}/${.TARGET:R}.mk ${.TARGET:R}.tmp ${BTOOLSPATH:U.}/${.TARGET:R}.mk ${.TARGET:R}.tmp
uuencode ${.TARGET:R}.tmp ${.TARGET:R} > ${.TARGET} uuencode ${.TARGET:R}.tmp ${.TARGET:R} > ${.TARGET}
rm -f ${.TARGET:R}.tmp 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> .include <bsd.prog.mk>

View File

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