#-*- Makefile -*- RLIB=../../../library DPKG=$(RLIB)/$(PKG) SPKG=. SAVE=CHECK ifneq ($(strip $(BUILD)),CROSS) SPKG0 = $(shell $(RHOME)/src/gnuwin32/Rpwd.exe $(SPKG)) DPKG0 = $(shell $(RHOME)/src/gnuwin32/Rpwd.exe $(DPKG)) else SPKG0=$(SPKG) DPKG0=$(DPKG) endif ifeq ($(strip $(DLLNM)),) DLLNAME=$(PKG) else DLLNAME=$(DLLNM) endif #this can be overwriten by the caller SRC = src #source directory SSPKG=$(SPKG)/$(SRC) # src Makefile? SRCMAKE=$(wildcard $(SSPKG)/Makefile.win) SDYNLIB=$(SSPKG)/$(DLLNAME).dll LSOURCES=$(wildcard $(SSPKG)/*.c $(SSPKG)/*.f $(SSPKG)/*.cc \ $(SSPKG)/*.cpp $(SSPKG)/*.C) ifeq ($(strip $(LSOURCES)),) LOBJS= else LOBJS=$(foreach i, $(LSOURCES), $(basename $i).o) endif # data DSOURCES=$(filter-out $(SPKG)/data/CVS $(SPKG)/data/.svn, $(wildcard $(SPKG)/data/*)) ifeq ($(strip $(DSOURCES)),) DATA= else DATA=$(DPKG)/data endif # R PKGRFILES0=$(wildcard $(SPKG)/R/*.[RSqrs]) RWIN32=$(wildcard $(SPKG)/R/windows/*.[Rr]) ifeq ($(strip RWIN32),) PKGRFILES=$(PKGRFILES0) else R1 = $(foreach i,$(RWIN32), $(addprefix $(SPKG)/R/, $(notdir $i))) PKGRFILES=$(filter-out $(R1), $(PKGRFILES0)) $(RWIN32) endif # demos PKGDEMOS0=$(wildcard $(SPKG)/demo/*) PKGDEMOS=$(filter-out $(SPKG)/demo/CVS $(SPKG)/demo/.svn, $(PKGDEMOS0)) # exec EXECFILES=$(filter-out $(SPKG)/exec/CVS $(SPKG)/exec/.svn, $(wildcard $(SPKG)/exec/*)) # Others: we will remove CVS and subversion files later. INSTFILES=$(wildcard $(SPKG)/inst/*) all: @$(MAKE) --no-print-directory -f $(RHOME)/src/gnuwin32/MakePkg $(DPKG)/zzzz @$(MAKE) --no-print-directory -f $(RHOME)/src/gnuwin32/MakePkg -s frontmatter @$(MAKE) --no-print-directory -f $(RHOME)/src/gnuwin32/MakePkg -s nmspace @$(MAKE) --no-print-directory -f $(RHOME)/src/gnuwin32/MakePkg Dynlib @$(MAKE) --no-print-directory -f $(RHOME)/src/gnuwin32/MakePkg -s R @$(MAKE) --no-print-directory -f $(RHOME)/src/gnuwin32/MakePkg -s $(DPKG)/demo $(DPKG)/exec $(DPKG)/inst $(DATA) @$(MAKE) --no-print-directory -f $(RHOME)/src/gnuwin32/MakePkg -s mansrcs indices fake: zzzfirst frontmatter nmspacefake R Rfake $(DPKG)/demo \ $(DPKG)/exec $(DPKG)/inst $(DATA) mansrcs indices include $(RHOME)/src/gnuwin32/MkRules clean: ifeq ($(strip $(SRCMAKE)),) $(RM) $(SDYNLIB) $(LOBJS) $(SSPKG)/$(DLLNAME).a $(SSPKG)/$(DLLNAME).def $(SSPKG)/$(DLLNAME)_res.* $(SSPKG)/*.d $(SSPKG)/Makedeps else $(MAKE) -C $(SSPKG) RHOME=$(RHOME) -f Makefile.win clean endif $(RM) -rf $(SPKG)/chm $(SPKG)/check ## used to build skeletal versions of packages, enough to run ## package tools to install them properly Rcode: Rcode0 Dynlib Rcode0: @$(MKDIR) -p $(DPKG) $(DPKG)/R @$(CAT) $(PKGRFILES) > $(DPKG)/R/$(PKG) @if test -f ${SPKG}/NAMESPACE; then \ $(CP) ${SPKG}/NAMESPACE $(DPKG)/NAMESPACE; \ fi @(cat DESCRIPTION; $(ECHO); $(ECHO) "Built: R" $(RVER)\; \; `date`) \ | $(SED) '/^\s*$$/d' > ${DPKG}/DESCRIPTION $(DPKG)/R/$(PKG): $(PKGRFILES) ifneq ($(strip $(PKG)),base) ifneq ($(strip $(PKGRFILES)),) @$(ECHO) " installing R files" @$(MKDIR) -p $(DPKG)/R ifeq ($(strip $(BUILD)),CROSS) @$(ECHO) ".installPackageCodeFiles('"$(SPKG)"', '"$(DPKG)"')" \ | R_DEFAULT_PACKAGES=tools R_OSTYPE=windows LC_COLLATE=C $(R_EXE) --vanilla --slave > /dev/null else @$(ECHO) ".installPackageCodeFiles('"$(SPKG)"', '"$(DPKG)"')" \ | $(RHOME)/bin/rterm.exe --vanilla --slave \ R_DEFAULT_PACKAGES=tools LC_COLLATE=C > /dev/null endif ## install halts here if collater failed @sh $(RHOME)/src/gnuwin32/install-save.sh $(SAVE) $(RLIB) $(PKG) $(RHOME) $(BUILD) $(R_EXE) else @$(ECHO) " no R files in this package" endif else ## .installPackageCodeFiles adds an unwanted .packageName @$(ECHO) " installing R files" @$(MKDIR) -p $(DPKG)/R @$(CAT) $(PKGRFILES) > $(DPKG)/R/$(PKG) endif $(DPKG)/demo: $(PKGDEMOS) ifneq ($(strip $(PKGDEMOS)),) @$(ECHO) " installing demos" @$(RM) -rf $@ @$(MKDIR) -p $@ @$(CP) $(PKGDEMOS) $@ endif $(DPKG)/exec: $(EXECFILES) ifneq ($(strip $(EXECFILES)),) @$(ECHO) " installing exec files" @$(RM) -rf $@ @$(MKDIR) -p $@ @$(CP) $(EXECFILES) $@ endif $(DPKG)/inst: $(INSTFILES) ifneq ($(strip $(INSTFILES)),) @$(ECHO) " installing inst files" -@$(CP) -r inst/* $(DPKG) @find $(DPKG) -name CVS -type d -prune -exec rm -rf {} \; @find $(DPKG) -name .svn -type d -prune -exec rm -rf {} \; endif $(DPKG)/zzzz: zzzfirst @if test -f ${SPKG}/configure.win; then \ sh ${SPKG}/configure.win; \ else if test -f ${SPKG}/configure; then \ $(ECHO) ; \ $(ECHO) " **********************************************" ; \ $(ECHO) " WARNING: this package has a configure script" ; \ $(ECHO) " It probably needs manual configuration" ; \ $(ECHO) " **********************************************" ; \ $(ECHO) ; \ fi; \ fi zzzfirst: ifeq ($(SPKG0),$(DPKG0)) @$(ECHO) @$(ECHO) " *** cannot install a package into its source directory ***" @$(ECHO) @exit 111 endif @$(ECHO) @$(ECHO) "---------- Making package $(PKG) ------------" @$(MKDIR) -p $(DPKG) frontmatter: @$(MKDIR) -p $(DPKG) @if test -f ${SPKG}/DESCRIPTION; then \ $(ECHO) " adding build stamp to DESCRIPTION"; \ else \ $(ECHO) "A package must contain a DESCRIPTION file"; \ exit 27; \ fi ifeq ($(strip $(BUILD)),CROSS) @$(ECHO) ".installPackageDescription('.', '"$(DPKG)"')" | \ R_DEFAULT_PACKAGES=tools R_OSTYPE=windows $(R_EXE) --vanilla --slave > /dev/null else @$(ECHO) ".installPackageDescription('.', '"$(DPKG)"')" | \ $(RHOME)/bin/rterm.exe --vanilla --slave R_DEFAULT_PACKAGES=tools > /dev/null endif nmspace: ifeq ($(strip $(BUILD)),CROSS) @if test -f ${SPKG}/NAMESPACE; then \ $(ECHO) -n " installing NAMESPACE file"; \ if test -f ${SPKG}/NAMESPACE.windows ; then \ cat ${SPKG}/NAMESPACE ${SPKG}/NAMESPACE.windows > $(DPKG)/NAMESPACE; \ else \ $(CP) ${SPKG}/NAMESPACE $(DPKG)/NAMESPACE; \ fi ; \ $(ECHO) " and metadata"; \ $(ECHO) ".installPackageNamespaceInfo('$(DPKG)', '$(DPKG)')" | \ R_DEFAULT_PACKAGES=tools R_OSTYPE=windows $(R_EXE) --vanilla --slave > /dev/null; \ fi else @if test -f ${SPKG}/NAMESPACE; then \ $(ECHO) -n " installing NAMESPACE file"; \ if test -f ${SPKG}/NAMESPACE.windows ; then \ cat ${SPKG}/NAMESPACE ${SPKG}/NAMESPACE.windows > $(DPKG)/NAMESPACE; \ else \ $(CP) ${SPKG}/NAMESPACE $(DPKG)/NAMESPACE; \ fi ; \ $(ECHO) " and metadata"; \ $(ECHO) ".installPackageNamespaceInfo('$(DPKG)', '$(DPKG)')" | \ $(RHOME)/bin/rterm.exe R_DEFAULT_PACKAGES=tools --vanilla --slave > /dev/null; \ fi endif nmspacefake: @if test -f ${SPKG}/NAMESPACE; then \ $(ECHO) " installing NAMESPACE file"; \ $(SED) -e '/useDynLib/d' ${SPKG}/NAMESPACE > $(DPKG)/NAMESPACE; \ fi $(DATA): $(DSOURCES) @$(ECHO) " installing data files" @$(RM) -rf $(DATA) @$(MKDIR) -p $(DATA) @$(CP) $^ $@ Dynlib: srcDynlib @if test -f $(SDYNLIB) ; then \ $(ECHO) " installing DLL" ; \ $(MKDIR) -p $(DPKG)/libs ; \ $(CP) $(SDYNLIB) $(DPKG)/libs ; \ fi srcDynlib: ifeq ($(strip $(SRCMAKE)),) ifneq ($(strip $(LOBJS)),) @$(ECHO) " making DLL ..." @$(MAKE) --no-print-directory -C $(SSPKG) RHOME=$(RHOME) \ -f $(RHOME)/src/gnuwin32/MakeDll DLLNAME=$(DLLNAME) @$(ECHO) " ... DLL made" endif else @$(ECHO) " running src/Makefile.win ..." @$(MAKE) --no-print-directory -C $(SSPKG) RHOME=$(RHOME) -f Makefile.win @$(ECHO) " ... done" endif # R AA=$(wildcard R/Makefile.win) ifeq ($(AA),) R: $(DPKG)/R/$(PKG) else include R/Makefile.win endif Rfake: @if test -f $(SPKG)/NAMESPACE; then \ echo ".onLoad <- function(list, pkg) NULL" >> $(DPKG)/R/$(PKG) ; \ else \ echo ".First.lib <- function(lib, pkg) NULL" >> $(DPKG)/R/$(PKG) ;\ fi MANMAIN=$(wildcard $(SPKG)/man/*.[Rr]d) MANWIN32=$(wildcard $(SPKG)/man/windows/*.[Rr]d) mansrcs: $(DPKG)/man/$(PKG).Rd PKGMANFILES=$(MANMAIN) $(MANWIN32) $(DPKG)/man/$(PKG).Rd: $(MANMAIN) $(MANWIN32) ifneq ($(strip $(PKGMANFILES)),) @$(ECHO) " installing man source files" @$(RM) -rf $(DPKG)/man @$(MKDIR) -p $(DPKG)/man @for rdfile in $^; do \ $(CAT) $${rdfile}; echo; echo '\eof'; \ done > $(DPKG)/man/$(PKG).Rd else @$(ECHO) " no man files in this package" endif indices: @$(ECHO) " installing indices" ifeq ($(strip $(BUILD)),CROSS) @$(ECHO) ".installPackageIndices('.', '"$(DPKG)"')" | \ R_DEFAULT_PACKAGES=tools LC_COLLATE=C R_OSTYPE=windows $(R_EXE) --vanilla --slave > /dev/null else @$(ECHO) ".installPackageIndices('.', '"$(DPKG)"')" | \ $(RHOME)/bin/rterm.exe --vanilla --slave R_DEFAULT_PACKAGES=tools LC_COLLATE=C > /dev/null endif # need not have HTML installed when building packages @$(MKDIR) -p $(RHOME)/doc/html/search @$(CAT) $(RHOME)/library/*/CONTENTS > $(RHOME)/doc/html/search/index.txt @PERL5LIB=$(RHOME)/share/perl $(PERL) \ $(RHOME)/share/perl/build-help-windows.pl -htmllists md5sums: ifneq ($(strip $(PKG)),base) @$(ECHO) " adding MD5 sums" ifeq ($(strip $(BUILD)),CROSS) @$(ECHO) ".installMD5sums('"$(DPKG)"')" | \ R_DEFAULT_PACKAGES=tools LC_COLLATE=C R_OSTYPE=windows $(R_EXE) --vanilla --slave > /dev/null else @$(ECHO) ".installMD5sums('"$(DPKG)"')" | \ $(RHOME)/bin/rterm.exe --vanilla --slave R_DEFAULT_PACKAGES=tools LC_COLLATE=C > /dev/null endif endif