#
# ${R_HOME}/src/library/base/Makefile

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

top_builddir = ../../..
subdir = src/library/base

include $(top_builddir)/Makeconf

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

pkg = base

RSRC = `LC_COLLATE=C ls $(srcdir)/R/*.R $(srcdir)/R/$(R_OSTYPE)/*.R`

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

## For people who do make -C ../src/library/base
update:
	@$(MAKE) all
	@$(MAKE) mklazycomp

all: Makefile DESCRIPTION
	@$(ECHO) "building package '$(pkg)'"
	@$(MKINSTALLDIRS) $(top_builddir)/library/$(pkg)
	@WHICH="@WHICH@" $(MAKE) mkRbase mkdesc2 mkdemos2 mkpo
	@$(INSTALL_DATA) $(srcdir)/inst/CITATION $(top_builddir)/library/$(pkg)

include $(top_srcdir)/share/make/basepkg.mk

$(top_builddir)/library/$(pkg)/R/$(pkg).rdb: all.R
	@$(ECHO) "byte-compiling package '$(pkg)'"
	@cat $(srcdir)/makebasedb.R | \
	  R_COMPILE_PKGS=1 R_COMPILER_SUPPRESS_ALL=1 \
	  R_DEFAULT_PACKAGES=NULL LC_ALL=C $(R_EXE) > /dev/null
	@$(INSTALL_DATA) $(srcdir)/baseloader.R \
	  $(top_builddir)/library/$(pkg)/R/$(pkg)

mkR: mkRbase

Rsimple:
	@WHICH="@WHICH@" $(MAKE) mkRbase mkRsimple

## Remove files to allow this to be done repeatedly
Rlazy:
	-@rm -f  $(top_builddir)/library/$(pkg)/R/$(pkg)*
	@WHICH="@WHICH@" $(MAKE) mkRbase
	@cat $(srcdir)/makebasedb.R | \
	  R_DEFAULT_PACKAGES=NULL LC_ALL=C $(R_EXE) > /dev/null
	@$(INSTALL_DATA) $(srcdir)/baseloader.R \
	  $(top_builddir)/library/$(pkg)/R/$(pkg)

Rlazycomp:
	@WHICH="@WHICH@" $(MAKE) mkRbase mklazycomp
