subdir = src/interp/

IN=$(srcdir)
DOC=$(axiom_target_docdir)/src/interp
BOOK=$(axiom_target_docdir)

# Command to translate Boot to Common Lisp
BOOT_TO_LISP = $(BOOTSYS) -- --translate $< 

# Command to translate Common Lisp to native object code
COMPILE_LISP = $(DEPSYS) -- --compile --output=$@ $<
AUTO=$(axiom_targetdir)/autoload

autoload_objects =

# Build platform-dependent Lisp image, at the base of other
# derived Lisp images (depsys, interpsys, AXIOMsys)
LISPSYS= $(axiom_build_bindir)/lisp

BOOTSYS= $(axiom_build_bindir)/bootsys    

DEPSYS = ./depsys
depsys_lisp_compiled_sources += parsing.lisp metalex.lisp bootlex.lisp \
	newaux.lisp preparse.lisp postprop.lisp def.lisp \
	fnewmeta.lisp

depsys_lisp_sources = $(depsys_lisp_noncompiled_sources) \
			$(depsys_lisp_compiled_sources)

depsys_boot_sources = postpar.boot parse.boot clam.boot slam.boot \
	g-boot.boot g-error.boot c-util.boot g-util.boot
DEP=	nlib.lisp	\
	macros.lisp	comp.lisp	\
	spaderror.lisp	debug.lisp	\
	spad.lisp	bits.lisp	\
	setq.lisp	property.lisp	\
	unlisp.lisp     foam_l.lisp      \
	axext_l.lisp

depsys_lisp_macro_sources = vmlisp.lisp ggreater.lisp hash.lisp \
	bootfuns.lisp union.lisp nlib.lisp macros.lisp	\
	comp.lisp spaderror.lisp debug.lisp \
	spad.lisp bits.lisp setq.lisp property.lisp \
	unlisp.lisp foam_l.lisp axext_l.lisp

depsys_lisp_noncompiled_sources += $(depsys_lisp_macro_sources)
depsys_lisp_SOURCES = $(addsuffix .pamphlet, $(depsys_lisp_sources))
LOADSYS= $(axiom_build_bindir)/lisp$(EXEEXT)
SAVESYS= interpsys$(EXEEXT)
AXIOMSYS= $(axiom_target_bindir)/AXIOMsys$(EXEEXT)

DEBUGSYS=$(axiom_build_bindir)/debugsys$(EXEEXT)

OBJS=	vmlisp.$(FASLEXT)	hash.$(FASLEXT)	\
	diagnostics.$(FASLEXT)				\
	bootfuns.$(FASLEXT)	macros.$(FASLEXT)	\
	unlisp.$(FASLEXT)	setq.$(FASLEXT)	\
	astr.$(FASLEXT)	bits.$(FASLEXT)	\
	alql.$(FASLEXT)	buildom.$(FASLEXT)	\
	cattable.$(FASLEXT)				\
	cformat.$(FASLEXT)	cfuns.$(FASLEXT)	\
	clam.$(FASLEXT)	clammed.$(FASLEXT)	\
	comp.$(FASLEXT)	        foam_l.$(FASLEXT) \
	compat.$(FASLEXT)	compress.$(FASLEXT)	\
	cparse.$(FASLEXT)	cstream.$(FASLEXT)	\
	database.$(FASLEXT)	\
	debug.$(FASLEXT)	dq.$(FASLEXT)		\
	fname.$(FASLEXT)	format.$(FASLEXT)	\
	g-boot.$(FASLEXT)	g-cndata.$(FASLEXT)	\
	g-error.$(FASLEXT)	g-opt.$(FASLEXT)	\
	g-timer.$(FASLEXT)	g-util.$(FASLEXT)	\
	ggreater.$(FASLEXT)				\
	hypertex.$(FASLEXT)	i-analy.$(FASLEXT)	\
	i-code.$(FASLEXT)	i-coerce.$(FASLEXT)	\
	i-coerfn.$(FASLEXT)	i-eval.$(FASLEXT)	\
	i-funsel.$(FASLEXT)	bookvol5.$(FASLEXT)	\
	i-intern.$(FASLEXT)	i-map.$(FASLEXT)	\
	i-output.$(FASLEXT)	i-resolv.$(FASLEXT)	\
	i-spec1.$(FASLEXT)				\
	i-spec2.$(FASLEXT)	i-syscmd.$(FASLEXT)	\
	i-toplev.$(FASLEXT)	i-util.$(FASLEXT)	\
	incl.$(FASLEXT)	int-top.$(FASLEXT)	\
	intfile.$(FASLEXT)				\
	lisplib.$(FASLEXT)	macex.$(FASLEXT)	\
	match.$(FASLEXT)				\
	monitor.$(FASLEXT)	msg.$(FASLEXT)		\
	msgdb.$(FASLEXT)	nci.$(FASLEXT)		\
	newaux.$(FASLEXT)	newfort.$(FASLEXT)	\
	nlib.$(FASLEXT)	nrunfast.$(FASLEXT)	\
	nrungo.$(FASLEXT)	nrunopt.$(FASLEXT)	\
	nruntime.$(FASLEXT)	osyscmd.$(FASLEXT)	\
	packtran.$(FASLEXT)	pathname.$(FASLEXT)	\
	pf2sex.$(FASLEXT)	pile.$(FASLEXT)	\
	posit.$(FASLEXT)	property.$(FASLEXT)	\
	ptrees.$(FASLEXT)	ptrop.$(FASLEXT)	\
	record.$(FASLEXT)				\
	rulesets.$(FASLEXT)	\
	scan.$(FASLEXT)	serror.$(FASLEXT)	\
	server.$(FASLEXT)				\
	setvars.$(FASLEXT)	\
	sfsfun-l.$(FASLEXT)	sfsfun.$(FASLEXT)	\
	simpbool.$(FASLEXT)	slam.$(FASLEXT)	\
	sockio.$(FASLEXT)	spad.$(FASLEXT)	\
	spaderror.$(FASLEXT)				\
	template.$(FASLEXT)	termrw.$(FASLEXT)	\
	trace.$(FASLEXT)	\
	union.$(FASLEXT)       daase.$(FASLEXT)  	\
	fortcall.$(FASLEXT)

