#
# This file is a Makefile for CTk.  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.
#
# @(#) $Id: ctk.shar,v 1.50 1996/01/15 14:47:16 andrewm Exp andrewm $

# Current CTk version;  used in various names.

VERSION = 8.0

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

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

prefix =	@prefix@
exec_prefix =	@exec_prefix@

# 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 Tcl
# scripts (note: you can set the CTK_LIBRARY environment variable at
# run-time to override the compiled-in location):
CTK_LIBRARY =		$(prefix)/lib/ctk$(VERSION)

# Path name to use when installing library scripts:
SCRIPT_INSTALL_DIR =	$(INSTALL_ROOT)$(CTK_LIBRARY)

# Directory in which to install the archive libctk.a:
LIB_INSTALL_DIR =	$(INSTALL_ROOT)$(exec_prefix)/lib

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

# Directory from which the program cwish should be referenced by scripts:
BIN_DIR =		$(exec_prefix)/bin

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

# Top-level directory for manual entries:
MAN_INSTALL_DIR =	$(INSTALL_ROOT)$(prefix)/man

# Directory in which to install manual entry for cwish:
MAN1_INSTALL_DIR =	$(MAN_INSTALL_DIR)/man1

# Libraries to use when linking:  must include at least the
# appropriate version of Tcl for this version of CTk, curses,
# and the math library (in that order).  It is (hopefully) filled
# in properly by the configure script.
LIBS = @LIBS@

# To change the compiler switches, for example to change from -O
# to -g, change the following line:
CFLAGS = -O

# Linker options (-L/.../lib) necessary to find the TCL
# and curses libraries (if any).  It is (hopefully) filled in
# properly by the configure script.
LDFLAGS =		@LDFLAGS@

# Preprocessor options (-I/.../include) necessary to find the TCL
# and curses header files (if any).  It is (hopefully) filled in
# properly by the configure script.
CPPFLAGS =		@CPPFLAGS@

# Preprocessor definitions.  It should be filled in properly by the
# configure script, but if configure did not find the curses library
# then you may have to add some definitions by hand.  The curses
# definitions are:
#
#   -DUSE_NCURSES_H=1	Curses include file is called "ncurses.h"
#   -DHAVE_CURS_SET=1	Curses package supports the curs_set() function
#   -DHAVE_SET_TERM=1	Curses package supports the set_term() function
#   -DHAVE_BEEP=1	Curses package supports the beep() function
#   -DHAVE_KEYPAD=1	Curses package supports the keypad() function
AC_FLAGS =		@DEFS@

# 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

# CTk used to let the configure script choose which program to use
# for installing, but there are just too many different versions of
# "install" around;  better to use the install-sh script that comes
# with the distribution, which is slower but guaranteed to work.

INSTALL = @srcdir@/install-sh -c

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

INSTALL_PROGRAM =	@INSTALL_PROGRAM@
INSTALL_DATA =		@INSTALL_DATA@
RANLIB =		@RANLIB@
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.
#----------------------------------------------------------------


CC =		@CC@
CC_SWITCHES =	${CFLAGS} ${CPPFLAGS} -I${SRC_DIR} \
${AC_FLAGS} ${PROTO_FLAGS} ${SECURITY_FLAGS} ${MEM_DEBUG_FLAGS} \
-DCTK_LIBRARY=\"${CTK_LIBRARY}\"

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

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

OBJS = ctkDisplay.o ctkRegion.o tkAppInit.o tkArgv.o tkBind.o tkCmds.o \
	tkConfig.o tkFocus.o tkFont.o tkGeometry.o tkGet.o \
	tkMain.o tkOption.o tkPack.o tkPlace.o tkPreserve.o tkUtil.o \
	tkWindow.o tkXEvent.o \
	$(WIDGOBJS) $(TEXTOBJS)

SRCS = ctkDisplay.c ctkRegion.c tkAppInit.c tkArgv.c tkBind.c tkButton.c \
	tkCmds.c tkConfig.c tkEntry.c tkFocus.c tkFont.c tkFrame.c \
	tkGeometry.c tkGet.c tkListbox.c tkMain.c tkMenu.c tkMenubutton.c \
	tkOption.c tkPack.c tkPlace.c tkPreserve.c tkScrollbar.c tkText.c \
	tkTextBTree.c tkTextDisp.c tkTextIndex.c tkTextMark.c tkTextTag.c \
	tkUtil.c tkWindow.c tkXEvent.c

HDRS = default.h keyCodes.h ks_names.h patchlevel.h tk.h tkInt.h \
	tkPort.h tkText.h

DEMOPROGS = widget

all: libctk.a cwish$(VERSION)

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

cwish$(VERSION): tkAppInit.o libctk.a
	$(CC) $(CC_SWITCHES) tkAppInit.o libctk.a $(LDFLAGS) $(LIBS) -o cwish$(VERSION)

configInfo: Makefile
	@rm -f configInfo
	@echo "# Definitions and libraries needed to build Tk applications" >> configInfo
	@echo "# (generated by the configure script):" >> configInfo
	@echo "TK_CC_SWITCHES = ${AC_FLAGS} ${MEM_DEBUG_FLAGS}" >> configInfo
	@echo "TK_LIBS = @LIBS@" >> configInfo

install: install-binaries install-libraries install-demos install-man

