example_objs=example1.o msb.o rabinpoly.o

go: compare run-test-chunker
	/bin/true

run-test-chunker: test-chunker build/lib.linux-i686-2.6/pyrabinf_mod.so drs_buffer/cython_drs_buffer_mod.so
	./test-chunker

drs_buffer/cython_drs_buffer_mod.so: drs_buffer/drs_buffer_mod.m4
	cd drs_buffer && make

compare: cpp-output py-output
	diff cpp-output py-output

cpp-output: example1
	./example1 test-input 16 > cpp-output

py-output: pyexample build/lib.linux-i686-2.6/pyrabinf_mod.so drs_buffer/cython_drs_buffer_mod.so
	./pyexample test-input 16 > py-output

build/lib.linux-i686-2.6/pyrabinf_mod.so: pyrabinf_mod.pyx
	python setup.py build

run-pyexample: build/lib.linux-i686-2.6/pyrabinf_mod.so
	./pyexample test-input 16

run-example1: example1
	ctags-exuberant *.C *.h
	# test-input is 3 copies of /etc/services
	./example1 test-input 16 | awk -F'==>' ' { print $$2 }' | sed 's/^\t*//' | sort -nr | uniq -c

example1: $(example_objs)
	g++ -o example1 $(example_objs)

clean:
	rm -f *.o core example1 pyrabinf_mod.cpp tags
	rm -rf build
	rm -f cpp-output py-output
	cd drs_buffer && make clean
	rm -f Profile.prof