# This works on a MicroVAX running 4.3BSD (without DLD)
#SYS = -DI_SYSTYPES -DVOIDSTAR='char *'
#CONFIG = -g -DTEST
#SYSLIB =
#SYSOBJ = $(XOBJS)
#YACC=bison

# This works on a Sun4/110 running ???  (Without DLD)
#SYS = -DI_SYSTYPES
#CONFIG = -g -DTEST
#SYSLIB =
#SYSOBJ = $(XOBJS)
#YACC = bison

# This works on an hp300 series running MORE/BSD (and using DLD)
#SYS = -DNEED_VPRINTF -DI_SYSTYPES
#CONFIG = -g -DTEST -DUSE_DLD
#SYSLIB = -ldld
#SYSOBJ = doprnt.o
#YACC=bison

# this works on an hp834 series running HP-UX 7.0
#SYS= -DSYSV -DNO_UALARM -DSETITIMER -DNO_RINT -DI_IOCTL -DI_SYSTYPES
#CONFIG = -g -DTEST
#SYSLIB = -lBSD
#SYSOBJ = random.o $(XOBJS)
#YACC=yacc

# HP/Apollo DN3000 series running Domain/OS
#SYS = -DI_SYSTYPES -DNO_RINT -DASM_INF -A cpu,$(TARGET) -A sys,bsd4.3 -U__STDC__
#TARGET = 3000
#CONFIG = -DTEST
#SYSLIB =
#SYSOBJ = apollo.o $(XOBJS)
#ASM = asm
#.SUFFIXES: .asm
#.asm.o:
#       $(ASM) $* -nl
#       mv $*.bin $@

## HP/Apollo DN10000 running Domain/OS is same as above, except:
#TARGET = 10000
#ASM = prasm

# This worked on a NeXT running 2.0
#SYS = -DNO_RINT -DI_STDDEF
#CONFIG = -g -DTEST
#SYSLIB =
#SYSOBJ = $(XOBJS)

# amiga test
SYS = -DI_STDDEF -DBITS_PER_CELLREF=16 -DA0_REFS 
CONFIG = -DTEST
SYSLIB =
SYSOBJ = $(XOBJS)
YACC = yacc

# This should be the end of the user-configurable stuff.
OLIB =  -lcurses -ltermcap -lm
CFLAGS = $(SYS) $(CONFIG)

OBJS = parse.tab.o byte_compile.o eval.o cell.o ref.o \
 decompile.o sort.o regions.o utils.o obstack.o \
 io_term.o io_disp.o io_utils.o hash.o\
 panic.o \
 $(SYSOBJ)
# include this if your doprnt is broken (some BSD systems)
# doprnt.o
# include this if you lack the random() function (MS-DOS, SYSV)
# random.o

XOBJS = sylk.o sc.o list.o busi.o string.o cells.o

TEST0= test_yylex.o parse.tab.o

TEST1 = test_parse.o parse.tab.o

TEST2 = test_compile.o parse.tab.o byte_compile.o

TEST3= test_eval.o parse.tab.o byte_compile.o eval.o

TEST4= test_decomp.o decompile.o parse.tab.o byte_compile.o

TEST5= test_cell.o cell.o

TEST6= test_ref.o parse.tab.o byte_compile.o eval.o cell.o ref.o

DIST=COPYING README HOW-TO-USE INSTALL TODO Makefile dld.pch appollo.asm *.[chy]

all:	oleo $(XOBJS)
	
oleo:	$(OBJS)
	$(CC) -o oleo $(CFLAGS) $(OBJS) $(OLIB) $(LIB) $(SYSLIB)

clean:
	rm -f $(OBJS) $(XOBJS) oleo core bugs parse.tab.c

install:
	cp oleo /usr/local/bin/oleo
	-mkdir /usr/local/lib/oleo
	-cp $(XOBJS) /usr/local/lib/oleo

dl:
	-mkdir new
	-rm dl.zoo
	for X in *.[chy] makefile.trc ; do echo $$X ; sed 's/$$/
/' $$X > new/$$X ; done
	cd new ; zoo aM ../dl.zoo *
	-rmdir new

dist:
	-mkdir dist-oleo
	for X in $(DIST); do ln $$X dist-oleo; done
	tar cvZbf 1 oleo.tar.Z dist-oleo
	rm -r dist-oleo

test0:	$(TEST0)
	$(CC) $(CFLAGS) -o test0 $(TEST0) $(LIB)

test1:	$(TEST1)
	$(CC) $(CFLAGS) -o test1 $(TEST1) $(LIB)

test2: $(TEST2)
	$(CC) $(CFLAGS) -o test2 $(TEST2) $(LIB)

test3: $(TEST3)
	$(CC) $(CFLAGS) -o test3 $(TEST3) -lm $(LIB)

test4:	$(TEST4)
	$(CC) $(CFLAGS) -o test4 $(TEST4) $(LIB)

test5:	
	$(CC) $(CFLAGS) -o test5 $(TEST5) $(LIB)

test6:	$(TEST6)
	$(CC) $(CFLAGS) -o test6 $(TEST6) -lm $(LIB)

test_yylex.o:	test.c
	$(CC) $(CFLAGS) -c -o test_yylex.o -DTEST_YYLEX test.c

test_parse.o:	test.c
	$(CC) $(CFLAGS) -c -o test_parse.o -DTEST_PARSE test.c

test_compile.o:	test.c
	$(CC) $(CFLAGS) -c -o test_compile.o -DTEST_COMPILE test.c

test_decomp.o:	test.c
	$(CC) $(CFLAGS) -c -o test_decomp.o -DTEST_DECOMPILE test.c

test_eval.o:	test.c
	$(CC) $(CFLAGS) -c -o test_eval.o -DTEST_EVAL test.c

test_cell.o:	test.c
	$(CC) $(CFLAGS) -c -o test_cell.o -DTEST_CELL test.c

test_ref.o:	test.c
	$(CC) $(CFLAGS) -c -o test_ref.o -DTEST_REF test.c
	
parse.tab.c:	parse.y eval.h node.h errors.h
# Use these two lines instead of the bison line if you don't have bison.
	$(YACC) parse.y
	-mv y.tab.c parse.tab.c
#	bison parse.y

parse.tab.o:	parse.tab.c
	$(CC) $(CFLAGS) -DYYDEBUG=2 -c parse.tab.c

byte_compile.o:	node.h eval.h

cell.o:	cell.h

decompile.o:	eval.h cell.h

eval.o:	cell.h eval.h errors.h

io_term.o:	kbd.h cell.h

io_mp.o:	cell.h

ref.o:	eval.h cell.h

regions.o:	cell.h

#doprnt.o:	doprnt.c
#	$(CC) $(CFLAGS) -c doprnt.c
#	...edit .s file here
#	as -o doprnt.o doprnt.s
