# File         : Makefile
# Author       : Xinying Li
# Created      : Thu Apr  9 12:22:15 1998
# Revision     : ver 1.1
# Updated      : $Date: 1998/04/23 14:52:33 $
# Copyright: Northeast Parallel Architectures Center at Syracuse University 1998


srcdir = @srcdir@
top_srcdir = @top_srcdir@

VPATH = .:${srcdir}

CC = @CC@
LD = @CC@ # $(MPICHPATH)/bin/mpicc

JDK = @JAVA@

MPI_INC = @MPI_INC@
MPI_LIB = @MPI_LIB@

CCLIBKEY = @CCLIBKEY@

INCLUDES = -I$(JDK)/include -I$(JDK)/include/@JOS@ -I$(MPI_INC)
CLASSPATH =.:$(JDK)/lib/classes.zip:$(JDK)/classes # for both solaris and irix

CLASSES = ../classes
LIB = ../lib

TITLE = mpi
PFX = $(TITLE)_
PKG = $(TITLE).
DIR = $(TITLE)/

RM = rm
CP = cp
MV = mv

JC = $(JDK)/bin/javac
JH = $(JDK)/bin/javah
JFLAG = -jni
CFLAGS = -c

#LFLAGS = -G # solaris native compiler and linker
#LFLAGS = -shared #gnu compiler and linker ; irix


OBJ = $(PFX)MPI.o $(PFX)Comm.o $(PFX)Op.o $(PFX)Datatype.o \
	  $(PFX)Intracomm.o $(PFX)Intercomm.o \
	  $(PFX)Cartcomm.o $(PFX)Graphcomm.o \
	  $(PFX)Group.o $(PFX)Status.o $(PFX)Request.o $(PFX)Prequest.o \
	  $(PFX)Errhandler.o

all:: $(LIB)/lib$(TITLE).so 
$(LIB)/lib$(TITLE).so : $(OBJ)
	if test "@JOS@" = "solaris" ; \
	then \
	$(CC) -G -o $(LIB)/lib$(TITLE).so -L$(MPI_LIB) $(OBJ) $(CCLIBKEY); \
	fi
	if test "@JOS@" = "irix" ; \
	then \
	$(CC) -shared -o $(LIB)/lib$(TITLE).so -L$(MPI_LIB) $(OBJ) $(CCLIBKEY); \
	fi

.SUFFIXES:
.SUFFIXES: .java .h .class .c .C .o

.C.o:
	$(CXX) -c $(INCLUDES)  -o $@ $*.C

.c.o:
	$(CC) -c $(INCLUDES)  -o $@ $*.c

#.java.class:
#	$(JC) -d $(CLASSES)  -classpath $(CLASSES):$(CLASSPATH) $*.java
#	cp $@ $(TITLE)

#.class.h:
#	$(JH) $(JFLAG) -classpath $(CLASSES):$(CLASSPATH) $*
#	touch $(PFX)$*.h

$(CLASSES)/$(DIR)MPI.class : MPI.java $(CLASSES)/$(DIR)Comm.class \
		$(CLASSES)/$(DIR)Intracomm.class \
				$(CLASSES)/$(DIR)Group.class $(CLASSES)/$(DIR)Op.class \
				$(CLASSES)/$(DIR)Datatype.class $(CLASSES)/$(DIR)Call_back.class
	$(JC) -d $(CLASSES)  -classpath $(CLASSES):$(CLASSPATH) MPI.java
$(CLASSES)/$(DIR)Comm.class : Comm.java $(CLASSES)/$(DIR)Datatype.class \
				$(CLASSES)/$(DIR)Status.class $(CLASSES)/$(DIR)Prequest.class \
				$(CLASSES)/$(DIR)Op.class \
				$(CLASSES)/$(DIR)Group.class  $(CLASSES)/$(DIR)Errhandler.class \
				Intercomm.java Intracomm.java Cartcomm.java  Graphcomm.java \
				$(CLASSES)/$(DIR)ShiftParms.class $(CLASSES)/$(DIR)CartParms.class \
				$(CLASSES)/$(DIR)GraphParms.class
	$(JC) -d $(CLASSES)  -classpath $(CLASSES):$(CLASSPATH) Comm.java Intercomm.java Intracomm.java Cartcomm.java  Graphcomm.java
