#! /bin/sh
#	$NetBSD: buildmake.sh.in,v 1.12 2018/01/16 08:53:51 uwe Exp $
#
# buildmake.sh.in - Autoconf-processed shell script for building make(1).
#

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

_CC="@CC@"

_CFLAGS="@CPPFLAGS@"
_CFLAGS="${_CFLAGS} -D_PATH_DEFSYSPATH=\"${NETBSDSRCDIR}/share/mk\""
_CFLAGS="${_CFLAGS} @DEFS@"
_CFLAGS="${_CFLAGS} @CFLAGS@"

_LDFLAGS="@LDFLAGS@ @LIBS@"

docmd () {
	echo "$1"
	$1 || exit 1
}

for f in $MKSRCDIR/*.c $MKSRCDIR/lst.lib/*.c; do
	docmd "${_CC} ${_CFLAGS} -c $f"
done

docmd "${_CC} -o ${_TOOL_PREFIX:-nb}make *.o ${_LDFLAGS}"
