#!/bin/sh

cachefile=${1-//}

if [ -f $cachefile ]; then
	echo "Using $cachefile" >&2
	exec cat $cachefile
fi

case $cachefile in
/*) ;;
*) cachefile=`pwd`/$cachefile ;;
esac

cd `dirname $0`
for systype in [a-z]*; do
	if [ -f $systype/probe ]; then
		if sh $systype/probe; then
			case $cachefile in
			//)	;;
			*) 	echo "Making $cachefile" >&2
				echo $systype > $cachefile
				;;
			esac
			exec echo $systype
		fi
	fi
done

echo unknown
exit 0
