#
# ${R_HOME}/etc/Makefile

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

top_builddir = ..
subdir = etc

include $(top_builddir)/Makeconf

distdir = $(top_builddir)/$(PACKAGE)-$(VERSION)/$(subdir)
DISTFILES = Rdconvlib.pl buildlib.pl html-layout.pl \
	Makeconf.in Makefile.in \
	colors.big colors.small Rd.files tasks test-things.Rd \
	gnome-interface.glade
SUBDIRS = Rdoc undoc

EXPORTFILE = @EXPORTFILE@
GNOME_IF_FILES = @GNOME_IF_FILES@

all: Makefile Makeconf R

Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
	@cd $(top_builddir) && \
	  CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= \
	  $(SHELL) ./config.status
Makeconf: $(srcdir)/Makeconf.in $(top_builddir)/config.status
	@cd $(top_builddir) && \
	  CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= \
	  $(SHELL) ./config.status

R:
	@if [ "$(srcdir)" != "." ]; then \
	  $(MAKE) rhome=$(top_builddir) install-perl; \
	  $(MAKE) rhome=$(top_builddir) install-gnome; \
	fi

install: installdirs install-perl install-gnome
	@echo "Installing etc ..."
	@$(INSTALL_DATA) Makeconf $(EXPORTFILE) \
	  $(rhome)/etc
installdirs:
	@$(MKINSTALLDIRS) $(rhome)/etc
install-perl:
	@for f in $(srcdir)/*.pl; do \
	  $(INSTALL_DATA) $$f $(rhome)/etc; \
	done
install-gnome:
	@if test -n "$(GNOME_IF_FILES)"; then \
	  for f in "$(GNOME_IF_FILES)"; do \
	    $(INSTALL_DATA) $(srcdir)/$$f $(rhome)/etc; \
	  done; \
	fi
install-strip: install
uninstall:
	@echo "Uninstalling etc ..."
	@if test -d $(rhome)/etc -a \
	  "`cd $(rhome); pwd`" != "`cd $(top_builddir); pwd`"; then \
	  (cd $(rhome)/etc && \
	    rm -f *.pl Makeconf $(EXPORTFILE) $(GNOME_IF_FILES)); \
	  rmdir $(rhome)/etc 2> /dev/null \
	    || echo "  subdir etc not removed"; \
	fi

mostlyclean: clean
clean:
	@if [ "$(srcdir)" != "." ]; then \
	  rm -f *.pl $(GNOME_IF_FILES); \
	fi
	@rm -f $(EXPORTFILE)
distclean: clean
	@rm -f Makeconf 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
	@((cd $(srcdir); \
	      $(TAR) -c -f - --exclude=CVS $(SUBDIRS)) \
	    | (cd $(distdir); $(TAR) -x -f -)) \
	  || exit 1; \
