The make Rules117
The same process is repeated for the
dnsresolver
and the following two lines are dis-
played:
gcc -g -O2 -c dnsresolver.c
gcc -static dnsresolver.o common.o -o dnsresolver
After building
dnsresolver
, nothing is left in the default target rule “all,” so
make
will
stop at this point.
Now let us see what happens if you modify the
ftp.h
file and run
make
again. The out-
put will be as follows:
[root@rr2 test]# make
gcc -g -O2 -c ftp.c
gcc -static ftp.o common.o -o ftp
[root@rr2 test]#
This time
make
only rebuilt
ftp
because
ftp.h
is a dependency only for the target
ftp
.
However if you modify
common.h
, it will rebuild
ftp
,
tftp
and
dnsresolver
as follows:
[root@rr2 test]# make
gcc -g -O2 -c ftp.c
gcc -static ftp.o common.o -o ftp
gcc -g -O2 -c tftp.c
gcc -static tftp.o common.o -o tftp
gcc -g -O2 -c dnsresolver.c
gcc -static dnsresolver.o common.o -o dnsresolver
[root@rr2 test]#
Modifying
common.c
will cause rebuilding of all object files as well. This result of
make
after modification in
common.c
is as follows:
[root@rr2 test]# make
gcc -g -O2 -c ftp.c
gcc -g -O2 -c common.c
gcc -static ftp.o common.o -o ftp
gcc -g -O2 -c tftp.c
gcc -static tftp.o common.o -o tftp
gcc -g -O2 -c dnsresolver.c
gcc -static dnsresolver.o common.o -o dnsresolver
[root@rr2 test]#
You can also use rules to build individual targets. For example, if you want to build only
ftp
, you use the following command line instead:
[root@rr2 test]# make ftp
gcc -g -O2 -c ftp.c
gcc -g -O2 -c common.c
gcc -static ftp.o common.o -o ftp
[root@rr2 test]#
Next Page >>
<< Previous Page
Back to the Table of Contents