#
#  Makefile for the SGML summarizers for the Essence system.
#
prefix = @prefix@
INSTALL_BINDIR	= $(prefix)/bin
INSTALL_LIBDIR	= $(prefix)/lib
INSTALL_UTILDIR	= $(INSTALL_LIBDIR)/gatherer
INSTALL_MANDIR 	= $(prefix)/man

CC		= @CC@
INSTALL		= @INSTALL@
INSTALL_BIN 	= @INSTALL_PROGRAM@
INSTALL_FILE 	= @INSTALL_DATA@
RANLIB		= @RANLIB@
LN_S		= @LN_S@
XTRA_LIBS	= @XTRA_LIBS@

SUBDIRS		= sgmls

SCRIPTS		= SGML.sum IMS-DOCUMENT.sum

all clean:
	@for dir in $(SUBDIRS); do \
		echo Making $@ in $$dir; \
		(cd $$dir; $(MAKE) $(MFLAGS) \
			CC="$(CC)" \
			INSTALL="$(INSTALL)" \
			INSTALL_BIN="$(INSTALL_BIN)" \
			INSTALL_FILE="$(INSTALL_FILE)" \
			RANLIB="$(RANLIB)" \
			INSTALL_BINDIR="$(INSTALL_BINDIR)" \
			INSTALL_UTILDIR="$(INSTALL_UTILDIR)" \
			INSTALL_LIBDIR="$(INSTALL_LIBDIR)" \
			INSTALL_MANDIR="$(INSTALL_MANDIR)" \
		$@); \
	done

install:	all
	@for f in $(SCRIPTS); do \
		if [ -f $$f ]; then \
			echo $(INSTALL_BIN) $$f $(INSTALL_UTILDIR); \
			$(INSTALL_BIN) $$f $(INSTALL_UTILDIR); \
		else \
			/bin/true; \
		fi; \
	done
	cp -rp sgmls-lib $(INSTALL_UTILDIR)
	@for dir in $(SUBDIRS); do \
		echo Making $@ in $$dir; \
		(cd $$dir; $(MAKE) $(MFLAGS) \
			CC="$(CC)" \
			INSTALL="$(INSTALL)" \
			INSTALL_BIN="$(INSTALL_BIN)" \
			INSTALL_FILE="$(INSTALL_FILE)" \
			RANLIB="$(RANLIB)" \
			INSTALL_BINDIR="$(INSTALL_BINDIR)" \
			INSTALL_UTILDIR="$(INSTALL_UTILDIR)" \
			INSTALL_LIBDIR="$(INSTALL_LIBDIR)" \
			INSTALL_MANDIR="$(INSTALL_MANDIR)" \
		$@); \
	done
	@if [ -d rbmaker ]; then \
		echo $(INSTALL_BIN) rbmaker/rbmaker.`uname -sr | sed -e 's/ /_/g'` $(INSTALL_UTILDIR)/rbmaker; \
		$(INSTALL_BIN) rbmaker/rbmaker.`uname -sr | sed -e 's/ /_/g'` $(INSTALL_UTILDIR)/rbmaker; \
		echo cp -rp rbmaker.dat $(INSTALL_UTILDIR); \
		cp -rp rbmaker.dat $(INSTALL_UTILDIR); \
	else \
		/bin/true; \
	fi
