SHELL=/bin/sh
CFLAGS	= -I. -O3  
MPICC=mpicc
BSPCC=bspcc
MPIFLAGS =  -lm -O3  
BSPBT=bspfin
MPIBT=mpifin
#BT=gbt
#BT=bt
#BT=gtt
BT=bt
BT=efdm
#EXT=100
EXT=1
#BSPFLAGS = -O3  -flibrary-level 2   -fcombine-puts  \
            -bspnoslots 1 -bspslotsize  40 \
            -bsproundtrip 200 -bspsendlatency 25 
#Former for small n, latter for 1024 or more
#25, 200,25
#25,180,25L ,100noslot for big prob size and 16procs
#25,180,25L ,1noslot   for big prob size and 4procs
BSPFLAGS =  -flibrary-level 2  -bspnoslots ${EXT}\
           -bspslotsize  25  -bsproundtrip 180\
           -bspsendlatency 25  -lm
BSPFLAGS =  -flibrary-level 2  -lm  -O3
BSPFLAGS =  -flibrary-level 2  -bspnoslots ${EXT}\
           -bspslotsize 25  -bsproundtrip 180\
           -bspsendlatency 25  -lm
allbsp	:	${BSPBT}
allmpi	:	${MPIBT}
bspfin:	${BT}main.o ${BT}.o 
	${BSPCC} ${BSPFLAGS} ${BT}main.o ${BT}.o -o bsp${BT}${EXT}
#	strip   bsp${BT}${EXT}
#	ccp bsp${BT}${EXT} run
	mv bsp${BT}${EXT} bsp${BT}
mpifin:	m${BT}main.o m${BT}.o  aimpi.o
	${MPICC} ${MPIFLAGS} ${BT}main.o ${BT}.o aimpi.o \
	-o mpi${BT}
#	strip   mpi${BT}
#	ccp mpi${BT} run
#
btmain.o:	btmain.c
	${BSPCC} ${CFLAGS} -c  btmain.c
mbtmain.o:	btmain.c
	${MPICC} ${CFLAGS} -c  btmain.c
gbtmain.o:	gbtmain.c
	${BSPCC} ${CFLAGS} -c  gbtmain.c
mgbtmain.o:	gbtmain.c
	${MPICC} ${CFLAGS} -c  gbtmain.c
gttmain.o:	gttmain.c
	${BSPCC} ${CFLAGS} -c  gttmain.c
efdmmain.o:	efdmmain.c
	${BSPCC} ${CFLAGS} -c  efdmmain.c
mgttmain.o:	gttmain.c
	${MPICC} ${CFLAGS} -c  gttmain.c
mefdmmain.o:	efdmmain.c
	${MPICC} ${CFLAGS} -c  efdmmain.c
#
bt.o:	bt.c
	${BSPCC} ${CFLAGS} -c  bt.c
mbt.o:	bt.c
	${MPICC} ${CFLAGS} -c  bt.c
#
gbt.o:	gbt.c
	${BSPCC} ${CFLAGS} -c  gbt.c
mgbt.o:	gbt.c
	${MPICC} ${CFLAGS} -c  gbt.c
#
gtt.o:	gtt.c
	${BSPCC} ${CFLAGS} -c  gtt.c
mgtt.o:	gtt.c
	${MPICC} ${CFLAGS} -c  gtt.c
efdm.o:	efdm.c
	${BSPCC} ${CFLAGS} -c  efdm.c
mefdm.o:	efdm.c
	${MPICC} ${CFLAGS} -c  efdm.c
#
aimpi.o:	aimpi.c
	${MPICC} ${CFLAGS} -c aimpi.c -o aimpi.o
clean:
	rm -f *.o bspefdm mpiefdm
#	rm -f *.o bspbt mpibt   bspgbt mpigbt bspgtt mpigtt bspefdm mpiefdm aimpi.o
tar:
	tar cvf efdm08v5.tar ai.h aimpi.c aimpi.h apot.seq bt.h\
		copy efdata efdm.c efdmmain.c efdm.rdm lamhosts Makefile\
		runs.bsp runs.mpi Tables.new \
		../Seq/efdata ../Seq/efdata.rdm ../Seq/efmain.c\
		../Seq/efoption.c ../Seq/Makefile ../Seq/option.h \
		../Seq/option01.tar
