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.
Overview
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 Rtools and 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
:
- Add R binaries to the Windows Path (e.g.,
C:\Program Files\R\R-2.11.1\bin
; see here for instructions) - 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 themakefile
in another text editor such asnotepad
. - For LaTeX I have MikTeX installed; this should be on the Windows path
Resources for Getting Started with makefiles for Sweave
- Ross Ihaka has a quick introduction to makefiles focusing on Sweave, R, and LaTeX
- Charlie Gibbons wrote a document with LaTeX, Sweave, and Beamer examples of makefiles
- Gregor Gorjanc shows an example Sweave make file using his custom Sweave command
- Documentation on GNU Make
- Running command line programs in Windows
- Getting Started with Sweave: R, LaTeX, Eclipse, StatET, & TeXlipse