interpsys_modules = $(patsubst %.$(FASLEXT), "%", $(OBJS))

AXIOMsys_noncompiled_lisp_sources = bootfuns.lisp nocompil.lisp \
	postprop.lisp property.lisp setq.lisp 

AXIOMsys_compiled_lisp_sources = bits.lisp \
	bootlex.lisp cfuns.lisp comp.lisp construc.lisp daase.lisp \
	debug.lisp def.lisp fname.lisp fnewmeta.lisp ggreater.lisp \
	hash.lisp macros.lisp metalex.lisp monitor.lisp newaux.lisp \
	nlib.lisp nspadaux.lisp parsing.lisp \
	patches.lisp preparse.lisp \
	sockio.lisp spad.lisp spaderror.lisp \
	union.lisp util.lisp vmlisp.lisp obey.lisp \
	unlisp.lisp intint.lisp nci.lisp sfsfun-l.lisp \
	axext_l.lisp foam_l.lisp

AXIOMsys_boot_sources = astr.boot alql.boot buildom.boot cattable.boot \
	cformat.boot clam.boot clammed.boot compat.boot compress.boot \
	cparse.boot cstream.boot database.boot dq.boot format.boot \
	g-boot.boot g-cndata.boot g-error.boot g-opt.boot g-timer.boot \
	g-util.boot hypertex.boot i-analy.boot i-code.boot i-coerce.boot \
	i-coerfn.boot i-eval.boot i-funsel.boot i-intern.boot i-map.boot \
	i-output.boot i-resolv.boot i-spec1.boot i-spec2.boot \
	i-syscmd.boot i-toplev.boot i-util.boot incl.boot int-top.boot \
	intfile.boot lisplib.boot macex.boot match.boot msg.boot \
	msgdb.boot newfort.boot nrunfast.boot nrungo.boot nrunopt.boot \
	nruntime.boot osyscmd.boot packtran.boot pathname.boot \
	pf2sex.boot pile.boot posit.boot ptrees.boot ptrop.boot \
	record.boot rulesets.boot scan.boot serror.boot server.boot \
	setvars.boot sfsfun.boot simpbool.boot slam.boot template.boot \
	termrw.boot trace.boot fortcall.boot
INOBJS=	varini.$(FASLEXT)	parini.$(FASLEXT)	\
	setvart.$(FASLEXT)	intint.$(FASLEXT)	\
        xrun.$(FASLEXT)        interop.$(FASLEXT)     \
        patches.$(FASLEXT)

IN_modules = $(patsubst %.$(FASLEXT), "%", $(INOBJS))

# These are autloaded old parser files
OPOBJS=	${AUTO}/parsing.$(FASLEXT)	${AUTO}/bootlex.$(FASLEXT)	\
        ${AUTO}/def.$(FASLEXT)	\
	${AUTO}/fnewmeta.$(FASLEXT)	${AUTO}/metalex.$(FASLEXT)	\
	${AUTO}/parse.$(FASLEXT)	${AUTO}/postpar.$(FASLEXT)	\
	${AUTO}/postprop.$(FASLEXT)	${AUTO}/preparse.$(FASLEXT)

autoload_objects += $(OPBJS)
OCOBJS=	${AUTO}/apply.$(FASLEXT)	${AUTO}/c-doc.$(FASLEXT)	\
	${AUTO}/c-util.$(FASLEXT)	${AUTO}/profile.$(FASLEXT)	\
	${AUTO}/category.$(FASLEXT)	${AUTO}/compiler.$(FASLEXT)	\
	${AUTO}/define.$(FASLEXT)	${AUTO}/functor.$(FASLEXT)	\
	${AUTO}/info.$(FASLEXT)	${AUTO}/iterator.$(FASLEXT)	\
	${AUTO}/modemap.$(FASLEXT)	${AUTO}/nruncomp.$(FASLEXT)	\
	${AUTO}/package.$(FASLEXT)	${AUTO}/htcheck.$(FASLEXT)	\
        ${AUTO}/xruncomp.$(FASLEXT)   

autoload_objects += $(OCOBJS)

BROBJS=	${AUTO}/bc-matrix.$(FASLEXT)				\
	${AUTO}/bc-misc.$(FASLEXT)	${AUTO}/bc-solve.$(FASLEXT)	\
	${AUTO}/bc-util.$(FASLEXT)				\
	${AUTO}/ht-util.$(FASLEXT)	${AUTO}/htsetvar.$(FASLEXT)	\
	${AUTO}/ht-root.$(FASLEXT)	\
	${AUTO}/br-con.$(FASLEXT)	\
	${AUTO}/br-data.$(FASLEXT)	${AUTO}/showimp.$(FASLEXT)    \
	${AUTO}/br-op1.$(FASLEXT)	${AUTO}/br-op2.$(FASLEXT)	\
	${AUTO}/br-search.$(FASLEXT)	${AUTO}/br-util.$(FASLEXT)	\
	${AUTO}/topics.$(FASLEXT)     ${AUTO}/br-prof.$(FASLEXT)    \
	${AUTO}/br-saturn.$(FASLEXT)

autoload_objects += $(BFOBJS)

TRANOBJS= ${AUTO}/wi1.$(FASLEXT) ${AUTO}/wi2.$(FASLEXT) ${AUTO}/pspad1.$(FASLEXT) \
	  ${AUTO}/pspad2.$(FASLEXT) ${AUTO}/mark.$(FASLEXT) ${AUTO}/nspadaux.$(FASLEXT) \
	  ${AUTO}/def.$(FASLEXT)

autoload_objects += $(TRANOBJS)

