#
# ${R_HOME}/tests/Examples/Makefile

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

top_builddir = ../..
subdir = tests/Examples

include $(top_builddir)/Makeconf

distdir = $(top_builddir)/$(PACKAGE)-$(VERSION)/$(subdir)
DISTFILES = Makefile.in  Makefile.win

R_EXE = $(top_builddir)/bin/R --slave --vanilla

all: Makefile test-Examples-Base

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

test-Examples: test-Examples-Base

## Should this go and update the R-ex directories?  It used to ...
## Who does make check but not make? -- maybe better to check what was made.
test-Examples-Base: Makefile
	@$(ECHO) "tools::testInstalledPackages(scope='base', types='examples')" | $(R_EXE)


## <NOTE>
## We do *not* want this to be added to test-Examples conditional on
## @USE_RECOMMENDED_PACKAGES_TRUE@.
## 'make check-all' is used for running test-Examples-Recommended in
## addition to 'make check'.
test-Examples-Recommended: test-Examples-Base
	@$(ECHO) "tools::testInstalledPackages(scope='recommended', types='examples')" | $(R_EXE)
## </NOTE>

mostlyclean: clean
clean:
	-@rm -f *.R *.Rout *.Rd* *.ps *.tex *.dat* data foo* ex*.gz Makedeps
distclean: clean
	-@rm -f *.R*prev .RData sink-examp.txt 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
