# Master makefile for Hypercad --- this makefile builds both
#   the graphics part and the Mathematica part of Hypercad
#   and the Interface.

# USE THIS MAKEFILE ONLY IF YOUR GRAPHICS HOST AND MATHEMATICA HOST
# ARE THE SAME, OR ARE THE SAME TYPE OF COMPUTER AND SHARE THE SAME
# FILESYSTEM.  FOR MORE INFO ON INSTALLING HYPERCAD, SEE THE README
# FILE IN THIS DIRECTORY.

####################################################################
# Configuration section

# PWD = complete pathname of the dir containing this makefile.  If you
# are using csh this should be set automatically by the shell.
# Otherwise, remove the comment char from the next line and append the
# pathname of this dir.
# PWD = 

# BINDIR = dir in which to install executable files. This is used by
# 'make install'.
BINDIR = $(PWD)/bin

# OPTIONS = compiler options
OPTIONS=-O

# CP = copying command for use in installation. Should be 'ln' or 'cp'.
CP=ln

# MATHDIR = pathname of the mathematica root dir on your system.
# This is the dir containing the subdirs Bin.*, Init, Packages, etc.
MATHDIR = /usr/local/lib/Mathematica

# MACHDIR = name of the subdirectory of the Mathematica root dir
# containing the Mathematica executable file 'mathexe'.  Use
# 	MACHDIR = Bin.sun3 	(for Sun 3's)
#   or	MACHDIR = Bin.sun4	(for Sun 4's)
#   or	MACHDIR = Bin.Iris 	(for IRISes)
# etc.
MACHDIR = Bin.sun3

# HELPDIR = dir in which to install help file.  The help file is
# needed at run-time.  To have the program compiled so that it uses
# the copy of the help file in the source code, set
# HELPDIR=$(PWD)/graphics/hgraphics/sunview.  You may change HELPDIR
# to any existing directory name. 'make' will compile the program so
# that it looks in that dir for the helpfile at run-time, and 'make
# install' will put a copy of the helpfile in that dir.  DO NOT
# COMMENT OUT THE DEF OF HELPDIR.  If you do, the program will not be
# able to find the help file.
HELPDIR=$(PWD)/graphics/Hypercad/hgraphics/sunview

# SPOOL_COMMAND = command to use for printing PostScript files.  If
# you can't print PostScript files, comment out this def.
SPOOL_COMMAND=lpr

# End configuration section --- don't change anything below here
####################################################################

SHELL = /bin/csh

INSTALL_BIN = $(PWD)/graphics/instl

MAKE_ARGS = \
  BINDIR="$(BINDIR)" \
  OPTIONS="$(OPTIONS)" \
  CP="$(CP)" \
  MATHDIR="$(MATHDIR)" \
  MACHDIR="$(MACHDIR)" \
  HELPDIR="$(HELPDIR)" \
  SPOOL_COMMAND="$(SPOOL_COMMAND)" \
  INSTALL_BIN="$(INSTALL_BIN)"

####################################################################

warning:
	@echo ''
	@echo 'You may only use this Makefile if your graphics host'
	@echo 'and Mathematica host are the same, or are the same type'
	@echo 'of computer and share a filesystem.  If you are sure'
	@echo 'that this is the case, type "make install" to perform the'
	@echo 'installtion.'
	@echo ''
	@echo 'For more information on installing Hypercad, and for'
	@echo 'instructions on running it, see the README file in this'
	@echo 'directory.'
	@echo ''

all:	compile_math compile_graphics

install:	install_math install_graphics
	@echo ''
	@echo 'Hypercad installation is now complete.  The executable files'
	@echo 'for both the graphics host and the Mathematica host are in'
	@echo 'the directory'
	@echo '     $(BINDIR)'
	@echo ''

compile_math:
	cd Mathematica ; \
	  $(MAKE) \
	    PWD="$(PWD)/Mathematica" \
	    $(MAKE_ARGS)

install_math:
	cd Mathematica ; \
	  $(MAKE) \
	    PWD="$(PWD)/Mathematica" \
	    $(MAKE_ARGS) \
	    install_quietly

compile_graphics:
	cd graphics ; \
	  $(MAKE) \
	    PWD="$(PWD)/graphics" \
	    $(MAKE_ARGS)

install_graphics:
	cd graphics ; \
	  $(MAKE) \
	    PWD="$(PWD)/graphics" \
	    $(MAKE_ARGS) \
	    install_quietly

