# -*-mode: makefile; fill-column: 75; tab-width: 8; coding: iso-latin-1-unix -*-
#
# $Id: Makefile.in,v 1.2.2.2 2001/11/13 21:51:06 idiscovery Exp $
#
# This file is a Makefile for Tix.  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.
#

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

# Use datadir from TCL_PACKAGE_PATH in tclConfig.sh
datadir	   =  @TCL_PACKAGE_PATH@

@SET_MAKE@

TIX_VERSION = @TIX_VERSION@

# Directory in which to install the library of Tix scripts and demos
# (note: you can set the TIX_LIBRARY environment variable at run-time to
# override the compiled-in location):
TIX_LIBRARY =	$(datadir)/tix$(TIX_VERSION)

# Directory in which to install the archive libtix.a:
LIB_DIR =	$(exec_prefix)/lib

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

# Directory in which to install the include file tix.h:
INCLUDE_DIR =	$(prefix)/include

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

# Directory in which to install manual entry for wish:
MAN1_DIR =	$(MAN_DIR)/man1

# Directory in which to install manual entries for Tix's C library
# procedures:
MAN3_DIR =	$(MAN_DIR)/man3

# Directory in which to install manual entries for the built-in
# Tcl commands implemented by Tix:
MANN_DIR =	$(MAN_DIR)/mann

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

#----------------------------------------------------------------
# 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		=	@SRC_DIR@/install.sh -c
INSTALL_PROGRAM =	@INSTALL_PROGRAM@
INSTALL_DATA	=	@INSTALL_DATA@
SRC_DIR		=	@SRC_DIR@
INC_DIR		=	@SRC_DIR@/generic
UNIX_DIR	=	@SRC_DIR@/unix
LIBRARY_DIR	=	@SRC_DIR@/library
DEMOS_DIR	=	@SRC_DIR@/demos
DEMO_PROGS	=	tixwidgets.tcl
TOOLS_DIR	=	@SRC_DIR@/tools
MANUAL_DIR	=	@SRC_DIR@/man
# CYGNUS LOCAL: Set VPATH to unix subdirectory, not top level.
VPATH		=	@SRC_DIR@/unix
CFLAGS		=	@CFLAGS@

BINDIRS = tk8.0 tk8.1 tk8.2 tk8.3 itcl3.0 itcl3.1 itcl3.2

default:
	error Please read ../docs/UnixInst.txt

all test:
	@for i in $(BINDIRS); \
	do \
	    if test -r $$i/Makefile; then \
	        echo "Entering directory $$i"; \
	        cd $$i; \
		$(MAKE) $@; \
		cd $(UNIX_DIR); \
	    fi; \
	done;

#----------------------------------------------------------------------
#
#			Installation
#
#----------------------------------------------------------------------
install:: install-basic install-binaries
	@echo done

install-binaries::
	@for i in $(BINDIRS); \
	do \
	    if test -r $$i/Makefile; then \
	        echo "Entering directory $$i"; \
	        cd $$i; \
	        $(MAKE) prefix=$(prefix) \
		    exec_prefix=$(exec_prefix) _install_; \
	        cd ..; \
            fi; \
	done;

#
# Basic installtion
#
install-basic:: install-libraries install-headers install-demos \
	install-man install-tools 

install-tools:
	@for i in $(BIN_DIR) ; \
	    do \
	    if [ ! -d $$i ] ; then \
		echo "Making directory $$i"; \
		mkdir $$i; \
		chmod 755 $$i; \
		else true; \
		fi; \
	    done;
	@echo "installing the tixindex program for building tclIndex for Tix scripts"
	@cd $(TOOLS_DIR); $(INSTALL_PROGRAM) tixindex $(BIN_DIR)/tixindex

install-headers:
	@for i in $(INCLUDE_DIR); \
	    do \
	    if [ ! -d $$i ] ; then \
		echo "Making directory $$i"; \
		mkdir $$i; \
		chmod 755 $$i; \
		else true; \
		fi; \
	    done;
	@for i in $(INC_DIR)/tix.h; \
	    do \
	    echo "Installing $$i"; \
	    $(INSTALL_DATA) $$i $(INCLUDE_DIR); \
	    done;

install-libraries:
	-chmod 755 $(INSTALL_PROGRAM)
	@for i in $(TIX_LIBRARY) $(TIX_LIBRARY)/bitmaps $(TIX_LIBRARY)/pref; \
	    do \
	    if [ ! -d $$i ] ; then \
		echo "Making directory $$i"; \
		mkdir $$i; \
		chmod 755 $$i; \
		else true; \
		fi; \
	    done;
	@for i in $(LIBRARY_DIR)/*.tcl $(LIBRARY_DIR)/tclIndex; \
	    do \
	    echo "Installing $$i"; \
	    $(INSTALL_DATA) $$i $(TIX_LIBRARY); \
	    done;
	@for i in $(LIBRARY_DIR)/bitmaps/* .gif $(LIBRARY_DIR)/bitmaps/*.x*m; \
	    do \
	    if [ -f $$i ] ; then \
		echo "Installing $$i"; \
		$(INSTALL_DATA) $$i $(TIX_LIBRARY)/bitmaps; \
		fi; \
	    done;
	@for i in $(LIBRARY_DIR)/pref/*.* $(LIBRARY_DIR)/pref/tixmkpref; \
	    do \
	    if [ -f $$i ] ; then \
		echo "Installing $$i"; \
		$(INSTALL_DATA) $$i $(TIX_LIBRARY)/pref; \
		fi; \
	    done;
	@echo "Installing pkgIndex.tcl"
	@cat */pkgIndex.tcl > pkgIndex.tcl
	@$(INSTALL_DATA) pkgIndex.tcl $(TIX_LIBRARY)

