#
# ${R_HOME}/etc/Makefile

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

top_builddir = ..
subdir = etc

include $(top_builddir)/Makeconf

## <NOTE>
## Need target rules for all elements of SOURCES/OBJECTS.
SOURCES = Makeconf.in Renviron.in
OBJECTS = $(SOURCES:.in=)
## </NOTE>
distdir = $(top_builddir)/$(PACKAGE)-$(VERSION)/$(subdir)
DISTFILES = Makefile.in $(SOURCES)

EXPORTFILES = @USE_EXPORTFILES_TRUE@ R.exp Rlapack.exp

CLEANFILES = $(EXPORTFILES)
DISTCLEANFILES = $(OBJECTS) Makefile

all: Makefile R

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

## <NOTE>
## Seems we need target rules for creating FOO from FOO.in: pattern
## rules ('%:%.in') are not portable, and some versions of Make do not
## allow separated dependencies for single suffix rules.
Makeconf: $(srcdir)/Makeconf.in $(top_builddir)/config.status
	@cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@
Renviron: $(srcdir)/Renviron.in $(top_builddir)/config.status
	@cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@
## </NOTE>

R: $(OBJECTS)

install: installdirs
	@echo "installing $(subdir) ..."
	@for f in $(OBJECTS) $(EXPORTFILES); do \
	  $(INSTALL_DATA) $${f} "$(rhome)/$(subdir)"; \
	done
installdirs:
	@$(MKINSTALLDIRS) "$(rhome)/$(subdir)"
install-strip: install

uninstall:
	@echo "uninstalling $(subdir) ..."
	@if test -d "$(rhome)/$(subdir)" \
	  && test "`cd \"$(rhome)\"; $(GETWD)`" \
	       != "`cd $(top_builddir); $(GETWD)`"; then \
	  (cd "$(rhome)/$(subdir)" && \
	    rm -f $(OBJECTS) $(EXPORTFILES)); \
	  rmdir "$(rhome)/$(subdir)" 2> /dev/null \
	    || echo "  subdir $(subdir) not removed"; \
	fi

mostlyclean: clean
clean:
	-@test -z "$(CLEANFILES)" || rm -f $(CLEANFILES)
distclean: clean
	-@test -z "$(DISTCLEANFILES)" || rm -f $(DISTCLEANFILES)
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