# Host-toolchain presence check for macOS. Not a real package: verify()
# only checks that the tools below are on PATH and fails with an actionable,
# OS-specific hint when one isn't - it builds/installs nothing itself.
# Depend on this from a recipe's makedepends (e.g. kcgi needs "bmake") to
# turn a silent mid-build() crash into a clear message during dependency
# resolution instead.
pkgname=build-essentials-stub
pkgver=0
pkgrel=0
pkgdesc="verifies macOS build toolchain presence (cc, make, bmake, tar, curl)"
arch="all"

checkdeps="cc make bmake tar curl"

_hint() {
	case "$1" in
	cc | make)
		echo "install Xcode Command Line Tools: xcode-select --install"
		;;
	bmake)
		echo "brew install bmake"
		;;
	tar | curl)
		echo "should ship with macOS - check your PATH"
		;;
	*)
		echo "no install hint available for '$1'"
		;;
	esac
}

verify() {
	_missing=""
	for _tool in $checkdeps; do
		command -v "$_tool" >/dev/null 2>&1 || _missing="$_missing $_tool"
	done

	[ -z "$_missing" ] && return 0

	for _tool in $_missing; do
		echo "! missing required tool: $_tool ($(_hint "$_tool"))" >&2
	done
	return 1
}
