#
# This file is a Makefile for Tclx.  If it has the name "Makefile.in"
# then it is a template for a Makefile;  to generate the actual Makefile,
# run "./configure", which is a configuration script generated by the
# "autoconf" program (constructs like "@foo@" will get replaced in the
# actual Makefile.
#
# RCS: @(#) $Id: Makefile.in,v 1.16.4.1 2002/01/16 22:38:25 andreas_kupries Exp $

TCLVERSION = @TCL_VERSION@
VERSION = @TCLX_VERSION@

#----------------------------------------------------------------
# Things you can change to personalize the Makefile for your own
# site (you can make these changes in either Makefile.in or
# Makefile, but changes to Makefile will get lost if you re-run
# the configuration script).
#----------------------------------------------------------------

# Libraries built with optimization switches have this additional extension
TCLX_DBGX = @TCLX_DBGX@

# The cygwin environment has tools to convert paths from UNIX style
# paths to Windows paths.

PATHTYPE = @PATHTYPE@

# Macro that expands to the first dependency argument with the appropriate
# path type already resolved.

DEPARG = "$(shell cygpath $(PATHTYPE) $<)"

# Default top-level directories in which to install architecture-
# specific files (exec_prefix) and machine-independent files such
# as scripts (prefix).  The values specified here may be overridden
# at configure-time with the --exec-prefix and --prefix options
# to the "configure" script.

srcdir		= @srcdir@
top_srcdir	= @top_srcdir@
prefix		= @prefix@
exec_prefix	= @exec_prefix@
bindir		= @bindir@
libdir		= @libdir@

# The following definition can be set to non-null for special systems
# like AFS with replication.  It allows the pathnames used for installation
# to be different than those used for actually reference files at
# run-time.  INSTALL_ROOT is prepended to $prefix and $exec_prefix
# when installing files.
INSTALL_ROOT	=

# Directory from which applications will reference the library of Tclx
# scripts (note: you can set the TCLX_LIBRARY environment variable at
# run-time to override this value):
TCLX_LIBRARY	= $(exec_prefix)/lib/tclX$(VERSION)
TKX_LIBRARY	= $(exec_prefix)/lib/tkX$(VERSION)

# Directory in which to install the program tclxsh:
BIN_INSTALL_DIR = $(INSTALL_ROOT)$(exec_prefix)/bin

# Directory in which to install libtclx.so or libtclx.a:
LIB_INSTALL_DIR = $(INSTALL_ROOT)$(exec_prefix)/lib

# Path name to use when installing library scripts:
TCLX_SCRIPT_INSTALL_DIR = $(INSTALL_ROOT)$(TCLX_LIBRARY)
TKX_SCRIPT_INSTALL_DIR  = $(INSTALL_ROOT)$(TKX_LIBRARY)

TCLX_SCRIPT_INSTALL_NATIVE= $(shell cygpath $(PATHTYPE) '$(INSTALL_ROOT)$(TCLX_LIBRARY)')
TKX_SCRIPT_INSTALL_NATIVE = $(shell cygpath $(PATHTYPE) '$(INSTALL_ROOT)$(TKX_LIBRARY)')

# Directory in which to install the include file tclx.h:
INCLUDE_INSTALL_DIR = $(INSTALL_ROOT)$(prefix)/include

TCLX_DLL_FILE		= @TCLX_DLL_FILE@
TCLX_LIB_FILE		= @TCLX_LIB_FILE@
TKX_LIB_FILE		= @TKX_LIB_FILE@
TKX_DLL_FILE		= @TKX_DLL_FILE@

TCLX_SRC_DIR		= @srcdir@
TCLX_ROOT_DIR		= $(TCLX_SRC_DIR)/../tcl
TCLX_GENERIC_DIR	= $(TCLX_ROOT_DIR)/generic
TCLX_COMPAT_DIR		= $(TCLX_ROOT_DIR)/compat
TCLX_WIN_DIR		= $(TCLX_ROOT_DIR)/win
TCLX_RUNTIME_DIR	= $(TCLX_ROOT_DIR)/runtime
TCLX_TOOLS_DIR		= $(TCLX_ROOT_DIR)/../unix/tools
TCLX_BIN_DIR		= .

TKX_SRC_DIR		= @srcdir@
TKX_ROOT_DIR		= $(TKX_SRC_DIR)/../tk
TKX_GENERIC_DIR		= $(TKX_ROOT_DIR)/generic
TKX_COMPAT_DIR		= $(TKX_ROOT_DIR)/compat
TKX_WIN_DIR		= $(TKX_ROOT_DIR)/win
TKX_RUNTIME_DIR		= $(TKX_ROOT_DIR)/runtime
TKX_TOOLS_DIR		= $(TCLX_ROOT_DIR)/../unix/tools
TKX_BIN_DIR		= $(TCLX_BIN_DIR)