NAGBROBJS= ${AUTO}/nag-c02.$(FASLEXT)   ${AUTO}/nag-c05.$(FASLEXT) \
           ${AUTO}/nag-c06.$(FASLEXT)   ${AUTO}/nag-d01.$(FASLEXT) \
           ${AUTO}/nag-d02.$(FASLEXT)   ${AUTO}/nag-d03.$(FASLEXT) \
           ${AUTO}/nag-e01.$(FASLEXT)   ${AUTO}/nag-e02.$(FASLEXT) \
           ${AUTO}/nag-e04.$(FASLEXT)   ${AUTO}/nag-f01.$(FASLEXT) \
           ${AUTO}/nag-f02.$(FASLEXT)   ${AUTO}/nag-f04.$(FASLEXT) \
           ${AUTO}/nag-f07.$(FASLEXT)   ${AUTO}/nag-s.$(FASLEXT) 

autoload_objects += $(NAGBROBJS)

ASCOMP= hashcode.$(FASLEXT) as.$(FASLEXT) \
	foam_l.$(FASLEXT) axext_l.$(FASLEXT)

AS_modules = $(patsubst %.$(FASLEXT), "%", $(ASCOMP))

ASAUTO= ${AUTO}/ax.$(FASLEXT)

autoload_objects += $(ASAUTO)
TIMESTAMP=$(axiom_targetdir)/timestamp
YEARWEEK=(progn (setq boot::timestamp "${TIMESTAMP}") \
                (setq boot::*build-version* "$(PACKAGE_STRING)") \
                (boot::yearweek))


.PRECIOUS:	${DEPSYS}
.PRECIOUS:	${SAVESYS}
.PRECIOUS:	${AXIOMSYS}

UNUSED= ${DOC}/anna.boot.dvi ${DOC}/construc.lisp.dvi \
	${DOC}/domain.lisp.dvi 	${DOC}/guess.boot.dvi \
	${DOC}/interp-fix.boot.dvi \
	${DOC}/nhyper.boot.dvi ${DOC}/pf2atree.boot.dvi \
	${DOC}/redefs.boot.dvi 	${DOC}/word.boot.dvi 


.SUFFIXES:
.SUFFIXES: .boot .clisp .lisp .pamphlet

.PHONY: all all-ax all-depsys all-interpsys all-axiomsys all-debugsys

all: all-ax

all-ax: stamp
	@echo finished $(srcdir)

stamp: $(AUTO) remove-stamp build-images
	$(STAMP) stamp

.PHONY: remove-stamp
remove-stamp:
	-rm -f stamp

.PHONY: build-images
build-images: remove-stamp all-interpsys all-debugsys

all-interpsys: all-depsys 
	$(mkinstalldirs) $(AUTO)
	$(MAKE) $(SAVESYS)

all-axiomsys: all-depsys 
	$(MAKE) $(AXIOMSYS)

all-debugsys: all-interpsys
	$(MAKE) $(DEBUGSYS)

all-depsys: $(DEPSYS)

.PRECIOUS: %.boot
%.boot: $(srcdir)/%.boot.pamphlet
	$(axiom_build_document) --tangle --output=$@ $<
.PRECIOUS: %.clisp
%.clisp: %.boot
	$(BOOT_TO_LISP)
.PRECIOUS: %.$(FASLEXT)
%.$(FASLEXT): %.clisp
	$(COMPILE_LISP)
# Extract and compile the part of the interpreter written
# in Common Lisp
.PRECIOUS: %.lisp
%.$(FASLEXT): %.lisp
	$(COMPILE_LISP)

%.lisp: $(srcdir)/%.lisp.pamphlet
	$(axiom_build_document) --tangle --output=$@ $<

mostlyclean-local:
	@rm -f *.fn *.data *.$(FASLEXT) *.lib

clean-local: mostlyclean-local
	@rm -f *.clisp *.lsp

distclean-local: clean-local

makeint.lisp:	${DEPSYS} ${OBJS} bookvol5.$(FASLEXT) util.$(FASLEXT) \
                nocompil.lisp \
	        ${OUTINTERP} ${OCOBJS} ${OPOBJS} ${BROBJS} obey.$(FASLEXT) \
		database.date ${INOBJS} ${ASCOMP} ${ASAUTO} \
		${NAGBROBJS} ${TRANOBJS} \
	        ${LOADSYS} \
		$(axiom_targetdir)/algebra/exposed.$(FASLEXT) \
		$(axiom_src_docdir)/msgs/s2-us.msgs \
	        ../algebra/warm.data
	@ echo 5 invoking make in `pwd` with parms:
	@rm -f makeint.lisp
	@ echo SYS= ${SYS} 
	@ echo LISP=${LISP} BYE=${BYE}
	$(mkinstalldirs) $(axiom_target_datadir)/msgs
	$(INSTALL_DATA) $(axiom_src_docdir)/msgs/s2-us.msgs \
		 $(axiom_target_datadir)/msgs
	@ echo '(|importModule| "vmlisp")' >> makeint.lisp
	@ echo '(|importModule| "hash")' >> makeint.lisp
	@ echo '(|importModule| "bootfuns")' >> makeint.lisp
	@ echo '(gbc t)' >> makeint.lisp
	@ echo '(load "nocompil.lisp")' >> makeint.lisp
	@ echo '(|importModule| "bookvol5")' >> makeint.lisp
	@ echo '(|importModule| "util")' >> makeint.lisp
	@ echo '(in-package "BOOT")' >> makeint.lisp
	@ touch ${TIMESTAMP}
	@ echo '${YEARWEEK}' >> makeint.lisp
	@ echo '(boot::build-interpsys (append (quote ($(interpsys_modules))) (quote ($(AS_modules))) (quote ($(IN_modules)))) (quote ($(patsubst %, "%", ${OPOBJS}))) (quote ($(patsubst %, "%", ${OCOBJS}))) (quote ($(patsubst %, "%", ${BROBJS}))) (quote ($(patsubst %, "%", ${TRANOBJS}))) (quote ($(patsubst %, "%", ${NAGBROBJS}))) (quote ($(patsubst %, "%", ${ASAUTO})))  "${AXIOM}")' >> makeint.lisp
	@ echo '(boot::set-restart-hook)' >> makeint.lisp
	@ echo '(in-package "BOOT")' >> makeint.lisp
	@ echo '(load "../algebra/warm.data")' >> makeint.lisp
	@ echo '(boot::|clearClams|)' >> makeint.lisp
	@ echo '(load "obey")' >> makeint.lisp
	@ echo '#+:akcl (setq compiler::*suppress-compiler-notes* t)' >> makeint.lisp
	@ echo '#+:akcl (si::gbc-time 0)' >> makeint.lisp
	@ echo '(gbc t)' >> makeint.lisp

