# Configure for
# 	@@PNAME@@ @@PMAJORV@@.@@PMINORV@@
#
# Copyright (c) @@YEAR@@ @@PORG@@
#
# Generated by @@CRITCL@@
# At           @@NOW@@

AC_INIT([@@PNAME@@],[@@PMAJORV@@.@@PMINORV@@])

TEA_INIT([3.9])

AC_CONFIG_AUX_DIR(tclconfig)

#--------------------------------------------------------------------
# Configure script for package '@@PNAME@@'.
# TEA compliant.
#--------------------------------------------------------------------

#--------------------------------------------------------------------
# Load the tclConfig.sh file
#--------------------------------------------------------------------

TEA_PATH_TCLCONFIG
TEA_LOAD_TCLCONFIG

#-----------------------------------------------------------------------
## Std TEA setup

TEA_PREFIX
TEA_SETUP_COMPILER
TEA_PUBLIC_TCL_HEADERS
#TEA_PRIVATE_TCL_HEADERS
TEA_ENABLE_THREADS
TEA_ENABLE_SHARED
TEA_CONFIG_CFLAGS
TEA_ENABLE_SYMBOLS
AC_DEFINE(USE_TCL_STUBS)
TEA_MAKE_LIB
TEA_PROG_TCLSH
@@API@@
@@UCONFIG@@
#-----------------------------------------------------------------------
## Convert the TEA settings determined by the macros in the last
## section into something critcl can use throughts configuration.

AC_MSG_RESULT([critcl config: derived from core TEA])

#AC_MSG_RESULT([critcl config: CC............. ${CC}])
#AC_MSG_RESULT([critcl config: CFLAGS......... ${CFLAGS}])
#AC_MSG_RESULT([critcl config: SHLIB_LD....... ${SHLIB_LD}])
#AC_MSG_RESULT([critcl config: LIBS........... ${LIBS}|
#AC_MSG_RESULT([critcl config: MATH_LIBS...... ${MATH_LIBS}])
#AC_MSG_RESULT([critcl config: CFLAGS_DEFAULT. ${CFLAGS_DEFAULT}])
#AC_MSG_RESULT([critcl config: CFLAGS_WARNING. ${CFLAGS_WARNING}])
#AC_MSG_RESULT([critcl config: SHLIB_CFLAGS... ${SHLIB_CFLAGS}])
#AC_MSG_RESULT([critcl config: LDFLAGS_DEFAULT ${LDFLAGS_DEFAULT}])

#-----------------------------------------------------------------------
## 1. Basic/foundational translation.

CRITCL_CC="$(eval echo ${CC} -c ${CFLAGS})"
CRITCL_VERSION="${CC} -v"
CRITCL_LINK="$(eval echo $(eval echo ${SHLIB_LD} ${LIBS} ${MATH_LIBS}))"
CRITCL_PLATFORM="$(${TCLSH_PROG} ${srcdir}/critcl/main.tcl -showtarget)"
CRITCL_LD_DBG=""
CRITCL_LD_REL=""
CRITCL_CC_OUTPUT="-o [[list \$outfile]]"
CRITCL_LD_OUTPUT=""

if test "${GCC}" = "yes"
then
   CRITCL_CPP_DEFINE="${CPP} -dM"
else
   CRITCL_CPP_DEFINE="${CPP}"

   if test "${TEA_PLATFORM}" = "windows"
   then
      # windows, no gcc => msvc
      CRITCL_CC_OUTPUT="[[list -Fo\$outfile]]"
      CRITCL_LD_OUTPUT="-dll [[list -out:\$outfile]]"
      CRITCL_LD_DBG="-debug:full -debugtype:cv -verbose:lib"
      CRITCL_LD_REL="-release -opt:ref -opt:icf,3 -ws:aggressive -verbose:lib"
      if test "$do64bit" = "no" ; then
          # 32bit
	  CRITCL_LD_DBG="$CRITCL_LD_DBG -nodefaultlib:libc"
      fi
   fi
fi
CRITCL_CPP_ENUM="${CPP}"

#-----------------------------------------------------------------------
## 2. Fine tuning the commands, this now is platform specific.

case $(uname -s) in
Darwin*)
	AC_MSG_RESULT([critcl config: darwin specific tune-up])

	# - Critcl, due to essentially generating its private
	#   lib{tcl,tk}stub.a does generate common symbols for the
	#   stubs tables. Use of -fno-common then prevents linking the
	#   object files.
	#
	# - A version 0.0 as pulled from TEA package version is not
	#   liked by the Darwin gcc either (Example: crimp).

	CRITCL_CC="$(echo   "$CRITCL_CC"  |sed -e 's,-fno-common,,g')"
	CRITCL_LINK="$(echo "$CRITCL_LINK"|sed -e 's,-fno-common,,g')"
	CRITCL_LINK="$(echo "$CRITCL_LINK"|sed -e 's,-current_version 0\.0,,g')"
	CRITCL_LINK="$(echo "$CRITCL_LINK"|sed -e 's,-compatibility_version 0\.0,,g')"
	;;
*)
	;;
esac

#-----------------------------------------------------------------------
## Conversion results

AC_MSG_RESULT([critcl config: platform.......... $CRITCL_PLATFORM])
AC_MSG_RESULT([critcl config: compile........... $CRITCL_CC])
AC_MSG_RESULT([critcl config: link.............. $CRITCL_LINK])
AC_MSG_RESULT([critcl config: cpp define........ $CRITCL_CPP_DEFINE])
AC_MSG_RESULT([critcl config: cpp enum.......... $CRITCL_CPP_ENUM])
AC_MSG_RESULT([critcl config: version inquiry... $CRITCL_VERSION])
AC_MSG_RESULT([critcl config: cc output......... $CRITCL_CC_OUTPUT])
AC_MSG_RESULT([critcl config: ld output......... $CRITCL_LD_OUTPUT])
AC_MSG_RESULT([critcl config: ld debug.......... $CRITCL_LD_DBG])
AC_MSG_RESULT([critcl config: ld release........ $CRITCL_LD_REL])

#-----------------------------------------------------------------------

AC_SUBST(CRITCL_CC)
AC_SUBST(CRITCL_VERSION)
AC_SUBST(CRITCL_LINK)
AC_SUBST(CRITCL_PLATFORM)
AC_SUBST(CRITCL_CPP_DEFINE)
AC_SUBST(CRITCL_CPP_ENUM)
AC_SUBST(CRITCL_CC_OUTPUT)
AC_SUBST(CRITCL_LD_OUTPUT)
AC_SUBST(CRITCL_LD_DBG)
AC_SUBST(CRITCL_LD_REL)
#AC_SUBST(CRITCL_)
#AC_SUBST()

#--------------------------------------------------------------------
# Finally, substitute all of the various values into the Makefile.
# You may alternatively have a special pkgIndex.tcl.in or other files
# which require substituting th AC variables in.  Include these here.
#--------------------------------------------------------------------

AC_OUTPUT([Makefile Config])