TCL_LIB_FILE	  = "$(shell cygpath $(PATHTYPE) '@TCL_BIN_DIR@/@TCL_LIB_FILE@')"
TCL_STUB_LIB_FILE = "$(shell cygpath $(PATHTYPE) '@TCL_BIN_DIR@/@TCL_STUB_LIB_FILE@')"
TCL_DLL_FILE		= @TCL_DLL_FILE@
TCL_SRC_DIR		= @TCL_SRC_DIR@
TCL_BIN_DIR		= $(shell cygpath -u '@TCL_BIN_DIR@')
TCL_GENERIC_DIR		= $(TCL_SRC_DIR)/generic
TCL_TEST_DIR		= $(TCL_SRC_DIR)/tests
TCL_WIN_DIR		= $(TCL_SRC_DIR)/win
TCL_LIBRARY_DIR		= $(TCL_SRC_DIR)/library

TK_LIB_FILE	  = "$(shell cygpath $(PATHTYPE) '@TK_BIN_DIR@/@TK_LIB_FILE@')"
TK_STUB_LIB_FILE = "$(shell cygpath $(PATHTYPE) '@TK_BIN_DIR@/@TK_STUB_LIB_FILE@')"
TK_DLL_FILE		= @TK_DLL_FILE@
TK_SRC_DIR		= @TK_SRC_DIR@
TK_BIN_DIR		= $(shell cygpath -u '@TK_BIN_DIR@')
TK_GENERIC_DIR		= $(TK_SRC_DIR)/generic
TK_TEST_DIR		= $(TK_SRC_DIR)/tests
TK_WIN_DIR		= $(TK_SRC_DIR)/win
TK_BITMAP_DIR		= $(TK_SRC_DIR)/bitmaps
TK_XLIB_DIR		= $(TK_SRC_DIR)/xlib
TK_LIBRARY_DIR		= $(TK_SRC_DIR)/library

TCLX_ROOT_DIR_NATIVE   	= $(shell cygpath $(PATHTYPE) '$(TCLX_ROOT_DIR)')
TCLX_WIN_DIR_NATIVE	= $(shell cygpath $(PATHTYPE) '$(TCLX_WIN_DIR)')
TCLX_GENERIC_DIR_NATIVE = $(shell cygpath $(PATHTYPE) '$(TCLX_GENERIC_DIR)')
TCLX_BIN_DIR_NATIVE	= $(shell cygpath $(PATHTYPE) "${TCLX_BIN_DIR}")
TCLX_RUNTIME_DIR_NATIVE = $(shell cygpath $(PATHTYPE) '$(TCLX_RUNTIME_DIR)')

TKX_ROOT_DIR_NATIVE	= $(shell cygpath $(PATHTYPE) '$(TKX_ROOT_DIR)')
TKX_WIN_DIR_NATIVE	= $(shell cygpath $(PATHTYPE) '$(TKX_WIN_DIR)')
TKX_GENERIC_DIR_NATIVE	= $(shell cygpath $(PATHTYPE) '$(TKX_GENERIC_DIR)')
TKX_BIN_DIR_NATIVE	= $(shell cygpath $(PATHTYPE) "${TKX_BIN_DIR}")
TKX_RUNTIME_DIR_NATIVE	= $(shell cygpath $(PATHTYPE) '$(TKX_RUNTIME_DIR)')

TCL_GENERIC_NATIVE	= $(shell cygpath $(PATHTYPE) '$(TCL_GENERIC_DIR)')
TCL_WIN_NATIVE		= $(shell cygpath $(PATHTYPE) '$(TCL_WIN_DIR)')
TCL_BIN_NATIVE		= $(shell cygpath $(PATHTYPE) '$(TCL_BIN_DIR)')
TCL_LIBRARY_DIR_NATIVE	= $(shell cygpath $(PATHTYPE) '$(TCL_LIBRARY_DIR)')

TK_GENERIC_NATIVE	= $(shell cygpath $(PATHTYPE) '$(TK_GENERIC_DIR)')
TK_WIN_NATIVE		= $(shell cygpath $(PATHTYPE) '$(TK_WIN_DIR)')
TK_BIN_NATIVE		= $(shell cygpath $(PATHTYPE) '$(TK_BIN_DIR)')
TK_LIBRARY_DIR_NATIVE	= $(shell cygpath $(PATHTYPE) '$(TK_LIBRARY_DIR)')
TK_BITMAP_DIR_NATIVE	= $(shell cygpath $(PATHTYPE) '$(TK_BITMAP_DIR)')
TK_XLIB_DIR_NATIVE	= $(shell cygpath $(PATHTYPE) '$(TK_XLIB_DIR)')

