#!/usr/bin/make -f

CPPFLAGS = $(shell pkg-config fflas-ffpack --cflags)
LDLIBS = $(shell pkg-config fflas-ffpack --libs)
CC = g++
VPATH=tests

# BASIC_TESTS from tests/Makefile.am
# remove the ones skipped in d/p/skip-failing-tests.patch
TESTS = test-fdot           \
	test-finit          \
	test-fscal          \
	test-fadd           \
	test-fger           \
	test-ftrsv          \
	test-ftrtri         \
	test-ftrmv          \
	test-ftrsm          \
	test-ftrstr         \
	test-ftrssyr2k      \
	test-ftrsm-check    \
	test-ftrmm          \
	test-fgemm          \
	test-fgemm-check    \
	test-permutations   \
	test-rpm            \
	test-compressQ      \
	test-lu             \
	test-pluq-check     \
	test-fsyr2k         \
	test-invert-check   \
	test-rankprofiles   \
	test-det            \
	test-det-check      \
	test-charpoly       \
	test-minpoly        \
	test-multifile1     \
	test-io             \
	test-maxdelayeddim  \
	test-solve          \
	test-fgesv          \
	test-simd           \
	test-fgemv          \
	test-nullspace      \
	regression-check

all: clean $(TESTS)
# data directory needed by test-io
	@mkdir -p data; \
	PASS=0; \
	FAIL=0; \
	for TEST in $(TESTS); \
	do \
		./$$TEST; \
		if [ $$? = 0 ]; \
		then \
			echo "PASS: $$TEST"; \
			PASS=$$(($$PASS+1)); \
		else \
			echo "FAIL: $$TEST"; \
			FAIL=$$(($$FAIL+1)); \
		fi; \
	done; \
	echo "========"; \
	echo "Summary:"; \
	echo "========"; \
	echo "PASS: $$PASS"; \
	echo "FAIL: $$FAIL"; \
	rm -f $(TESTS) *.o; \
	exit $$FAIL

# we rename test-multifile -> testmultifile1 to take advantage of implicit rules
test-multifile1: test-multifile2.o

clean:
	rm -f $(TESTS) *.o
	cd tests && rm -f $(TESTS) *.o
