#
# This file is a Makefile for [incr 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.
#
# RCS: $Id: Makefile.in,v 1.1.1.1 1999/01/03 06:52:52 sparker Exp $

# Current [incr Tcl] version;  used in various names.

MAJOR_VERSION = @ITCL_MAJOR_VERSION@
MINOR_VERSION = @ITCL_MINOR_VERSION@
RELEASE_LEVEL = @ITCL_RELEASE_LEVEL@
VERSION = @ITCL_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).
#----------------------------------------------------------------

# 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 ITK_LIBRARY environment variable at
# run-time to override the compiled-in location):
ITK_LIBRARY = $(prefix)/lib/itk$(VERSION)

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

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

# Path to use at runtime to refer to LIB_INSTALL_DIR:
LIB_RUNTIME_DIR =	$(exec_prefix)/lib

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

# Directory in which to install the include file itk.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 wish:
MAN1_INSTALL_DIR =	$(MAN_INSTALL_DIR)/man1

# Directory in which to install manual entries for Tk's C library
# procedures:
MAN3_INSTALL_DIR =	$(MAN_INSTALL_DIR)/man3

# Directory in which to install manual entries for the built-in
# Tcl commands implemented by Tk:
MANN_INSTALL_DIR =	$(MAN_INSTALL_DIR)/mann

# The directory containing the Tcl sources and headers appropriate
# for this version of [incr Tk]:
TCL_SRC_DIR =		@TCL_SRC_DIR@

# The directory containing the Tcl library archive file appropriate
# for this version of [incr Tk]:
TCL_LIB_DIR =		@TCL_LIB_DIR@

# Library flags for Tcl library
TCL_LIB_FLAG =		@TCL_LIB_FLAG@

# Tcl libraries built with optimization switches have this additional extension
DBGX =			@TCL_DBGX@

# The directory containing the Tk sources and headers appropriate
# for this version of [incr Tk]:
TK_SRC_DIR =		@TK_SRC_DIR@

# The directory containing the Tk library archive file appropriate
# for this version of [incr Tk]:
TK_LIB_DIR =		@TK_LIB_DIR@

# Library flags for Tk library
TK_LIB_FLAG =		@TK_LIB_FLAG@

# The directory containing the [incr Tcl] sources and headers appropriate
# for this version of [incr Tk]:
ITCL_SRC_DIR =		@ITCL_SRC_DIR@

# The directory containing the [incr Tcl] library archive file appropriate
# for this version of [incr Tk]:
ITCL_LIB_DIR =		@ITCL_LIB_DIR@

# 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 =		@TK_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 =	@TK_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 = @TK_LIB_SPEC@ $(X11_LIB_SWITCHES) \
	@ITCL_BUILD_LIB_SPEC@ @TCL_LIB_SPEC@ \
	@TCL_LIBS@ @DL_LIBS@ -lc

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

# 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

# If your X server is X11R4 or earlier, then you may wish to reverse
# the comment characters on the following two lines.  This will enable
# extra code to speed up XStringToKeysym.  In X11R5 and later releases
# XStringToKeysym is plenty fast, so you needn't define REDO_KEYSYM_LOOKUP.
KEYSYM_FLAGS =
#KEYSYM_FLAGS = -DREDO_KEYSYM_LOOKUP

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

# Tk 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 = $(TOP_DIR)/../config/install-sh -c
INSTALL_PROGRAM =	${INSTALL}
INSTALL_DATA =		${INSTALL} -m 644
MKINSTALLDIRS =		$(TOP_DIR)/../config/mkinstalldirs

# The symbols below provide support for dynamic loading and shared
# libraries.  The values of the symbols are normally set by the
# configure script.  You shouldn't normally need to modify any of
# these definitions by hand.

SHLIB_CFLAGS = @SHLIB_CFLAGS@

LD_SEARCH_FLAGS = @LD_SEARCH_FLAGS@

