100 Useful Command-Line Utilities

by Oliver; 2014

67. make

make is a program which executes a special type of script called a Makefile. As this tutorial notes:
As a build automation tool, Make generates files (called targets), each of which can depend upon the existence of other files (called dependencies). Targets, dependencies, and instructions for how to build them (called recipes) are defined in a special file called a Makefile.
Suppose you have a file called input1 and you want to produce a file called output3. You write a makefile, which species how to do this with a bunch of rules. In pseudocode:
  • Rule1: Use input1 to produce output1
  • Rule2: Use output1 to produce output2
  • Rule3: Finally, use output2 to produce output3
You run make and produce your output3. At this point you're asking, why didn't I just use an ordinary script? Suppose now you delete output3 and want to produce it anew. The beauty of make is that it works backwards from your final rule, figures out which dependencies it needs to create your final file, and only runs the necessary rules. In our example, if output2 were still present, it would only run Rule3. If make detected output2 were missing, it would look to run Rule2, etc.

I'll let the experts speak here, since I don't have much experience with this utility: Note: The make concept—a script that starts backwards and only runs what it needs to—is so useful it's been adapted into a Python version called Snakemake primarily used for bioinformatics.

<PREV   NEXT>