# Host-toolchain presence check for Linux. See Darwin/build-essentials-stub
# for the general idea - this just carries Linux-appropriate install hints.
pkgname=build-essentials-stub
pkgver=0
pkgrel=0
pkgdesc="verifies Linux build toolchain presence (cc, make, tar, curl)"
arch="all"

checkdeps="cc make tar curl"

_hint() {
	case "$1" in
	cc | make)
		echo "apt: apt install build-essential | apk: apk add build-base | dnf: dnf groupinstall 'Development Tools'"
		;;
	tar | curl)
		echo "apt: apt install $1 | apk: apk add $1 | dnf: dnf install $1"
		;;
	*)
		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
}
