next up previous contents
Next: Expressions Up: Introduction Previous: From source to executable   Contents


Automated compilation

In the previous section, all commands in the process from source to executable were entered manually. Obviously, this is tedious. In addition it becomes error-prone when the number of source files making up the executable increases. Luckily, the make utility was invented long ago.

make operates on makefiles, usually named Makefile. A Makefile contains a description of the dependencies between the files in a project, and commands to recreate files when they have become out-of-date.

The GNU project, in their quest for a free UNIX, have also written a make utility. As with a lot of GNU software, GNU make offers superior functionality over the original. Therefore the TOM Project uses GNU make. To remind you of this, all makefiles are called GNUmakefile. To build TOM programs, you normally use the TOM makefiles1.4. This is a collection of makefiles, one for each kind of project. The makefiles are usually installed in /usr/local/lib/tom/makefiles. To use them for the `Hello, world!' example, all you need to do is create a file GNUmakefile, with the following contents:

UNIT=		hello

TOM_SRC=	hello

include /usr/local/tom/makefiles/GNUmakefile.bin

When you have edited any of the source files, to regenerate the program just enter the following command line1.5:

$ make

All you need to remember when using the template GNUmakefile is that if you add or remove files from the TSRC macro, you must remove the unit file, so it can be recreated. Now you know how to create an executable from TOM source files, time has come to dive into the language itself, starting with the next chapter.


next up previous contents
Next: Expressions Up: Introduction Previous: From source to executable   Contents
Pieter J. Schoenmakers tiggr at gerbil.org