aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon J. Gerraty <sjg@FreeBSD.org>2023-04-20 17:05:43 +0000
committerSimon J. Gerraty <sjg@FreeBSD.org>2023-04-20 17:05:43 +0000
commit8fe4f8f7a75f3f6d1fc52e31a6d25a112d4644fd (patch)
tree9dfa80a120af5221ee8e2523c14efee1a5d5526b
parentde4da6cd04bf299e46f0c65d4bfd9fa94bf00f08 (diff)
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
-rw-r--r--bin/csh/Makefile5
-rw-r--r--bin/sh/Makefile7
-rw-r--r--lib/ncurses/tinfo/Makefile13
-rw-r--r--share/mk/local.meta.sys.mk7
-rw-r--r--share/syscons/scrnmaps/Makefile10
-rw-r--r--usr.bin/awk/Makefile2
6 files changed, 37 insertions, 7 deletions
diff --git a/bin/csh/Makefile b/bin/csh/Makefile
index d59626703685..2d1edcf53a80 100644
--- a/bin/csh/Makefile
+++ b/bin/csh/Makefile
@@ -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}
diff --git a/bin/sh/Makefile b/bin/sh/Makefile
index c61094b06720..039da7309adc 100644
--- a/bin/sh/Makefile
+++ b/bin/sh/Makefile
@@ -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
diff --git a/lib/ncurses/tinfo/Makefile b/lib/ncurses/tinfo/Makefile
index fc4e4447562e..2d251072acb8 100644
--- a/lib/ncurses/tinfo/Makefile
+++ b/lib/ncurses/tinfo/Makefile
@@ -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
diff --git a/share/mk/local.meta.sys.mk b/share/mk/local.meta.sys.mk
index 6b5ff5e97555..6d54d9c5881c 100644
--- a/share/mk/local.meta.sys.mk
+++ b/share/mk/local.meta.sys.mk
@@ -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} == "" && \
diff --git a/share/syscons/scrnmaps/Makefile b/share/syscons/scrnmaps/Makefile
index fb6bf59131b9..f3b5ed273cd3 100644
--- a/share/syscons/scrnmaps/Makefile
+++ b/share/syscons/scrnmaps/Makefile
@@ -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>
diff --git a/usr.bin/awk/Makefile b/usr.bin/awk/Makefile
index 28212f75f7d9..f604684804fa 100644
--- a/usr.bin/awk/Makefile
+++ b/usr.bin/awk/Makefile
@@ -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