Skip to content

Instantly share code, notes, and snippets.

@njtierney
Forked from PirateGrunt/Makefile
Created September 20, 2016 05:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save njtierney/8809d71c057bda6655f620f20a1e4c8e to your computer and use it in GitHub Desktop.
Save njtierney/8809d71c057bda6655f620f20a1e4c8e to your computer and use it in GitHub Desktop.
Basic makefile
####################
# Makefile
# Copyright Brian A. Fannin 2015
####################
RDIR = .
DATA_DIR = $(RDIR)/data
GATHER_DIR = $(DATA_DIR)/gather
GATHER_SOURCE = $(wildcard $(GATHER_DIR)/*.Rmd)
GATHER_OUT = $(GATHER_SOURCE:.Rmd=.docx)
PROCESS_DIR = $(DATA_DIR)/process
PROCESS_SOURCE = $(wildcard $(PROCESS_DIR)/*.Rmd)
PROCESS_OUT = $(PROCESS_SOURCE:.Rmd=.docx)
ANALYSIS_DIR = $(RDIR)/analysis
ANALYSIS_SOURCE = $(wildcard $(ANALYSIS_DIR)/*.Rmd)
ANALYSIS_OUT = $(ANALYSIS_SOURCE:.Rmd=.docx)
PRESENTATION_DIR = $(RDIR)/presentation
PRESENTATION_SOURCE = $(wildcard $(PRESENTATION_DIR)/*.Rmd)
PRESENTATION_OUT = $(PRESENTATION_SOURCE:.Rmd=.html)
KNIT = Rscript -e "require(rmarkdown); render('$<')"
all: $(GATHER_OUT) $(PROCESS_OUT) $(ANALYSIS_OUT) $(PRESENTATION_OUT)
#########################
## Gather
$(GATHER_DIR)/%.docx:$(GATHER_DIR)/%.Rmd
$(KNIT)
#########################
# Process
$(PROCESS_DIR)/%.docx:$(PROCESS_DIR)/%.Rmd $(GATHER_OUT)
$(KNIT)
#########################
# Analyze
$(ANALYSIS_DIR)/%.docx:$(ANALYSIS_DIR)/%.Rmd $(PROCESS_OUT)
$(KNIT)
#########################
# Present
$(PRESENTATION_DIR)/%.docx:$(PRESENTATION_DIR)/%.Rmd $(ANALYSIS_OUT)
$(KNIT)
clean:
rm -fv $(GATHER_OUT)
rm -fv $(PROCESS_OUT)
rm -fv $(ANALYSIS_OUT)
rm -fv $(PRESENTATION_OUT)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment