CC          = gcc
AR          = ar cr
LIBNAME     = /proj/tpfimos/larour/Libraries/linux/mpich2-1.0.2p1/lib/libmpich.a
RANLIB      = ranlib
srcdir      = /proj/tpfimos/larour/Libraries/linux/mpich2-1.0.2p1/src/mpi/romio/mpi-io
CC_SHL      = ${CC} -fpic
SHLIBNAME   = /proj/tpfimos/larour/Libraries/linux/mpich2-1.0.2p1/lib/libmpich

INCLUDE_DIR = -I. -I${srcdir} -I../include -I${srcdir}/../adio/include -I../adio/include -I${srcdir}/../../../include  -I../../../include 
CFLAGS      =  -I/proj/tpfimos/larour/Libraries/linux/mpich2-1.0.2p1/src/binding/f77 -I/proj/tpfimos/larour/Libraries/linux/mpich2-1.0.2p1/src/binding/f77 -I/proj/tpfimos/larour/Libraries/linux/mpich2-1.0.2p1/src/mpid/ch3/include -I/proj/tpfimos/larour/Libraries/linux/mpich2-1.0.2p1/src/mpid/ch3/include -I/proj/tpfimos/larour/Libraries/linux/mpich2-1.0.2p1/src/mpid/common/datatype -I/proj/tpfimos/larour/Libraries/linux/mpich2-1.0.2p1/src/mpid/common/datatype -I/proj/tpfimos/larour/Libraries/linux/mpich2-1.0.2p1/src/mpid/ch3/channels/sock/include -I/proj/tpfimos/larour/Libraries/linux/mpich2-1.0.2p1/src/mpid/ch3/channels/sock/include -I/proj/tpfimos/larour/Libraries/linux/mpich2-1.0.2p1/src/mpid/common/sock -I/proj/tpfimos/larour/Libraries/linux/mpich2-1.0.2p1/src/mpid/common/sock -I/proj/tpfimos/larour/Libraries/linux/mpich2-1.0.2p1/src/mpid/common/sock/poll -I/proj/tpfimos/larour/Libraries/linux/mpich2-1.0.2p1/src/mpid/common/sock/poll  -O -DFORTRANDOUBLEUNDERSCORE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -DHAVE_ROMIOCONF_H $(MPIOPROFILE) $(INCLUDE_DIR)

top_builddir  = /proj/tpfimos/larour/Libraries/linux/mpich2-1.0.2p1
LIBTOOL       = 
C_COMPILE_SHL = $(CC_SHL) 

VPATH = .:${srcdir}

# mpi_sources gives the files that implement the MPI IO routines.  
# This is used for the MPICH2 documentation target, and does not
# include files either not used in MPICH2 or that do not contain
# documentation entries.
mpi_sources = close.c read.c open.c write.c set_view.c \
      iread.c iwrite.c \
      seek.c get_posn.c \
      delete.c read_all.c read_at.c \
      read_atall.c iread_at.c iwrite_at.c write_all.c get_bytoff.c \
      write_at.c write_atall.c get_view.c get_group.c get_amode.c \
      get_extent.c fsync.c get_atom.c set_atom.c \
      set_size.c get_size.c prealloc.c file_f2c.c file_c2f.c \
      set_info.c get_info.c \
      rd_atallb.c rd_atalle.c read_allb.c read_alle.c wr_atallb.c \
      wr_atalle.c write_allb.c write_alle.c \
      get_posn_sh.c iread_sh.c read_sh.c write_sh.c \
      iwrite_sh.c seek_sh.c read_ord.c read_orde.c write_ordb.c \
      read_ordb.c write_ord.c write_orde.c mpiu_greq.c register_datarep.c

