#
# This file is a Makefile for [incr Widgets].  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:58 sparker Exp $

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

ITCL_VERSION = @ITCL_VERSION@
IWIDGETS_VERSION = @IWIDGETS_VERSION@
VERSION = $(ITCL_VERSION).$(IWIDGETS_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 =

# Path name to use when installing library scripts:
SCRIPT_INSTALL_DIR = $(INSTALL_ROOT)$(prefix)/lib/iwidgets$(VERSION)

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

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

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

# Top-level directory in which to install manual entries:
MAN_INSTALL_DIR = $(INSTALL_ROOT)$(prefix)/man

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

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

# Directory in which to install manual entries for the built-in
# [incr Tcl] commands:
MANN_INSTALL_DIR = $(MAN_INSTALL_DIR)/mann

# Directory in which to install html version of manual entries:
HTML_INSTALL_DIR = $(INSTALL_ROOT)$(prefix)/doc

# Tcl libraries can be found here:
TCL_LIB_DIR = @TCL_LIB_DIR@

# Directory containing Tcl source code (for library used during test):
TCL_SRC_DIR = @TCL_SRC_DIR@

# Tk libraries can be found here:
TK_LIB_DIR = @TK_LIB_DIR@

# Directory containing Tk source code (for library used during test):
TK_SRC_DIR = @TK_SRC_DIR@

# Itcl libraries can be found here:
ITCL_LIB_DIR = @ITCL_LIB_DIR@

# Directory containing Itcl source code (for library used during test):
ITCL_SRC_DIR = @ITCL_SRC_DIR@

# Itk libraries can be found here:
ITK_LIB_DIR = @ITK_LIB_DIR@

# Directory containing Itk source code (for library used during test):
ITK_SRC_DIR = @ITK_SRC_DIR@

# [incr Tk] build directory containing the itkwish binary for 'make test'
ITK_BIN_DIR = ../../itk/unix

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

INSTALL =		@INSTALL@
INSTALL_PROGRAM =	$(INSTALL)
INSTALL_DATA =		$(INSTALL) -m 644
MKINSTALLDIRS =		$(ITCL_SRC_DIR)/../config/mkinstalldirs
RANLIB =		@RANLIB@
LN_S =			ln -s
TOP_DIR =		@IWIDGETS_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.
#----------------------------------------------------------------

all: build

build:
	@for i in iwidgets.tcl pkgIndex.tcl ; do \
	    echo "Building $$i" ; \
	    rm -f $$i ; \
	    cat $(UNIX_DIR)/$$i.in \
	        | sed -e "s#%ITCL_VERSION%#$(ITCL_VERSION)#g" \
	        | sed -e "s#%IWIDGETS_VERSION%#$(IWIDGETS_VERSION)#g" \
	        > $$i ; \
	    done;

test: $(ITK_BIN_DIR)/itkwish
	LD_LIBRARY_PATH=$(TCL_LIB_DIR):$(TK_LIB_DIR):$(ITCL_LIB_DIR):$(ITK_LIB_DIR):$(LD_LIBRARY_PATH); export LD_LIBRARY_PATH ; \
	TCL_LIBRARY=$(TCL_SRC_DIR)/library; export TCL_LIBRARY; \
	ITCL_LIBRARY=$(ITCL_SRC_DIR)/library; export ITCL_LIBRARY; \
	TK_LIBRARY=$(TK_SRC_DIR)/library; export TK_LIBRARY; \
	ITK_LIBRARY=$(ITK_SRC_DIR)/library; export ITK_LIBRARY; \
	( echo lappend auto_path $(TOP_DIR)/generic \; package provide Iwidgets $(VERSION) \; cd $(TOP_DIR)/tests\; source all\; exit ) | $(ITK_BIN_DIR)/itkwish

static:

standalone:

plusplus:

install: install-libraries install-demos install-man

install-libraries:
	@$(MKINSTALLDIRS) $(SCRIPT_INSTALL_DIR) $(LIB_INSTALL_DIR)
	@rm -f $(LIB_INSTALL_DIR)/iwidgets
	$(LN_S) iwidgets$(VERSION) $(LIB_INSTALL_DIR)/iwidgets
	@$(MKINSTALLDIRS) $(SCRIPT_INSTALL_DIR)/scripts
	@for i in $(GENERIC_DIR)/*.itk $(GENERIC_DIR)/*.itcl $(GENERIC_DIR)/tclIndex $(GENERIC_DIR)/*.gif ; \
	    do \
	    echo "Installing $$i"; \
	    $(INSTALL_DATA) $$i $(SCRIPT_INSTALL_DIR)/scripts; \
	    done;
	@for i in iwidgets.tcl pkgIndex.tcl ; \
	    do \
	    echo "Installing $$i"; \
	    $(INSTALL_DATA) $$i $(SCRIPT_INSTALL_DIR); \
	    done;

install-demos:
	@$(MKINSTALLDIRS) $(SCRIPT_INSTALL_DIR)/demos/images $(SCRIPT_INSTALL_DIR)/demos/html
	@cd $(TOP_DIR)/demos; for i in *; \
	    do \
	    if [ -f $$i ] ; then \
	        echo "Installing $$i"; \
	        $(INSTALL_DATA) $$i $(SCRIPT_INSTALL_DIR)/demos; \
	        chmod 555 $(SCRIPT_INSTALL_DIR)/demos/$$i; \
	    fi; \
	    done;
	@cd $(TOP_DIR)/demos; for i in images/*; \
	    do \
	    if [ -f $$i ] ; then \
	        echo "Installing $$i"; \
	        $(INSTALL_DATA) $$i $(SCRIPT_INSTALL_DIR)/demos/images; \
	        chmod 444 $(SCRIPT_INSTALL_DIR)/demos/$$i; \
	    fi; \
	    done;
	@cd $(TOP_DIR)/demos; for i in html/*; \
	    do \
	    if [ -f $$i ] ; then \
	        echo "Installing $$i"; \
	        $(INSTALL_DATA) $$i $(SCRIPT_INSTALL_DIR)/demos/html; \
	        chmod 444 $(SCRIPT_INSTALL_DIR)/demos/$$i; \
	    fi; \
	    done;

install-man:
	@$(MKINSTALLDIRS) $(MANN_INSTALL_DIR)
	@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;

install-html:
	@$(MKINSTALLDIRS) $(HTML_INSTALL_DIR)
	@cd $(TOP_DIR)/doc/html; for i in *.html; \
	    do \
	    echo "Installing $(HTML_INSTALL_DIR)/$$i"; \
	    $(INSTALL_DATA) $$i $(HTML_INSTALL_DIR); \
            chmod 444 $(HTML_INSTALL_DIR)/$$i; \
	    done;

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

clean:
	rm -f core errs *~ \#* TAGS *.E a.out errors
	rm -f iwidgets.tcl pkgIndex.tcl

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

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

configure: configure.in
	autoconf

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