hypercad.tar.Z:	hypercad.tar
	compress hypercad.tar

hypercad.tar:	rm-hypercad.tar
	tar chbf 512 /tmp/hypercad.tar *
	/bin/mv /tmp/hypercad.tar .

rm-hypercad.tar:
	/bin/rm -f hypercad.tar ;

rcslinks:
	ln -s $(HOME)/records/Hypercad-Distribution-Dir \
	  ./RCS
	ln -s $(HOME)/records/Hypercad-Distribution-Dir/Mathematica \
	  Mathematica/RCS
	ln -s $(HOME)/records/Hypercad/Mathematica \
	  Mathematica/Hypercad/RCS
	ln -s $(HOME)/records/Hypercad/Mathematica/Packages \
	  Mathematica/Hypercad/Packages/RCS
	ln -s $(HOME)/records/Hypercad/Mathematica/separate \
	  Mathematica/Hypercad/separate/RCS
	ln -s $(HOME)/records/Interface/Mathematica \
	  Mathematica/Interface/RCS
	ln -s $(HOME)/records/Interface/Mathematica/Packages \
	  Mathematica/Interface/Packages/RCS
	ln -s $(HOME)/records/Interface/Mathematica/bothpipe \
	  Mathematica/Interface/bothpipe/RCS
	ln -s $(HOME)/records/Interface/Mathematica/mathpipe \
	  Mathematica/Interface/mathpipe/RCS
	ln -s $(HOME)/records/Hypercad-Distribution-Dir/graphics \
	  graphics/RCS
	ln -s $(HOME)/records/Hypercad/graphics \
	  graphics/Hypercad/RCS
	ln -s $(HOME)/records/fsa \
	  graphics/Hypercad/fsa/RCS
	ln -s $(HOME)/records/gdb \
	  graphics/Hypercad/gdb/RCS
	ln -s $(HOME)/records/Hypercad/graphics/hgraphics \
	  graphics/Hypercad/hgraphics/RCS
	ln -s $(HOME)/records/Hypercad/graphics/hgraphics/sunview \
	  graphics/Hypercad/hgraphics/sunview/RCS
	ln -s $(HOME)/records/Hypercad/graphics/hgraphics/sunview/images \
	  graphics/Hypercad/hgraphics/sunview/images/RCS
	ln -s $(HOME)/records/strtokq \
	  graphics/Hypercad/strtokq/RCS
	ln -s $(HOME)/records/Interface/graphics \
	  graphics/Interface/RCS
	ln -s $(HOME)/records/Interface/graphics/remotepipe \
	  graphics/Interface/remotepipe/RCS

rcsclean:
	/bin/rm -f ./RCS ;
	/bin/rm -f Mathematica/RCS ;
	/bin/rm -f Mathematica/Hypercad/RCS ;
	/bin/rm -f Mathematica/Hypercad/Packages/RCS ;
	/bin/rm -f Mathematica/Hypercad/separate/RCS ;
	/bin/rm -f Mathematica/Interface/RCS ;
	/bin/rm -f Mathematica/Interface/Packages/RCS ;
	/bin/rm -f Mathematica/Interface/bothpipe/RCS ;
	/bin/rm -f Mathematica/Interface/mathpipe/RCS ;
	/bin/rm -f graphics/RCS ;
	/bin/rm -f graphics/Hypercad/RCS ;
	/bin/rm -f graphics/Hypercad/fsa/RCS ;
	/bin/rm -f graphics/Hypercad/gdb/RCS ;
	/bin/rm -f graphics/Hypercad/hgraphics/RCS ;
	/bin/rm -f graphics/Hypercad/hgraphics/sunview/RCS ;
	/bin/rm -f graphics/Hypercad/hgraphics/sunview/images/RCS ;
	/bin/rm -f graphics/Hypercad/strtokq/RCS ;
	/bin/rm -f graphics/Interface/RCS ;
	/bin/rm -f graphics/Interface/remotepipe/RCS ;

localclean:
	/bin/rm -f *~ ;

clean:	localclean
	cd graphics ; $(MAKE) clean
	cd Mathematica ; $(MAKE) clean

veryclean:	localclean
	cd graphics ; $(MAKE) veryclean
	cd Mathematica ; $(MAKE) veryclean

distclean:	localclean
	/bin/rm -r -f ./bin
	cd graphics ; $(MAKE) distclean
	cd Mathematica ; $(MAKE) distclean
