Makefiles - automatic compiling, linking, etc


Instead of defining the terms of a makefile, here is an example of a typical makefile. You can modify it to suit your needs.

Always name a makefile as makefile.

A makefile is like a batch file or a short program. But it has a lot more intelligence built in. The main reason to use makefiles is to let the computer do repetitive tasks instead of the user.

Very often you may have about 15 different files which contain subroutines called by a main program. If you edit one of these files, you have to recompile only the file edited. Most of the time you may not be sure which files need to be recompiled. The makefile does all that for you. It also saves you from typing long commands for linking 50 files together!

To run a makefile, type

% make

or to run a specific target

% make targetname

For more information on targets, click here.

Back to the main menu


James Weighton and R. G. Hindman