install-demos:
	@for i in $(prefix)/lib $(TIX_LIBRARY) $(TIX_LIBRARY)/demos \
		$(TIX_LIBRARY)/demos/bitmaps $(TIX_LIBRARY)/demos/samples ; \
	    do \
	    if [ ! -d $$i ] ; then \
		echo "Making directory $$i"; \
		mkdir $$i; \
		chmod 755 $$i; \
		else true; \
		fi; \
	    done;
	@cd $(DEMOS_DIR); for i in *; \
	    do \
	    if [ -f $$i ] ; then \
		echo "Installing demos/$$i"; \
		sed -e '1 s|/usr/local/bin/tixwish|$(BIN_DIR)/tixwish|' \
			$$i > $(TIX_LIBRARY)/demos/$$i; \
	    fi; \
	    done;
	@for i in $(DEMO_PROGS); \
	    do \
	    chmod 755 $(TIX_LIBRARY)/demos/$$i; \
	    done;
	@for i in $(DEMOS_DIR)/bitmaps/*; \
	    do \
	    if [ -f $$i ] ; then \
		echo "Installing $$i"; \
		$(INSTALL_DATA) $$i $(TIX_LIBRARY)/demos/bitmaps; \
		fi; \
	    done;
	@for i in $(DEMOS_DIR)/samples/*; \
	    do \
	    if [ -f $$i ] ; then \
		echo "Installing $$i"; \
		$(INSTALL_DATA) $$i $(TIX_LIBRARY)/demos/samples; \
		fi; \
	    done;

install-man:
	@for i in $(MAN_DIR) $(MAN1_DIR) $(MAN3_DIR) $(MANN_DIR) ; \
	    do \
	    if [ ! -d $$i ] ; then \
		echo "Making directory $$i"; \
		mkdir $$i; \
		chmod 755 $$i; \
		else true; \
		fi; \
	    done;
	@cd $(MANUAL_DIR); for i in *.n *.1; \
	    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;

# CYGNUS LOCAL: install-minimal target.
install-minimal: install-libraries

tests::
	@for i in $(BINDIRS); \
	do \
	    if test -r $$i/Makefile; then \
	        echo "Entering directory $$i"; \
	        cd $$i; \
		$(MAKE) tests; \
		cd $(UNIX_DIR); \
	    fi; \
	done;

sa-tests::
	@for i in $(BINDIRS); \
	do \
	    if test -r $$i/Makefile; then \
	        echo "Entering directory $$i"; \
	        cd $$i; \
		$(MAKE) sa-tests; \
		cd $(UNIX_DIR); \
	    fi; \
	done;

compile::
	@for i in $(BINDIRS); \
	do \
	    if test -r $$i/Makefile; then \
	        echo "Entering directory $$i"; \
	        cd $$i; \
		$(MAKE) CFLAGS=$(CFLAGS) ; \
		cd $(UNIX_DIR); \
	    fi; \
	done;

clean::
	@for i in $(BINDIRS); \
	do \
	    if test -r $$i/Makefile; then \
	        echo "Entering directory $$i"; \
	        cd $$i; \
		$(MAKE) clean; \
		cd $(UNIX_DIR); \
	    fi; \
	done;
	- rm -f tixSamLib.c tixBitmaps.c

distclean::
	@for i in $(BINDIRS); \
	do \
	    if test -r $$i/Makefile; then \
	        echo "Entering directory $$i"; \
	        cd $$i; \
		$(MAKE) distclean; \
		cd $(UNIX_DIR); \
	    fi; \
	done;
	- rm -f config.status Makefile.bak config.status \
	  config.cache config.log tixConfig.tcl *~ Makefile

# CYGNUS LOCAL: Makefile depends upon config.status
Makefile:Makefile.in config.status
	./config.status

autoconf::
	autoconf

config::
	-cd tk8.0; ./configure
	-cd tk8.1; ./configure
	-cd tk8.2; ./configure
	-cd tk8.3; ./configure
	-cd itcl2.0; ./configure
	-cd itcl2.1; ./configure
	-cd itcl2.2; ./configure

config-shared::
	-cd tk8.0; ./configure
	-cd tk8.1; ./configure --enable-shared
	-cd tk8.2; ./configure --enable-shared
	-cd tk8.3; ./configure --enable-shared
	-cd itcl2.0; ./configure
	-cd itcl2.1; ./configure --enable-shared
	-cd itcl2.2; ./configure --enable-shared

config-shared-sam::
	-cd tk8.0; ./configure --enable-sam
	-cd tk8.1; ./configure --enable-shared --enable-sam
	-cd tk8.2; ./configure --enable-shared --enable-sam
	-cd tk8.3; ./configure --enable-shared
	-cd itcl2.0; ./configure
	-cd itcl2.1; ./configure --enable-shared
	-cd itcl2.2; ./configure --enable-shared