install-binaries: libctk.a cwish$(VERSION)
	@for i in $(LIB_INSTALL_DIR) $(BIN_INSTALL_DIR) ; \
	    do \
	    if [ ! -d $$i ] ; then \
		echo "Making directory $$i"; \
		mkdir $$i; \
		chmod 755 $$i; \
		else true; \
		fi; \
	    done;
	@echo "Installing libctk.a"
	@$(INSTALL_DATA) libctk.a $(LIB_INSTALL_DIR)
	@$(RANLIB) $(LIB_INSTALL_DIR)/libctk.a
	@echo "Installing cwish$(VERSION)"
	@$(INSTALL_PROGRAM) cwish$(VERSION) $(BIN_INSTALL_DIR)

install-libraries:
	@for i in $(INSTALL_ROOT)$(prefix)/lib $(INCLUDE_INSTALL_DIR) \
		$(SCRIPT_INSTALL_DIR) ; \
	    do \
	    if [ ! -d $$i ] ; then \
		echo "Making directory $$i"; \
		mkdir $$i; \
		chmod 755 $$i; \
		else true; \
		fi; \
	    done;
	@echo "Installing ctk.h"
	@$(INSTALL_DATA) $(SRC_DIR)/tk.h $(INCLUDE_INSTALL_DIR)/ctk.h
	for i in $(SRC_DIR)/library/*.tcl $(SRC_DIR)/library/tclIndex; \
	    do \
	    echo "Installing $$i"; \
	    $(INSTALL_DATA) $$i $(SCRIPT_INSTALL_DIR); \
	    done;

install-demos:
	@for i in $(INSTALL_ROOT)$(prefix)/lib $(SCRIPT_INSTALL_DIR) \
		$(SCRIPT_INSTALL_DIR)/demos; \
	    do \
	    if [ ! -d $$i ] ; then \
		echo "Making directory $$i"; \
		mkdir $$i; \
		chmod 755 $$i; \
		else true; \
		fi; \
	    done;
	@cd $(SRC_DIR)/library/demos; for i in *; \
	    do \
	    if [ -f $$i ] ; then \
		echo "Installing library/demos/$$i"; \
		sed -e '1 s|/usr/local/bin/cwish|$(BIN_DIR)/cwish$(VERSION)|' \
			$$i > $(SCRIPT_INSTALL_DIR)/demos/$$i; \
	    fi; \
	    done;
	@for i in $(DEMOPROGS); \
	    do \
	    chmod 755 $(SCRIPT_INSTALL_DIR)/demos/$$i; \
	    done;

install-man:
	@for i in $(MAN_INSTALL_DIR) $(MAN1_INSTALL_DIR); \
	    do \
	    if [ ! -d $$i ] ; then \
		echo "Making directory $$i"; \
		mkdir $$i; \
		chmod 755 $$i; \
		else true; \
		fi; \
	    done;
	@for i in *.1; \
	    do \
	    echo "Installing doc/$$i"; \
	    $(INSTALL_DATA) $$i $(MAN1_INSTALL_DIR); \
	    done;

Makefile: $(SRC_DIR)/Makefile.in
	$(SHELL) config.status

clean:
	rm -f *.a *.o core errs *~ \#* TAGS *.E a.out errors tktest cwish$(VERSION) \
		config.info

distclean: clean
	rm -f Makefile config.status

depend:
	makedepend -- $(CC_SWITCHES) -- $(SRCS)

.c.o:
	$(CC) -c $(CC_SWITCHES) $<

#
# Target to check for proper usage of UCHAR macro.
#

checkuchar:
	-egrep isalnum\|isalpha\|iscntrl\|isdigit\|islower\|isprint\|ispunct\|isspace\|isupper\|isxdigit $(SRCS) | grep -v UCHAR

#
# Target to make sure that only symbols with "Tk" or "Ctk" prefixes are
# exported.
#

checkexports: libctk.a
	-nm -p libctk.a | awk '$$2 ~ /[TDB]/ { print $$3 }' | sort -n | grep -v '^[Cc]?[Tt]k'

#
# Target to create a proper Tk distribution from information in the
# master source directory.  DISTDIR must be defined to indicate where
# to put the distribution.
#

configure: configure.in
	autoconf
dist:   configure
	rm -rf $(DISTDIR)
	mkdir $(DISTDIR)
	cp license.terms Makefile.in $(DISTDIR)
	chmod 664 $(DISTDIR)/Makefile.in
	cp -p $(SRCS) $(HDRS) $(DISTDIR)
	mkdir $(DISTDIR)/compat
	cp -p license.terms compat/unistd.h compat/stdlib.h $(DISTDIR)/compat
	cp -p README README.TERM ToDo changes porting.notes *.1 $(DISTDIR)
	cp -p configure configure.in install-sh $(DISTDIR)
	chmod 775 $(DISTDIR)/configure $(DISTDIR)/configure.in
	chmod +x $(DISTDIR)/install-sh
	mkdir $(DISTDIR)/library
	cp -p license.terms library/*.tcl library/tclIndex $(DISTDIR)/library
	mkdir $(DISTDIR)/library/demos
	cp -pr library/demos/widget library/demos/README \
		license.terms $(DISTDIR)/library/demos

mci_args:
	@echo ctk README README.TERM ToDo changes porting.notes license.terms \
		Makefile.in configure.in install-sh \
		$(SRCS) $(HDRS) compat library
		
# DO NOT DELETE THIS LINE -- make depend depends on it.
