cc guess.c sequence.c test.c
However, it is somewhat inefficient to recompile ALL of the modules
of the program, when it was only
guess.c that changed.
Instead, we could have simply done:
cc guess.c sequence.o test.o
to recompile guess.c, and link the previously compiled
sequence.o and test.o modules.
We can save time this way - only recompile the parts of the program that need to be recompiled. Unfortunately, as we modify different parts of the program, it is up to US to keep track of what modules need to be recompiled. This is even more difficult if we only change a .h file, then we need to remember to recompile all the .c files which include that .h. We are likely to make mistakes, and end up tracking down a bug that doesn't exist, simply because we forgot to recompile somthing we should have.
There ought to be a better way...
ee150:wiliki:66> make
cc -Aa -c guess.c
Linking guess ...
done
The make utility uses the Makefile to determine which files
are needed and which files they are dependent on,
look at their modification times, and determines just which files
should be recompiled and then links the modules to update the
executable.
ee150:wiliki:75> ls Makefile guess.h@ sequence.c@ tfdef.h@ guess.c play.h@ test.c@Those with the '@' character after the names are links. We can see where they are linked with
ee150:wiliki:76> ll total 18 -rw-r--r-- 1 ee150tep 99 1618 Sep 24 12:36 Makefile -rw-r--r-- 1 ee150tep 99 1716 Sep 24 12:14 guess.c lrwxr-xr-x 1 ee150tep 99 10 Sep 20 16:07 guess.h@ -> ../guess.h lrwxr-xr-x 1 ee150tep 99 9 Sep 20 16:07 play.h@ -> ../play.h lrwxr-xr-x 1 ee150tep 99 13 Sep 20 16:07 sequence.c@ -> ../sequence .c lrwxr-xr-x 1 ee150tep 99 9 Sep 20 16:07 test.c@ -> ../test.c lrwxr-xr-x 1 ee150tep 99 10 Sep 20 16:07 tfdef.h@ -> ../tfdef.h
I created these links with commands like:
ln -s ../guess.h .