Makefiles

How to install make:

  • macOS:
    1. Run xcode-select --install
  • Windows:
    1. Install chocolately
    2. Run choco install make

Sample Makefile

(Important! You must use tabs in Makefiles, not spaces)

# Read as "mypaper.pdf depends on mypaper.md and figures/fig1.jpg"
mypaper.pdf: mypaper.md figures/fig1.jpg
  pandoc mypaper.md --citeproc -o mypaper.pdf

# Read as "figures/fig1.jpg depends on analysis/figs.R"
figures/fig1.jpg: analysis/figs.R 
  Rscript analysis/fig.R