The R Project SVN R

Rev

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

#-*- Makefile -*-
#
# ${R_HOME}/src/library/Makefile

srcdir = .
top_srcdir = ../..
top_builddir = ../..

include ../../share/make/vars.mk
include ../gnuwin32/MkRules #for USE_CHM

ECHO = echo
MKINSTALLDIRS = mkdir -p
INSTALL_DATA = cp
RVER = $(shell cut -d' ' -f1 ../../VERSION | sed -n 1p)
RHOME = $(shell ../gnuwin32/Rpwd.exe ../..)

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

.SUFFIXES: .Rdts

all: R

## beware there is a bootstrapping problem here: tools uses tools to
## dump its namespace. So it works initially, but not to update.
R:
    @$(MKINSTALLDIRS) $(top_builddir)/library
    @for pkg in $(R_PKGS_BASE); do \
      $(MAKE) -C $${pkg} -f Makefile.win RHOME=$(RHOME) \
        R_OSTYPE=windows VERSION=$(RVER) all install-tests || exit 1; \
    done
    @(cd base && $(MAKE) -f Makefile.win RHOME=$(RHOME) mkdesc)
    @$(ECHO) "tools:::.vinstall_package_descriptions_as_RDS(\"$(top_builddir)/library\", \"$(R_PKGS_BASE)\")" | \
      R_DEFAULT_PACKAGES=tools LC_ALL=C $(R_EXE) > /dev/null
    @$(ECHO) "installing parsed NAMESPACE files"
    @rm -f $(top_builddir)/library/tools/Meta/nsInfo.rds
    @$(ECHO) "tools:::.vinstall_package_namespaces_as_RDS(\"$(top_builddir)/library\", \"$(R_PKGS_BASE)\")" | \
      R_DEFAULT_PACKAGES=tools LC_ALL=C $(R_EXE) > /dev/null
    @$(INSTALL_DATA) $(top_srcdir)/doc/html/R.css \
      $(top_builddir)/library
    @gzip -9f ../../library/grDevices/afm/*.afm
    @cp -p ../library/datasets/data/morley.tab ../../library/datasets/data

## do Rdobjects before metadata before help indices
docs:
    @$(MAKE) -f Makefile.win Rdobjects
    @$(MAKE) -f Makefile.win metadata
    @$(MAKE) -f Makefile.win help-indices
    @$(MAKE) -f Makefile.win Rdfiles
    @touch stamp-docs

# fix the order to make best use of parallel builds
RD-TS = base.Rdts stats.Rdts utils.Rdts methods.Rdts graphics.Rdts grDevices.Rdts datasets.Rdts grid.Rdts tools.Rdts tcltk.Rdts splines.Rdts stats4.Rdts
# RD-TS = $(R_PKGS_BASE:=.Rdts)
Rd-ts: $(RD-TS)

%.Rdts:
    @$(ECHO) "tools:::.install_package_Rd_objects(\"$(srcdir)/$*\", \"$(top_builddir)/library/$*\")" | R_DEFAULT_PACKAGES=NULL $(R_EXE) || exit 1
    @$(ECHO) -n " $*$(ECHO_C)"

Rdobjects:
    @$(ECHO) -n "installing parsed Rd:"
    @$(MAKE) -f Makefile.win Rd-ts
    @$(ECHO)

help-indices:
    @$(ECHO) -n "writing indices for package:"
    @for pkg in $(R_PKGS_BASE); do \
      $(ECHO) -n " $${pkg}" ; \
      $(ECHO) "tools:::.writePkgIndices(\"$${pkg}\", \"$(top_builddir)/library/$${pkg}\", CHM = $(USE_CHM))" | R_DEFAULT_PACKAGES=utils LC_ALL=C $(R_EXE) || exit 1; \
    done
    @$(ECHO)

Rdfiles:
    @$(ECHO) "building all R object docs"
ifeq ($(strip $(USE_CHM)),TRUE)
    @for pkg in $(R_PKGS_BASE); do \
      $(ECHO) "tools:::.convertRdfiles(\"$(srcdir)/$${pkg}\", \"$(top_builddir)/library/$${pkg}\", types=c('html', 'chm'), silent = TRUE)" | LC_ALL=C $(R_EXE) || exit 1; \
      $(MAKE) --no-print-directory -C $${pkg}/chm \
        -f $(RHOME)/src/gnuwin32/help/MkChm $${pkg}.chm RHOME=$(RHOME); \
      if test -f $${pkg}/chm/$${pkg}.chm ; then \
        $(MKDIR) -p $(RLIB)/$${pkg}/chtml ;\
        $(CP) $${pkg}/chm/$${pkg}.chm $(RHOME)/library/$${pkg}/chtml ; \
      else \
        echo CHM compile failed:  HTML Help Workshop not installed? ; \
        exit 1; \
      fi; \
    done
else
    @for pkg in $(R_PKGS_BASE); do \
      $(ECHO) "tools:::.convertRdfiles(\"$(srcdir)/$${pkg}\", \"$(top_builddir)/library/$${pkg}\", silent = TRUE)" | LC_ALL=C $(R_EXE) || exit 1; \
    done
endif

metadata:
    @$(ECHO) "building/updating package metadata ..."
    @$(ECHO) "tools:::.vinstall_package_indices(\"$(srcdir)\", \"$(top_builddir)/library\", \"$(R_PKGS_BASE)\")" | \
      R_DEFAULT_PACKAGES=tools LC_ALL=C $(R_EXE) > /dev/null
    @cat $(top_builddir)/library/*/CONTENTS \
      > $(top_builddir)/doc/html/search/index.txt

clean:
    @for pkg in $(R_PKGS_BASE); do \
      $(MAKE) --no-print-directory -C $${pkg} \
        -f Makefile.win RHOME=$(RHOME) clean-win; \
    done
    -@rm -f stamp-*