${SAVESYS}: makeint.lisp
	AXIOM="$(AXIOM)" DAASE="$(axiom_src_datadir)" \
		$(LOADSYS) -- --make --output=$@ --main="BOOT::RESTART" \
			 --load-directory=. makeint.lisp
	@ echo 6 ${SAVESYS} created
	$(mkinstalldirs) $(axiom_target_bindir)
depsys_lisp_sources += parsing.lisp metalex.lisp bootlex.lisp \
			newaux.lisp preparse.lisp postprop.lisp \
			fnewmeta.lisp

depsys_boot_sources = postpar.boot parse.boot clam.boot slam.boot \
			g-boot.boot g-error.boot c-util.boot g-util.boot

depsys_SOURCES = $(depsys_lisp_SOURCES) $(depsys_boot_SOURCES)

depsys_objects = nocompil.$(FASLEXT) bookvol5.$(FASLEXT) g-error.$(FASLEXT) \
		util.$(FASLEXT) postpar.$(FASLEXT) parse.$(FASLEXT) \
		parsing.$(FASLEXT) metalex.$(FASLEXT) bootlex.$(FASLEXT) \
		newaux.$(FASLEXT) preparse.$(FASLEXT) postprop.$(FASLEXT) \
		fnewmeta.$(FASLEXT) clam.$(FASLEXT) \
		slam.$(FASLEXT) g-boot.$(FASLEXT) c-util.$(FASLEXT) \
		g-util.$(FASLEXT)
VPATH =



${DEPSYS}:	vmlisp.$(FASLEXT) \
		hash.$(FASLEXT) \
		ggreater.$(FASLEXT) \
		union.$(FASLEXT) \
		boot-pkg.$(FASLEXT) \
		sys-constants.$(FASLEXT) \
		sys-globals.$(FASLEXT) \
		diagnostics.$(FASLEXT) \
		bootfuns.$(FASLEXT) \
		${DEP} \
		nocompil.$(FASLEXT) \
	        bookvol5.$(FASLEXT)\
		util.$(FASLEXT) \
	        postpar.clisp parse.clisp \
	        parsing.lisp metalex.lisp \
	        bootlex.lisp newaux.lisp \
	        preparse.lisp \
	        postprop.lisp def.lisp \
	        fnewmeta.lisp \
		g-error.clisp \
	        g-boot.clisp c-util.${LISP} \
	        g-util.clisp \
	        clam.clisp \
	        slam.clisp
	@ echo 3 making ${DEPSYS} 
	@ rm -f makedep.lisp
	@ $(mkinstalldirs) $(axiom_build_bindir)
	@ echo '(|importModule| "vmlisp")' >> makedep.lisp
	@ echo '(|importModule| "hash")' >> makedep.lisp
	@ echo '(|importModule| "ggreater")' >> makedep.lisp
	@ echo '(|importModule| "union")' >> makedep.lisp
	@ echo '(|importModule| "bootfuns")' >> makedep.lisp
	@ echo '(|importModule| "nocompil")' >> makedep.lisp
	@ echo '(|importModule| "bookvol5")' >> makedep.lisp
	@ echo '(|importModule| "parsing")' >> makedep.lisp
	@ echo '(|importModule| "util")' >> makedep.lisp
	@ echo '(in-package "BOOT")' >> makedep.lisp
	@ echo '(build-depsys (quote ($(patsubst %, "%", ${DEP}))) "${AXIOM}")' >> makedep.lisp
	@ echo '(unless (probe-file "postpar.$(FASLEXT)") (compile-file "postpar.clisp" :output-file "postpar.$(FASLEXT)"))' >> makedep.lisp
	@ echo '(load "postpar")' >> makedep.lisp
	@ echo '(unless (probe-file "parse.$(FASLEXT)") (compile-file "parse.clisp" :output-file "parse.$(FASLEXT)"))' >> makedep.lisp
	@ echo '(load "parse")' >> makedep.lisp
	@ echo '(unless (probe-file "metalex.$(FASLEXT)") (compile-file "metalex.lisp" :output-file "metalex.$(FASLEXT)"))' >> makedep.lisp
	@ echo '(load "metalex")' >> makedep.lisp
	@ echo '(unless (probe-file "bootlex.$(FASLEXT)") (compile-file "bootlex.lisp" :output-file "bootlex.$(FASLEXT)"))' >> makedep.lisp
	@ echo '(load "bootlex")' >> makedep.lisp
	@ echo '(unless (probe-file "newaux.$(FASLEXT)") (compile-file "newaux.lisp" :output-file "newaux.$(FASLEXT)"))' >> makedep.lisp
	@ echo '(load "newaux")' >> makedep.lisp
	@ echo '(unless (probe-file "preparse.$(FASLEXT)") (compile-file "preparse.lisp" :output-file "preparse.$(FASLEXT)"))' >> makedep.lisp
	@ echo '(load "preparse")' >> makedep.lisp
	@ echo '(unless (probe-file "postprop.$(FASLEXT)") (compile-file "postprop.lisp" :output-file "postprop.$(FASLEXT)"))' >> makedep.lisp
	@ echo '(load "postprop")' >> makedep.lisp
	@ echo '(unless (probe-file "def.$(FASLEXT)") (compile-file "def.lisp" :output-file "def.$(FASLEXT)"))' >> makedep.lisp
	@ echo '(load "def")' >> makedep.lisp
	@ echo '(unless (probe-file "fnewmeta.$(FASLEXT)") (compile-file "fnewmeta.lisp" :output-file "fnewmeta.$(FASLEXT)"))' >> makedep.lisp
	@ echo '(load "fnewmeta")' >> makedep.lisp
	@ echo '(unless (probe-file "clam.$(FASLEXT)") (compile-file "clam.clisp" :output-file "clam.$(FASLEXT)"))' >> makedep.lisp
	@ echo '(load "clam")' >> makedep.lisp
	@ echo '(unless (probe-file "slam.$(FASLEXT)") (compile-file "slam.clisp" :output-file "slam.$(FASLEXT)"))' >> makedep.lisp
	@ echo '(load "slam")' >> makedep.lisp
	@ echo '(unless (probe-file "g-error.$(FASLEXT)") (compile-file "g-error.clisp" :output-file "g-error.$(FASLEXT)"))' >> makedep.lisp
	@ echo '(load "g-error")' >> makedep.lisp
	@ echo '(unless (probe-file "g-boot.$(FASLEXT)") (compile-file "g-boot.clisp" :output-file "g-boot.$(FASLEXT)"))' >> makedep.lisp
	@ echo '(load "g-boot")' >> makedep.lisp
	@ echo '(unless (probe-file "c-util.$(FASLEXT)") (compile-file "c-util.${LISP}" :output-file "c-util.$(FASLEXT)"))' >> makedep.lisp
	@ echo '(load "c-util")' >> makedep.lisp
	@ echo '(unless (probe-file "g-util.$(FASLEXT)") (compile-file "g-util.clisp" :output-file "g-util.$(FASLEXT)"))' >> makedep.lisp
	@ echo '(load "g-util")' >> makedep.lisp
	../lisp/base-lisp$(EXEEXT) -- --make --output=$@ \
		--load-directory=. makedep.lisp
	@rm $(addsuffix .$(FASLEXT), \
		postpar parse metalex bootlex newaux preparse \
		postprop def fnewmeta clam slam g-error \
		g-boot c-util g-util)
	@ echo 4 ${DEPSYS} created


