
    # jlisp makefile
    # $Id: Makefile,v 1.31 94/08/23 09:08:29 weisberg Exp Locker: weisberg $

    # if your OS does not provide the nessecary regex routines
    # then uncomment the following line
    # it is not needed for SunOS, ...
# REGEX = regex.o

CC = cc

OPTIMIZE = -g
# gc_mark occasionally segv.s when -O2ed ???

OBJSA = unexec.o alloc.o eval.o gc.o jlisp.o reader.o\
	symtab.o print.o jlib.o pred.o string.o \
	list.o alist.o math.o port.o unistd.o \
	ball.o hooks.o error.o signals.o debug.o \
	weak.o $(REGEX)

OBJSL = init_l.o
OBJSS = init_s.o

SRCS =  unexec.c alloc.c eval.c gc.c jlisp.c reader.c\
	symtab.c print.c jlib.c pred.c string.c \
	list.c alist.c math.c port.c unistd.c \
	ball.c hooks.c error.c signals.c debug.c \
	weak.c init.c


CFLAGS = -I. \
		$(OPTIMIZE)	\
		$(STANDALONE)	\
		-DJLISP_INIT=$(INIT_FILE) 	\
		-DVERSION_MAJOR=$(version)

all: jl jlisp.a

jl: $(OBJSA) $(OBJSS) defproto.h
	$(CC)  $(CFLAGS) -o jl $(OBJSA) $(OBJSS) -lm

init_l.o:	defun.list defvar.list init.c
	$(CC) $(CFLAGS) -DNOT_STAND_ALONE -c init.c
	mv init.o init_l.o
init_s.o:	defun.list defvar.list init.c
	$(CC) $(CFLAGS) -c init.c
	mv init.o init_s.o

$(OBJSA): jlisp.h
$(OBJSL): jlisp.h
$(OBJSS): jlisp.h

jlisp.a: $(OBJSA) $(OBJSL)
	ar rcuv jlisp.a $(OBJSA) $(OBJSL)
	ranlib jlisp.a

clean:
	-rm -f $(OBJSA) $(OBJSL) $(OBJSS) jlisp.a defun.list defvar.list
	-rm -rf defun.list.tmp defvar.list.tmp defproto.h
	-rm -rf a.out core

realclean: clean
	-rm -f jl

defun.list: defun.list.tmp
	../bin/if-changed cp defun.list.tmp defun.list
defun.list.tmp: defun
defun:
	exec > defun.list.tmp;\
	for f in $(SRCS); do \
		echo ""; \
		echo "/* $$f */"  ; \
		sed -n -f mdefun.sed $$f ; \
	done

defvar.list: defvar.list.tmp
	../bin/if-changed cp defvar.list.tmp defvar.list
defvar.list.tmp: defvar
defvar:
	exec > defvar.list.tmp;\
	for f in $(SRCS); do \
		echo ""; \
		echo "/* $$f */"  ; \
		sed -n -f mdefvar.sed $$f ; \
	done
	
defproto.h: defun.list defproto.gen
	cpp -I. -C -P defproto.gen > defproto.h

rcs:
	for f in $(SRCS) *.h Internals Makefile ToDo; do echo .|ci -l $$f; done
	for x in `find Doc -name RCS -prune -o -type f -print`; do echo . | ci -l $$x; done

depends:
	@echo making depends...
	@$(CC) -M $(CFLAGS) *.c\
	| grep -v /usr/ceas\
	| grep -v /usr/include > depends