# EXTRA objects are ones that need to be included for all but MPICH2
MPIO_OBJECTS = close.o read.o open.o write.o set_view.o \
      iread.o iwrite.o \
      seek.o get_posn.o \
      delete.o read_all.o read_at.o \
      read_atall.o iread_at.o iwrite_at.o write_all.o get_bytoff.o \
      write_at.o write_atall.o get_view.o get_group.o get_amode.o \
      get_extent.o fsync.o get_atom.o set_atom.o \
      set_size.o get_size.o prealloc.o file_f2c.o file_c2f.o \
      set_info.o get_info.o \
      rd_atallb.o rd_atalle.o read_allb.o read_alle.o wr_atallb.o \
      wr_atalle.o write_allb.o write_alle.o \
      get_posn_sh.o iread_sh.o read_sh.o write_sh.o \
      iwrite_sh.o seek_sh.o read_ord.o read_orde.o write_ordb.o \
      read_ordb.o write_ord.o write_orde.o mpiu_greq.o mpich2_fileutil.o \
      register_datarep.o

# MPIO_REQOBJECTS are the routines that provide the MPIO_Wait etc.
# routines (iotest.o, iowait.o iowaitall.o iowaitany.o iotestall.o
# iotestany.o iowaitsome.o and iotestsome.o)
MPIO_REQOBJECTS = 

# Either get_errh.o set_errh.o or empty 
MPIO_EXTRA_OBJECTS =  

# mpich2_fileutil.p is not included because it does not include any
# name-shifted functions
MPIO_TMP_POBJECTS = close.p read.p open.p write.p get_extent.p \
      iread.p iwrite.p \
      seek.p \
      delete.p read_all.p read_at.p \
      read_atall.p iread_at.p iwrite_at.p get_posn.p \
      write_all.p write_at.p write_atall.p get_bytoff.p \
      set_view.p get_view.p get_group.p get_amode.p \
      fsync.p get_atom.p set_atom.p set_size.p get_size.p prealloc.p \
      file_f2c.p file_c2f.p set_info.p get_info.p \
      rd_atallb.p rd_atalle.p read_allb.p read_alle.p wr_atallb.p \
      wr_atalle.p write_allb.p write_alle.p \
      get_posn_sh.p iread_sh.p read_sh.p write_sh.p \
      iwrite_sh.p seek_sh.p read_ord.p read_orde.p write_ordb.p \
      read_ordb.p write_ord.p write_orde.p register_datarep.p

# Either get_errh.p set_errh.p or empty 
MPIO_EXTRA_TMP_POBJECTS =  

# _mpich2_fileutil.o is not included because it does not include any 
# name-shifted functions
MPIO_REAL_POBJECTS = _close.o _read.o _open.o _get_extent.o \
      _write.o _set_view.o _seek.o _read_at.o _prealloc.o \
      _iread.o _iwrite.o \
      _get_posn.o \
      _delete.o _read_all.o _get_bytoff.o \
      _read_atall.o _iread_at.o _iwrite_at.o _get_group.o _get_amode.o \
      _write_all.o _write_at.o _write_atall.o _get_view.o \
      _fsync.o _get_atom.o _set_atom.o _set_size.o _get_size.o \
      _file_f2c.o _file_c2f.o \
      _set_info.o _get_info.o \
      _rd_atallb.o _rd_atalle.o _read_allb.o _read_alle.o _wr_atallb.o \
      _wr_atalle.o _write_allb.o _write_alle.o \
      _get_posn_sh.o _iread_sh.o _read_sh.o _write_sh.o \
      _iwrite_sh.o _seek_sh.o _read_ord.o _read_orde.o _write_ordb.o \
      _read_ordb.o _write_ord.o _write_orde.o _register_datarep.o

# Either _get_errh.o _set_errh.o or empty 
MPIO_EXTRA_REAL_POBJECTS =  

all: $(LIBNAME)
	@if [ "gcc" != "none" ] ; then \
	    $(MAKE) $(SHLIBNAME).la ;\
	fi

.SUFFIXES: $(SUFFIXES) .p .sp .lo .man .html .latex .txt 

.c.o:
	$(CC) $(CFLAGS) -c $<
