ALL:  grid0.$(ARCH) grid1.$(ARCH) grid2.$(ARCH) grid3.$(ARCH) grid4.$(ARCH)

#The variable ITOOLSDIR points to the location of the tools software
#written by W. Gropp at ANL
ITOOLSDIR = /home/jones/chameleon
#ITOOLSDIR = /disk/delilah7/curfman/tools.core

#The variable BSDIR points to the location of the include files for BlockSolve
BSDIR = ..

#The fortran libraries for this architecture
# for the sun, nothing is needed
# for the intel delta, -lf
# for the SP/1, /usr/lib/libxlf.a /usr/lib/libm.a /usr/lib/libxlf90.a
#FORTLIBS = -lf
#FORTLIBS = /usr/lib/libxlf.a /usr/lib/libm.a /usr/lib/libxlf90.a

#Misc. libraries (only defined as something on an intel system)
#NXLIB = -node

#Compiler flags:
#MLOG turns on logging
#MCOUNT turns on counting of most floating point operations
#DEBUG_ALL turns on error code checking
#DEBUG_TRACEBACK turns on the printing of error messages when errors are
#                encountered during execution
#NO_NATIVE_SUBSET instructs the compiler not to use any native operations
#                 for operating on subsets of processors
#USE_NATIVE_GLOBAL instructs the compiler to use native operations
#                  for global operations

CFLAGS    = -I$(ITOOLSDIR) -I$(BSDIR) $(OPT) $(COPT) -DDEBUG_ALL -DDEBUG_TRACEBACK -DNO_NATIVE_SUBSET -DUSE_NATIVE_GLOBAL
LDIR      = $(ITOOLSDIR)/libs/libs$(BOPT)$(PROFILE)/$(ARCH)

#Necessary libraries
# line 1: the BlockSolve library
# line 2: libraries from Bill Gropp's tools
# line 3: LAPACK, BLAS, misc libs, Fortran, C math lib
# Note: on the SP/1 the ESSL library must also included
#       it is typically stored in /usr/lib/libessl.a
LIBS = $(BSDIR)/bslib$(BOPT)$(COMM).$(ARCH).a \
       -L$(LDIR) -lpecomm$(COMM) -lpetsc -lpecore -lpecomm$(COMM) \
       $(LAPACK) $(BLAS) $(NXLIB) $(FORTLIBS) -lm

LIBNAME = dummy

#source for example 0
SOURCE0 = master0.c worker0.c get_mat0.c
OBJS0 = master0.o worker0.o get_mat0.o

#source for example 1
SOURCE1 = master1.c worker1.c get_mat.c
OBJS1 = master1.o worker1.o get_mat.o

#source for example 2
SOURCE2 = master2.c worker2.c get_mat.c
OBJS2 = master2.o worker2.o get_mat.o

#source for example 3
SOURCE3 = master3.c worker3.c get_mat3.c map3.c
OBJS3 = master3.o worker3.o get_mat3.o map3.o

#source for example 4
SOURCE4 = master4.c worker4.c get_mat4.c
OBJS4 = master4.o worker4.o get_mat4.o

#various Makefile stuff that must be included from the tools package
include $(ITOOLSDIR)/bmake/$(ARCH).$(BOPT)$(PROFILE)
include $(ITOOLSDIR)/bmake/$(ARCH)
include $(ITOOLSDIR)/bmake/$(ARCH).$(COMM)

# The location of LAPACK can be provided here to override the
# location given by Chameleon
#The location of LAPACK
#LAPACK = /usr/local/delta/LAPACK/lapack.a
LAPACK = /src/icl/LAPACK_SUN4/lapack.a

#The location of the level 1, 2, and 3 BLAS
#BLAS = -lkmath
BLAS = /src/icl/LAPACK_SUN4/blas.a

#Note: on the delta PATCH is defined as ccprobe.o -- a routine that
#      fixes a problem with the cprobe command
#PATCH = ccprobe.o

#Note: on the Sun, we have found it necessary to use FLINKER below to
#      correctly link the programs.  On other architectures CLINKER
#      has proven successful.

grid0.$(ARCH): $(SOURCE0) $(OBJS0) $(BSDIR)/bslib$(BOPT)$(COMM).$(ARCH).a
	$(FLINKER) -o grid0.$(ARCH) $(CFLAGS) $(BASEOPT) $(OBJS0) $(PATCH) $(LIBS) $(CLIB) $(SLIB)

grid1.$(ARCH): $(SOURCE1) $(OBJS1) $(BSDIR)/bslib$(BOPT)$(COMM).$(ARCH).a
	$(FLINKER) -o grid1.$(ARCH) $(CFLAGS) $(BASEOPT) $(OBJS1) $(PATCH) $(LIBS) $(CLIB) $(SLIB)

grid2.$(ARCH): $(SOURCE2) $(OBJS2) $(BSDIR)/bslib$(BOPT)$(COMM).$(ARCH).a
	$(FLINKER) -o grid2.$(ARCH) $(CFLAGS) $(BASEOPT) $(OBJS2) $(PATCH) $(LIBS) $(CLIB) $(SLIB)

grid3.$(ARCH): $(SOURCE3) $(OBJS3) $(BSDIR)/bslib$(BOPT)$(COMM).$(ARCH).a
	$(FLINKER) -o grid3.$(ARCH) $(CFLAGS) $(BASEOPT) $(OBJS3) $(PATCH) $(LIBS) $(CLIB) $(SLIB)

grid4.$(ARCH): $(SOURCE4) $(OBJS4) $(BSDIR)/bslib$(BOPT)$(COMM).$(ARCH).a
	$(FLINKER) -o grid4.$(ARCH) $(CFLAGS) $(BASEOPT) $(OBJS4) $(PATCH) $(LIBS) $(CLIB) $(SLIB)
