VERSION=0.92
SUBDIRS = stdio test

srcdir = .

#### package, host, target, and site dependent Makefile fragments come in here.
##

DIST_NAME=iostream-${VERSION}
DIST_FILE=$(DIST_NAME).tar.Z
${DIST_FILE}: dist
.PHONY: dist
dist: FORCE
	-mkdir $(DIST_NAME)
	cd $(DIST_NAME); \
	  ln -s $(srcdir)/../Make.defs .; \
	  ln -s $(srcdir)/../g++-include/_G_config.h .; \
	  ln -s $(srcdir)/* \
	    $(srcdir)/../../configure $(srcdir)/../../config.sub .; \
	  rm -rf test stdio *~ CVS configure.in; \
	  sed -e 's|\.\./||' <$(srcdir)/configure.in > configure.in; \
	  mkdir test stdio
	cd $(DIST_NAME)/stdio; \
	  ln -s $(srcdir)/stdio/* .; \
	  rm -rf *~ CVS configure.in; \
	  sed -e 's|\.\./||' <$(srcdir)/stdio/configure.in > configure.in
	cd $(DIST_NAME)/test; \
	  ln -s $(srcdir)/test/* .; \
	  rm -rf *~ CVS configure.in; \
	  sed -e 's|\.\./||' <$(srcdir)/test/configure.in > configure.in
	tar -c -h -f - $(DIST_NAME) | compress -c >$(DIST_NAME).tar.Z
	rm -rf $(DIST_NAME)

IOSTREAM_OBS= streambuf.o stdstrbufs.o iostream.o stdstreams.o strstream.o \
  indstream.o PlotFile.o SFile.o fstream.o parsestream.o stream.o makebuf.o \
  editbuf.o filebuf.o sgetline.o igetline.o igetsb.o procbuf.o \
  sbufvform.o sbufvscan.o stdiostream.o floatconv.o outfloat.o iomanip.o


# The following include files are merely to provide partial
# compatibilty with the old stream library from libg++.

COMPAT_INCLUDES = istream.h ostream.h stream.h

# The following include files are publicly visible, and
# should be installed where user programs can find them.

USER_INCLUDES = editbuf.h fstream.h iomanip.h iostream.h indstream.h \
  parsestream.h streambuf.h strstream.h PlotFile.h SFile.h procbuf.h \
  stdiostream.h $(COMPAT_INCLUDES)

# The following include files are private to the implementation.

INTERNAL_INCLUDES = ioprivate.h floatio.h

DEPEND_SOURCES = $(srcdir)/*.C
# ../libg++.a depends on the stamp file.
stamp: $(IOSTREAM_OBS)
	@touch stamp

$(TARGETLIB): stamp
	-rm -f $(TARGETLIB)
	$(AR) $(AR_FLAGS) $(TARGETLIB) $(IOSTREAM_OBS)
	$(RANLIB) $(TARGETLIB)

.PHONY: add-to-targetlib
# Invoked from other directories, overriding $(TARGETLIB).
add-to-targetlib:
	$(AR) $(AR_FLAGS) $(TARGETLIB) $(IOSTREAM_OBS)

.PHONY: install-include-files
install-include-files:
	[ -d $(gxx_includedir) ] || mkdir $(gxx_includedir)
	cd $(srcdir); \
	for FILE in $(USER_INCLUDES) ; do \
		rm -f $(gxx_includedir)/$$FILE ; \
		$(INSTALL_DATA) $$FILE $(gxx_includedir)/$$FILE ; \
		chmod a-x $(gxx_includedir)/$$FILE ; \
	done
