#-*- 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) LSOURCES=$(wildcard $(SSPKG)/*.c $(SSPKG)/*.f $(SSPKG)/*.cc \ $(SSPKG)/*.cpp $(SSPKG)/*.C) ifeq ($(strip $(LSOURCES) $(SRCMAKE)),) LOBJS= DYNLIB= else LOBJS=$(foreach i, $(LSOURCES), $(basename $i).o) DYNLIB=$(DPKG)/libs/$(DLLNAME).dll endif # data DSOURCES=$(filter-out $(SPKG)/data/CVS, $(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, $(PKGDEMOS0)) # exec EXECFILES=$(filter-out $(SPKG)/exec/CVS, $(wildcard $(SPKG)/exec/*)) # Others INSTFILES=$(filter-out $(SPKG)/inst/CVS, $(wildcard $(SPKG)/inst/*)) all: $(DPKG)/zzzz $(DYNLIB) R $(DPKG)/demo $(DPKG)/exec $(DATA) mansrcs \ indices bare: $(DPKG)/zzzz R $(DPKG)/demo include $(RHOME)/src/gnuwin32/MkRules clean: ifeq ($(strip $(SRCMAKE)),) $(RM) $(SSPKG)/$(DLLNAME).dll $(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 $(PKGRFILES)),) @$(ECHO) " installing R files" @$(MKDIR) -p $(DPKG)/R @$(CAT) $(PKGRFILES) > $@ @sh $(RHOME)/src/gnuwin32/install-save.sh $(SAVE) $(RLIB) $(PKG) $(RHOME) else @$(ECHO) " no R files in this package" 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)/zzzz: ifeq ($(SPKG0),$(DPKG0)) @$(ECHO) @$(ECHO) " *** cannot install a package into its source directory ***" @$(ECHO) @exit 111 endif @$(ECHO) @$(ECHO) "---------- Making package $(PKG) ------------" @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 @$(MKDIR) -p $(DPKG) ifneq ($(strip $(INSTFILES)),) @$(ECHO) " installing inst files" -@$(CP) -r inst/* $(DPKG) endif @if test -f ${SPKG}/DESCRIPTION; then \ $(ECHO) " adding build stamp to DESCRIPTION"; \ else \ $(ECHO) "A package must contain a DESCRIPTION file"; \ exit 27; \ fi @if test -f ${SPKG}/NAMESPACE; then \ $(ECHO) " installing NAMESPACE file"; \ $(CP) ${SPKG}/NAMESPACE $(DPKG)/NAMESPACE; \ fi ifeq ($(strip $(BUILD)),CROSS) @(cat DESCRIPTION; $(ECHO); $(ECHO) "Built: R" $(RVER)\; Win32\; `date`) \ | $(SED) '/^\s*$$/d' > ${DPKG}/DESCRIPTION else @$(ECHO) ".installPackageDescription('.', '"$(DPKG)"')" | \ $(RHOME)/bin/rterm.exe --vanilla --slave R_DEFAULT_PACKAGES=tools> /dev/null endif $(DATA): $(DSOURCES) @$(ECHO) " installing data files" @$(RM) -rf $(DATA) @$(MKDIR) -p $(DATA) @$(CP) $^ $@ $(DYNLIB): $(SSPKG)/$(DLLNAME).dll @$(MKDIR) -p $(DPKG)/libs @$(CP) $^ $@ $(SSPKG)/$(DLLNAME).dll: FORCE @$(ECHO) " making DLL ..." ifeq ($(strip $(SRCMAKE)),) @$(MAKE) --no-print-directory -C $(SSPKG) RHOME=$(RHOME) \ -f $(RHOME)/src/gnuwin32/MakeDll DLLNAME=$(DLLNAME) else @$(MAKE) --no-print-directory -C $(SSPKG) RHOME=$(RHOME) -f Makefile.win endif @$(ECHO) " ... DLL made" FORCE: AA=$(wildcard R/Makefile.win) ifeq ($(AA),) R: $(DPKG)/R/$(PKG) else include R/Makefile.win endif 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 '\eof'; \ done > $(DPKG)/man/$(PKG).Rd else @$(ECHO) " no man files in this package" endif indices: @$(ECHO) " installing indices" ifeq ($(strip $(BUILD)),CROSS) @$(ECHO) "library(tools); .installPackageIndices('.', '"$(DPKG)"')" | \ R_DEFAULT_PACKAGES=tools $(R_EXE) --vanilla --slave > /dev/null else @$(ECHO) ".installPackageIndices('.', '"$(DPKG)"')" | \ $(RHOME)/bin/rterm.exe --vanilla --slave R_DEFAULT_PACKAGES=tools > /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) "library(tools); .installMD5sums('"$(DPKG)"')" | \ R_DEFAULT_PACKAGES=tools $(R_EXE) --vanilla --slave > /dev/null else @$(ECHO) ".installMD5sums('"$(DPKG)"')" | \ $(RHOME)/bin/rterm.exe --vanilla --slave R_DEFAULT_PACKAGES=tools > /dev/null endif endif