Make is a popular tool for automating the building of software - compiling source code into executable programs.
Though Make is nearly 40 years old, and there are many other build tools available, its fundamental concepts are common across build tools.
Today, researchers working with legacy codes in C or FORTRAN, which are very common in high-performance computing, will, very likely encounter Make.
Researchers are also finding Make of use in implementing reproducible research workflows, automating data analysis and visualization (using Python or R) and combining tables and plots with text to produce reports and papers for publication.
The overall lesson can be done in a 2 hour slot.
Solutions for challenges are used in subsequent topics.
A number of example Makefiles, including sample solutions to
challenges, are in code/samples
and are identified below.
Recommend instructors and students use nano
as the text editor for
this lesson because
Please point out to students during setup that they can and should use another text editor if they’re already familiar with it.
Instructors and students should use two shell windows: one for running nano, and one for running Make.
Check that all attendees have Make installed and that it runs correctly, before beginning the session.
Python scripts to be invoked by Make are in code/
.
Data files are in data/books
.
You can either create a simple Git repository for students to clone which contains:
wordcount.py
plotcount.py
zipf_test.py
books/
Or, ask students to download make-lesson.zip from this repository.
To recreate make-lesson.zip
, run:
$ make make-lesson.zip
The single most commonly occurring problem will be students using spaces instead of TABs when intending actions.
Some of these pages use images of Makefile dependencies, in the fig directory.
These are created using makefile2graph,
which is assumed to be in the PATH
.
This tool, in turn, needs the dot
tool, part of GraphViz.
To install GraphViz on Scientific Linux 6:
$ sudo yum install graphviz
$ dot -V
dot - graphviz version 2.26.0 (20091210.2329)
To install GraphViz on Ubuntu 14.04.3 and 15.10:
$ sudo apt-get install graphviz
$ dot -V
dot - graphviz version 2.38.0 (20140413.2041)
To download and build makefile2graph on Linux:
$ cd
$ git clone https://github.com/lindenb/makefile2graph
$ cd makefile2graph/
$ make
$ export PATH=~/makefile2graph/:$PATH
$ cd
$ which makefile2graph
/home/ubuntu/makefile2graph/makefile2graph
To create the image files for the lesson:
$ make figures
See commands.mk
’s diagrams
target.