From: j8takagi <j8takagi@nifty.com> Date: Fri, 15 Mar 2013 02:23:54 +0000 (+0900) Subject: RのMakefileを修正 X-Git-Url: http://www.j8takagi.net/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c46a32a33663b349c8dc7edbfee3bfda46d7dcab;p=makefiles.git RのMakefileを修正 --- diff --git a/R_mk/R.mk b/R_mk/R.mk index 5f19e7b..c1f021c 100644 --- a/R_mk/R.mk +++ b/R_mk/R.mk @@ -1,16 +1,46 @@ .PHONY: R-clean R-distclean -CAT = cat -ECHO = echo -EPSTOPDF = epstopdf -R = R +CAT := cat +ECHO := echo +EPSTOPDF := epstopdf +R := R +SED := sed RFLAG = --slave --vanilla +# read.tableæã§èªã¿è¾¼ã¾ããtableãã¡ã¤ã« +tablefiles = $(strip $(shell $(SED) -n -e 's/.*read\.table."\(.*\)".*;/\1/gp' $<)) + +# sourceæã§èªã¿è¾¼ã¾ããtableãã¡ã¤ã« +sourcefiles = $(strip $(shell $(SED) -n -e 's/.*source."\(.*\)".*;/\1/gp' $<)) + # used by R postscript device. # For details, type '?postscriptFonts' in R. psfamily ?= Japan1 +# ä¾åé¢ä¿ãèªåçæããdãã¡ã¤ã«ã«æ ¼ç´ +%.d: %.R + @$(ECHO) '$@ is created by scanning $^.' + # ç»åãã¡ã¤ã«ã¨Rãã¡ã¤ã«ã®ä¾åé¢ä¿ + @($(ECHO) '$(subst .R,.eps,$<) $(subst .R,.png,$<) $(subst .R,.jpeg,$<): $<' >$@) + # ãã¼ãã«ãã¡ã¤ã«ã®ä¾åé¢ä¿ + $(if $(tablefiles),@( \ + $(ECHO); \ + $(ECHO) '# Table Files'; \ + $(ECHO) '$(subst .R,.eps,$<) $(subst .R,.png,$<) $(subst .R,.jpeg,$<): $(tablefiles)') >>$@) + # ã½ã¼ã¹ãã¡ã¤ã«ã®ä¾åé¢ä¿ + $(if $(sourcefiles),@( \ + $(ECHO); \ + $(ECHO) '# Source Files'; \ + $(ECHO) '$(subst .R,.eps,$<) $(subst .R,.png,$<) $(subst .R,.jpeg,$<): $(sourcefiles)') >>$@) + +# 夿°TARGETSã§æå®ãããã¿ã¼ã²ãããã¡ã¤ã«ã«å¯¾å¿ããdãã¡ã¤ã«ãã¤ã³ã¯ã«ã¼ã +# .dãã¡ã¤ã«ããããããã¡ã¤ã«ã®ä¾åé¢ä¿ãåå¾ãã +# ã¿ã¼ã²ããã« clean ãå«ã¾ãã¦ããå ´åã¯é¤ã +ifeq (,$(filter %clean,$(MAKECMDGOALS))) + -include $(addsuffix .d,$(basename $(TARGETS))) +endif + %.eps.R: %.R @$(ECHO) 'postscript(file="$(subst .R,.eps,$<)",family="$(psfamily)", onefile=F, horizontal=F)' >$@ @$(CAT) $< >>$@ @@ -49,7 +79,7 @@ psfamily ?= Japan1 $(R) $(RFLAG) <$< R-clean: - $(RM) *.pdf.R *.png.R *.jpeg.R *.svg.R *.eps.R + $(RM) *.pdf.R *.png.R *.jpeg.R *.svg.R *.eps.R *.d R-distclean: R-clean $(RM) $(subst .R,.pdf,$(wildcard *.R)) $(subst .R,.png,$(wildcard *.R)) $(subst .R,.jpeg,$(wildcard *.R)) $(subst .R,.svg,$(wildcard *.R)) $(subst .R,.eps,$(wildcard *.R))