Next: Make Programming Up: Writing Larger Programs Previous: Scope of externals

The Make Utility

The make utility is an intelligent program manager that maintains integrity of a collection of program modules, a collection of programs or a complete system - does not have be programs in practice can be any system of files ( e.g. chapters of text in book being typeset).

Its main use has been in assisting the development of software systems.

Make was originally developed on UNIX but it is now available on most systems.

NOTE: Make is a programmers utility not part of C language or any language for that matter.

Consider the problem of maintaining a large collection of source files:

main.c f1.c ......... fn.c

We would normally compile our system via:

cc -o main main.c f1.c ......... fn.c

However, if we know that some files have been compiled previously and their sources have not changed since then we could try and save overall compilation time by linking in the object code from those files say:

cc -o main main.c f1.c ... fi.o .. fj.o ... fn.c

We can use the C compiler option (Appendix ) -c to create a .o for a given module. For example:

cc -c main.c

will create a main.o file. We do not need to supply any library links here as these are resolved at the linking stage of compilation.

We have a problem in compiling the whole program in this long hand way however:

It is time consuming to compile a .c module - if the module has been compiled before and not been altered there is no need to recompiled it. We can just link the object files in. However, it will not be easy to remember which files are in fact up to date. If we link in an old object file our final executable program will be wrong.

It is error prone and laborious to type a long compile sequence on the command line. There may be many of our own files to link as well as many system library files. It may be very hard to remember the correct sequence. Also if we make a slight change to our system editing command line can be error prone.

If we use the make utility all this control is taken care by make. In general only modules that have older object files than source files will be recompiled.

Next: Make Programming Up: Writing Larger Programs Previous: Scope of externals
Wed Sep 14 10:06:31 BST 1994