Main Content

What is Make?

Archive - Originally posted on "The Horse's Mouth" - 2012-03-02 06:03:49 - Graham Ellis

Make is a build tool. Let me give you some examples of where it might be used:
• If you're making an executable program, there is often a quite complex series of instructions to follow to convert your source files into the final executable file (your ultimate target).
• Similarly, if you're installing software from a distribution there is often a complex series of steps to move from that distribution to a fully installed and deployed installation.
• Another task which is similarly structured is the production of a test report from a series of test, which run on a system of some sort.

In writing your makefile - your instructions to make - you break down the operations you want to perform (your build) into a series of stages, each of which has some dependencies (the starting files) and a target (the output file), and rules describing how to get from dependencies to target. When you run the make tool, it looks at the relative time stamps on each of the files, and which targets are missing too, and works out which rules need to be run and in which order, so that only the rules that need to be run are run.

Make supports a wide variety of facilities to help the author of the makefile write a short and maintainable makefile which doesn't repeat things time and time again, and allows the author the ability to generate multiple output files and to "nest" make within make for greater flexibility. Other facilities allow the author to provide feedback and error handling during the running of make so that the user who is building or installing a product or running a series of tests through make is kept informed of its progress. But these powerful facilities come at the cost of a certain bewilderment for the newcomer, who can take a look at the make manual and wonder where to start. It's really not that hard with a bit of instruction and some hands on training and exercises.

I first trained on make as long ago as the early 1990s, having been a user of extensive makefiles for building, testing and installing our Designer I software package over the previous decade - a full-featured Computer Aided Design system written in C, Fortran and Assembler. Make was used for builds, for testing, and for installation across multiple platforms with our own preprocessors for system compatibility controlled from within make to allow us to easily maintain common source across a number of operating systems. And I still use make, most notably for C and C++ courses, where we include a short section within some of our public courses. I can also provide private training on make - a good introduction in half a day, or a full and quite deep course taking a day.

These days, we're very happy for delegates to use their own computers on most of our private training courses, and we only provide laptops ourselves where they're required (we remain very happy to do so). With make, though, we'll always provide systems, as there's going to be a wide variety of source data / material to use during the course, and the course covers installation of software as the administrator / root, and on delegate's own systems this would mean substantial downloading prior to the course, and could mean security concerns as to just what was installed during the make process - especially if in the learning process the student made errors that (for example) cleaned up (a.k.a. deleted) parts of the system. Better to do the early learning and experimentation on our machines which can be rebuilt than on your own.