#-*- Makefile -*- RLIB=../../../library DPKG=$(RLIB)/$(PKG) SPKG=. SAVE=CHECK ifeq ($(strip $(DLLNM)),) DLLNAME=$(PKG) else DLLNAME=$(DLLNM) endif #this can be overwriten by the caller SRC = src STAMP = YES #source directory SSPKG=$(SPKG)/$(SRC) LSOURCES=$(wildcard $(SSPKG)/*.c $(SSPKG)/*.f $(SSPKG)/*.cc \ $(SSPKG)/*.cpp $(SSPKG)/*.C) ifeq ($(strip $(LSOURCES)),) 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)) # Others OFILES0=$(wildcard $(SPKG)/*) OFILES1= INDEX TITLE OFILES-NO= R r chm data man src src-c demo Makefile.in inst check orig tests \ DESCRIPTION DESCRIPTION.in INDEX TITLE index title \ configure configure.in cleanup CVS cvs OFILES3=$(foreach i, $(OFILES1), $(SPKG)/$i) OFILES2=$(foreach i, $(OFILES-NO), $(SPKG)/$i) OFILES=$(filter-out $(OFILES2),$(OFILES0)) INSTFILES=$(wildcard $(SPKG)/inst/*) # src Makefile? SRCMAKE=$(wildcard $(SSPKG)/Makefile.win) all: $(DPKG)/zzzz $(DYNLIB) R $(DPKG)/demo $(DATA) 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.* else $(MAKE) -C $(SSPKG) RHOME=$(RHOME) -f Makefile.win clean endif $(RM) -rf $(SPKG)/chm $(SPKG)/check #SEDP='/^[ ]*$$/d;s/$(DLLNAME).so/$(DLLNAME).dll/' $(DPKG)/R/$(PKG): $(PKGRFILES) ifneq ($(strip $(PKGRFILES)),) @echo " installing R files" @$(MKDIR) -p $(DPKG)/R # $(CAT) $(PKGRFILES) | $(SED) $(SEDP) > $@ @$(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" @$(MKDIR) -p $@ @$(CP) $(PKGDEMOS) $@ endif $(SPKG)/TITLE: if [ ! -f $(SPKG)/TITLE -a -f $(SPKG)/DESCRIPTION ] ; then \ perl $(RHOME)/share/perl/maketitle.pl $(SPKG)/DESCRIPTION > $@; \ fi # This fails if DESCRIPTION.. doesn't exist. # $(DPKG)/zzzz: $(OFILES3) $(OFILES) # On the other hand, ...zzzz is never created so $(DPKG)/zzzz: $(SPKG)/TITLE @$(ECHO) "---------- Making package $(PKG) ------------" $(MKDIR) -p $(DPKG) ifeq ($(strip $(INSTFILES)),) -$(CP) -r $(OFILES3) $(OFILES) $(DPKG)/ else -$(CP) -r $(OFILES3) inst/* $(DPKG)/ endif @if test -f ${SPKG}/DESCRIPTION; then \ $(SED) '/^\s*$$/d' ${SPKG}/DESCRIPTION > ${DPKG}/DESCRIPTION; \ fi ifeq ($(strip $(STAMP)),YES) @echo " adding build stamp to DESCRIPTION" @echo "cat('Built: R ', R.version[['major']], '.', R.version[['minor']], '; Win32; ', format(Sys.time()), sep='')" | $(RHOME)/bin/Rterm --slave --vanilla >> ${DPKG}/DESCRIPTION endif $(DATA): $(DSOURCES) @echo " installing data files" @$(MKDIR) -p $(DATA) @$(CP) $^ $@ $(DYNLIB): $(SSPKG)/$(DLLNAME).dll $(MKDIR) -p $(DPKG)/libs $(CP) $^ $@ $(SSPKG)/$(DLLNAME).dll: FORCE @echo " making DLL" ifeq ($(strip $(SRCMAKE)),) @$(MAKE) -C $(SSPKG) RHOME=$(RHOME) \ -f $(RHOME)/src/gnuwin32/MakeDll DLLNAME=$(DLLNAME) else @$(MAKE) -C $(SSPKG) RHOME=$(RHOME) -f Makefile.win endif @echo " DLL made" @echo FORCE: AA=$(wildcard R/Makefile.win) ifeq ($(AA),) R: $(DPKG)/R/$(PKG) else include R/Makefile.win endif