makefiles for Sweave, R and LaTeX using Eclipse on Windows

[This article was first published on Jeromy Anglim's Blog: Psychology and Statistics, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

This post provides a brief introduction to make and makefiles. In particular it describes how to set up make on Windows with an emphasis on using make in Eclipse on projects involving R, Sweave, and LaTeX.


make is software that uses makefiles to build projects. make has many benefits.

  • One click build
  • Reliable build (always build derived files that need to be built; i.e., ensure build is up to date)
  • Fast build (i.e., don’t build things that don’t need to be built)
  • Clean up a project

make has won the ACM Software System Award. It shares this honour with two of my other favourite tools: TeX and S.

make has also encouraged me to think more about dependencies, one-click builds, and project file structures. Specifically, I use make in conjunction with R, Sweave, LaTeX, and other command line tools to build reproducible research output. I’ll post some examples in the near future.

Installation on Windows

  • Option 1: Install Cygwin
  • Option 2: Install Rtoolsand add Rtools to the Windows path (installation can do this for you);

In order to run Sweave on the command line on Windows using: R CMD Sweave foo.Rnw:

  1. Add R binaries to the Windows Path (e.g., C:\Program Files\R\R-2.11.1\bin; see here for instructions)
  2. Have Rtools installed

Introduction to R has more information about running R at the command line.

Running makefiles in Eclipse

I use Eclipse to edit R and Sweave files. To configure make in Eclipse:

  • Run - External Tools - External Tools Configurations
  • New
    • Name: make
    • Location: location of make file; e.g., C:\Program Files\GnuWin32\bin\make.exe
    • Working Directory: ${Project_loc}

Thus, with a makefile in the root directory of a project, Run - External Tools - Make runs the makefile.

Also note:

  • Whenever a directory is added to the Windows Path, Eclipse needs to be restarted for this to take effect. Sometimes it seems that Windows itself has to be restarted.
  • Editing makefiles in Eclipse requires the use of tabs. The following setting enables tabs instead of space substitution (Window - Preferences - General - Editors - Text Editors - Insert Space for Tables (uncheck)); or edit the makefile in another text editor such as notepad.
  • For LaTeX I have MikTeX installed; this should be on the Windows path

Resources for Getting Started with makefiles for Sweave

To leave a comment for the author, please follow the link and comment on their blog: Jeromy Anglim's Blog: Psychology and Statistics. offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

Never miss an update!
Subscribe to R-bloggers to receive
e-mails with the latest R posts.
(You will not see this message again.)

Click here to close (This popup will not appear again)