diff --git a/bin/csh/Makefile b/bin/csh/Makefile --- a/bin/csh/Makefile +++ b/bin/csh/Makefile @@ -118,15 +118,18 @@ 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 --- a/bin/sh/Makefile +++ b/bin/sh/Makefile @@ -39,15 +39,18 @@ 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 --- a/lib/ncurses/tinfo/Makefile +++ b/lib/ncurses/tinfo/Makefile @@ -270,6 +270,11 @@ 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_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 --- a/share/mk/local.meta.sys.mk +++ b/share/mk/local.meta.sys.mk @@ -210,12 +210,19 @@ .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 --- a/share/syscons/scrnmaps/Makefile +++ b/share/syscons/scrnmaps/Makefile @@ -14,16 +14,18 @@ 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 diff --git a/usr.bin/awk/Makefile b/usr.bin/awk/Makefile --- a/usr.bin/awk/Makefile +++ b/usr.bin/awk/Makefile @@ -25,9 +25,11 @@ 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