# Generated automatically from Makefile.in by configure.
#
# Makefile --
#
# Makefile for building Tcl sources used by wishx.
#------------------------------------------------------------------------------
# Copyright 1992-1995 Karl Lehenbauer and Mark Diekhans.
#
# Permission to use, copy, modify, and distribute this software and its
# documentation for any purpose and without fee is hereby granted, provided
# that the above copyright notice appear in all copies.  Karl Lehenbauer and
# Mark Diekhans make no representations about the suitability of this
# software for any purpose.  It is provided "as is" without express or
# implied warranty.
#------------------------------------------------------------------------------
# $Id: Makefile.in,v 5.0 1995/07/25 06:00:34 markd Rel $
#------------------------------------------------------------------------------
#
SHELL=/bin/sh

#------------------------------------------------------------------------------
# Autoconfig defines that can be overridden in Config.mk

srcdir            = .
srcbasedir        = /opt/dsap/tcl7.4tk4.0/itcl2.0/tclX7.4a-p2
bldbasedir        = /opt/dsap/tcl7.4tk4.0/itcl2.0/tclX7.4a-p2
prefix            = /opt/dsap/tcl7.4tk4.0
exec_prefix       = ${prefix}
ARCH              = 

#------------------------------------------------------------------------------
# Include user-editable defines.

include ${bldbasedir}/Config.mk

#------------------------------------------------------------------------------

HELPSRC     = ${srcbasedir}/tkhelp
DEMOSSRC    = ${TK_UCB_SRC}/library/demos
TKMANPAGES  = ${srcbasedir}/tools/tkmanpages
CONVERTLIB  = ../runtcl ${srcbasedir}/tools/libconvert.tcl
GENINDEX    = ../runtcl ${srcbasedir}/tools/genindex.tcl
INST_MASTER = ${TK_MASTERDIR}/`../tools/tkxversion`
BLDMANHELP  = ../runtcl ${srcbasedir}/tools/bldmanhelp
INSTCOPY    = ../runtcl ../tools/instcopy
SYMLINKEXT  = ../tools/symlinkext

TMPMASTER    = ../tkmaster
TKTCL        = ${TMPMASTER}/tk.tcl
TKTLIB       = ${TMPMASTER}/tk.tlib
TKTNDX       = ${TMPMASTER}/tk.tndx
PROLOGPS     = ${TMPMASTER}/prolog.ps
DEMOS        = ${TMPMASTER}/demos
TMPHELP      = ${TMPMASTER}/help

#------------------------------------------------------------------------------
# Copy all files.
#

all: made.tmp ${TKTCL} ${TKTLIB} ${TKTNDX} ${PROLOGPS} tclhelp ${TMPHELP} \
     ${DEMOS}

# Can't use 'test -d X || mkdir X', it don't work on Ultrix
made.tmp:
	if [ ! -d ${TMPMASTER} ] ; then mkdir ${TMPMASTER} ; else exit 0; fi
	touch made.tmp

#
# Update tk.tcl to autoload from our library rather than explictly source
# the files.  We pick an entry point in each file to force it to be brought
# in.
#
${TKTCL}: ${TK_UCB_SRC}/library/tk.tcl made.tmp
	rm -f ${TKTCL}
	sed -f ${srcdir}/tk.tcl.sed ${TK_UCB_SRC}/library/tk.tcl >${TKTCL}

${TKTLIB}: ${TK_UCB_SRC}/library/tclIndex tkdemo.tcl made.tmp
	${CONVERTLIB} ${TK_UCB_SRC}/library/tclIndex ${TKTLIB}
	rm -f ${TKTNDX}
	cat ${srcdir}/tkdemo.tcl >>${TKTLIB}

${TKTNDX}: ${TKTLIB}
	${GENINDEX} ${TKTLIB}
	
${PROLOGPS}: ${TK_UCB_SRC}/library/prolog.ps made.tmp
	rm -f ${PROLOGPS}
	cp ${TK_UCB_SRC}/library/prolog.ps ${PROLOGPS}

tclhelp: ${srcdir}/tclhelp.tcl
	rm -f tclhelp
	echo "#!${TCL_BINDIR}/wishx"  >  tclhelp
	cat ${srcdir}/tclhelp.tcl     >> tclhelp
	chmod +rx tclhelp

#------------------------------------------------------------------------------
# Need a "help" and "demos" directories in this directory so that the help and
# tkdemo commands will work before installation.  Normaly just symlink, unless
# we don't have them.# (Must enforce master dir being there, as a dependency
# on make.tmp causes it to be always rebuilt).

${TMPHELP}:
	if [ ! -d ${TMPMASTER} ] ; then mkdir ${TMPMASTER} ; else exit 0; fi
	if [ "YES" = "YES" ] ; then \
	    rm -rf ${TMPHELP} ;\
	    ln -s ${HELPSRC} ${TMPHELP} ;\
	else \
	    rm -rf ${TMPHELP} ;\
	    mkdir ${TMPHELP} ;\
	    (cd ${HELPSRC}; tar -cf -) | (cd ${TMPHELP}; tar -xf -) ;\
	fi

#------------------------------------------------------------------------------
# Build demos directory for wishx

DEMOPROGS = browse hello ixset rmt rolodex square tcolor timer widget

${DEMOS}:
	if [ ! -d ${TMPMASTER} ] ; then mkdir ${TMPMASTER} ; else exit 0; fi
	if [ ! -d ${DEMOS} ] ; then mkdir ${DEMOS} ; else exit 0; fi
	${INSTCOPY} ${DEMOSSRC} ${DEMOS}
	@for i in $(DEMOPROGS); \
	    do \
	    rm -f ${DEMOS}/$$i; \
	    sed -e "s/^exec wish/exec wishx"/ ${DEMOSSRC}/$$i >${DEMOS}/$$i; \
	    chmod 755 ${DEMOS}/$$i; \
	done;

#------------------------------------------------------------------------------
# Build help for Tk.

buildtkhelp:
	rm -rf ${HELPSRC} help
	mkdir ${HELPSRC}
	${BLDMANHELP} ${TK_UCB_SRC}/doc ${TKMANPAGES} ${HELPSRC} Tk.brf

#------------------------------------------------------------------------------

install: install-exec install-library

install-library:
	${INSTCOPY} ${TKTCL} ${TKTLIB} ${TKTNDX} ${INSTALL_ROOT}${INST_MASTER}
	${INSTCOPY} ${TK_UCB_SRC}/library/prolog.ps \
	    ${INSTALL_ROOT}${INST_MASTER}
	${INSTCOPY} ${HELPSRC} ${INSTALL_ROOT}${INST_MASTER}/help
	${INSTCOPY} ${DEMOS} ${INSTALL_ROOT}${INST_MASTER}/demos

install-exec:
	${INSTCOPY} tclhelp ${INSTALL_ROOT}${TCL_BINDIR}

install-master: install
	${INSTCOPY} tclhelp ${INSTALL_ROOT}${INST_MASTER}/bin${ARCH}
	${SYMLINKEXT} ${INST_MASTER}/bin${ARCH}/tclhelp \
	    ${INSTALL_ROOT}${TCL_BINDIR}

install-master-exec: install-exec

#------------------------------------------------------------------------------

clean:
	rm -rf tclhelp ${TMPMASTER} made.tmp

#------------------------------------------------------------------------------
# Restore to the distributed state.

distclean: clean
	rm -f Makefile

# Disable Sun's parallel make, it doesn't get the dependencies right.
.NO_PARALLEL:
