4

suppose that you have a program which you installed that from source by make command . That program include files a.cc, b.cc, c.cc, d.cc and ... .

Now I changed a.cc a bit. In order to enable the changes I should compile the program again by make command.

My question: Is make command just recompile the changed files or recompile all of the files.

ps :all of the files are define on as .o on the Makefile.

Mohammad Reza Rezwani
  • 10,076
  • 35
  • 91
  • 127
  • 1
    I *think* if you have something like `*.o` as a target, then it will act as an incremental compiler. – saiarcot895 Jul 18 '14 at 14:09
  • you mean make compile all of them and by *.o we can tell make to compile which file exactly? – Mohammad Reza Rezwani Jul 18 '14 at 14:11
  • 1
    Edit: See [this](http://stackoverflow.com/questions/8663626/make-and-incremental-builds#comment10766995_8663675) comment and the corresponding answer. In the case of that answer, if you run `make result`, it should do an incremental build. – saiarcot895 Jul 18 '14 at 14:16

1 Answers1

1

In general way, You don't need recompile all of .cc files according to modify a .cc file.

The a .cc file is related with other .cc by using .h file.

For example:

Let's guess b.h is a header about b.cc.

And a.cc use b.h.

You don't need recompile a.cc due to modify and compile b.cc.

But You need to recompile about b.h.

If the makefile is created as well(based on autotools), make command will process the dependencies as well.

xiaodongjie
  • 2,796
  • 1
  • 17
  • 37