all: fastemulator emulator nocacheemulator

# for profiling CC = cc -p
# for VAXen     CC = tcc
# for RTs       CC = hc -Dibmrt
# for Convexes  CC = vc, OLEVEL = 2

EMS = emulator.o mymalloc.o mem.o worldio.o gc.o

FEMS = nocacheemulator.o mymalloc.o mem.o worldio.o fastgc.o

CEMS = fastemulator.o mymalloc.o mem.o worldio.o fastgc.o

worldio.o: worldio.c emulator.h
	$(CC) -g -c worldio.c

mem.o: mem.c emulator.h
	$(CC) -g -c mem.c

fastgc.c: gc.c
	-rm -f fastgc.c
	ln gc.c fastgc.c

fastgc.o: fastgc.c emulator.h
	$(CC) -O$(OLEVEL) -DFAST -c fastgc.c

gc.o: gc.c emulator.h
	$(CC) -g -c gc.c

emulator.o: emulator.c emulator.h
	$(CC) -g -c emulator.c

emulator: $(EMS)
	$(CC) -g -o emulator $(EMS)

fastemulator.o:	fastemulator.c emulator.h
	$(CC) -O$(OLEVEL) -DFAST -DMETH_CACHE -c fastemulator.c

fastemulator.c: emulator.c
	-rm -f fastemulator.c
	ln emulator.c fastemulator.c

fastemulator: $(CEMS)
	$(CC) -O$(OLEVEL) -DFAST -DMETH_CACHE -o fastemulator $(CEMS)

nocacheemulator.o: nocacheemulator.c emulator.h
	$(CC) -O$(OLEVEL) -DFAST -c nocacheemulator.c

nocacheemulator.c: emulator.c
	-rm -f nocacheemulator.c
	ln emulator.c nocacheemulator.c

nocacheemulator: $(FEMS)
	$(CC) -O$(OLEVEL) -o nocacheemulator $(FEMS)



LS = emulator.c mymalloc.c mem.c worldio.c gc.c

.linted: $(LS) emulator.h
	echo Cache
	lint -DFAST -DMETH_CACHE $(LS)
	echo Slow
	lint $(LS)
	echo Fast
	lint -DFAST $(LS)
	touch .linted

world:
	set file = `ls -t *.cold|head -1`
	echo "$file.ol" | fastemulator -d -b -G $file
