#! /bin/csh

# 
# This is the Makefile for 'proof'. It is available, along with the
# rest of the 'proof' v0.1 distribution via anonymous ftp from
# scam.Berkeley.EDU (128.32.138.1), the Experimental Computing Facility
# (XCF) of UC Berkeley.
#
# You will want to change the DIR variables for your site, and get rid
# of "demo" DEMODIR, and FTPDIR, since you probably won't be demoing
# or distributing 'proof' from your site.
#
# Please email all 'proof' correspondence to proof@xcf.Berkeley.EDU,
# and/or comments of general interest to 'proof' users to
# proof-users@xcf.Berkeley.EDU. 
#
# Thanks  --craig.
#

CC = cc

HOMEDIR = /usr/users/latta
HOMELIBDIR = $(HOMEDIR)/lib

SRCS = motor.c rules.c hash.c
TEMPLATES = rule_template.c package_template.c function_template.c
HDRS = proof.h hash.h stuff.h
OBJS = motor.o rules.o hash.o
OTHERHDRS = $(HOMEDIR)/include/config.h /usr/include/gdbm.h

DEMODIR = /usr/users/demo/proof
FTPDIR = /usr/users/ftp/ftp_public/src/local/proof

DOCDIR = $(HOMEDIR)/projects/xcf/proof/doc
CMIPSLIBDIR = /usr/local/lib
CSUNLIBDIR = $(HOMELIBDIR)/sun4

FILES = proof gloating motd
DOCFILES = $(DOCDIR)/peace $(DOCDIR)/works $(DOCDIR)/define $(DOCDIR)/proof.1
SRCFILES = Makefile
LIBFILES = lexicon $(CSUNLIBS) $(CMIPSLIBS)

CFLAGS   = -g -I$(HOMEDIR)/include
CSUNLIBS = $(CSUNLIBDIR)/sunlibstuff.a
CMIPSLIBS = $(CMIPSLIBDIR)/stuff.a $(CMIPSLIBDIR)/gdbm.a

install:
	make proofmips gloat demo

proofmips: $(OBJS)
	$(CC) $(CFLAGS) -o proof $(OBJS) $(CMIPSLIBS)
	echo "proof: an interactive grammar scanner, version 0.2, by Craig Latta (c) 1991.                                                                                               " > motd
	echo "   Significant changes:                                                         9/26: gdbm used instead of ndbm.                                                "
	echo "   Please send email to proof@xcf.Berkeley.EDU with your alphatest comments,    and/or to proof-users@xcf.Berkeley.EDU with comments of interest to all         'proof' users. Thanks  --craig.                                                                                   " >> motd
	echo "   Known bugs:                                                                     none.                                                                          " >> motd
	echo "   Last compilation: `date`" >> motd
	echo "   Caution: the demo lexicon is overwritten with every compile. Please email    significant lexicon changes to proof@xcf.Berkeley.EDU." >> motd

proofsun: $(OBJS)
	$(CC) $(CFLAGS) -o proofsun $(OBJS) $(CSUNLIBS)

sabermips:
	#load $(CFLAGS) $(CMIPSLIBS) $(SRCS)

sabersun:
	#load $(CFLAGS) $(CSUNLIBS) $(SRCS)

motor.o: motor.c proof.h hash.h
rules.o: rules.c proof.h hash.h
hash.o: hash.c hash.h

clean:
	rm -f $(OBJS) *.o *~

demo:
	cp -f $(FILES) $(DOCFILES) $(SRCFILES) proofFE $(DEMODIR)
	cp -f $(SRCS) $(HDRS) $(SRCFILES) $(TEMPLATES) $(FTPDIR)/src
	cp -f $(DOCFILES) $(FTPDIR)/doc
	cp -f $(LIBFILES) $(FTPDIR)/lib
	cp -f $(OTHERHDRS) $(FTPDIR)/include
	chmod ugo+rw $(DEMODIR)/lexicon.*

gloat:
	echo "   Lines of code:" > ./gloating
	wc -l $(SRCS) $(HDRS) >> ./gloating
	echo "                                                                                   Disk usage:" >> ./gloating
	ls -al proof ../lib/lexicon* >> ./gloating

touch:
	touch $(SRCS) $(HDRS)