util.$(FASLEXT): util.lisp parsing.$(FASLEXT)
	$(BOOTSYS) -- --compile --output=$@ --load-directory=. $<

parsing.$(FASLEXT): parsing.lisp boot-pkg.$(FASLEXT)
	$(BOOTSYS) -- --compile --output=$@ --load-directory=. $<

bookvol5.$(FASLEXT): bookvol5.lisp boot-pkg.$(FASLEXT)
	$(BOOTSYS) -- --compile --output=$@ --load-directory=. $<

nocompil.$(FASLEXT): nocompil.lisp boot-pkg.$(FASLEXT)
	$(BOOTSYS) -- --compile --output=$@ --load-directory=. $<

bootfuns.$(FASLEXT): bootfuns.lisp hash.$(FASLEXT) \
			sys-constants.$(FASLEXT) sys-globals.$(FASLEXT)
	$(BOOTSYS) -- --compile --output=$@ --load-directory=. $<

diagnostics.$(FASLEXT): diagnostics.boot sys-constants.$(FASLEXT) \
				sys-globals.$(FASLEXT)
	$(BOOTSYS) -- --compile --output=$@ --load-directory=. $<

sys-globals.$(FASLEXT): sys-globals.boot boot-pkg.$(FASLEXT) \
				hash.$(FASLEXT)
	$(BOOTSYS) -- --compile --output=$@ --load-directory=. $<

sys-constants.$(FASLEXT): sys-constants.boot boot-pkg.$(FASLEXT)
	$(BOOTSYS) -- --compile --output=$@ --load-directory=. $<

boot-pkg.$(FASLEXT): boot-pkg.lisp vmlisp.$(FASLEXT)
	$(BOOTSYS) -- --compile --output=$@ --load-directory=. $<

hash.$(FASLEXT): hash.lisp vmlisp.$(FASLEXT)
	$(BOOTSYS) -- --compile --output=$@ --load-directory=. $<

union.$(FASLEXT): union.lisp vmlisp.$(FASLEXT)
	$(BOOTSYS) -- --compile --output=$@ --load-directory=. $<

ggreater.$(FASLEXT): ggreater.lisp vmlisp.$(FASLEXT)
	$(BOOTSYS) -- --compile --output=$@ --load-directory=. $<

vmlisp.$(FASLEXT): vmlisp.lisp
	$(BOOTSYS) -- --compile --output=$@ $<


## GCL-2.6.8pre has the following behaviour that it will
## try to forcefully put the compiled code in the same directory
## as the source.  This is hardly what we want, especially when
## the source file reside in non-writeable areas.  Consequently,
## we copy the source file to the current working directory --
## until we find a better way to convince GCL to do the right thing.
boot-pkg.lisp: $(srcdir)/boot-pkg.lisp
	cp $< $@

diagnostics.boot: $(srcdir)/diagnostics.boot
	cp $< $@

sys-globals.boot: $(srcdir)/sys-globals.boot
	cp $< $@

sys-constants.boot: $(srcdir)/sys-constants.boot
	cp $< $@

.PHONY: all-axiomsys

all-axiomsys: ${AXIOMSYS}

${AXIOMSYS}: makeint.lisp
	AXIOM="$(AXIOM)" DAASE="$(axiom_targetdir)" \
		$(LOADSYS) -- --make --output=$@ --main="BOOT::RESTART" \
			--load-directory=. makeint.lisp
	@ echo 6a ${AXIOMSYS} created
${DEBUGSYS}: debugsys.lisp
	@ echo 7 building debugsys
	@ echo '(progn (gbc t) (load "debugsys.lisp") (in-package "BOOT") (spad-save "$@"))' | ${LISPSYS}
	@ echo 8 ${DEBUGSYS} created

