make program has many applications. One of the most common
applications of make is to update an executable so it is consistent
with updated source files.
Consider a project that has 3 course files, a.c, b.c and
c.c. In order to create an executable, the following commands need to
be issued:
gcc -c a.c gcc -c b.c gcc -c c.c gcc -o abc a.o b.o c.o
Of course, one can also execute the following command instead:
gcc -o abc a.c b.c c.c
However, the one-command version may recompile source files that have not been updated. With three small files, the penalty is minimal. However, for a large scale project, the one-command method is unacceptable.
If we update b.c, the minimum compilation and linking can be done
as follows:
gcc -c b.c gcc -o abc a.o b.o c.o
What if we forget to recompile b.c? We'll be running the old
version of the program! This can lead to unnecessary time for debugging
and much frustration.
It'd be nice if we can somehow have a tool to figure out what needs to be
recompiled and relinked at a minimum level. Well, that's make!