# Note that colib.s is now colib.S so that the preprocessor
# can conditionally add underlines to external refernces
# such as malloc. This is needed for systems such as Cygwin.
# Uncomment one of the following tw lines.

# AS = gcc -DUNDERLINES
AS = gcc

CC = gcc -O3

help:
	@echo
	@echo "make bench       Run cobench"
	@echo "make bencht      Run cobench with tracing"
	@echo "make bench100    Run cobench with n=100"
	@echo "make bench500    Run cobench with n=500 (the default)"
	@echo "make bench10000  Run cobench with n=10000"
	@echo "make sim         Run cosim"
	@echo "make simt        Run cosim with tracing"
	@echo "make sim100      Run cosim with n=100"
	@echo "make sim500      Run cosim with n=500 (the default)"
	@echo "make sim10000    Run cosim with n=10000"
	@echo "make test        Run cotest"
	@echo "make clean       Delete compiled files"
	@echo "make help        Display the help infomation"
	@echo

bench:	bench500

bench100:	cobench
	time ./cobench -k 10000 -n 100

bench500:	cobench
	time ./cobench -k 10000 -n 500

bench10000:	cobench
	time ./cobench -k 10000 -n 10000

bencht:	cobench
	time ./cobench -k 3 -n 2 -t

test:	cotest
	time ./cotest

sim:	sim500

sim100:	cosim
	time ./cosim -s 1000000 -p 1000 -n 100

sim500:	cosim
	time ./cosim -s 1000000 -p 1000 -n 500

sim10000:	cosim
	time ./cosim -s 1000000 -p 1000 -n 10000

simt:	cosim
	./cosim -n 5 -s 1000 -p 500 -t






cobench:	cobench.o colib.o
	$(CC) -o cobench cobench.o colib.o

cosim:	cosim.o colib.o
	$(CC) -o cosim cosim.o colib.o

cotest:	cotest.o colib.o
	$(CC) -o cotest cotest.o colib.o

cobench.o:	cobench.c cohdr.h
	$(CC) -o cobench.o -c cobench.c

cosim.o:	cosim.c cohdr.h
	$(CC) -o cosim.o -c cosim.c

cotest.o:	cotest.c cohdr.h
	$(CC) -o cotest.o -c cotest.c

colib.o:	colib.s
	$(AS) -o colib.o -c colib.S

clean:
	rm -f cobench cosim cotest colib *.o *~
