# Makefile to compile a parallel Jacobi solver for the Laplacian equation in 2D
# Makefile written by A. Pedrono, H. Neau, P Elyakime and E. Courcelle 
# (IMFT, INPT, CNRS, CALMIP)
# The Makefile variable VISIT enables compilation with VisIt. 
# Otherwise, the program will be compiled in stand-alone mode.

# At IMFT, BEFORE calling make, you can initialize the environment with:
# module purge
# module load mpich/3.2.0/gcc-5.4
# source ../../visit_GUI.sh
# or 
# module purge
# module load openmpi/1.10.3/gcc-5.4 
# source ../../visit_GUI.sh

# On Eos, BEFORE calling make, you can initialize the environment with:
# module purge
# module load intel/17.0.4 intelmpi/5.1.3.210
# if you need VisIt in batch mode please use:
# module load visit/vbatch-2.12.3
# The visit module define the variable VISIT_DIR
#
# On Eos, comment out the following line
CC = mpiicc
#
# # Or using gcc on your machine:
# CC = mpicc  
# 
OPT = 

#
# To compile with visit:
# 1/ Initiate the environment with .visit_batch.sh, (on Eos: module load visit/vbatch-2.10.2)
# 2/ Decomment the following line:
VISIT = 1
#

EXE = pjacobi


ifdef VISIT

DEFINE = -D_VISIT_

#VISIT_DIR=
VISIT_INCDIR = -I$(VISIT_DIR)/linux-x86_64/libsim/V2/include
VISIT_INCLUDE += $(VISIT_INCDIR)

VISIT_LIBS = -L$(VISIT_DIR)/linux-x86_64/libsim/V2/lib -lsimV2 -Wl,--no-as-needed -ldl
LIBS = $(VISIT_LIBS) 

OBJS = solvers.o pjacobi.o PJacobi_Visit.o 

else

OBJS = solvers.o pjacobi.o

endif


$(EXE):	$(OBJS) 
	$(CC) $(OPT) $(OBJS) $(VISIT_INCLUDE) $(LIBS) -o $(EXE)
	
solvers.o:	solvers.c
	$(CC) $(OPT) $(VISIT_INCLUDE) $(DEFINE) solvers.c -c 
	
pjacobi.o:	pjacobi.c
	$(CC) $(OPT) $(VISIT_INCLUDE) $(DEFINE) pjacobi.c -c 
	
PJacobi_Visit.o:		PJacobi_Visit.c
	$(CC) $(OPT) $(VISIT_INCLUDE)  PJacobi_Visit.c -c

clean :
	/bin/rm -f $(OBJS) $(EXE)


