#!/bin/sh
# $Id: cfg-tin,v 1.15 2021/01/03 15:52:08 tom Exp $
# Remove the files created by this script before running it.
rm -f config.cache config.status config.log
rm -f src/Makefile include/autoconf.h

if [ -n "$CC" ]
then
	echo "CC is set: $CC"
else
	: ${TMPDIR=/tmp}

	for compiler in gcc cc c89 c99
	do
		rm -f $TMPDIR/cfg-tin* *.o
		cat >$TMPDIR/cfg-tin.c <<EOF
#include <stdio.h>
int main(void) { printf("Hello!"); return 0; }
EOF
		if $compiler -c $TMPDIR/cfg-tin.c # >/dev/null 2>/dev/null
		then
			CC=$compiler
			export CC
			echo "CC is now set: $CC"
			break
		fi
	done
	rm -f $TMPDIR/cfg-tin* *.o
fi

case .$SHELL in
.*/sh)
	;;
*)
	# SHELL=/bin/sh
	# test -f /usr/xpg4/bin/sh && SHELL=/usr/xpg4/bin/sh 
	;;
esac

# export SHELL
# CONFIG_SHELL=$SHELL
# export CONFIG_SHELL

echo "SHELL is set: $SHELL"

./conf-tin "$@"
mv td-conf.out configure.out
