#
# This file is a Makefile for Tk.  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.


include ../config.make

#----------------------------------------------------------------
# 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).
#----------------------------------------------------------------

# Directory in which to install the library of Tk scripts and demos
# (note: you can set the STK_LIBRARY environment variable at run-time to
# override the compiled-in location):
STK_LIBRARY = $(libdir)

# Directory in which to install the manual pages
MAN1_DIR = $(mandir)/man1
MAN3_DIR = $(mandir)/man3
MANN_DIR = $(mandir)/mann

# A "-I" switch that can be used when compiling to make all of the
# X11 include files accessible (the configure script will try to
# set this value, and will cause it to be an empty string if the
# include files are accessible via /usr/include).
X11_INCLUDES =	$(XINCLUDES)

# Linker switch(es) to use to link with the X11 library archive (the
# configure script will try to set this value automatically, but you
# can override it).
X11_LIB_SWITCHES =	@XLIBSW@

# Libraries to use when linking:  must include at least Tk, Tcl, Xlib,
# and the math library (in that order).  The "@LIBS@" part will be
# replaced (or has already been replaced) with relevant libraries as
# determined by the configure script.
LIBS = libtk.a $(TCL_DIR)/libtcl.a $(X11_LIB_SWITCHES) -lm @LIBS@

# To turn off the security checks that disallow incoming sends when
# the X server appears to be insecure, reverse the comments on the
# following lines:
SECURITY_FLAGS =
#SECURITY_FLAGS = -DTK_NO_SECURITY

# To disable ANSI-C procedure prototypes reverse the comment characters
# on the following lines:
PROTO_FLAGS =
#PROTO_FLAGS = -DNO_PROTOTYPE

# To enable memory debugging reverse the comment characters on the following
# lines.  Warning:  if you enable memory debugging, you must do it
# *everywhere*, including all the code that calls Tcl, and you must use
# ckalloc and ckfree everywhere instead of malloc and free.
MEM_DEBUG_FLAGS =
#MEM_DEBUG_FLAGS = -DTCL_MEM_DEBUG

# Some versions of make, like SGI's, use the following variable to
# determine which shell to use for executing commands:
SHELL =		/bin/sh

#----------------------------------------------------------------
# The information below is modified by the configure script when
# Makefile is generated from Makefile.in.  You shouldn't normally
# modify any of this stuff by hand.
#----------------------------------------------------------------

AC_FLAGS =		@DEFS@
SRC_DIR =		@srcdir@
VPATH =			@srcdir@

#----------------------------------------------------------------
# The information below should be usable as is.  The configure
# script won't modify it and you shouldn't need to modify it
# either.
#----------------------------------------------------------------

ALLOC=

CFLAGS = $(STKCFLAGS) $(ALLOC) -I. -I../Tcl ${CC_SWITCHES}  ${X11_INCLUDES} \
${AC_FLAGS} ${PROTO_FLAGS} ${SECURITY_FLAGS} ${MEM_DEBUG_FLAGS}

WIDGOBJS = tkButton.o tkEntry.o tkFrame.o tkListbox.o \
	tkMenu.o tkMenubutton.o tkMessage.o tkScale.o \
	tkScrollbar.o

CANVOBJS = tkCanvas.o tkCanvArc.o tkCanvBmap.o tkCanvLine.o \
	tkCanvPoly.o tkCanvPs.o tkCanvText.o tkCanvWind.o \
	tkRectOval.o tkTrig.o

TEXTOBJS = tkText.o tkTextBTree.o tkTextDisp.o tkTextIndex.o tkTextTag.o

OBJS = tk3d.o tkArgv.o tkAtom.o tkBind.o tkBitmap.o tkCmds.o \
	tkColor.o tkConfig.o tkCursor.o tkError.o tkEvent.o \
	tkFocus.o tkFont.o tkGet.o tkGC.o tkGeometry.o tkGrab.o \
        tkOption.o tkPack.o tkPlace.o tkPreserve.o tkSelect.o \
        tkSend.o tkWindow.o tkWm.o $(WIDGOBJS) \
	$(CANVOBJS) $(TEXTOBJS)

all: libtk.a 

libtk.a: $(OBJS)
	rm -f libtk.a
	ar cr libtk.a $(OBJS)
	$(RANLIB) libtk.a

install: all

install.libs: install
	-if [ ! -d $(execdir) ] ; then mkdir -p $(execdir); fi 
	$(CP) libtk.a $(execdir)
	$(RANLIB) $(execdir)/libtk.a
	-if [ ! -d $(incdir) ] ; then mkdir -p $(incdir); fi
	$(CP) tk.h $(incdir)

install.man: all
	@echo "Installing manual pages"
	-if [ ! -d $(MAN3_DIR) ] ; then mkdir -p $(MAN3_DIR); fi	
	@cd $(SRC_DIR)/doc; for i in *.3; \
	    do \
	    echo "Installing doc/$$i"; \
	    rm -f $(MAN3_DIR)/$$i; \
	    sed -e '/man\.macros/r man.macros' -e '/man\.macros/d' \
		    $$i > $(MAN3_DIR)/$$i; \
	    chmod 444 $(MAN3_DIR)/$$i; \
	    done;
	-if [ ! -d $(MANN_DIR) ] ; then mkdir -p $(MANN_DIR); fi
	@cd $(SRC_DIR)/doc; for i in *.n; \
	    do \
	    echo "Installing doc/$$i"; \
	    rm -f $(MANN_DIR)/$$i; \
	    sed -e '/man\.macros/r man.macros' -e '/man\.macros/d' \
		    $$i > $(MANN_DIR)/$$i; \
	    chmod 444 $(MANN_DIR)/$$i; \
	    done;

clean:
	rm -f *.a *.o core errs *~ \#* TAGS *.E a.out 

distclean: clean
	rm -f Makefile config.status

$(OBJS): tk.h tkInt.h tkConfig.h
$(WIDGOBJS): default.h
$(CANVOBJS): default.h tkCanvas.h
$(TEXTOBJS): default.h tkText.h
tkWindow.o: patchlevel.h
