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

# Master makefile for graphics 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
# complete 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

# 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)/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)/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

# OPTIONS = compiler options
OPTIONS=-O

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

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

INSTALL_BIN = $(PWD)/../instl

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

SHELL = /bin/sh

HGRAPHICS_MAKE_OPTIONS =  \
  PWD="$(PWD)/hgraphics"  \
  OPTIONS="$(OPTIONS)"  \
  SHELL="$(SHELL)"  \
  BINDIR="$(BINDIR)"  \
  HELPDIR="$(HELPDIR)"  \
  SPOOL_COMMAND="$(SPOOL_COMMAND)"  \
  CP="$(CP)"  \
  INSTALL_BIN="$(INSTALL_BIN)"  \
  GDB="../gdb/libgdb.a"  \
  FSA="../fsa/fsa.o"  \
  STRTOKQ="../strtokq/strtokq.o"  \
  GDB_HEADER="../gdb/gdb.h"

HGRAPHICSPATH = $(BINDIR)/hgraphics
ELBOWDPATH = $(BINDIR)/elbowd

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

all:	libs hgraphics_bin

libs:	fsa_obj strtokq_obj gdb_lib 

install:	$(BINDIR) libs install_hgraphics install_starthyper

$(BINDIR):
	mkdir $(BINDIR)

fsa_obj:
	cd fsa ;				\
	$(MAKE)					\
	    OPTIONS="$(OPTIONS)"		\
	    fsa.o

strtokq_obj:
	cd strtokq ;				\
	$(MAKE)					\
	    OPTIONS="$(OPTIONS)"		\
	    strtokq.o

gdb_lib:
	cd gdb ;				\
	$(MAKE)					\
	    OPTIONS="$(OPTIONS)"		\
	    libgdb.a

hgraphics_bin:
	cd hgraphics ;				\
	$(MAKE)					\
	    $(HGRAPHICS_MAKE_OPTIONS)		\
	    hgraphics

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

rm-starthyper:
	/bin/rm -f starthyper ;

install_hgraphics:
	cd hgraphics ;				\
	$(MAKE)					\
	    $(HGRAPHICS_MAKE_OPTIONS)		\
	    install

install_starthyper:	starthyper
	$(INSTALL) '$(BINDIR)' starthyper

localclean:
	/bin/rm -f *~ ;

clean:	localclean
	cd fsa ; $(MAKE) clean
	cd strtokq ; $(MAKE) clean
	cd gdb ; $(MAKE) clean
	cd hgraphics ; $(MAKE) clean

veryclean:	localclean
	/bin/rm -f *~ starthyper ;
	cd fsa ; $(MAKE) veryclean
	cd strtokq ; $(MAKE) veryclean
	cd gdb ; $(MAKE) veryclean
	cd hgraphics ; $(MAKE) veryclean

distclean:	localclean
	/bin/rm -r -f ./bin
	cd fsa ; $(MAKE) distclean
	cd strtokq ; $(MAKE) distclean
	cd gdb ; $(MAKE) distclean
	cd hgraphics ; $(MAKE) distclean


