CFLAGS=-O3  -I../../../include -I../../include -DUSE_SPROC -D_BSD_SIGNALS -D_DEBUG_
# CFLAGS=-Ofast  -I../include -DUSE_SPROC -D_BSD_SIGNALS -D_DEBUG_
OBJS=shmem.o ukey.o bcast.new.o twait.o gettime.o reduce.o utils.o
TARGET=testbcast testMPI_Bcast testreduce stestbcast stestreduce
HEADER=../../include/ukey.h ../../include/anl_shmem.h ../../include/twait.h ../..include/bcast.h

.IGNORE :

all : $(TARGET)

testMPI_Bcast: testMPI_Bcast.c gettime.o
	cc $(CFLAGS) $@.c gettime.o -o testMPI_Bcast -lmpi

stestbcast : $$@.c $(OBJS)
	cc $(CFLAGS) $@.c $(OBJS)  -o $@
	
stestreduce : $$@.c $(OBJS)
	cc $(CFLAGS) $@.c $(OBJS)  -o $@
	
testbcast : $$@.c $(OBJS)
	cc $(CFLAGS) $@.c $(OBJS)  -o $@
	
testreduce : $$@.c $(OBJS)
	cc $(CFLAGS) $@.c $(OBJS)  -o $@
	
shmem.o : ../../shmem/shmem.c
	cc $(CFLAGS) -c $? -o $@

ukey.o : ../../ukey/ukey_sproc.c
	cc $(CFLAGS) -c $? -o $@

twait.o : ../../utils/twait.c
	cc -O2  -I../../include -DUSE_SPROC -D_BSD_SIGNALS -D_DEBUG_ -c $? -o $@

bcast.o : ../bcast.c
	cc $(CFLAGS) -c $? -o $@

utils.o : ../../utils/utils.c
	cc $(CFLAGS) -c $? -o $@

reduce.o : ../reduce.c
	cc $(CFLAGS) -c $? -o $@

gettime.o : ../../kernelbench/gettime.c
	cc $(CFLAGS) -c $? -o $@

rebuild : 
	touch *.c
	/bin/rm shmem.o ukey.o twait.o bcast.o
	make all

test : 
	make all
	testbcast
	mpirun -np 4 testMPI_Bcast

clean :
	\rm *.o  $(TARGET)
