The R Project SVN R

Rev

Rev 47593 | Rev 47861 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

#-*- Makefile -*-
#
# ${RHOME}/tests/Makefile.win

RHOME=../..
include $(RHOME)/src/gnuwin32/MkRules
include $(RHOME)/share/make/vars.mk

R = $(RHOME)/bin/Rterm --vanilla LANGUAGE=en
RLIB = $(RHOME)/library

EX_IN_BASE = $(R_PKGS_BASE:=-Ex.R)
EX_OUT_BASE = $(EX_IN_BASE:.R=.Rout)

RDIFF = $(RHOME)/bin/Rcmd Rdiff
RVAL_IF_DIFF = 0

.PHONY: FORCE

.SUFFIXES:
.SUFFIXES: .R .Rout

all:  $(EX_OUT_BASE)

## if we don't FORCE here we have to work out a dependence on R.
$(EX_IN_BASE): FORCE $(RHOME)/share/R/massage-examples.R

FORCE:

base-Ex.R: $(RLIB)/base/R-ex/Rex.zip
datasets-Ex.R: $(RLIB)/datasets/R-ex/Rex.zip
grDevices-Ex.R: $(RLIB)/grDevices/R-ex/Rex.zip
graphics-Ex.R: $(RLIB)/graphics/R-ex/Rex.zip
grid-Ex.R: $(RLIB)/grid/R-ex/Rex.zip
methods-Ex.R: $(RLIB)/methods/R-ex/Rex.zip
splines-Ex.R: $(RLIB)/splines/R-ex/Rex.zip
stats-Ex.R: $(RLIB)/stats/R-ex/Rex.zip
stats4-Ex.R: $(RLIB)/stats4/R-ex/Rex.zip
tcltk-Ex.R: $(RLIB)/tcltk/R-ex/Rex.zip
tools-Ex.R: $(RLIB)/tools/R-ex/Rex.zip
utils-Ex.R: $(RLIB)/utils/R-ex/Rex.zip

%-Ex.R: 
    @$(ECHO) "Massaging examples into '$*-Ex.R' ..."
    @if test -f $(RLIB)/$*/R-ex/Rex.zip; then \
      (cd $(RLIB)/$*/R-ex; unzip -oq Rex); \
      LC_ALL=C $(RHOME)/bin/rterm --slave --vanilla < $(RHOME)/share/R/massage-examples.R --args $* $(RLIB)/$*/R-ex/*.R > $@; \
      (cd $(RLIB)/$*/R-ex; $(RM) -f *.R); \
    else \
      LC_ALL=C $(RHOME)/bin/rterm --slave --vanilla < $(RHOME)/share/R/massage-examples.R --args $* $(RLIB)/$*/R-ex/*.R > $@; \
    fi

.R.Rout:
    @if test -f $@ ; then \
      mv $@ $@.prev ; fi
    @rm -f $@.fail
    @$(ECHO) "Running examples in '$<' ..."
    @$(R) R_LIBS='$(RLIB);$(R_LIBS)' < $< > $@ 2>&1 \
      || (mv  $@ $@.fail && exit 1)
    @if test -f $@.prev ; then \
      mv $@ $@.fail; \
      echo -n "Comparing \`$@' to \`$@.prev' ..."; \
      $(RDIFF) $@.fail $@.prev 0 || exit 1; \
      mv $@.fail $@; \
      echo "OK"; \
    fi

clean:
    -@rm -f *.R *.Rout *.Rd* *.ps *.tex *.dat* data foo* ex*.gz
distclean: clean
    -@rm -f *.R*bak *.R*bakk *.R*prev .RData sink-examp.txt