ALL: nbody nbodypipe nbodypipe2
##### User configurable options #####

ARCH        = sun4
COMM        = p4
BOPT        = g
P4_DIR      = /usr/local/p4-1.3
TOOLS_DIR   = /home/gropp/tools.n
MPIR_HOME   = /home/lusk/mpich
CC          = cc
F77         = f77 -u
AR          = ar
RANLIB      = ranlib
INCLUDE_DIR =  -I/home/gropp/tools.n -Impid/chameleon -Iinclude
DEVICE      = chameleon

### End User configurable options ###

DEVICE_INCLUDE = $MPIR_HOME/include/mpid.h
ITOOLSDIR  = $(TOOLS_DIR)
DDIR       = $(ITOOLSDIR)/libs/libsg/$(ARCH)/
DEVICE_MAIN = 
DEVICE_MAINF =
DEVICE_LIB = $(DDIR)/tools$(COMM).a $(DDIR)/tools.a $(DDIR)/system.a $(CLIB)
CFLAGS = -g -I$(MPIR_HOME)/include -I$(MPIR_HOME)/mpid/$(DEVICE) \
            -I$(TOOLS_DIR) -DMPI_$(ARCH) -I$(MPIR_HOME)/mpe
#FFLAGS = '-qdpc=e' 
FFLAGS = -g 
CLINKER = $(CC) 
LIBDIR = $(MPIR_HOME)/lib/$(ARCH)/$(COMM)
LIBS = $(LIBDIR)/libmpi.a $(DEVICE_LIB)
EXECS = nbody nbodypipe nbodypipepr nbodypipe2
        
PROFLIBS = $(LIBDIR)/mpe_proff.o $(LIBDIR)/mpe_prof.o $(LIBDIR)/libmpe.a \
	   $(LIBDIR)/libmpi.a \
	   $(LIBDIR)/libpmpi.a $(LIBDIR)/libmpi.a $(DEVICE_LIB)
include $(ITOOLSDIR)/bmake/$(ARCH).$(BOPT)$(PROFILE)
include $(ITOOLSDIR)/bmake/$(ARCH)
include $(ITOOLSDIR)/bmake/$(ARCH).$(COMM)

default: nbody

nbody: nbody.o 
	$(FLINKER) $(FFLAGS) -o nbody  $(DEVICE_MAINF) \
		nbody.o $(LIBS)
	if [ ! -x nbody ] ; then /bin/rm -f nbody ; fi
nbodypipe: nbodypipe.o 
	$(FLINKER) $(FFLAGS) -o nbodypipe  $(DEVICE_MAINF) \
		nbodypipe.o $(LIBS)
	if [ ! -x nbodypipe ] ; then /bin/rm -f nbodypipe ; fi
nbodypipe2: nbodypipe2.o 
	$(FLINKER) $(FFLAGS) -o nbodypipe2  $(DEVICE_MAINF) \
		nbodypipe2.o $(LIBS)
	if [ ! -x nbodypipe2 ] ; then /bin/rm -f nbodypipe2 ; fi

# Profiling versions
nbodypr: nbody.o 
	$(FLINKER) -o nbodypr  $(DEVICE_MAINF) \
		nbody.o $(PROFLIBS)
	if [ ! -x nbodypr ] ; then /bin/rm -f nbodypr ; fi
nbodypipepr: nbodypipe.o 
	$(FLINKER) -o nbodypipepr  $(DEVICE_MAINF) \
		nbodypipe.o $(PROFLIBS)
	if [ ! -x nbodypipepr ] ; then /bin/rm -f nbodypipepr ; fi

.c.o:
	$(CC) $(CFLAGS) -c $*.c

.f.o:   
	$(F77) $(FFLAGS) -c $*.f

clean:
	/bin/rm -f *.o *~ PI* $(EXECS)