exposed.lsp: $(axiom_src_algdir)/exposed.lsp.pamphlet
	@ echo 615 making exposed.lsp from $(axiom_src_algdir)/exposed.lsp.pamphlet
	$(axiom_build_document) --tangle --output=$@ $<

$(axiom_targetdir)/algebra/exposed.$(FASLEXT) : exposed.lsp ${LISPSYS}
	@ echo 616 making $@ from exposed.lsp
	$(mkinstalldirs) $(axiom_targetdir)/algebra
	@ echo '(progn  (compile-file "exposed.lsp" :output-file "$(axiom_targetdir)/algebra/exposed.$(FASLEXT)"))' | ${LISPSYS} 

database.date:
	@ echo 617 the database was updated...remaking interpsys
	@ touch database.date


## Copy FASLs that are autoloaded to the autoload directory.
.PREVIOUS: $(AUTO)/%.$(FASLEXT)

$(AUTO)/%.$(FASLEXT): %.$(FASLEXT)
	$(INSTALL) $< $@

as.clisp: as.boot
	@ echo 417 making $@ from $<
	@ echo '(progn (old-boot::boot "as.boot"))' | ${DEPSYS}

ax.clisp: ax.boot
	@ echo 463 making $@ $<
	@ echo '(progn (old-boot::boot "ax.boot"))' | ${DEPSYS} 

bc-matrix.clisp: bc-matrix.boot
	@ echo 424 making $@ from $<
	@ echo '(progn (old-boot::boot "bc-matrix.boot"))' | ${DEPSYS}

bc-misc.clisp: bc-misc.boot
	@ echo 428 making $@ from $<
	@ echo '(progn (old-boot::boot "bc-misc.boot"))' | ${DEPSYS}

bc-solve.clisp: bc-solve.boot
	@ echo 432 making $@ from $<
	@ echo '(progn (old-boot::boot "bc-solve.boot"))' | ${DEPSYS}

bc-util.clisp: bc-util.boot
	@ echo 436 making $@ from $<
	@ echo '(progn (old-boot::boot "bc-util.boot"))' | ${DEPSYS}

br-con.clisp: br-con.boot
	@ echo 467 making $@ from $<
	@ echo '(progn (old-boot::boot "br-con.boot"))' | ${DEPSYS} 

br-data.clisp: br-data.boot
	@ echo 483 making $@ from $<
	@ echo '(progn (old-boot::boot "br-data.boot"))' | ${DEPSYS} 

br-op1.clisp: br-op1.boot
	@ echo 475 making $@ from $<
	@ echo '(progn (old-boot::boot "br-op1.boot"))' | ${DEPSYS}

br-op2.clisp: br-op2.boot
	@ echo 479 making $@ from $<
	@ echo '(progn (old-boot::boot "br-op2.boot"))' | ${DEPSYS} 

br-prof.clisp: br-prof.boot
	@ echo 499 making $@ from $<
	@ ($(axiom_build_document) --tangle --output=br-prof.boot $< ;\
	  echo '(progn (old-boot::boot "br-prof.boot"))' | ${DEPSYS}; \
	  rm br-prof.boot )


br-saturn.clisp: br-saturn.boot
	@ echo 491 making $@ from $<
	@ echo '(progn (old-boot::boot "br-saturn.boot"))' | ${DEPSYS}

br-search.clisp: br-search.boot
	@ echo 471 making $@ from $<
	@ echo '(progn (old-boot::boot "br-search.boot"))' | ${DEPSYS} 

br-util.clisp: br-util.boot
	@ echo 487 making $@ from $<
	@ echo '(progn (old-boot::boot "br-util.boot"))' | ${DEPSYS}

buildom.clisp: buildom.boot
	@ echo 143 making $@ from $<
	@ echo '(progn (old-boot::boot "buildom.boot"))' | ${DEPSYS}


category.clisp: category.boot
	@ echo 212 making $@ from $<
	@ echo '(progn (old-boot::boot "category.boot"))' | ${DEPSYS} 

cattable.clisp: cattable.boot
	@ echo 215 making $@ from $<
	@ echo '(progn (old-boot::boot "cattable.boot"))' | ${DEPSYS}

c-doc.clisp: c-doc.boot
	@ echo 219 making $@ from $<
	@ echo '(progn (old-boot::boot "c-doc.boot"))' | ${DEPSYS} 

clammed.clisp: clammed.boot
	@ echo 226 making $@ from $<
	@ echo '(progn (old-boot::boot "clammed.boot"))' | ${DEPSYS} 

compat.clisp: compat.boot
	@ echo 229 making $@ from $<
	@ echo '(progn (old-boot::boot "compat.boot"))' | ${DEPSYS} 

compiler.clisp: compiler.boot
	@ echo 233 making $@ from $<
	@ echo '(progn (old-boot::boot "compiler.boot"))' | ${DEPSYS}

c-util.${LISP}: $(srcdir)/c-util.boot.pamphlet
	@ echo 146 making c-util.${LISP} from $(srcdir)/c-util.boot.pamphlet
	@ rm -f c-util.$(FASLEXT)
	$(axiom_build_document) --tangle=c-util.clisp --output=$@ $<

c-util.clisp: c-util.boot
	@ echo 148 making $@ from $<
	@ echo '(progn (old-boot::boot "c-util.boot"))' | ${DEPSYS}


database.clisp: database.boot
	@ echo 243 making $@ from $<
	@ echo '(progn (old-boot::boot "database.boot"))' | ${DEPSYS}

debugsys.lisp: $(srcdir)/debugsys.lisp.pamphlet
	$(axiom_build_document) --tangle --output=$@ $<

define.clisp: define.boot
	@ echo 247 making $@ from $<
	@ echo '(progn (old-boot::boot "define.boot"))' | ${DEPSYS}

format.clisp: format.boot
	@ echo 250 making $@ from $<
	@ echo '(progn (old-boot::boot "format.boot"))' | ${DEPSYS}

fortcall.clisp: fortcall.boot
	@ echo 55 making $@ from $<
	@ echo '(progn (old-boot::boot "fortcall.boot"))' | ${DEPSYS}


