all: fastemulator emulator nocacheemulator

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

SOURCE = Makefile emulator.c mymalloc.c mem.c worldio.c gc.c stacks.c \
 emulator.h stacks.h

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

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

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




# code for moving all the changed guys to bronto:

bronto: .tb_Makefile .tb_emulator.c .tb_mymalloc.c .tb_mem.c .tb_worldio.c .tb_gc.c .tb_stacks.c .tb_emulator.h .tb_stacks.h .tb_config.h

.tb_Makefile: Makefile
	rcp Makefile bronto:oak/emulator
	touch .tb_Makefile

.tb_emulator.c: emulator.c
	rcp emulator.c bronto:oak/emulator
	touch .tb_emulator.c

.tb_mymalloc.c: mymalloc.c
	rcp mymalloc.c bronto:oak/emulator
	touch .tb_mymalloc.c

.tb_mem.c: mem.c
	rcp mem.c bronto:oak/emulator
	touch .tb_mem.c

.tb_worldio.c: worldio.c
	rcp worldio.c bronto:oak/emulator
	touch .tb_worldio.c

.tb_gc.c: gc.c
	rcp gc.c bronto:oak/emulator
	touch .tb_gc.c

.tb_stacks.c: stacks.c
	rcp stacks.c bronto:oak/emulator
	touch .tb_stacks.c

.tb_emulator.h: emulator.h
	rcp emulator.h bronto:oak/emulator
	touch .tb_emulator.h

.tb_stacks.h: stacks.h
	rcp stacks.h bronto:oak/emulator
	touch .tb_stacks.h

.tb_config.h: config.h
	rcp config.h bronto:oak/emulator
	touch .tb_config.h


emulator.h: config.h
	touch emulator.h






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

faststacks.c: stacks.c
	-rm -f faststacks.c
	ln stacks.c faststacks.c

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

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

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

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

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

fastemulator.s:	fastemulator.c emulator.h stacks.h
	$(CC) -O$(OLEVEL) -S -DFAST -DMETH_CACHE -c fastemulator.c

stacks.o: stacks.c stacks.h emulator.h
	$(CC) -g -c stacks.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 stacks.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 stacks.c

.linted: $(LS) emulator.h
	echo Slow
	lint $(LS)
	touch .linted

#	echo Fast
#	lint -DFAST -DMETH_CACHE $(LS)

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