#
#  (C) 1993 by Argonne National Laboratory and Mississipi State University.
#      All rights reserved.  See COPYRIGHT in top-level directory.
#

ALL: default
##### User configurable options #####

ARCH        = @ARCH@
COMM        = @COMM@
BOPT        = @BOPT@
MPIR_HOME   = @MPIR_HOME@
CC          = @CC@
F77         = @F77@
AR          = @AR@
RANLIB      = @RANLIB@
INCLUDE_DIR = @INCLUDE_PATH@ -I../../mpid/@DEVICE@ -I../../include
DEVICE      = @DEVICE@
OPTFLAGS    = @OPTFLAGS@

### End User configurable options ###

SHELL = /bin/sh

DEVICE_INCLUDE = ../../mpid/$(DEVICE)/dmch.h

MPI_INCLUDE    = ../../include/mpi.h ../../include/mpi_bc.h \
                 ../../include/mpir.h ../../include/mpi_ad.h \
		 ../../include/mpisys.h 
DEVICE_LIB = 
CFLAGS = @CFLAGS@ $(OPTFLAGS) @OPTFLAGSC@ $(INCLUDE_DIR) \
	-DMPI_$(ARCH) $(MPIPROFILE)

LIBS = ../../lib/$(ARCH)/$(COMM)/lib@MPILIBNAME@.a $(DEVICE_LIB)
MPI_CSOURCES = util_hbt.c mpirutil.c sbcnst.c ptrcvt.c bsendutil.c tr.c
MPI_SOURCES =  $(MPI_CSOURCES)
MPI_COBJECTS = util_hbt.o mpirutil.o sbcnst.o ptrcvt.o bsendutil.o tr.o
MPI_OBJECTS =  $(MPI_COBJECTS)
MPI_WOBJECTS = 
default: ../../lib/$(ARCH)/$(COMM)/lib@MPILIBNAME@.a

bsendutil.o: bsendutil.c bsendutil2.c
profile: ../../lib/$(ARCH)/$(COMM)/libp@MPILIBNAME@.a

$(MPI_OBJECTS) :  $(MPI_INCLUDE)

# default_all is the same as default, but without the RANLIB.  This
# can speed up the build (ranlibs can take a LONG time).  profile_all 
# is the same, but for the profile library
default_all: $(MPI_OBJECTS)
	$(AR) ../../lib/$(ARCH)/$(COMM)/lib@MPILIBNAME@.a $?
profile_all: $(MPI_OBJECTS)
	$(AR) ../../lib/$(ARCH)/$(COMM)/libp@MPILIBNAME@.a $?
wrapperlib: $(MPI_WOBJECTS)
	if [ "$(MPI_WOBJECTS)" != "" ] ; then \
	$(AR) ../../lib/$(ARCH)/$(COMM)/libf@MPILIBNAME@.a $?	; fi

wrappers:
#	../../util/bfort -ferr -mpi -mnative -mapptr -ptrprefix MPIR_ \
#		-anyname -I pubinc $(MPI_CSOURCES)	

manpages:
	../../util/doctext -mpath ../../man/man3 -ext 3 -I pubinc \
	   -index ../../www.index -jumpfile ../../jumpfile.list \
	   -indexdir "http:/www.mcs.anl.gov/mpi/www/www3" -heading MPI \
		-quotefmt ../../util/fortnotes ../../util/errnotes \
		$(MPI_CSOURCES)
	../../util/doc2lt $(MPI_CSOURCES) >> ../../rsum.tmp

wwwpages:
	../../util/doctext -html -mpath ../../www/www3 -I pubinc \
	   -index ../../www.index -jumpfile ../../jumpfile.list \
	   -mapref $(MPIR_HOME)/util/mpis.cit \
	   -indexdir "http:/www.mcs.anl.gov/mpi/www/www3" -heading MPI \
		-quotefmt ../../util/fortnotes ../../util/errnotes \
		$(MPI_CSOURCES)

source_names:
	@echo $(MPI_CSOURCES)

.c.o:
	$(CC) $(CFLAGS) -c $*.c $(MPI_PROFILE)

../../lib/$(ARCH)/$(COMM)/lib@MPILIBNAME@.a: $(MPI_OBJECTS) 
	$(AR) $@ $?
	$(RANLIB) $@

../../lib/$(ARCH)/$(COMM)/libp@MPILIBNAME@.a: $(MPI_OBJECTS) 
	$(AR) $@ $?
	$(RANLIB) $@

clean:
	/bin/rm -f *.o *~ 
