--- a/makefile
+++ b/makefile
@@ -1,2 +1,20 @@
-KlustaKwik: KlustaKwik.C
-	g++ -g -O -o KlustaKwik KlustaKwik.C  param.c -lm
+SRC=KlustaKwik.C
+MSRC=KlustaKwik.h param.c param.h Array.h
+ASRC=$(SRC) $(MSRC)
+
+CPPFLAGS=-O -g
+
+KlustaKwik: $(SRC) $(MSRC)
+	g++ $(CPPFLAGS) -o $@ KlustaKwik.C  param.c -lm
+
+test: check
+check: KlustaKwik
+	./KlustaKwik test 1 -MinClusters 2 >| tempout
+	: # For now no actual test, because non-noise cluster
+	: # indicies differ from the 'test' ones
+	diff test_res.clu.1 test.clu.1 || :
+
+clean:
+	-rm -f $(SRC:.C=) tempout test.clu.1 test.klg.1 test.out
+
+.PHONY: check test