ITK_LIB_FILE = @ITK_LIB_FILE@
#ITK_LIB_FILE = libitk.a

# The symbol below provides support for dynamic loading and shared
# libraries.  See configure.in for a description of what it means.
# The values of the symbolis normally set by the configure script.

SHLIB_LD = @SHLIB_LD@

#----------------------------------------------------------------
# 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 =		@TCL_DEFS@
RANLIB =		@RANLIB@
TOP_DIR =		@ITK_SRC_DIR@
GENERIC_DIR =		$(TOP_DIR)/generic
UNIX_DIR =		$(TOP_DIR)/unix

#----------------------------------------------------------------
# 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) $(SHLIB_CFLAGS) -I$(UNIX_DIR) -I$(GENERIC_DIR) \
-I$(TCL_SRC_DIR)/generic -I$(ITCL_SRC_DIR)/generic \
-I$(TK_SRC_DIR)/generic $(X11_INCLUDES) \
$(AC_FLAGS) $(PROTO_FLAGS) $(MEM_DEBUG_FLAGS) $(KEYSYM_FLAGS) \
-DITK_LIBRARY=\"$(ITK_LIBRARY)\"

OBJS = itk_cmds.o itk_option.o itk_archetype.o itk_util.o

SRCS = $(GENERIC_DIR)/itk_cmds.c $(GENERIC_DIR)/itk_option.c \
	$(GENERIC_DIR)/itk_archetype.c $(GENERIC_DIR)/itk_util.c

all: itkwish

# The following target is configured by autoconf to generate either
# a shared library or non-shared library for [incr Tk].

@ITK_LIB_FILE@: ${OBJS}
	rm -f $(ITK_LIB_FILE)
	@MAKE_LIB@
	$(RANLIB) $(ITK_LIB_FILE)

itkwish: tkAppInit.o $(ITK_LIB_FILE)
	$(CC) @LD_FLAGS@ tkAppInit.o @ITK_BUILD_LIB_SPEC@ \
		$(LIBS) $(LD_SEARCH_FLAGS) -o itkwish

# Note, in the target below TCL_LIBRARY needs to be set or else
# "make test" won't work in the case where the compilation directory
# isn't the same as the source directory.

test: itkwish
	TCLLIBPATH="`pwd` $(TK_LIB_DIR) $(ITCL_LIB_DIR) $(TCL_LIB_DIR)"; export TCLLIBPATH; \
	LD_LIBRARY_PATH=`pwd`:$(ITCL_LIB_DIR):$(TK_LIB_DIR):$(TCL_LIB_DIR):$(LD_LIBRARY_PATH); export LD_LIBRARY_PATH; \
	TCL_LIBRARY=$(TCL_SRC_DIR)/library; export TCL_LIBRARY; \
	TK_LIBRARY=$(TK_SRC_DIR)/library; export TK_LIBRARY; \
	ITCL_LIBRARY=$(ITCL_SRC_DIR)/library; export ITCL_LIBRARY; \
	ITK_LIBRARY=$(TOP_DIR)/library; export ITK_LIBRARY; \
	( echo cd $(TOP_DIR)/tests\; source all\; exit ) \
	| ./itkwish -geometry +0+0

install: install-binaries install-libraries install-man

install-binaries: $(ITK_LIB_FILE) itkwish
	@$(MKINSTALLDIRS) $(LIB_INSTALL_DIR) $(BIN_INSTALL_DIR)
	@echo "Installing $(ITK_LIB_FILE)"
	@$(INSTALL_DATA) $(ITK_LIB_FILE) $(LIB_INSTALL_DIR)
	@(cd $(LIB_INSTALL_DIR); $(RANLIB) $(ITK_LIB_FILE))
	@chmod 555 $(LIB_INSTALL_DIR)/$(ITK_LIB_FILE)
	@echo "Installing itkwish"
	$(INSTALL_PROGRAM) itkwish $(BIN_INSTALL_DIR)/itkwish$(VERSION)
	@echo "Installing itkConfig.sh"
	@$(INSTALL_DATA) itkConfig.sh $(LIB_INSTALL_DIR)/itkConfig.sh

