CITS4407 Open Source Tools and Scripting  
prev
next CITS4407 help4407 CITS4407 schedule  

Maintaining multi-file projects

As large projects grow to involve many, tens, even hundreds, of source files, it becomes a burden to remember which ones have been recently changed and, hence, need recompiling.

This is particularly difficult to manage if multiple people are contributing to the same project, each editing different files.

As a "cop out" we could (expensively) just compile everything!

cc -std=c99 -Wall -pedantic -Werror -o calcmarks calcmarks.c globals.c readmarks.c correlation.c 

Introducing make

The program make maintains up-to-date versions of programs that result from a sequence of actions on a set of files.

make reads specifications from a file typically named Makefile or makefile and performs the actions associated with rules if indicated files are "out of date".

Basically, in pseudo-code (not in C) :

if (files on which a certain file depends)
       i) do not exist, or
      ii) are not up-to-date
then
     create an up-to-date version;

make operates over rules and actions recursively and will abort its execution if it cannot create an up-to-date file on which another file depends.

Note that make can be used for many tasks other than just compiling C - such as compiling other code from programming languages, reformatting text and web documents, making backup copies of files that have recently changed, etc.

 


CITS4407 Open Source Tools and Scripting, Week 9, p5.