Makefile compiles all files, even though changes are done in a single c++ file -
i work on project involving large number of c++
files. asking question out of curiosity.
usually after make
done, particular c++
file under modification compiled alone subsequent make
s. experience small modification in single c++
file results compilation of other c++
files , final executable.
what reason makefile
compile other non-modified c++
files?
so here comes concept of timestamping
in makefile
. example make
rule this
output: dep1 rule-1 dep1: dep2 rule-2
when execute makefile
make
first checks timestamp
of output
file, (if output
file doesn't exists default rule executed). output
created @ 1200hrs , change file dep1 @ 1205hrs , execute make
, make
finds target output older depepndency dep1
execute rule-1. if suppose output
created @ 1300hrs, dep1
@ 1230hrs, , update dep2
@ 1310hrs, , execute make
. can see here since dep1
older dep2
rule-2 executed , dep1
's timestamp has been changed, output
older dep1
rule-1 executed. can see here though output
doesn't directly depend on dep2
rebuilt when updated dep2
this happening in case. check makefile
, try check dependency of file edited. targets depend on edited file rebuilt.
Comments
Post a Comment