1#!/bin/sh
2# Looks for a suitable tclsh or jimsh in the PATH
3# If not found, builds a bootstrap jimsh in current dir from source
4# Prefer $autosetup_tclsh if is set in the environment (unless ./jimsh0 works)
5d="`dirname "$0"`"
6for tclsh in ./jimsh0 $autosetup_tclsh jimsh tclsh tclsh8.5 tclsh8.6 tclsh8.7; do
7	{ $tclsh "$d/autosetup-test-tclsh"; } 2>/dev/null && exit 0
8done
9echo 1>&2 "No installed jimsh or tclsh, building local bootstrap jimsh0"
10for cc in ${CC_FOR_BUILD:-cc} gcc; do
11	{ $cc -o jimsh0 "$d/jimsh0.c"; } 2>/dev/null || continue
12	./jimsh0 "$d/autosetup-test-tclsh" && exit 0
13done
14echo 1>&2 "No working C compiler found. Tried ${CC_FOR_BUILD:-cc} and gcc."
15echo false
16