#! /bin/sh
#	$NetBSD: buildmake.sh.in,v 1.18 2023/07/20 15:16:44 lukem Exp $
#
# buildmake.sh.in - Autoconf-processed shell script for building make(1).
#

: ${NETBSDSRCDIR:=@srcdir@/../..}
MKSRCDIR=${NETBSDSRCDIR}/usr.bin/make

docmd()
{
	local msg=$1
	local tgt=$2
	shift 2
	case "${MAKEVERBOSE:-2}" in
	0)
		;;
	1)
		echo "    ${msg} ${tgt##*/}" ;;
	*)
		echo "$*" ;;
	esac
	"$@" || exit 1
}

for f in $MKSRCDIR/*.c; do
	docmd "compile " "$f" @CC@ @CPPFLAGS@ @DEFS@ @CFLAGS@ @NOWARNFLAGS@ \
		-D_PATH_DEFSYSPATH=\"${NETBSDSRCDIR}/share/mk\" -c "$f"
done

docmd "   link " "${_TOOL_PREFIX:-nb}make" \
	@CC@ -o ${_TOOL_PREFIX:-nb}make *.o @LDFLAGS@ @LIBS@