@SET_MAKE@

# Setting the VPATH variable to a list of paths will cause the 
# makefile to look into these paths when resolving .c to .obj
# dependencies.

VPATH = $(TCLX_GENERIC_DIR);$(TCLX_WIN_DIR);$(TKX_GENERIC_DIR);$(TKX_WIN_DIR);$(TCLX_COMPAT_DIR);$(TCL_GENERIC_DIR);$(TCL_WIN_DIR);$(TK_GENERIC_DIR);$(TK_WIN_DIR) # :

# warning flags
CFLAGS_WARNING	= @CFLAGS_WARNING@

# The default switches for optimization or debugging
CFLAGS_DEBUG    = @CFLAGS_DEBUG@
CFLAGS_OPTIMIZE	= @CFLAGS_OPTIMIZE@

# The default switches for optimization or debugging
LDFLAGS_DEBUG    = @LDFLAGS_DEBUG@
LDFLAGS_OPTIMIZE = @LDFLAGS_OPTIMIZE@

# To change the compiler switches, for example to change from optimization to
# debugging symbols, change the following line:
#CFLAGS		= $(CFLAGS_DEBUG)
#CFLAGS		= $(CFLAGS_OPTIMIZE)
#CFLAGS		= $(CFLAGS_DEBUG) $(CFLAGS_OPTIMIZE)
CFLAGS		= @CFLAGS@

AR		= @AR@
CC		= @CC@
RC		= @RC@
AC_FLAGS	= @EXTRA_CFLAGS@ @DEFS@
CPPFLAGS	= @CPPFLAGS@
LDFLAGS		= @LDFLAGS@
LDFLAGS_CONSOLE	= @LDFLAGS_CONSOLE@
LDFLAGS_WINDOW	= @LDFLAGS_WINDOW@
EXEEXT		= @EXEEXT@
OBJEXT		= @OBJEXT@
STLIB_LD	= @STLIB_LD@
SHLIB_LD	= @SHLIB_LD@
SHLIB_LD_LIBS	= @SHLIB_LD_LIBS@ $(TCL_STUB_LIB_FILE) Wsock32.lib
SHLIB_CFLAGS	= @SHLIB_CFLAGS@
SHLIB_SUFFIX	= @SHLIB_SUFFIX@
VER		= @TCLX_MAJOR_VERSION@@TCLX_MINOR_VERSION@@TCLX_PATCH_LEVEL@
DOTVER	        = @TCLX_MAJOR_VERSION@.@TCLX_MINOR_VERSION@.@TCLX_PATCH_LEVEL@
LIBS		= @LIBS@ Wsock32.lib @TCL_LIBS@
WISHLIBS	= @LIBS@ Wsock32.lib @TK_LIBS@
RMDIR		= rm -rf
MKDIR		= mkdir -p
RM		= rm -f
COPY		= cp
AUTOCONF	= autoconf

TCLXSH		= tclxsh.exe
WISHX		= wishx.exe
TCLXTEST	= tclxtest
TKXTEST		= tkxtest
CAT32		= cat32
CATTCL		= cattcl

CC_OBJNAME	= @CC_OBJNAME@
CC_EXENAME	= @CC_EXENAME@

SHARED_LIBRARIES = $(TCLX_DLL_FILE) $(TKX_DLL_FILE)
STATIC_LIBRARIES = $(TCLX_LIB_FILE) $(TKX_LIB_FILE)

CC_SWITCHES = ${CFLAGS} ${CFLAGS_WARNING} ${SHLIB_CFLAGS} \
-I"${TCLX_GENERIC_DIR_NATIVE}" -I"${TCLX_WIN_DIR_NATIVE}"  \
-I"${TCL_GENERIC_NATIVE}" -I"${TCL_WIN_NATIVE}"  \
-I"${TK_GENERIC_NATIVE}" -I"${TK_WIN_NATIVE}"  \
-I"${TK_XLIB_DIR_NATIVE}" -I"${TK_BITMAP_DIR_NATIVE}"  \
${AC_FLAGS}

STUB_CC_SWITCHES = ${CC_SWITCHES}

RUN_TCLX_SETUP	= PATH="$(TCL_BIN_DIR)"; export PATH; \
		  TCL_LIBRARY="$(TCL_LIBRARY_DIR_NATIVE)"; export TCL_LIBRARY; \
		  TCLX_LIBRARY="$(TCLX_BIN_DIR_NATIVE)"; export TCLX_LIBRARY; \
		  TCL_PROGRAM="$(TCLX_BIN_DIR_NATIVE)/$(TCLXTEST)"; \
		  export TCL_PROGRAM;

