##############################################################################
# File:         Makefile
# Description:  for building, distributing, and maintaining frobs
# Author:       Eric G. Muehle, Jed Krohnfeldt, Craig Steury
# Created:      22-Sep-87
# RCS $Header: /u/misc/pass/lisp/tools/frobs/RCS/Makefile,v 1.33 1992/10/08 22:35:26 eeide Exp $
#
# (c) Copyright 1987, 1988, University of Utah, all rights reserved
##############################################################################
#
# Set the variables below for your site and Lisp system:
#
# CL is the path/name of the lisp used to build Frobs.
# OBJ is the extension (such .b or .o) for Lisp binary object files.
# LSP is the extension (such as .l) for Lisp source files.
# QUIT is the name of the Lisp function used to terminate a Lisp session.
# BIN is the directory where frobs.b should find all of the frobs .b files.
#     (make sure BIN is an absolute path, and not a relative one)

CL	 = cl
OBJ	 = b
LSP      = l
QUIT	 = sys:exit
INITS    =
BIN      = \$$LISP/modules/the-frobs

INSTALL = \
	/n/morgan/v/lisp/modules \
	/n/jensen/v/misc/cl/modules \
	/n/jaguar/usr/server/hp300/lisp/modules

##############################################################################
# Files.
##############################################################################

# frob manual
DOC     = frobs

# frob sources
SOURCES = Makefile globals.$(LSP) pack.$(LSP) struct.$(LSP) misc.$(LSP)\
	define.$(LSP) ask-assert.$(LSP) user-methods.$(LSP)\
	daemons.$(LSP) dynamic.$(LSP) p-frobs.$(LSP) useful.$(LSP)\
	the-rules.$(LSP) paths.$(LSP) sys-specific.$(LSP) $(DOC).tex 

# frob binaries
KERNEL	= globals.$(OBJ) pack.$(OBJ) struct.$(OBJ) misc.$(OBJ) define.$(OBJ)
FROBS	= ask-assert.$(OBJ) user-methods.$(OBJ) daemons.$(OBJ) dynamic.$(OBJ)\
	the-rules.$(OBJ) sys-specific.$(OBJ)
AUX     = p-frobs.$(OBJ) useful.$(OBJ)

# frob load file - loads frobs
LOAD    = frobs.$(OBJ)

# frob test files
TEST    = examples/prob1.$(LSP) examples/prob1a.$(LSP)\
	examples/prob1a-m.$(LSP) examples/prob1b.$(LSP)\
	examples/prob1b-m.$(LSP) examples/prob2.$(LSP)\
	examples/prob3.$(LSP) examples/prob4.$(LSP)\
	examples/prob5.$(LSP) examples/prob5a.$(LSP)\
	examples/prob5b.$(LSP) examples/ships.$(LSP)\
	examples/sticks.$(LSP) examples/test.$(LSP)

############################################################################
# Make targets.
############################################################################

# default target
help:
	@echo "make [frobs install clean doc test help]"

# build frobs system
frobs:	$(KERNEL) $(FROBS) $(LOAD)

# build auxiliary frobs tools
aux:	$(AUX)

# install frobs binaries
install: frobs
	@csh install.csh $(INSTALL)

# clean frobs directory
clean:
	rm -f $(KERNEL) $(FROBS) $(AUX) $(LOAD) frobs.$(LSP) *.aux *.dvi *.log

# build frobs documentation
doc:		$(DOC).dvi
$(DOC).dvi:	$(DOC).aux
$(DOC).aux:	$(DOC).tex

# test frobs system
test:
	(cd examples; make test CL=$(CL) LSP=$(LSP) QUIT=$(QUIT))
	
############################################################################
# Individual file targets. 
############################################################################

.SUFFIXES: .$(LSP) .$(OBJ) .dvi .aux .tex .c

# Turn off the implicit GNU Make LEX rule.
%.c : %.l
%.r : %.l

.tex.aux:
	@latex $*
	@rm -f $*.dvi

.aux.dvi:
	@latex $*

.$(LSP).$(OBJ):
	@echo "Compiling $*.$(LSP)..."
	echo \(progn\
		'$(INITS)'\
		\(load\ \"sys-specific\"\)\
		\(load\ \"pack\"\)\
		\(load\ \"globals\"\)\
		\(load\ \"struct\"\)\
		\(load\ \"misc\"\)\
		\(load\ \"define\"\)\
		\(load\ \"user-methods\"\)\
		\(load\ \"ask-assert\"\)\
		\(compile-file \"$*.$(LSP)\"\)\
		\($(QUIT)\)\)\) | $(CL)

############################################################################
# Frobs file targets.
############################################################################

sys-specific.$(OBJ):	sys-specific.$(LSP)

globals.$(OBJ):		sys-specific.$(OBJ) globals.$(LSP) 

pack.$(OBJ):		globals.$(OBJ) pack.$(LSP)

struct.$(OBJ):		globals.$(OBJ) struct.$(LSP)

misc.$(OBJ):		globals.$(OBJ) misc.$(LSP)

define.$(OBJ):		globals.$(OBJ) pack.$(OBJ) struct.$(OBJ)\
			misc.$(OBJ) define.$(LSP)

ask-assert.$(OBJ):	$(KERNEL) ask-assert.$(LSP)

user-methods.$(OBJ):	$(KERNEL) user-methods.$(LSP)

daemons.$(OBJ):		$(KERNEL) ask-assert.$(OBJ) daemons.$(LSP)

dynamic.$(OBJ):		$(KERNEL) daemons.$(OBJ) user-methods.$(OBJ)\
			ask-assert.$(OBJ) dynamic.$(LSP)

p-frobs.$(OBJ):		$(KERNEL) user-methods.$(OBJ) p-frobs.$(LSP)

useful.$(OBJ):		$(KERNEL) user-methods.$(OBJ) useful.$(LSP)

the-rules.$(OBJ):	$(KERNEL) daemons.$(OBJ)

##############################################################################
# The file paths.l has Lisp forms like (load "./struct") in it.  This
# Makefile copies paths.l to frobs.l, replacing occurrences of "./ with
# $(BIN) which was set above.  Then frobs.l is compiled.  This file loads
# all of the rest of the frobs files, and should be put on a standard system
# directory, such as on the (require ..) path for your Common Lisp.
##############################################################################

frobs.$(LSP):		Makefile paths.$(LSP)
	rm -f frobs.$(LSP)
	sed -e "s#\"\.\/#\"$(BIN)\/#" < paths.$(LSP) > frobs.$(LSP)

frobs.$(OBJ): 	frobs.$(LSP)
	@echo "Compiling frobs.$(LSP)..."
	@echo \(progn\
		'$(INITS)'\
		\(load\ \"globals\"\)\
		\(compile-file\ \"frobs.$(LSP)\"\)\
		\($(QUIT)\)\)\) | $(CL)

##############################################################################
# End of file.
##############################################################################
