
##### User configurable options #####

MAKE                 = @MAKE@

MPI_CC               = @MPI_CC@
MPI_F77              = @MPI_F77@
MPI_CLINKER          = $(MPI_CC)
MPI_FLINKER          = $(MPI_F77)

DEBUG_LIBS           = @DEBUG_LIBS@
MPI_INC              = @MPI_INC@
MPI_LIBS             = @MPI_LIBS@
CFLAGS               = @CFLAGS@
FFLAGS               = @FFLAGS@
MPE_INCDIR           = @includebuild_dir@
MPE_LIBDIR           = @libbuild_dir@
MPE_SBINDIR          = @sbinbuild_dir@
F2CMPI_LIBS          = @F2CMPI_LIBS@
COLLCHK_LIBS         = -L$(MPE_LIBDIR) @COLLCHK_LIBS@ $(MPI_LIBS)
COLLCHK_FLIBS        = @FLIB_PATH_LEADER@$(MPE_LIBDIR) \
                       $(F2CMPI_LIBS) @COLLCHK_LIBS@ \
                       $(MPI_LIBS)

C_INCS               = -I$(MPE_INCDIR) $(MPI_INC)
F_INCS               = @FINC_PATH_LEADER@$(MPE_INCDIR) $(MPI_INC)
LDFLAGS              = @LDFLAGS@
MPE_BUILD_FORTRAN2C  = @MPE_BUILD_FORTRAN2C@

#### End User configurable options ###

SHELL         = @SHELL@
RM            = @RM@

@VPATH@

srcdir        = @srcdir@

CC_FLAGS      = $(CFLAGS) $(C_INCS) $(MPE_COPTS)
FC_FLAGS      = $(FFLAGS) $(F_INCS) $(MPE_FOPTS)
CC_LDFLAGS    = $(LDFLAGS) $(CFLAGS) $(MPE_LDOPTS)
FC_LDFLAGS    = $(LDFLAGS) $(FFLAGS) $(MPE_LDOPTS)

.SUFFIXES: .c .f .@OBJEXT@ @EXEEXT@

C_SRC         = wrong_composite.c wrong_scatterv.c \
                wrong_int_byte.c wrong_root.c \
                composite.c scatterv.c \
                time_bcast.c time_allreduce.c \
                time_alltoallv.c time_alltoallv0.c
F_SRC         = wrong_reals.f
C_OBJS        = $(C_SRC:.c=.@OBJEXT@)
F_OBJS        = $(F_SRC:.f=.@OBJEXT@)
C_EXECS       = $(C_OBJS:.o=)

OPT_C_EXECS   = time_bcast_nochk@EXEEXT@ time_allreduce_nochk@EXEEXT@ \
                time_alltoallv0_nochk@EXEEXT@ time_alltoallv_nochk@EXEEXT@

OPT_F_EXECS   = wrong_reals@EXEEXT@ wrong_reals_nochk@EXEEXT@

.c.@OBJEXT@:
	$(MPI_CC) $(CC_FLAGS) -c $<

.f.@OBJEXT@:
	$(MPI_F77) $(FC_FLAGS) -c $<

.@OBJEXT@@EXEEXT@:
	$(MPI_CLINKER) $(CC_LDFLAGS) -o $@ $< $(COLLCHK_LIBS)

time_bcast_nochk@EXEEXT@: time_bcast.@OBJEXT@
	$(MPI_CLINKER) $(CC_LDFLAGS) -o $@ $? $(MPI_LIBS)

time_allreduce_nochk@EXEEXT@: time_allreduce.@OBJEXT@
	$(MPI_CLINKER) $(CC_LDFLAGS) -o $@ $? $(MPI_LIBS)

time_alltoallv_nochk@EXEEXT@: time_alltoallv.@OBJEXT@
	$(MPI_CLINKER) $(CC_LDFLAGS) -o $@ $? $(MPI_LIBS)

time_alltoallv0_nochk@EXEEXT@: time_alltoallv0.@OBJEXT@
	$(MPI_CLINKER) $(CC_LDFLAGS) -o $@ $? $(MPI_LIBS)

wrong_reals@EXEEXT@: wrong_reals.@OBJEXT@
	$(MPI_FLINKER) $(FC_LDFLAGS) -o $@ $? $(COLLCHK_FLIBS)

wrong_reals_nochk@EXEEXT@: wrong_reals.@OBJEXT@
	$(MPI_FLINKER) $(FC_LDFLAGS) -o $@ $? $(MPI_LIBS)

default: $(C_OBJS) $(C_EXECS) $(OPT_C_EXECS)

linktest: linktest_C

linktest_C:
	@-$(MPE_SBINDIR)/mpetestlink wrong_int_byte@EXEEXT@ \
	  "*** Link C program with the MPI collective/datatype checking library ....."
	@-echo ; $(MAKE) clean

linktest_F77:
	@-if [ "$(MPE_BUILD_FORTRAN2C)" = "yes" ] ; then \
	    $(MPE_SBINDIR)/mpetestlink wrong_reals@EXEEXT@ \
	    "*** Link F77 program with the MPI collective/datatype checking library ..." ; \
	    $(MAKE) clean ; \
	    echo ; \
	  fi


runtest_C:
	@-$(MPE_SBINDIR)/mpetestexec wrong_int_byte@EXEEXT@ \
	  "*** Test C program with the MPI collective/datatype checking library ....."
	@-echo ; $(MAKE) clean

runtest_F77:
	@-if [ "$(MPE_BUILD_FORTRAN2C)" = "yes" ] ; then \
	    $(MPE_SBINDIR)/mpetestexec wrong_reals@EXEEXT@ \
	    "*** Test F77 program with the MPI collective/datatype checking library ..." ; \
	    $(MAKE) clean ; \
	    echo ; \
	  fi

clean:
	@-$(RM) -f $(C_OBJS) $(F_OBJS) *.@OBJEXT@
	@-$(RM) -f $(C_EXECS) $(OPT_C_EXECS) $(OPT_F_EXECS)

distclean: clean
	@-$(RM) -f Makefile