RUN_TKX_SETUP	= PATH="$(TCL_BIN_DIR)"; export PATH; \
		  TCL_LIBRARY="$(TCL_LIBRARY_DIR_NATIVE)"; export TCL_LIBRARY; \
		  TK_LIBRARY="$(TK_LIBRARY_DIR_NATIVE)"; export TK_LIBRARY; \
		  TCLX_LIBRARY="$(TCLX_BIN_DIR_NATIVE)"; export TCLX_LIBRARY; \
		  TKX_LIBRARY="$(TKX_BIN_DIR_NATIVE)"; export TKX_LIBRARY; \
		  TCL_PROGRAM="$(TCLX_BIN_DIR_NATIVE)/$(TKXTEST)"; \
		  export TCL_PROGRAM;

RUN_TCLXSH	= $(RUN_TCLX_SETUP) $(TCLX_BIN_DIR)/$(TCLXSH)
RUN_TCLXTEST	= $(RUN_TCLX_SETUP) $(TCLX_BIN_DIR)/$(TCLXTEST)
RUN_WISHX	= $(RUN_TKX_SETUP)  $(TCLX_BIN_DIR)/$(WISHX)
RUN_TKXTEST	= $(RUN_TKX_SETUP)  $(TCLX_BIN_DIR)/$(TKXTEST)
INSTCOPY	= $(RUN_TCLXSH) ./instcopy

TCLXSH_OBJS = \
	tclXAppInit.$(OBJEXT)

TCLXTEST_OBJS = \
	tclXtest.$(OBJEXT) \
	tclXwinTest.$(OBJEXT) \
	tclTest.$(OBJEXT) \
	tclWinTest.$(OBJEXT) \
	tclTestObj.$(OBJEXT)

TCLX_OBJS = \
	tclXbsearch.$(OBJEXT) \
	tclXchmod.$(OBJEXT) \
	tclXcmdInit.$(OBJEXT) \
	tclXcmdloop.$(OBJEXT) \
	tclXdebug.$(OBJEXT) \
	tclXdup.$(OBJEXT) \
	tclXfcntl.$(OBJEXT) \
	tclXfilecmds.$(OBJEXT) \
	tclXfilescan.$(OBJEXT) \
	tclXflock.$(OBJEXT) \
	tclXfstat.$(OBJEXT) \
	tclXgeneral.$(OBJEXT) \
	tclXhandles.$(OBJEXT) \
	tclXinit.$(OBJEXT) \
	tclXkeylist.$(OBJEXT) \
	tclXlgets.$(OBJEXT) \
	tclXlib.$(OBJEXT) \
	tclXlibInit.$(OBJEXT) \
	tclXlist.$(OBJEXT) \
	tclXmath.$(OBJEXT) \
	tclXmsgcat.$(OBJEXT) \
	tclXoscmds.$(OBJEXT) \
	tclXprocess.$(OBJEXT) \
	tclXprofile.$(OBJEXT) \
	tclXshell.$(OBJEXT) \
	tclXsignal.$(OBJEXT) \
	tclXsocket.$(OBJEXT) \
	tclXstring.$(OBJEXT) \
	tclXutil.$(OBJEXT) \
	tclXwinId.$(OBJEXT) \
	tclXwinCmds.$(OBJEXT) \
	tclXwinDup.$(OBJEXT) \
	tclXwinOS.$(OBJEXT) \
	random.$(OBJEXT) \
	getopt.$(OBJEXT)

WISHX_OBJS = \
	tkXAppInit.$(OBJEXT)

TKXTEST_OBJS = \
	tkTest.$(OBJEXT) \
	tkSquare.$(OBJEXT) \
	tkXwinTest.$(OBJEXT)

TKX_OBJS = \
        tkXinit.$(OBJEXT) \
        tkXshell.$(OBJEXT) \
        tkXwinUtil.$(OBJEXT)