.c.lo:
	$(C_COMPILE_SHL) $(CFLAGS) -c $< -o _s$*.o
	@mv -f _s$*.o $*.lo

.c.p:
	@cp $(srcdir)/$*.c _$*.c
	$(CC) $(CFLAGS) -c _$*.c
	@rm -f _$*.c
.c.sp:
	$(C_COMPILE_SHL) $(CFLAGS) -c $< -o _$*.lo


profile: $(MPIO_TMP_POBJECTS) $(MPIO_EXTRA_TMP_POBJECTS)
	$(AR) $(LIBNAME) $(MPIO_REAL_POBJECTS) $(MPIO_EXTRA_REAL_POBJECTS)
	$(RANLIB) $(LIBNAME) 
	@if [ "gcc" != "none" ] ; then \
	    $(MAKE) P$(SHLIBNAME).la ;\
	fi
	@rm -f _*.o

coverage:
	-@for file in  ${MPIO_OBJECTS:.o=.c} ; do \
		gcov -b -f $$file ; done

$(LIBNAME): $(MPIO_OBJECTS) $(MPIO_EXTRA_OBJECTS)
	$(AR) $(LIBNAME) $(MPIO_OBJECTS) $(MPIO_EXTRA_OBJECTS)
	$(RANLIB) $(LIBNAME)

MPIO_LOOBJECTS = $(MPIO_OBJECTS:.o=.lo)
MPIO_EXTRA_LOOBJECTS = $(MPIO_EXTRA_OBJECTS:.o=.lo)

$(SHLIBNAME).la: $(MPIO_LOOBJECTS) $(MPIO_EXTRA_LOOBJECTS)
	$(AR) $(SHLIBNAME).la $(MPIO_LOOBJECTS) $(MPIO_EXTRA_LOOBJECTS)

# --------------------------------------------------------------------------
# We use P$(SHLBNAME) simply to distinguish the regular lib build from the
# profiling library build
MPIO_LOPOBJECTS = $(MPIO_REAL_POBJECTS:.o=.lo)
MPIO_EXTRA_LOPOBJECTS = $(MPIO_EXTRA_REAL_POBJECTS:.o=.lo)
MPIO_TMP_LOPOBJECTS = ${MPIO_TMP_POBJECTS:.p=.sp}
MPIO_EXTRA_LOPOBJECTS = ${MPIO_EXTRA_TMP_OBJECTS:.p=.sp}
P$(SHLIBNAME).la: $(MPIO_TMP_LOPOBJECTS) $(MPIO_EXTRA_TMP_LOPOBJECTS)
	$(AR) $(SHLIBNAME).la $(MPIO_LOPOBJECTS) $(MPIO_EXTRA_LOPOBJECTS)
# --------------------------------------------------------------------------
clean:
	@rm -f *.o *.lo

# MPICH2 documentation targets
master_top_srcdir = /proj/tpfimos/larour/Libraries/linux/mpich2-1.0.2p1
DOCTEXT = false
.c.man:
	$(DOCTEXT) -mpath ../../../../man/man3 -ext 3 -heading MPI \
		-quotefmt ${master_top_srcdir}/maint/docnotes $<
.c.latex:
	$(DOCTEXT) -latex -mpath ../../../../doc/refman  -heading MPI \
		-quotefmt ${master_top_srcdir}/maint/docnotes $<
.c.html:
	$(DOCTEXT) -html -mpath ../../../../www/www3  -heading MPI \
		-quotefmt ${master_top_srcdir}/maint/docnotes $<
mandoc: ${mpi_sources:.c=.man}
latexdoc: ${mpi_sources:.c=.latex}
htmldoc: ${mpi_sources:.c=.html}

tags: TAGS
SOURCES = ${mpi_sources}
HEADERS = 
TAGS:${HEADERS} ${SOURCES}
	here=`cd ../../../.. && pwd` ; cd ${srcdir} && etags -o $$here/TAGS --append ${HEADERS} ${SOURCES}
