#/****************************************************************************
#**  fzjlinktest                                                            **
#*****************************************************************************
#**  Copyright (c) 2008-2009                                                **
#**  Forschungszentrum Juelich, Juelich Supercomputing Centre               **
#**                                                                         **
#**  See the file COPYRIGHT in the package base directory for details       **
#****************************************************************************/
BGP_SYS = /bgsys/drivers/ppcfloor/

CC = xlc
MPICC = mpixlc_r
MPIFC = mpixlf90_r
MPIGCC = mpicc

CFLAGS= -D_BGP -I./sionlib/install/sionlib_bgp/include -g -qfullpath -DBCASTDT
CFLAGS_MPI= -qtune=450 -qarch=450 -I./sionlib/install/sionlib_bgp/include -D_BGP -g -qfullpath -DBCASTDT
GCCFLAGS= -I$(BGP_SYS)/comm/include -I$(BGP_SYS)/arch/include -I$(BGP_SYS)/gnu-linux/powerpc-bgp-linux/sys-include/ -D_BGP -g -DBCASTDT

LIBS_MPI = -qtune=450 -qarch=450 -L./sionlib/install/sionlib_bgp/lib -lsion_32 -lsionser_32 -g -qfullpath
LIBS = -L./sionlib/install/sionlib_bgp/lib -lsionserfe_32 -g

default: mpilinktest pingponganalysis limqueuetest 

limprioqueue.o:   limprioqueue.c
	$(CC) $(FLAGS) -c limprioqueue.c 

postscript_driver.o:   postscript_driver.c postscript_driver.h
	$(CC) $(CFLAGS) -c postscript_driver.c 

pingponganalysis_tools.o:   pingponganalysis_tools.c pingponganalysis_tools.h
	$(CC) $(CFLAGS) -c pingponganalysis_tools.c 

mapping.o:   mapping.c
	$(MPIGCC) $(GCCFLAGS) -c mapping.c 

mpilinktestbgp.o: mpilinktestbgp.c Makefile_BGP
	$(MPICC) $(CFLAGS_MPI) $(BGCFLAGS) -c mpilinktestbgp.c 

mpilinktestbgp_ori.o: mpilinktestbgp_ori.c Makefile
	$(MPICC) $(CFLAGS_MPI) $(BGCFLAGS) -c mpilinktestbgp_ori.c 

mpilinktest: ./sionlib/install/sionlib_bgp/include/sion.h  mpilinktestbgp.o mapping.o limprioqueue.o
	$(MPICC) $(CFLAGS_MPI) -o mpilinktest mapping.o limprioqueue.o mpilinktestbgp.o $(LIBS_MPI) 

mpilinktest_ori:   mpilinktestbgp_ori.o mapping.o ppmwrite.o
	$(MPICC) $(CFLAGS_MPI) -o mpilinktest_ori mapping.o ppmwrite.o mpilinktestbgp_ori.o $(LIBS_MPI) 

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

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

pingponganalysis:   pingponganalysis.o ppmwrite.o limprioqueue.o postscript_driver.o pingponganalysis_tools.o
	$(CC) $(CFLAGS)  -o pingponganalysis pingponganalysis.o ppmwrite.o limprioqueue.o postscript_driver.o pingponganalysis_tools.o $(LIBS)

./sionlib/install/sionlib_bgp/include/sion.h:
	(cd sionlib/src; gmake -f Makefile_BE clean all install;gmake -f Makefile_FE clean all install)

./sionlib/install/sionlib_bgp/lib/libsion.a:
	(cd sionlib/src; gmake -f Makefile_BE clean all install;gmake -f Makefile_FE clean all install)

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

limqueuetest:   limqueuetest.o limprioqueue.o
	$(CC) $(CFLAGS) -o limqueuetest limqueuetest.o limprioqueue.o $(LIBS)
#	cp limqueuetest ..

./sionlib/install/sionlib_linux/include/sion.h:
	(cd sionlib/src; gmake -f Makefile_LINUX all install)

./sionlib/install/sionlib_linux/lib/libsion.a:
	(cd sionlib/src; gmake -f Makefile_LINUX all install)

clean::
	rm -rf *.o  *~ *core*
	rm -rf mpilinktest