$(CLASSES)/$(DIR)Datatype.class : Datatype.java
	$(JC) -d $(CLASSES)  -classpath $(CLASSES):$(CLASSPATH) Datatype.java
$(CLASSES)/$(DIR)Op.class : Op.java $(CLASSES)/$(DIR)User_function.class
	$(JC) -d $(CLASSES)  -classpath $(CLASSES):$(CLASSPATH) Op.java
$(CLASSES)/$(DIR)Status.class : Status.java
	$(JC) -d $(CLASSES)  -classpath $(CLASSES):$(CLASSPATH) Status.java
$(CLASSES)/$(DIR)Request.class : Request.java
	$(JC) -d $(CLASSES)  -classpath $(CLASSES):$(CLASSPATH) Request.java
$(CLASSES)/$(DIR)Prequest.class : Prequest.java $(CLASSES)/$(DIR)Request.class
	$(JC) -d $(CLASSES)  -classpath $(CLASSES):$(CLASSPATH) Prequest.java
$(CLASSES)/$(DIR)Intracomm.class : Intracomm.java $(CLASSES)/$(DIR)Op.class \
			$(CLASSES)/$(DIR)Comm.class 
	$(JC) -d $(CLASSES)  -classpath $(CLASSES):$(CLASSPATH) Intracomm.java
$(CLASSES)/$(DIR)Intercomm.class : Intercomm.java $(CLASSES)/$(DIR)Comm.class Intracomm.java
	$(JC) -d $(CLASSES)  -classpath $(CLASSES):$(CLASSPATH) Intercomm.java
$(CLASSES)/$(DIR)Cartcomm.class : Cartcomm.java $(CLASSES)/$(DIR)Intracomm.class \
		$(CLASSES)/$(DIR)CartParms.class $(CLASSES)/$(DIR)ShiftParms.class
	$(JC) -d $(CLASSES)  -classpath $(CLASSES):$(CLASSPATH) Cartcomm.java 
$(CLASSES)/$(DIR)Graphcomm.class : Graphcomm.java $(CLASSES)/$(DIR)Intracomm.class \
		$(CLASSES)/$(DIR)GraphParms.class
	$(JC) -d $(CLASSES)  -classpath $(CLASSES):$(CLASSPATH) Graphcomm.java
$(CLASSES)/$(DIR)CartParms.class : CartParms.java
	$(JC) -d $(CLASSES)  -classpath $(CLASSES):$(CLASSPATH) CartParms.java
$(CLASSES)/$(DIR)ShiftParms.class : ShiftParms.java
	$(JC) -d $(CLASSES)  -classpath $(CLASSES):$(CLASSPATH) ShiftParms.java
$(CLASSES)/$(DIR)GraphParms.class : GraphParms.java
	$(JC) -d $(CLASSES)  -classpath $(CLASSES):$(CLASSPATH) GraphParms.java
$(CLASSES)/$(DIR)Group.class : Group.java
	$(JC) -d $(CLASSES)  -classpath $(CLASSES):$(CLASSPATH) Group.java
$(CLASSES)/$(DIR)Errhandler.class : Errhandler.java
	$(JC) -d $(CLASSES)  -classpath $(CLASSES):$(CLASSPATH) Errhandler.java
$(CLASSES)/$(DIR)Call_back.class : Call_back.java
	$(JC) -d $(CLASSES)  -classpath $(CLASSES):$(CLASSPATH) Call_back.java
$(CLASSES)/$(DIR)User_function.class : User_function.java
	$(JC) -d $(CLASSES)  -classpath $(CLASSES):$(CLASSPATH) User_function.java

$(PFX)MPI.h : $(CLASSES)/$(DIR)MPI.class
	$(JH) $(JFLAG) -classpath $(CLASSES):$(CLASSPATH) $(PKG)MPI
	touch $@
