include ../../conf/Makefile.inc
#include ../Makefile.object
#
# Makefile - for the Testing subdir
# 2000 - Jakob Ostergaard
#

#
# Hi !   If you just wrote another test program, then please
# append it to the TESTS variable just below
#
TESTS = dgemm dgemmseq
#
# That's it !
#
# There are no user-servicable parts below this point
#

.PHONY: regress clean

TESTSOURCES = $(foreach s, $(TESTS), test_$s.c )
TESTPROGS = $(foreach s, $(TESTS), $(BINDIR)/test_$s )

LIB = $(NETSOLVE_ROOT)/lib/$(NETSOLVE_ARCH)/libnetsolve.a
TDEP = $(LIB) $(OBJDIR)/test_common.o

regress: $(TESTPROGS)
	@for i in $(TESTS); do $(BINDIR)/test_$$i; done
	@echo "-------------------------------------------"
	@for i in $(TESTS); do \
		echo "( $$i ):"; \
		cat test_$$i.time; \
		done
	@echo "-------------------------------------------"
	@for i in $(TESTS); do \
		if ! grep -q FAIL test_$$i.result; \
		then echo "test_$$i: ALL OK"; \
		else cat test_$$i.result; \
		fi; \
		done
	@echo "-------------------------------------------"
	@for i in $(TESTS); do \
		if grep -q FAIL test_$$i.result; \
		then echo "test_$$i: TEST HAD FAILURE(S)"; \
		fi; \
		done

#  Nice, but not portable
#$(TESTPROGS): test_%: test_%.c $(TDEP)
#	@echo Compiling $@
#	$(CC) -o $@ $(CFLAGS) testcommon.o $< -lnetsolve

$(OBJDIR)/test_common.o: test_common.c
	@echo Compiling $@
	$(CC) $(NS_CFLAGS) -c test_common.c -o $(OBJDIR)/test_common.o
$(OBJDIR)/test_dgemm.o: test_dgemm.c
	@echo Compiling $@
	$(CC) $(NS_CFLAGS) -c test_dgemm.c -o $(OBJDIR)/test_dgemm.o
$(OBJDIR)/test_dgemmseq.o: test_dgemmseq.c
	@echo Compiling $@
	$(CC) $(NS_CFLAGS) -c test_dgemmseq.c -o $(OBJDIR)/test_dgemmseq.o
$(OBJDIR)/test_skeleton.o: test_skeleton.c
	@echo Compiling $@
	$(CC) $(NS_CFLAGS) -c test_skeleton.c -o $(OBJDIR)/test_skeleton.o

$(TESTPROGS): $(BINDIR)/test_dgemm $(BINDIR)/test_dgemmseq $(BINDIR)/test_skeleton

$(BINDIR)/test_dgemm: $(OBJDIR)/test_dgemm.o $(TDEP)
	@echo Compiling $@
	$(CC) $(LDFLAGS) $(CFLAGS) -o $@ $(OBJDIR)/test_common.o \
           $(OBJDIR)/test_dgemm.o -L$(LIBDIR) -lnetsolve
$(BINDIR)/test_dgemmseq: $(OBJDIR)/test_dgemmseq.o $(TDEP)
	@echo Compiling $@
	$(CC) $(LDFLAGS) $(CFLAGS) -o $@ $(OBJDIR)/test_common.o \
            $(OBJDIR)/test_dgemmseq.o -L$(LIBDIR) -lnetsolve
$(BINDIR)/test_skeleton: $(OBJDIR)/test_skeleton.o $(TDEP)
	@echo Compiling $@
	$(CC) $(LDFLAGS) $(CFLAGS) -o $@ $(OBJDIR)/test_common.o \
            $(OBJDIR)/test_skeleton.o -L$(LIBDIR) -lnetsolve

clean:
	rm -f *.time *.result core
