# $Id: Makefile,v 1.2 90/07/11 13:07:52 mbp Exp Locker: mbp $

# Master makefile for Mathematica part of hypercad

####################################################################
# 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'.  By default (as this Makefile is distributed),
# executables are placed in a subdir of this dir called 'bin'.  If you
# want to put them somewhere else, change the def here, preferably to
# a dir which is on your search path.
BINDIR = $(PWD)/bin

# OPTIONS = compiler options
OPTIONS=-O

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

# HGRAPHICSPATH = pathname, on graphics host, of executable file
# 'hgraphics'.  This is used only by the Hypercad shell script.
HGRAPHICSPATH = $(PWD)/../graphics/bin/hgraphics

# ELBOWDPATH = pathname, on graphics host, of executable file
# 'elbowd'.  This is used only by the Hypercad shell script.
ELBOWDPATH = $(PWD)/../graphics/bin/elbowd

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

# 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

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

INSTALL_BIN = $(PWD)/../instl

HYPERMATHPATH = $(BINDIR)/HyperMath

HYPERPACKAGEPATH = $(PWD)/Packages

INTERFACEPACKAGEPATH = $(PWD)/../Interface/Packages

INSTALL = $(INSTALL_BIN) -cp "$(CP)"

SHELL = /bin/sh

SEPARATE_MAKE_OPTIONS =  \
  PWD="$(PWD)/separate"  \
  OPTIONS="$(OPTIONS)"  \
  BINDIR="$(BINDIR)"  \
  CP="$(CP)"  \
  INSTALL_BIN="$(INSTALL_BIN)"

PACKAGES_MAKE_OPTIONS = \
  SEPARATEPATH="$(PWD)/bin/separate"

SED_ARGS = \
  -e 's|HYPERPACKAGEPATH|$(HYPERPACKAGEPATH)|' \
  -e 's|INTERFACEPACKAGEPATH|$(INTERFACEPACKAGEPATH)|' \
  -e 's|MATHDIR|$(MATHDIR)|' \
  -e 's|MACHDIR|$(MACHDIR)|' \
  -e 's|HGRAPHICSPATH|$(HGRAPHICSPATH)|' \
  -e 's|ELBOWDPATH|$(ELBOWDPATH)|' \
  -e 's|HYPERMATHPATH|$(HYPERMATHPATH)|'

OBJS = Hypercad HyperMath

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

all:	separate_bin packages scripts

install:	$(BINDIR) install_separate install_scripts

$(BINDIR):
	mkdir $(BINDIR)

scripts:	Hypercad HyperMath

separate_bin:
	cd separate ;				\
	$(MAKE)					\
	  $(SEPARATE_MAKE_OPTIONS)		\
	  separate

packages:
	cd Packages ;			\
	$(MAKE)				\
	  $(PACKAGES_MAKE_OPTIONS)	\
	  all

HyperMath:	rm-HyperMath HyperMath.tpl
	sed \
	  $(SED_ARGS) \
	  -e 's|#TPLWARNING|# DO NOT EDIT THIS FILE DIRECTLY!  EDIT ONLY THE CORRESPONDING .tpl FILE.|' \
	  -e '/#TPL.*$$/d' \
	  < HyperMath.tpl > HyperMath
	chmod -w,+x HyperMath

rm-HyperMath:
	/bin/rm -f HyperMath ;

Hypercad:	rm-Hypercad Hypercad.tpl
	sed \
	  $(SED_ARGS) \
	  -e 's|#TPLWARNING|# DO NOT EDIT THIS FILE DIRECTLY!  EDIT ONLY THE CORRESPONDING .tpl FILE.|' \
	  -e '/#TPL.*$$/d' \
	  < Hypercad.tpl > Hypercad
	chmod -w,+x Hypercad

rm-Hypercad:
	/bin/rm -f Hypercad ;

install_separate:
	cd separate ;				\
	$(MAKE)					\
	  $(SEPARATE_MAKE_OPTIONS)		\
	  install

install_scripts:	HyperMath Hypercad
	$(INSTALL) '$(BINDIR)' HyperMath Hypercad

localclean:
	/bin/rm -f *~ ;

clean:		localclean
	cd separate ; $(MAKE) clean
	cd Packages ; $(MAKE) clean

veryclean:	localclean
	cd separate ; $(MAKE) veryclean
	cd Packages ; $(MAKE) veryclean

distclean:	localclean
	/bin/rm -r -f ./bin $(OBJS)
	cd separate ; $(MAKE) distclean
	cd Packages ; $(MAKE) distclean