functor.clisp: functor.boot
	@ echo 254 making $@ from $<
	@ echo '(progn (old-boot::boot "functor.boot"))' | ${DEPSYS}

g-cndata.clisp: g-cndata.boot
	@ echo 261 making $@ from $<
	@ echo '(progn (old-boot::boot "g-cndata.boot"))' | ${DEPSYS}

g-opt.clisp: g-opt.boot
	@ echo 267 making $@ from $<
	@ echo '(progn (old-boot::boot "g-opt.boot"))' | ${DEPSYS}

g-timer.clisp: g-timer.boot
	@ echo 270 making $@ from $<
	@ echo '(progn (old-boot::boot "g-timer.boot"))' | ${DEPSYS}

htcheck.clisp: htcheck.boot
	@ echo 455 making $@ from $<
	@ echo '(progn (old-boot::boot "htcheck.boot"))' | ${DEPSYS}

ht-root.clisp: ht-root.boot
	@ echo 451 making $@ from $<
	@ echo '(progn (old-boot::boot "ht-root.boot"))' | ${DEPSYS}

htsetvar.clisp: htsetvar.boot
	@ echo 444 making $@ from $<
	@ echo '(progn (old-boot::boot "htsetvar.boot"))' | ${DEPSYS}

ht-util.clisp: ht-util.boot
	@ echo 440 making $@ from $<
	@ echo '(progn (old-boot::boot "ht-util.boot"))' | ${DEPSYS}

hypertex.clisp: hypertex.boot
	@ echo 277 making $@ from $<
	@ echo '(progn (old-boot::boot "hypertex.boot"))' | ${DEPSYS}

i-analy.clisp: i-analy.boot
	@ echo 280 making $@ from $<
	@ echo '(progn (old-boot::boot "i-analy.boot"))' | ${DEPSYS}

i-code.clisp: i-code.boot
	@ echo 283 making $@ from $<
	@ echo '(progn (old-boot::boot "i-code.boot"))' | ${DEPSYS}

i-coerce.clisp: i-coerce.boot
	@ echo 286 making $@ from $<
	@ echo '(progn (old-boot::boot "i-coerce.boot"))' | ${DEPSYS}

i-coerfn.clisp: i-coerfn.boot
	@ echo 289 making $@ from $<
	@ echo '(progn (old-boot::boot "i-coerfn.boot"))' | ${DEPSYS}

i-eval.clisp: i-eval.boot
	@ echo 292 making $@ from $<
	@ echo '(progn (old-boot::boot "i-eval.boot"))' | ${DEPSYS}

i-funsel.clisp: i-funsel.boot
	@ echo 295 making $@ from $<
	@ echo '(progn (old-boot::boot "i-funsel.boot"))' | ${DEPSYS}

bookvol5.lisp: $(srcdir)/bookvol5.pamphlet
	@ echo 298 making $@ from $<
	$(axiom_build_document) --tangle=Interpreter --output=$@ $<

i-intern.clisp: i-intern.boot
	@ echo 301 making $@ from $<
	@ echo '(progn (old-boot::boot "i-intern.boot"))' | ${DEPSYS}

i-map.clisp: i-map.boot
	@ echo 304 making $@ from $<
	@ echo '(progn (old-boot::boot "i-map.boot"))' | ${DEPSYS} 

info.clisp: info.boot
	@ echo 329 making $@ from $<
	@ echo '(progn (old-boot::boot "info.boot"))' | ${DEPSYS}

i-output.clisp: i-output.boot
	@ echo 307 making $@ from $<
	@ echo '(progn (old-boot::boot "i-output.boot"))' | ${DEPSYS}

i-resolv.clisp: i-resolv.boot
	@ echo 310 making $@ from $<
	@ echo '(progn (old-boot::boot "i-resolv.boot"))' | ${DEPSYS}

i-spec1.clisp: i-spec1.boot
	@ echo 313 making $@ from $<
	@ echo '(progn (old-boot::boot "i-spec1.boot"))' | ${DEPSYS}

i-spec2.clisp: i-spec2.boot
	@ echo 316 making $@ from i-spec2.boot
	@ echo '(progn (old-boot::boot "i-spec2.boot"))' | ${DEPSYS} 

i-syscmd.clisp: i-syscmd.boot
	@ echo 319 making $@ from $<
	@ echo '(progn (old-boot::boot "i-syscmd.boot"))' | ${DEPSYS}

iterator.clisp: iterator.boot
	@ echo 333 making $@ from $<
	@ echo '(progn (old-boot::boot "iterator.boot"))' | ${DEPSYS}

i-toplev.clisp: i-toplev.boot
	@ echo 322 making $@ from $<
	@ echo '(progn (old-boot::boot "i-toplev.boot"))' | ${DEPSYS}

i-util.clisp: i-util.boot
	@ echo 325 making $@ from $<
	@ echo '(progn (old-boot::boot "i-util.boot"))' | ${DEPSYS}

lisplib.clisp: lisplib.boot
	@ echo 336 making $@ from $<
	@ echo '(progn (old-boot::boot "lisplib.boot"))' | ${DEPSYS}

match.clisp: match.boot
	@ echo 339 making $@ from $<
	@ echo '(progn (old-boot::boot "match.boot"))' | ${DEPSYS}

modemap.clisp: modemap.boot
	@ echo 343 making $@ from $<
	@ echo '(progn (old-boot::boot "modemap.boot"))' | ${DEPSYS}

msgdb.clisp: msgdb.boot
	@ echo 346 making $@ from $<
	@ echo '(progn (old-boot::boot "msgdb.boot"))' | ${DEPSYS}

nag-c02.clisp: nag-c02.boot
	@ echo 152 making $@ from $<
	@ echo '(progn (boot::reroot "${AXIOM}") (old-boot::boot "nag-c02.boot"))' | ${DEPSYS}


