

    # $Id: Makefile,v 1.48 94/06/21 17:19:03 weisberg Exp Locker: weisberg $

jlversion = 1.03

prefix = /usr/local

    # where the resultant binaries are installed
bindir = $(prefix)/bin

libdir = $(prefix)/lib

    # where the lispcode will be
lispdir = $(libdir)/jlisp/lisp

    # where to place local lisp files
locallispdir = $(libdir)/jlisp/local-lisp

    # where some helper files will be
    # and helpfiles, ...
etcdir = $(libdir)/jlisp/etc

    # the jlisp initialization code
jlisp_init = $(lispdir)/init.jl

BAKEXT = .bak

INSTALL = install

LISPOBJS = lisp/init.jl lisp/mrirc.jl

all: jl lispcode

lispcode: $(LISPOBJS)

jl: xxjl $(LISPOBJS)
	@echo "Dumping..."
	./xxjl -e '(progn (unexec "jl" "xxjl") (quit))'

xxjl: _xxjl
_xxjl:
	cd src; $(MAKE) jl INIT_FILE="$(jlisp_init)" version=$(jlversion)
	./bin/if-changed cp src/jl xxjl

lisp/init.jl: lisp/init.cf.jl configure.sed
	sed -f configure.sed lisp/init.cf.jl > lisp/init.jl

lisp/mrirc.jl: lisp/mrirc.cf.jl configure.sed
	sed -f configure.sed lisp/mrirc.cf.jl > lisp/mrirc.jl

jlisp.a: _jlispa
_jlispa:
	cd src; $(MAKE) jlisp.a STANDALONE=-DNOT_STAND_ALONE 
	./bin/if-changed cp src/jlisp.a jlisp.a

include/defproto.h: src/defproto.h
	./bin/if-changed cp src/defproto.h include/defproto.h

src/defproto.h:
	cd src; $(MAKE) defproto.h

configure.sed: 
	@-mv configure.sed configure.sed$(BAKEXT)
	@echo s@%SRCDIR%@.@g           >> configure.sed
	@echo s@%PREFIX%@$(prefix)@g   >> configure.sed
	@echo s@%BINDIR%@$(bindir)@g   >> configure.sed
	@echo s@%LIBDIR%@$(libdir)@g   >> configure.sed
	@echo s@%ETCDIR%@$(etcdir)@g   >> configure.sed
	@echo s@%LISPDIR%@$(lispdir)@g >> configure.sed
	@echo s@%LOCALLISP%@$(locallispdir)@g >> configure.sed

install: all install.dirs install.jl install.lisp 

install.dirs:
	-mkdir -p $(bindir) $(libdir) $(lispdir) $(locallispdir) $(etcdir)

install.jl: jl
	$(INSTALL) -m 555  jl        $(bindir)/jl

install.lisp: lispcode
	cp lisp/*.jl $(lispdir)

clean:
	-rm -f $(LISPOBJS) $(OBSLS) core a.out #*# include/cli-defvar.list include/cli-defun.list include/defproto.h
	cd src;  $(MAKE) clean

realclean: clean
	-rm -f jl xxjl stamp *bak configure.sed
	cd src; $(MAKE) realclean

depends:
	@echo making depends...
	cd src; $(MAKE) depends

Makefile: stamp
	@echo making Makefile...
	@cp Makefile Makefile$(BAKEXT)
	@sed -n '1,/#END_[oO]F_MAKE/p' Makefile\
		| sed "s%^srcdir =.*\$$%srcdir = `pwd`%"  >Make.new
	@cat Make.new > Makefile
	@rm -f Make.new

stamp:
	touch stamp

disk: realclean
	cd ..; tar cvf /dev/rfd0 jlisp-$(jlversion) 


# DO NOT remove following line!
#END_OF_MAKE