TLIB_SRCS = \
	$(TCLX_RUNTIME_DIR)/arrayprocs.tcl \
	$(TCLX_RUNTIME_DIR)/compat.tcl \
	$(TCLX_RUNTIME_DIR)/convlib.tcl \
	$(TCLX_RUNTIME_DIR)/edprocs.tcl \
	$(TCLX_RUNTIME_DIR)/events.tcl \
	$(TCLX_RUNTIME_DIR)/forfile.tcl \
	$(TCLX_RUNTIME_DIR)/globrecur.tcl \
	$(TCLX_RUNTIME_DIR)/help.tcl \
	$(TCLX_RUNTIME_DIR)/profrep.tcl \
	$(TCLX_RUNTIME_DIR)/pushd.tcl \
	$(TCLX_RUNTIME_DIR)/setfuncs.tcl \
	$(TCLX_RUNTIME_DIR)/showproc.tcl \
	$(TCLX_RUNTIME_DIR)/stringfile.tcl \
	$(TCLX_RUNTIME_DIR)/tcllib.tcl \
	$(TCLX_RUNTIME_DIR)/fmath.tcl \
	$(TCLX_RUNTIME_DIR)/buildhelp.tcl

TLIB_SRCS_NATIVE= \
	"$(TCLX_RUNTIME_DIR_NATIVE)\arrayprocs.tcl" \
	"$(TCLX_RUNTIME_DIR_NATIVE)\compat.tcl" \
	"$(TCLX_RUNTIME_DIR_NATIVE)\convlib.tcl" \
	"$(TCLX_RUNTIME_DIR_NATIVE)\edprocs.tcl" \
	"$(TCLX_RUNTIME_DIR_NATIVE)\events.tcl" \
	"$(TCLX_RUNTIME_DIR_NATIVE)\forfile.tcl" \
	"$(TCLX_RUNTIME_DIR_NATIVE)\globrecur.tcl" \
	"$(TCLX_RUNTIME_DIR_NATIVE)\help.tcl" \
	"$(TCLX_RUNTIME_DIR_NATIVE)\profrep.tcl" \
	"$(TCLX_RUNTIME_DIR_NATIVE)\pushd.tcl" \
	"$(TCLX_RUNTIME_DIR_NATIVE)\setfuncs.tcl" \
	"$(TCLX_RUNTIME_DIR_NATIVE)\showproc.tcl" \
	"$(TCLX_RUNTIME_DIR_NATIVE)\stringfile.tcl" \
	"$(TCLX_RUNTIME_DIR_NATIVE)\tcllib.tcl" \
	"$(TCLX_RUNTIME_DIR_NATIVE)\fmath.tcl" \
	"$(TCLX_RUNTIME_DIR_NATIVE)\buildhelp.tcl"

all: binaries libraries doc

binaries: @LIBRARIES@ $(TCLXSH) $(WISHX)

libraries: autoload.tcl tclx.tcl tkx.tcl tcl.tlib tcl.tndx buildidx.tcl instcopy

doc:

$(TCLXSH): $(TCLX_LIB_FILE) $(TCLXSH_OBJS) tcl.res
	$(CC) $(CFLAGS) $(TCLXSH_OBJS) $(TCL_LIB_FILE) $(TCLX_LIB_FILE) \
	@STUB_LIBS@ \
	$(LIBS) tcl.res $(CC_EXENAME)

$(TCLXTEST): $(TCLX_LIB_FILE) $(TCLXTEST_OBJS) tcl.res
	$(CC) $(CFLAGS) $(TCLXTEST_OBJS) $(TCL_LIB_FILE) $(TCLX_LIB_FILE) \
	@STUB_LIBS@ \
	$(LIBS) tcl.res $(CC_EXENAME)

$(WISHX): $(TKX_LIB_FILE) $(WISHX_OBJS) wishx.res
	$(CC) $(CFLAGS) $(WISHX_OBJS) $(TKX_LIB_FILE) $(TCLX_LIB_FILE) \
	$(TCL_LIB_FILE) $(TK_LIB_FILE) \
	@STUB_LIBS@ \
	$(WISHLIBS) wishx.res $(CC_EXENAME) \
	-link $(LDFLAGS_WINDOW)

$(TKXTEST): $(TKX_LIB_FILE) $(TKXTEST_OBJS) wishx.res
	$(CC) $(CFLAGS) $(TKXTEST_OBJS) $(TKX_LIB_FILE) $(TCLX_LIB_FILE) \
	$(TCL_LIB_FILE) $(TK_LIB_FILE) \
	@STUB_LIBS@ \
	$(LIBS) wishx.res $(CC_EXENAME)

$(CAT32)${EXEEXT}: $(CAT32).${OBJEXT}
	$(CC) $(CFLAGS) $(CAT32).${OBJEXT} $(CC_EXENAME) \
	-link $(LDFLAGS_CONSOLE)

$(CAT32).${OBJEXT}: cat.c
	$(CC) -c $(CC_SWITCHES) $(DEPARG) $(CC_OBJNAME)

