# This is the makefile for testing mesa mtx package 

MESA_DIR = ../../..

#################################################################

# STEP 1: set up the standard info

include $(MESA_DIR)/utils/makefile_header

ifeq ($(MTX_OFFLOAD),YES)
CC += -Doffload
FC += -Doffload
endif

#################################################################

# STEP 2: info about the libraries

LOAD_LOCAL = -L$(LOCAL_LIB_DIR) $(LOAD_MATRIX)
LOAD_OTHER = -L$(MESA_LIB_DIR)

#################################################################

# STEP 3: build the test program

#test_umf_dble.o test_umf_quad.o 
TEST_SUPPORT_OBJS = \
   test_mtx_support.o \
   test_block_tri_dble.o test_block_tri_quad.o \
   test_klu_dble.o test_klu_quad.o \
   test_square.o test_square_quad.o test_sparse.o
   
TEST_OBJS = $(TEST_SUPPORT_OBJS) test_mtx.o 

TEST = tester

all : $(TEST)

$(TEST) : $(TEST_OBJS)
	$(LOADER) $(FCopenmp) -o $(TEST_DIR)/$(TEST) $(TEST_OBJS) \
	$(LOAD_LOCAL) $(LOAD_OTHER)


#################################################################

%.o: $(TEST_SRC_DIR)/%.f
	$(TEST_COMPILE) $(FCfree) $<
	
test_umf_dble.o: $(TEST_SRC_DIR)/test_umf.f
	$(TEST_COMPILE) $(FCfree) $(FC_free_preprocess) -DDBLE -o test_umf_dble.o $<
test_umf_quad.o: $(TEST_SRC_DIR)/test_umf.f
	$(TEST_COMPILE) $(FCfree) $(FC_free_preprocess) -o test_umf_quad.o $<
	
test_klu_dble.o: $(TEST_SRC_DIR)/test_klu.f
	$(TEST_COMPILE) $(FCfree) $(FC_free_preprocess) -DDBLE -o test_klu_dble.o $<
test_klu_quad.o: $(TEST_SRC_DIR)/test_klu.f
	$(TEST_COMPILE) $(FCfree) $(FC_free_preprocess) -o test_klu_quad.o $<

test_block_tri_dble.o: $(TEST_SRC_DIR)/test_block_tridiagonal.f
	$(TEST_COMPILE) $(FCfree) $(FC_free_preprocess) -DDBLE -o test_block_tri_dble.o $<
test_block_tri_quad.o: $(TEST_SRC_DIR)/test_block_tridiagonal.f
	$(TEST_COMPILE) $(FCfree) $(FC_free_preprocess) -o test_block_tri_quad.o $<

clean:
	-@rm -f *.o *.mod $(TEST_LIB) $(TEST_DIR)/$(TEST)