$(PFX)Comm.h : $(CLASSES)/$(DIR)Comm.class
	$(JH) $(JFLAG) -classpath $(CLASSES):$(CLASSPATH) $(PKG)Comm
	touch $@
$(PFX)Intracomm.h : $(CLASSES)/$(DIR)Intracomm.class
	$(JH) $(JFLAG) -classpath $(CLASSES):$(CLASSPATH) $(PKG)Intracomm
	touch $@
$(PFX)Intercomm.h : $(CLASSES)/$(DIR)Intercomm.class
	$(JH) $(JFLAG) -classpath $(CLASSES):$(CLASSPATH) $(PKG)Intercomm
	touch $@
$(PFX)Status.h : $(CLASSES)/$(DIR)Status.class
	$(JH) $(JFLAG) -classpath $(CLASSES):$(CLASSPATH) $(PKG)Status
	touch $@
$(PFX)Op.h : $(CLASSES)/$(DIR)Op.class
	$(JH) $(JFLAG) -classpath $(CLASSES):$(CLASSPATH) $(PKG)Op
	touch $@
$(PFX)Request.h : $(CLASSES)/$(DIR)Request.class
	$(JH) $(JFLAG) -classpath $(CLASSES):$(CLASSPATH)  $(PKG)Request
	touch $@
$(PFX)Prequest.h : $(CLASSES)/$(DIR)Prequest.class
	$(JH) $(JFLAG) -classpath $(CLASSES):$(CLASSPATH) $(PKG)Prequest
	touch $@
$(PFX)Datatype.h : $(CLASSES)/$(DIR)Datatype.class
	$(JH) $(JFLAG) -classpath $(CLASSES):$(CLASSPATH) $(PKG)Datatype
	touch $@
$(PFX)Cartcomm.h : $(CLASSES)/$(DIR)Cartcomm.class
	$(JH) $(JFLAG) -classpath $(CLASSES):$(CLASSPATH) $(PKG)Cartcomm
	touch $@
$(PFX)Graphcomm.h : $(CLASSES)/$(DIR)Graphcomm.class
	$(JH) $(JFLAG) -classpath $(CLASSES):$(CLASSPATH) $(PKG)Graphcomm
	touch $@
$(PFX)Group.h : $(CLASSES)/$(DIR)Group.class
	$(JH) $(JFLAG) -classpath $(CLASSES):$(CLASSPATH) $(PKG)Group
	touch $@
$(PFX)Errhandler.h : $(CLASSES)/$(DIR)Errhandler.class
	$(JH) $(JFLAG) -classpath $(CLASSES):$(CLASSPATH) $(PKG)Errhandler
	touch $@    

$(PFX)MPI.o : $(PFX)MPI.c $(PFX)MPI.h
$(PFX)Comm.o : $(PFX)Comm.c $(PFX)Comm.h
$(PFX)Intercomm.o : $(PFX)Intercomm.c $(PFX)Intercomm.h
$(PFX)Intracomm.o : $(PFX)Intracomm.c $(PFX)Intracomm.h
$(PFX)Status.o : $(PFX)Status.c $(PFX)Status.h
$(PFX)Op.o : $(PFX)Op.c $(PFX)Op.h
$(PFX)Request.o : $(PFX)Request.c $(PFX)Request.h
$(PFX)Prequest.o : $(PFX)Prequest.c $(PFX)Prequest.h
$(PFX)Datatype.o : $(PFX)Datatype.c $(PFX)Datatype.h
$(PFX)Cartcomm.o : $(PFX)Cartcomm.c $(PFX)Cartcomm.h
$(PFX)Graphcomm.o : $(PFX)Graphcomm.c $(PFX)Graphcomm.h
$(PFX)Group.o : $(PFX)Group.c $(PFX)Group.h
$(PFX)Errhandler.o : $(PFX)Errhandler.c $(PFX)Errhandler.h

clean :
	$(RM) -f $(CLASSES)/$(DIR)*.class
	$(RM) -f $(PFX)*.h
	$(RM) -f *.o 
	$(RM) -f $(LIB)/lib*.so
