default: tests

.PHONY: runtests

# tests: ext meshext 
TESTS= test_laplace test_row test_formsize test_form test_indices test_formsizebdr test_formbdr test_formbdrbnd test_bdr_coords


# default: test

DYMOLAINC=-I$(DYMOLADIR)/Source

CPPFLAGS += $(DYMOLAINC) -I.. -I ../rheolef -DWITHOUT_DYMOLA

LIBEXTSRCS= read_array_common.c read_matrix.c 

LIBRHEOLEFSRCS= poisson_rheolef.c
LIBBAMGSRCS= bamg.c
LIBMESHEXTSRCS= meshext.c

LIBEXTOBJS=  $(LIBEXTSRCS:%.c=%.o) 
LIBRHEOLEFOBJS= $(LIBRHEOLEFSRCS:%.c=%.o)
LIBBAMGOBJS= $(LIBBAMGSRCS:%.c=%.o)
LIBMESHEXTOBJS= $(LIBMESHEXTSRCS:%.c=%.o)

LIBSRCS= $(LIBEXTSRCS) $(LIBRHEOLEFSRCS) $(LIBBAMGSRCS) $(LIBMESHEXTSRCS)

LIBOBJS= $(LIBEXTOBJS) $(LIBRHEOLEFOBJS) $(LIBBAMGOBJS) $(LIBMESHEXTOBJS)


%.o: ../%.c
	$(CC) $(CPPFLAGS) $(CFLAGS) -c -o $@ $<


test_laplace: $(LIBOBJS) test_laplace.o
	$(CXX) $(LDFLAGS) -o test_laplace  test_laplace.o $(LIBOBJS) $(LDLIBS)

test_row: $(LIBOBJS) test_row.o
	$(CXX) $(LDFLAGS) -o test_row  test_row.o $(LIBOBJS) $(LDLIBS)

test_form: $(LIBOBJS) test_form.o ../rheolef/print.h
	$(CXX) $(LDFLAGS) -o test_form  test_form.o $(LIBOBJS) $(LDLIBS)

test_formbdr: $(LIBOBJS) test_formbdr.o ../rheolef/print.h
	$(CXX) $(LDFLAGS) -o test_formbdr  test_formbdr.o $(LIBOBJS) $(LDLIBS)

test_formbdrbnd: $(LIBOBJS) test_formbdrbnd.o
	$(CXX) $(LDFLAGS) -o test_formbdrbnd  test_formbdrbnd.o $(LIBOBJS) $(LDLIBS)

test_indices: $(LIBOBJS) test_indices.o ../rheolef/print.h
	$(CXX) $(LDFLAGS) -o test_indices  test_indices.o $(LIBOBJS) $(LDLIBS)

test_formsize: $(LIBOBJS) test_formsize.o 
	$(CXX) $(LDFLAGS) -o test_formsize  test_formsize.o $(LIBOBJS) $(LDLIBS)

test_formsizebdr: $(LIBOBJS) test_formsizebdr.o 
	$(CXX) $(LDFLAGS) -o test_formsizebdr  test_formsizebdr.o $(LIBOBJS) $(LDLIBS)

test_ext: $(LIBOBJS) test_ext.o
	$(CXX) $(LDFLAGS) -o test_ext  test_ext.o $(LIBOBJS) $(LDLIBS)

test_meshext: $(LIBOBJS) test_meshext.o
	$(CXX) $(LDFLAGS) -o test_meshext test_meshext.o $(LIBOBJS) $(LDLIBS)

test_bdr_coords: $(LIBOBJS) test_bdr_coords.o ../rheolef/print.h
	$(CXX) $(LDFLAGS) -o test_bdr_coords  test_bdr_coords.o $(LIBOBJS) $(LDLIBS)



tests: $(TESTS)

runtests: $(TESTS)
	@for x in $(TESTS); do \
	  ./run-test.sh $$x || exit 1; \
	done;