nag-c05.clisp: nag-c05.boot
	@ echo 156 making $@ from $<
	@ echo '(progn (boot::reroot "${AXIOM}") (old-boot::boot "nag-c05.boot"))' | ${DEPSYS}


nag-c06.clisp: nag-c06.boot
	@ echo 160 making $@ from $<
	@ echo '(progn (boot::reroot "${AXIOM}") (old-boot::boot "nag-c06.boot"))' | ${DEPSYS}


nag-d01.clisp: nag-d01.boot
	@ echo 164 making $@ from $<
	@ echo '(progn (boot::reroot "${AXIOM}") (old-boot::boot "nag-d01.boot"))' | ${DEPSYS}


nag-d02.clisp: nag-d02.boot
	@ echo 168 making $@ from $<
	@ echo '(progn (boot::reroot "${AXIOM}") (old-boot::boot "nag-d02.boot"))' | ${DEPSYS}


nag-d03.clisp: nag-d03.boot
	@ echo 172 making $@ from $<
	@ echo '(progn (boot::reroot "${AXIOM}") (old-boot::boot "nag-d03.boot"))' | ${DEPSYS}


nag-e01.clisp: nag-e01.boot
	@ echo 176 making $@ from $<
	@ echo '(progn (boot::reroot "${AXIOM}") (old-boot::boot "nag-e01.boot"))' | ${DEPSYS}


nag-e02.clisp: nag-e02.boot
	@ echo 184 making $@ from $<
	@ echo '(progn (boot::reroot "${AXIOM}") (old-boot::boot "nag-e02.boot"))' | ${DEPSYS}


nag-e04.clisp: nag-e04.boot
	@ echo 188 making $@ from $<
	@ echo '(progn (boot::reroot "${AXIOM}") (old-boot::boot "nag-e04.boot"))' | ${DEPSYS}


nag-f01.clisp: nag-f01.boot
	@ echo 192 making $@ from $<
	@ echo '(progn (boot::reroot "${AXIOM}") (old-boot::boot "nag-f01.boot"))' | ${DEPSYS}


nag-f02.clisp: nag-f02.boot
	@ echo 196 making $@ from $<
	@ echo '(progn (boot::reroot "${AXIOM}") (old-boot::boot "nag-f02.boot"))' | ${DEPSYS}


nag-f04.clisp: nag-f04.boot
	@ echo 200 making $@ from $<
	@ echo '(progn (boot::reroot "${AXIOM}") (old-boot::boot "nag-f04.boot"))' | ${DEPSYS}


nag-f07.clisp: nag-f07.boot
	@ echo 204 making $@ from $<
	@ echo '(progn (boot::reroot "${AXIOM}") (old-boot::boot "nag-f07.boot"))' | ${DEPSYS}


nag-s.clisp: nag-s.boot
	@ echo 208 making $@ from $<
	@ echo '(progn (boot::reroot "${AXIOM}") (old-boot::boot "nag-s.boot"))' | ${DEPSYS}


newfort.clisp: newfort.boot
	@ echo 349 making $@ from $<
	@ echo '(progn (old-boot::boot "newfort.boot"))' | ${DEPSYS}

nruncomp.clisp: nruncomp.boot
	@ echo 353 making $@ from $<
	@ echo '(progn (old-boot::boot "nruncomp.boot"))' | ${DEPSYS}

nrunfast.clisp: nrunfast.boot
	@ echo 356 making $@ from $<
	@ echo '(progn (old-boot::boot "nrunfast.boot"))' | ${DEPSYS}

nrungo.clisp: nrungo.boot
	@ echo 359 making $@ from $<
	@ echo '(progn (old-boot::boot "nrungo.boot"))' | ${DEPSYS}

nruntime.clisp: nruntime.boot
	@ echo 362 making $@ from $<
	@ echo '(progn (old-boot::boot "nruntime.boot"))' | ${DEPSYS}

nrunopt.clisp: nrunopt.boot
	@ echo 365 making $@ from $<
	@ echo '(progn (old-boot::boot "nrunopt.boot"))' | ${DEPSYS}

profile.clisp: profile.boot
	@ echo 237 making $@ from $<
	@ echo '(progn (old-boot::boot "profile.boot"))' | ${DEPSYS}

record.clisp: record.boot
	@ echo 447 making $@ $<
	@ echo '(progn (old-boot::boot "record.boot"))' | ${DEPSYS}

rulesets.clisp: rulesets.boot
	@ echo 388 making $@ from $<
	@ echo '(progn (old-boot::boot "rulesets.boot"))' | ${DEPSYS}

server.clisp: server.boot
	@ echo 391 making $@ from $<
	@ echo '(progn (old-boot::boot "server.boot"))' | ${DEPSYS}

setvart.clisp: setvart.boot
	@ echo 398 making $@ from $<
	@ echo '(progn (old-boot::boot "setvart.boot"))' | ${DEPSYS}

template.clisp: template.boot
	@ echo 408 making $@ from $<
	@ echo '(progn (old-boot::boot "template.boot"))' | ${DEPSYS} 

termrw.clisp: termrw.boot
	@ echo 411 making $@ from $<
	@ echo '(progn (old-boot::boot "termrw.boot"))' | ${DEPSYS} 

topics.clisp: topics.boot
	@ echo 495 making $@ from $<
	@ echo '(progn (old-boot::boot "topics.boot"))' | ${DEPSYS} 

trace.clisp: trace.boot
	@ echo 414 making $@ from $<
	@ echo '(progn (old-boot::boot "trace.boot"))' | ${DEPSYS}

../algebra/warm.data: $(srcdir)/Makefile.pamphlet
	@ echo 2 building warm.data
	$(axiom_build_document) --tangle=warm.data --output=$@ $<


xruncomp.clisp: xruncomp.boot
	@ echo 459 making $@ from $<
	@ echo '(progn (old-boot::boot "xruncomp.boot"))' | ${DEPSYS}

$(axiom_build_texdir)/diagrams.tex: $(axiom_src_docdir)/diagrams.tex
	$(INSTALL_DATA) $< $@