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 an easy way out, we could (expensively) just compile everything!
cc -std=c11 -Wall -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.
CITS2002 Systems Programming, Lecture 17, p10, 26th September 2023.
|