#!/bin/sh
# License: CNCL 1.0 (Could Not Care Less), see LICENSE at the top of the tree.
# ccache-cc -- the target compiler of the build, behind ccache.
#
# The root Makefile hands this to build.sh as CC (MAKEFLAGS='CC=...': a make
# command-line variable beats the CC= of share/mk/bsd.own.mk, which the
# environment, -V and mk.conf do not).  A wrapper script and not
# `CC="ccache gcc"', because MAKEFLAGS splits at blanks.  TOOLDIR is in the
# environment of every command nbmake runs (src/build.sh makeenv).
: "${TOOLDIR:?ccache-cc: TOOLDIR not set; run through make}"
for cc in "$TOOLDIR"/bin/*--netbsd*-gcc; do
	[ -x "$cc" ] && exec ccache "$cc" "$@"
done
echo "ccache-cc: no target gcc in $TOOLDIR/bin" >&2
exit 1