install-libraries:
	@$(MKINSTALLDIRS) $(INCLUDE_INSTALL_DIR) $(SCRIPT_INSTALL_DIR)
	@echo "Installing itk.h"
	@$(INSTALL_DATA) $(GENERIC_DIR)/itk.h $(INCLUDE_INSTALL_DIR)
	@for i in $(TOP_DIR)/library/*.* $(TOP_DIR)/library/tclIndex $(UNIX_DIR)/tkAppInit.c; \
	    do \
	    echo "Installing $$i"; \
	    $(INSTALL_DATA) $$i $(SCRIPT_INSTALL_DIR); \
	    done;
	@echo "Installing pkgIndex.tcl"
	@$(INSTALL_DATA) pkgIndex.tcl $(SCRIPT_INSTALL_DIR)

install-man:
	@$(MKINSTALLDIRS) $(MAN1_INSTALL_DIR) $(MANN_INSTALL_DIR)
	@cd $(TOP_DIR)/doc; for i in *.1; \
	    do \
	    echo "Installing doc/$$i"; \
	    rm -f $(MAN1_INSTALL_DIR)/$$i; \
	    sed -e '/man\.macros/r man.macros' -e '/man\.macros/d' \
		    $$i > $(MAN1_INSTALL_DIR)/$$i; \
	    chmod 444 $(MAN1_INSTALL_DIR)/$$i; \
	    done;
	@cd $(TOP_DIR)/doc; for i in *.n; \
	    do \
	    echo "Installing doc/$$i"; \
	    rm -f $(MANN_INSTALL_DIR)/$$i; \
	    sed -e '/man\.macros/r man.macros' -e '/man\.macros/d' \
		    $$i > $(MANN_INSTALL_DIR)/$$i; \
	    chmod 444 $(MANN_INSTALL_DIR)/$$i; \
	    done;

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

clean:
	rm -f *.a *.o core errs *~ \#* TAGS *.E a.out errors \
	rm -f itkwish* libitk* *pure* *% ../tests/core

distclean: clean
	rm -f Makefile config.status config.log config.cache pkgIndex.tcl

pure: tkAppInit.o $(ITK_LIB_FILE)
	purify $(CC) @LD_FLAGS@ tkAppInit.o @ITK_BUILD_LIB_SPEC@ \
		$(LIBS) $(LD_SEARCH_FLAGS) -o itkwish.pure

profile: tkAppInit.o $(ITK_LIB_FILE)
	quantify $(CC) @LD_FLAGS@ tkAppInit.o @ITK_BUILD_LIB_SPEC@ \
		$(LIBS) $(LD_SEARCH_FLAGS) -o itkwish.pure

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

configure: configure.in
	autoconf

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

tkAppInit.o:	$(UNIX_DIR)/tkAppInit.c Makefile
	$(CC) -c $(CC_SWITCHES) $(UNIX_DIR)/tkAppInit.c

itk_cmds.o:	$(GENERIC_DIR)/itk_cmds.c Makefile
	$(CC) -c $(CC_SWITCHES) $(GENERIC_DIR)/itk_cmds.c

itk_option.o:	$(GENERIC_DIR)/itk_option.c
	$(CC) -c $(CC_SWITCHES) $(GENERIC_DIR)/itk_option.c

itk_archetype.o:	$(GENERIC_DIR)/itk_archetype.c
	$(CC) -c $(CC_SWITCHES) $(GENERIC_DIR)/itk_archetype.c

itk_util.o:	$(GENERIC_DIR)/itk_util.c
	$(CC) -c $(CC_SWITCHES) $(GENERIC_DIR)/itk_util.c

# DO NOT DELETE THIS LINE -- make depend depends on it.
