CC          = @CC@
AR          = @AR@
RANLIB      = @RANLIB@
LIBNAME     = @LIBNAME@
MPI         = @MPI@
srcdir      = @srcdir@
CC_SHL      = @CC_SHL@
SHLIBNAME   = @SHLIBNAME@

INCLUDE_DIR = -I@MPI_INCLUDE_DIR@ -I${srcdir}/../include -I../include \
	-I../../include -I${srcdir}/../../../../../src/include \
	-I../../../../../src/include
CFLAGS      = @CPPFLAGS@ @CFLAGS@ $(INCLUDE_DIR)

top_builddir  = @master_topbuild_dir@
LIBTOOL       = @LIBTOOL@
C_COMPILE_SHL = $(CC_SHL) 

@VPATH@

AD_OBJECTS = ad_close.o ad_init.o ad_end.o ad_open.o flatten.o \
      async_list.o req_malloc.o malloc.o ad_read_coll.o eof_offset.o \
      ad_write_coll.o lock.o ad_read_str.o ad_write_str.o iscontig.o \
      get_fp_posn.o ad_seek.o ad_delete.o ad_flush.o ad_hints.o error.o \
      ad_fstype.o ad_get_sh_fp.o ad_set_sh_fp.o shfp_fname.o byte_offset.o \
      status_setb.o ad_aggregate.o cb_config_list.o \
      ad_read_str_naive.o ad_set_view.o ad_iopen.o \
      ad_write_str_naive.o ad_resize.o ad_read.o ad_write.o ad_iread.o \
      ad_iwrite.o ad_done.o ad_wait.o adi_close.o ad_prealloc.o ad_fcntl.o \
      ad_iread_fake.o ad_iwrite_fake.o ad_done_fake.o ad_wait_fake.o \
      ad_subarray.o ad_darray.o strfns.o

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

.SUFFIXES: $(SUFFIXES) .p .lo

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

$(LIBNAME): $(AD_OBJECTS)
	$(AR) $(LIBNAME) $(AD_OBJECTS)
	$(RANLIB) $(LIBNAME) 

AD_LOOBJECTS = $(AD_OBJECTS:.o=.lo)

$(SHLIBNAME).la: $(AD_LOOBJECTS)
	$(AR) $(SHLIBNAME).la $(AD_LOOBJECTS)

clean:
	@rm -f *.o *.lo *.gcno *.gcda *.bb *.bbg
	@rm -f ${srcdir}/*.gcno ${srcdir}/*.gcda 
	@rm -f ${srcdir}/*.bb ${srcdir}/*.bbg

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