#==============================================================================
#                                  Makefile
#------------------------------------------------------------------------------
# Main makefile for Tcl SIPP.  It has the following targets:
#    o all - Compile and link the tsipp interpreter (default).
#    o test - Run the standard tests.
#    o clean - Remove all generated files.
#    o buildhelp - Build the help files.
#    o demo - Generate the demo pictures.
#    o both - Run the tests and generate the demos.
#    o tkdemo - Run the interactive tkdemo.
#------------------------------------------------------------------------------

include Config.mk

SHELL=/bin/sh
BUILDHELP=tsipp -c "load buildhelp.tcl"

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

all: tsipp $(TK_SIPP_SHELL)

tsipp: TSIPP_MAKES

TSIPP_MAKES: $(TK_SIPP_SHELL)
	cd libsipp; $(MAKE) -$(MAKEFLAGS) all
	cd src;     $(MAKE) -$(MAKEFLAGS) all
	cd tclsrc;  $(MAKE) -$(MAKEFLAGS) all

#-----------------------------------------------------------------------------
# This does not build the wish shell, it just makes the dependencies.????
#
tksipp: TKSIPP_MAKES

TKSIPP_MAKES:
	cd photo;    $(MAKE) -$(MAKEFLAGS) all

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

buildhelp:
	-mkdir help 2>/dev/null
	cd help ; rm -rf *
	$(BUILDHELP) -b tsipp.brf help man/tsipp.man man/photo.man

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

test: all
	cd tests;$(MAKE) -$(MAKEFLAGS) test

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

demo: all
	cd demos;$(MAKE) -$(MAKEFLAGS) demo

tkdemo: all
	cd demos;$(MAKE) -$(MAKEFLAGS) tkdemo

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

both: test forcedemo

forcedemo:
	cd demos;    $(MAKE) -$(MAKEFLAGS) clean
	cd demos;    $(MAKE) -$(MAKEFLAGS) demo

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

clean: 
	rm -rf help
	rm -f $(OBJS) tsipp core libtsipp.a
	cd src;      $(MAKE) -$(MAKEFLAGS) clean
	cd libsipp;  $(MAKE) -$(MAKEFLAGS) clean
	cd tclsrc;   $(MAKE) -$(MAKEFLAGS) clean
	cd tests;    $(MAKE) -$(MAKEFLAGS) clean
	cd demos;    $(MAKE) -$(MAKEFLAGS) clean
	cd photo;    $(MAKE) -$(MAKEFLAGS) clean