$(CATTCL)${EXEEXT}: $(CATTCL).${OBJEXT}
	$(CC) $(CFLAGS) $(CATTCL).${OBJEXT} $(CC_EXENAME) \
	-link $(LDFLAGS_CONSOLE)

$(CATTCL).${OBJEXT}: cattcl.c
	$(CC) -c $(CC_SWITCHES) $(DEPARG) $(CC_OBJNAME)

# The following targets are configured by autoconf to generate either
# a shared library or static library

${TCLX_DLL_FILE}: ${TCLX_OBJS} tcl.res
	@$(RM) ${TCLX_DLL_FILE}
	@MAKE_SHARED_LIB@ ${TCLX_OBJS} tcl.res

${TCLX_LIB_FILE}: ${TCLX_OBJS}
	@$(RM) ${TCLX_LIB_FILE}
	@MAKE_STATIC_LIB@ ${TCLX_OBJS}

${TKX_DLL_FILE}: ${TKX_OBJS} tkx.res
	@$(RM) ${TKX_DLL_FILE}
	@MAKE_SHARED_LIB@ ${TKX_OBJS} ${TCLX_LIB_FILE} ${TK_STUB_LIB_FILE} tkx.res 

${TKX_LIB_FILE}: ${TKX_OBJS}
	@$(RM) ${TKX_LIB_FILE}
	@MAKE_STATIC_LIB@ ${TKX_OBJS} 

# Special case object targets

tclXinit.$(OBJEXT): tclXinit.c
	$(CC) -c $(STUB_CC_SWITCHES) ${DEPARG} \
	-DTCLX_LIBRARY="\"$(TCLX_LIBRARY)\"" -DBUILD_TCLX \
	$(CC_OBJNAME)

tclXAppInit.$(OBJEXT): tclXAppInit.c
	$(CC) -c $(CC_SWITCHES) ${DEPARG} $(CC_OBJNAME)

tclXtest.$(OBJEXT): tclXtest.c
	$(CC) -c $(CC_SWITCHES) ${DEPARG} $(CC_OBJNAME)

tclXwinTest.$(OBJEXT): tclXwinTest.c
	$(CC) -c $(CC_SWITCHES) ${DEPARG} $(CC_OBJNAME)

tclTest.$(OBJEXT): tclTest.c
	$(CC) -c $(CC_SWITCHES) ${DEPARG} $(CC_OBJNAME)

tclWinTest.$(OBJEXT): tclWinTest.c
	$(CC) -c $(CC_SWITCHES) ${DEPARG} $(CC_OBJNAME)

tclTestObj.$(OBJEXT): tclTestObj.c
	$(CC) -c $(CC_SWITCHES) ${DEPARG} $(CC_OBJNAME)

getopt.$(OBJEXT): getopt.c
	$(CC) -c $(STUB_CC_SWITCHES) -DWIN32 -DBUILD_TCLX ${DEPARG} \
	$(CC_OBJNAME)

tkXinit.$(OBJEXT): tkXinit.c
	$(CC) -c $(STUB_CC_SWITCHES) ${DEPARG} \
	-DBUILD_tkx \
	-DTKX_LIBRARY="\"$(TCLX_LIBRARY)\"" $(CC_OBJNAME)

tkXshell.$(OBJEXT): tkXshell.c
	$(CC) -c $(STUB_CC_SWITCHES) ${DEPARG} \
	-DBUILD_tkx $(CC_OBJNAME)

tkXwinUtil.$(OBJEXT): tkXwinUtil.c
	$(CC) -c $(STUB_CC_SWITCHES) ${DEPARG} \
	-DBUILD_tkx $(CC_OBJNAME)

tkXAppInit.$(OBJEXT): tkXAppInit.c
	$(CC) -c $(CC_SWITCHES) ${DEPARG} $(CC_OBJNAME)

tkXwinTest.$(OBJEXT): tkXwinTest.c
	$(CC) -c $(CC_SWITCHES) ${DEPARG} $(CC_OBJNAME)

tkTest.$(OBJEXT): tkTest.c
	$(CC) -c $(CC_SWITCHES) ${DEPARG} $(CC_OBJNAME)

tkSquare.$(OBJEXT): tkSquare.c
	$(CC) -c $(CC_SWITCHES) ${DEPARG} $(CC_OBJNAME)

#------------------------------------------------------------------------------
# Generate the runtime .tlib library in the current directory.  Copy other
# runtime files into this directory so it can be used as a temporary runtime
# directory before installation.  Also need a "help" directory here so that
# the help command will work before installation.  Normally just symlink,
# unless we don't have them.
#

tcl.tlib: ${TLIB_SRCS} autoload.tcl $(CATTCL)${EXEEXT}
	@$(RM) $@ 
	./$(CATTCL)${EXEEXT} ${TLIB_SRCS_NATIVE} > tcl.tlib

tcl.tndx: tclx.tcl tcl.tlib buildidx.tcl
	@$(RM) $@ 
	$(RUN_TCLXSH) -q  \
		"$(shell cygpath $(PATHTYPE) '$(TCLX_TOOLS_DIR)/genindex.tcl')" \
		tcl.tlib

tclx.tcl: ${TCLX_RUNTIME_DIR}/tclx.tcl
	@$(RM) tclx.tcl
	$(COPY) ${TCLX_RUNTIME_DIR}/tclx.tcl tclx.tcl

buildidx.tcl: ${TCLX_RUNTIME_DIR}/buildidx.tcl
	@$(RM) buildidx.tcl
	$(COPY) ${TCLX_RUNTIME_DIR}/buildidx.tcl buildidx.tcl

autoload.tcl: ${TCLX_RUNTIME_DIR}/autoload.tcl
	@$(RM) autoload.tcl
	$(COPY) ${TCLX_RUNTIME_DIR}/autoload.tcl autoload.tcl

tkx.tcl: ${TKX_RUNTIME_DIR}/tkx.tcl
	@$(RM) tkx.tcl
	$(COPY) ${TKX_RUNTIME_DIR}/tkx.tcl tkx.tcl

instcopy: $(TCLX_TOOLS_DIR)/buildutil.tcl $(TCLX_TOOLS_DIR)/instcopy.tcl \
		$(CATTCL)${EXEEXT}
	@$(RM) instcopy
	./$(CATTCL)${EXEEXT} \
	    "$(shell cygpath $(PATHTYPE) '$(TCLX_TOOLS_DIR)/buildutil.tcl')" \
	    "$(shell cygpath $(PATHTYPE) '$(TCLX_TOOLS_DIR)/instcopy.tcl')" >$@

# Add the object extension to the implicit rules.  By default .obj is not
# automatically added.

.SUFFIXES: .${OBJEXT}
.SUFFIXES: .res
.SUFFIXES: .rc

# Implicit rule for all object files that will end up in the Tclx library

.c.${OBJEXT}:
	$(CC) -c $(STUB_CC_SWITCHES) -DBUILD_TCLX ${DEPARG} $(CC_OBJNAME)

.rc.res:
	$(RC) -fo $@ -r -i "$(TCLX_GENERIC_DIR_NATIVE)" \
		-i "$(TCLX_WIN_DIR_NATIVE)" $(DEPARG)

install: all install-binaries install-libraries install-doc

install-binaries:
	@for i in $(BIN_INSTALL_DIR) $(LIB_INSTALL_DIR); \
	    do \
	    if [ ! -d $$i ] ; then \
		echo "Making directory $$i"; \
		$(MKDIR) $$i; \
		fi; \
	    done;
	@for i in $(TCLXSH) $(TCLX_DLL_FILE) $(WISHX) $(TKX_DLL_FILE); \
	    do \
	    if [ -f $$i ]; then \
		echo "Installing into $(BIN_INSTALL_DIR) $$i"; \
		$(COPY) $$i "$(BIN_INSTALL_DIR)"; \
	    fi; \
	    done
	@for i in $(TCLX_LIB_FILE) $(TKX_LIB_FILE); \
	    do \
	    if [ -f $$i ]; then \
		echo "Installing into $(LIB_INSTALL_DIR) $$i"; \
		$(COPY) $$i "$(LIB_INSTALL_DIR)"; \
	    fi; \
	    done

