Summary and Setup
Make is a tool which can run commands to read files, process these files in some way, and write out the processed files. For example, in software development, Make is used to compile source code into executable programs or libraries, but Make can also be used to:
- run analysis scripts on raw data files to get data files that summarize the raw data;
- run visualization scripts on data files to produce plots; and to
- parse and combine text files and plots to create papers.
Make is called a build tool - it builds data files, plots, papers, programs or libraries. It can also update existing files if desired.
Make tracks the dependencies between the files it creates and the files used to create these. If one of the original files (e.g. a data file) is changed, then Make knows to recreate, or update, the files that depend upon this file (e.g. a plot).
There are now many build tools available, all of which are based on the same concepts as Make.
Prerequisites
In this lesson we use make
from the Unix Shell. Some
previous experience with using the shell to list directories, create,
copy, remove and list files and directories, and run simple scripts is
necessary.
Setup
In order to follow this lesson, you will need to download some files. Please follow instructions on the setup page.
Files
You need to download some files to follow this lesson:
Download make-lesson.zip.
Move
make-lesson.zip
into a directory which you can access via your bash shell.Open a Bash shell window.
Navigate to the directory where you downloaded the file.
Unpack
make-lesson.zip
:
$ unzip make-lesson.zip
- Change into the
make-lesson
directory:
$ cd make-lesson
Software
You also need to have the software installed on your computer to follow this lesson.
Install shell
If you do not already have the shell software installed, you will need to download and install it.
After installing the shell,
- Open a terminal. If you’re not sure how to open a terminal on your operating system, see the instructions below.
- In the terminal type
cd
then press the Return key. This step will make sure you start with your home folder as your working directory.
In the lesson, you will find out how to move to the current directory.
Where to type commands: How to open a new shell
The shell is a program that enables us to send commands to the computer and receive output. It is also referred to as the terminal or command line.
Some computers include a default Unix Shell program. The steps below describe some methods for identifying and opening a Unix Shell program if you already have one installed. There are also options for identifying and downloading a Unix Shell program, a Linux/UNIX emulator, or a program to access a Unix Shell on a server.
If none of the options below address your circumstances, try an online search for: Unix shell [your computer model] [your operating system].
Computers with Windows operating systems do not automatically have a Unix Shell program installed. In this lesson, we encourage you to use an emulator included in Git for Windows, which gives you access to both Bash shell commands and Git.
Once installed, you can open a terminal by running the program Git Bash from the Windows start menu.
For advanced users:
As an alternative to Git for Windows you may wish to Install the Windows Subsystem for Linux which gives access to a Bash shell command-line tool in Windows 10 and above.
Please note that commands in the Windows Subsystem for Linux (WSL) may differ slightly from those shown in the lesson or presented in the workshop.
For a Mac computer running macOS Mojave or earlier releases, the default Unix Shell is Bash. For a Mac computer running macOS Catalina or later releases, the default Unix Shell is Zsh. Your default shell is available via the Terminal program within your Utilities folder.
To open Terminal, try one or both of the following:
- In Finder, select the Go menu, then select Utilities. Locate Terminal in the Utilities folder and open it.
- Use the Mac ‘Spotlight’ computer search function. Search for:
Terminal
and press Return.
To check if your machine is set up to use something other than Bash,
type echo $SHELL
in your terminal window.
If your machine is set up to use something other than Bash, you can
run it by opening a terminal and typing bash
.
The default Unix Shell for Linux operating systems is usually Bash.
On most versions of Linux, it is accessible by running the Gnome
Terminal or KDE Konsole or xterm, which can be found
via the applications menu or the search bar. If your machine is set up
to use something other than Bash, you can run it by opening a terminal
and typing bash
.
Install GNU Make
Linux
Make is a standard tool on most Linux systems and should already be
available. Check if you already have Make installed by typing
make -v
into a terminal.
One exception is Debian, and you should install Make from the
terminal using sudo apt-get install make
.
OSX
You will need to have Xcode installed (download from the Apple website). Check if
you already have Make installed by typing make -v
into a
terminal.
Windows
Use the Windows installer.
Python
Python2 or Python3, Numpy and Matplotlib are required. They can be installed separately, but the easiest approach is to install Anaconda which includes all of the necessary python software.