#!/bin/sh
# $Id: cfg-tin,v 1.18 2024/12/07 16:05:49 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

if test -d /opt/dickey/include
then
	CFLAGS="-I/opt/dickey/include $CFLAGS"
	export CFLAGS
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