install-libraries:
	@for i in $(INCLUDE_INSTALL_DIR) $(TCLX_SCRIPT_INSTALL_DIR) \
		  $(TKX_SCRIPT_INSTALL_DIR); \
	    do \
	    if [ ! -d $$i ] ; then \
		echo "Making directory $$i"; \
		$(MKDIR) $$i; \
		fi; \
	    done;
	@for i in $(TCLX_GENERIC_DIR)/tclExtend.h ; \
	    do \
	    if [ -f $$i ]; then \
		echo "Installing into $(INCLUDE_INSTALL_DIR) $$i"; \
		$(COPY) $$i "$(INCLUDE_INSTALL_DIR)"; \
	    fi; \
	    done
	@for i in tcl.tlib tcl.tndx tclx.tcl tkx.tcl buildidx.tcl autoload.tcl; \
	    do \
	    if [ -f $$i ]; then \
		echo "Installing into $(TCLX_SCRIPT_INSTALL_DIR) $$i"; \
		$(COPY) $$i "$(TCLX_SCRIPT_INSTALL_DIR)"; \
	    fi; \
	    done
	@for i in tkx.tcl ; \
	    do \
	    if [ -f $$i ]; then \
		echo "Installing into $(TKX_SCRIPT_INSTALL_DIR) $$i"; \
		$(COPY) $$i "$(TKX_SCRIPT_INSTALL_DIR)"; \
	    fi; \
	    done
	@$(RM) ./tclXTempPkgIndexFile
	@echo " \
	lassign \$$argv package indexPath dllName ; \
	set fd       [open \$$indexPath w] ; \
	set version  [package require Tcl] ; \
	set xversion [package require Tclx] ; \
	puts \$$fd \"# Tcl package index file, version 1.0\" ; \
	puts \$$fd \"#\" ; \
	puts \$$fd \"# Package index for \$$package \$$xversion.\" ; \
	puts \$$fd \"#\" ; \
	puts \$$fd \"if \{\[catch {package require Tcl \$$version\}\]\} \{\" ;\
	puts \$$fd \"    return\" ; \
	puts \$$fd \"}\" ; \
	puts \$$fd \"package ifneeded \$$package \$$xversion \\\\\" ; \
	puts \$$fd \"\\t\[list load \[file join \\\$$dir .. .. bin \$$dllName] \$$package]\" ; \
	close \$$fd ; \
	" >> ./tclXTempPkgIndexFile
	@echo "installing into $(TCLX_SCRIPT_INSTALL_DIR) pkgIndex.tcl"
	@$(RUN_TCLXSH) -q  ./tclXTempPkgIndexFile Tclx \
		"$(TCLX_SCRIPT_INSTALL_NATIVE)/pkgIndex.tcl" "$(TCLX_DLL_FILE)"
	@echo "installing into $(TKX_SCRIPT_INSTALL_DIR) pkgIndex.tcl"
	@$(RUN_TCLXSH) -q  ./tclXTempPkgIndexFile Tkx \
		"$(TKX_SCRIPT_INSTALL_NATIVE)/pkgIndex.tcl" "$(TKX_DLL_FILE)"
	@$(RM) ./tclXTempPkgIndexFile

install-doc:
#	@echo "installing into $(TCLX_SCRIPT_INSTALL_DIR)/help help"
#	@$(INSTCOPY) $(TCLX_ROOT_DIR)/help "$(TCLX_SCRIPT_INSTALL_NATIVE)/help"
#	@echo "installing into $(TKX_SCRIPT_INSTALL_DIR)/help help"
#	@$(INSTCOPY) $(TKX_ROOT_DIR)/help "$(TKX_SCRIPT_INSTALL_NATIVE)/help";\

test: all $(TCLXTEST) $(TKXTEST) $(CAT32)${EXEEXT}
	(cd "$(TKX_ROOT_DIR_NATIVE)\tests"; $(RUN_TKXTEST) all \
	$(TESTFLAGS)) | ./$(CAT32)${EXEEXT}
	(cd "$(TCLX_ROOT_DIR_NATIVE)\tests"; $(RUN_TCLXTEST) all \
	$(TESTFLAGS)) | ./$(CAT32)${EXEEXT}

runtest: all $(TCLXTEST)
	(cd "$(TCLX_ROOT_DIR_NATIVE)\tests"; $(RUN_TCLXTEST))

runtclxsh: all $(TCLXSH)
	$(RUN_TCLXSH)

runwishx: all $(WISHX)
	$(RUN_WISHX)

depend:

clean:
	$(RM) *.${OBJEXT}
	$(RM) *~ \#* TAGS a.out
	$(RM) tcl.tlib tcl.tndx tclx.tcl buildidx.tcl
	$(RM) autoload.tcl instcopy
	$(RM) *.exp *.lib *.exe *.def *.res *.pch *.pdb *.ilk
	$(RM) $(TCLX_LIB_FILE) $(TCLX_DLL_FILE)
	$(RM) $(TKX_LIB_FILE) $(TKX_DLL_FILE)
	$(RM) $(TCLXSH) $(TCLXTEST) $(WISHX) $(TKXTEST) $(CAT32) $(CATTCL)

distclean: clean
	$(RM) Makefile config.status config.cache config.log

Makefile: $(srcdir)/Makefile.in  config.status
	CONFIG_FILES=$@ CONFIG_HEADERS= $(SHELL) ./config.status

config.status: $(srcdir)/configure
	$(SHELL) ./config.status --recheck
$(srcdir)/configure: $(srcdir)/configure.in $(ACLOCAL_M4) $(CONFIGURE_DEPENDENCIES)
	cd $(srcdir) && $(AUTOCONF)
