#
# ${R_HOME}/doc/html/Makefile

VPATH = @srcdir@
srcdir = @srcdir@
top_srcdir = @top_srcdir@

top_builddir = ../..
subdir = doc/html

include $(top_builddir)/Makeconf

distdir = $(top_builddir)/$(PACKAGE)-$(VERSION)/$(subdir)
## <FIXME>
## Remove function.html eventually ...
INSTFILES = \
	R.css \
	left.jpg logo.jpg logosm.jpg right.jpg up.jpg \
	about.html \
	faq.html \
	function.html \
	packages-head.html \
	resources.html \
	template.html \
	thanks.html
## </FIXME>
## FIXME:
## build-help really should not create package.html in *this* directory.
CLEANFILES = packages.html packages-foot.html
## </FIXME>
DISTFILES = Makefile.in $(INSTFILES) index-default.html R-admin.html
SUBDIRS = search

OBJECTS = index.html

all: Makefile R

Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
	@cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@

R: Makefile $(OBJECTS)
	@if test "$(BUILDDIR_IS_SRCDIR)" = no ; then \
	  $(MAKE) rhome=$(top_builddir) install-sources; \
	fi
	@for d in $(SUBDIRS); do \
	  (cd $${d} && $(MAKE) $@) || exit 1; \
	done

index.html: FORCE
	@$(PERL) $(top_srcdir)/tools/linkcheck.pl \
	  $(srcdir)/index-default.html > $@ || \
	  $(INSTALL_DATA) $(srcdir)/index-default.html $@
FORCE:

install: install-message installdirs install-sources
	@for f in $(OBJECTS); do \
	  $(INSTALL_DATA) $${f} $(rhome)/$(subdir); \
	done
	@for d in $(SUBDIRS); do \
	  (cd $${d} && $(MAKE) $@) || exit 1; \
	done
installdirs:
	@$(MKINSTALLDIRS) $(rhome)/$(subdir)
install-message:
	@echo "installing $(subdir) ..."
install-sources:
	@for f in $(INSTFILES); do \
	  $(INSTALL_DATA) $(srcdir)/$${f} $(rhome)/$(subdir); \
	done
install-strip: install
uninstall:
	@echo "uninstalling $(subdir) ..."
	@for d in $(SUBDIRS); do \
	  (cd $${d} && $(MAKE) $@); \
	done
	@for f in $(CLEANFILES) $(INSTFILES) $(OBJECTS); do \
	  rm -f $(rhome)/$(subdir)/$${f}; \
	done
	@rmdir $(rhome)/$(subdir) 2>/dev/null \
	  || echo "  subdir $(subdir) not removed"

mostlyclean:
clean:
	@for d in $(SUBDIRS); do \
	  (cd $${d} && $(MAKE) $@); \
	done
	@if test "$(BUILDDIR_IS_SRCDIR)" = no ; then \
	  rm -f $(INSTFILES); \
	fi
	@rm -f $(CLEANFILES) $(OBJECTS)
distclean: clean
	@for d in $(SUBDIRS); do \
	  (cd $${d} && $(MAKE) $@); \
	done
	@rm -f Makefile
maintainer-clean: distclean

distdir: $(DISTFILES)
	@for f in $(DISTFILES); do \
	  test -f $(distdir)/$${f} \
	    || ln $(srcdir)/$${f} $(distdir)/$${f} 2>/dev/null \
	    || cp -p $(srcdir)/$${f} $(distdir)/$${f}; \
	done
	@for d in $(SUBDIRS); do \
	  if test -f $${d}/Makefile; then \
	    test -d $(distdir)/$${d} \
	      || mkdir $(distdir)/$${d} \
	      || exit 1; \
	    chmod 755 $(distdir)/$${d}; \
	    (cd $${d} && $(MAKE) distdir) \
	      || exit 1; \
	  else \
	    ((cd $(srcdir); $(TAR) -c -f - --exclude=CVS $${d}) \
	        | (cd $(distdir); $(TAR) -x -f -)) \
	      || exit 1; \
	  fi; \
	done