SHELL=/bin/sh
BENCHMARK=bt
BENCHMARKU=BT

include ../config/make.def
include ../sys/make.common

SOURCES = bt.fdv \
	set_constants.fdv \
	initialize.fdv \
	exact_solution.fdv \
	verify.fdv \
	compute_errors.fdv \
	timers.fdv \
	print_result.fdv

SOURCES_MPI = z_solve_mpi.fdv y_solve_mpi.fdv x_solve_mpi.fdv compute_rhs_mpi.fdv exact_rhs.fdv
SOURCES_SINGLE = z_solve.fdv y_solve.fdv x_solve.fdv compute_rhs.fdv exact_rhs.fdv
SOURCES_BLOCK = z_solve_block.fdv y_solve_block.fdv x_solve_block.fdv compute_rhs_block.fdv exact_rhs_block.fdv
SOURCES_BLOCK1 = z_solve_block.fdv y_solve_block.fdv x_solve_block.fdv compute_rhs.fdv exact_rhs.fdv
SOURCES_BLOCK2 = z_solve_block.fdv y_solve_block.fdv x_solve_block.fdv compute_rhs_block2.fdv exact_rhs.fdv

OBJS = ${SOURCES:.fdv=.o}
OBJS_SINGLE = ${SOURCES_SINGLE:.fdv=.o}
OBJS_MPI = ${SOURCES_MPI:.fdv=.o}
OBJS_BLOCK = ${SOURCES_BLOCK:.fdv=.o}
OBJS_BLOCK1 = ${SOURCES_BLOCK1:.fdv=.o}
OBJS_BLOCK2 = ${SOURCES_BLOCK2:.fdv=.o}

${PROGRAM}: config
	@if [ "$(VERSION)" = "MPI" ] ; then	\
		${MAKE} MPI_VER;  \
	else       \
		if [ "$(VERSION)" = "BLOCK" ] ; then \
			${MAKE} BLOCK_VER; \
		else \
			if [ "$(VERSION)" = "BLOCK1" ] ; then \
				${MAKE} BLOCK_VER1; \
			else \
				${MAKE} SINGLE_VER;\
			fi \
		fi \
	fi
	
MPI_VER: $(OBJS) $(OBJS_MPI)
	${FLINK} -o ${PROGRAM} ${OBJS} $(OBJS_MPI)

SINGLE_VER: $(OBJS) $(OBJS_SINGLE)
	${FLINK} -o ${PROGRAM} ${OBJS} $(OBJS_SINGLE)

BLOCK_VER: $(OBJS) $(OBJS_BLOCK)
	${FLINK} -o ${PROGRAM} ${OBJS} $(OBJS_BLOCK)

BLOCK_VER1: $(OBJS) $(OBJS_BLOCK1)
	${FLINK} -o ${PROGRAM} ${OBJS} $(OBJS_BLOCK1)

BLOCK_VER2: $(OBJS) $(OBJS_BLOCK2)
	${FLINK} -o ${PROGRAM} ${OBJS} $(OBJS_BLOCK2)	

%.o: %.fdv npbparams.h header3d.h
	${F77} ${FFLAGS} -c -o $@ $<

clean:
	rm -f npbparams.h
	rm -f *.o *~
	rm -f *.cu *.cuf *.c *.f
